@@ -116,7 +116,7 @@ private CustomerCreditTransferInitiationV03 build() {
116116 paymentInstructionInformationSCT3 .setCtrlSum (this .getTotalAmount ());
117117 paymentInstructionInformationSCT3 .setDbtr (partyIdentification (this .debtor ));
118118 paymentInstructionInformationSCT3 .setDbtrAcct (cashAccount (this .debtorAccount ));
119- branchAndFinancialInstitutionIdentification ( this .debtorAccount ). ifPresent ( paymentInstructionInformationSCT3 :: setDbtrAgt );
119+ paymentInstructionInformationSCT3 . setDbtrAgt ( mandatoryBranchAndFinancialInstitutionIdentification ( this .debtorAccount ));
120120
121121 if (this .serviceLevelCode != null ) {
122122 ServiceLevel8Choice serviceLevel = new ServiceLevel8Choice ();
@@ -179,28 +179,28 @@ private CreditTransferTransactionInformation10 transaction(Transaction transacti
179179
180180 transaction .getChargeBearerCode ().ifPresent (creditTransferTransactionInformation ::setChrgBr );
181181
182- branchAndFinancialInstitutionIdentification (transaction .getAccount ()).ifPresent (creditTransferTransactionInformation ::setCdtrAgt );
182+ optionalBranchAndFinancialInstitutionIdentificationOpt (transaction .getAccount ()).ifPresent (creditTransferTransactionInformation ::setCdtrAgt );
183183 Iterator <BankAccount > intermediaryAgentsIterator = transaction .getIntermediaryAgents ().iterator ();
184184 if (intermediaryAgentsIterator .hasNext ()) {
185185 BankAccount first = intermediaryAgentsIterator .next ();
186186 creditTransferTransactionInformation .setIntrmyAgt1Acct (cashAccount (first ));
187- branchAndFinancialInstitutionIdentification (first ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt1 );
187+ optionalBranchAndFinancialInstitutionIdentificationOpt (first ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt1 );
188188 }
189189 if (intermediaryAgentsIterator .hasNext ()) {
190190 BankAccount second = intermediaryAgentsIterator .next ();
191191 creditTransferTransactionInformation .setIntrmyAgt2Acct (cashAccount (second ));
192- branchAndFinancialInstitutionIdentification (second ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt2 );
192+ optionalBranchAndFinancialInstitutionIdentificationOpt (second ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt2 );
193193 }
194194 if (intermediaryAgentsIterator .hasNext ()) {
195195 BankAccount third = intermediaryAgentsIterator .next ();
196196 creditTransferTransactionInformation .setIntrmyAgt3Acct (cashAccount (third ));
197- branchAndFinancialInstitutionIdentification (third ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt3 );
197+ optionalBranchAndFinancialInstitutionIdentificationOpt (third ).ifPresent (creditTransferTransactionInformation ::setIntrmyAgt3 );
198198 }
199199
200200 return creditTransferTransactionInformation ;
201201 }
202202
203- private Optional <BranchAndFinancialInstitutionIdentification4 > branchAndFinancialInstitutionIdentification (BankAccount bankAccount ) {
203+ private Optional <BranchAndFinancialInstitutionIdentification4 > optionalBranchAndFinancialInstitutionIdentificationOpt (BankAccount bankAccount ) {
204204 return bankAccount .getBic ().map (bic -> {
205205 BicUtil .validate (bic );
206206 FinancialInstitutionIdentification7 financialInstitutionIdentification = new FinancialInstitutionIdentification7 ();
@@ -211,6 +211,17 @@ private Optional<BranchAndFinancialInstitutionIdentification4> branchAndFinancia
211211 });
212212 }
213213
214+ private BranchAndFinancialInstitutionIdentification4 mandatoryBranchAndFinancialInstitutionIdentification (BankAccount bankAccount ) {
215+ BranchAndFinancialInstitutionIdentification4 branchAndFinancialInstitutionIdentification = new BranchAndFinancialInstitutionIdentification4 ();
216+ FinancialInstitutionIdentification7 financialInstitutionIdentification = new FinancialInstitutionIdentification7 ();
217+ bankAccount .getBic ().ifPresent (bic -> {
218+ BicUtil .validate (bic );
219+ financialInstitutionIdentification .setBIC (bic );
220+ });
221+ branchAndFinancialInstitutionIdentification .setFinInstnId (financialInstitutionIdentification );
222+ return branchAndFinancialInstitutionIdentification ;
223+ }
224+
214225 private PartyIdentification32 partyIdentification (Party party ) {
215226 PartyIdentification32 partyIdentification = new PartyIdentification32 ();
216227 if (party != null ) {
0 commit comments