PaymentInstructionBuilder fix

This commit is contained in:
etreschenkov 2023-05-27 14:58:19 +03:00
parent 25b64c3c09
commit 515e68de67

View file

@ -11,12 +11,15 @@ import ru.spcex.platform.enumeration.InOutDirection;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.ImdgProvider;
import java.time.Instant;
import java.time.LocalDate;
import java.util.Map;
public class PaymentInstructionBuilder {
private Registry registry;
private ImdgProvider imdgProvider;
private Long sessionId;
public static PaymentInstructionBuilder builder(ImdgProvider imdgProvider, Registry registry) {
return new PaymentInstructionBuilder(imdgProvider, registry);
@ -27,6 +30,11 @@ public class PaymentInstructionBuilder {
this.registry = registry;
}
public PaymentInstructionBuilder sessionId(Long sessionId) {
this.sessionId = sessionId;
return this;
}
public PaymentInstruction build() {
PaymentInstruction paymentInstruction = new PaymentInstruction();
paymentInstruction.setSenderId(registry.getCompanyId());
@ -67,9 +75,21 @@ public class PaymentInstructionBuilder {
}
paymentInstruction.setDebitLeg_accountId(registry.getAccountId());
// Imdg<DepoAccount> depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
account = accountImdg.getSingleObjectByID(paymentInstruction.getDebitLeg_accountId());
if (account != null) {
paymentInstruction.setDebitLeg_account(account.getAccount());
}
paymentInstruction.setCreditLeg_direction(InOutDirection.out.getKey());
paymentInstruction.setDebitLeg_direction(InOutDirection.in.getKey());
// Account account = accountImdg.getSingleObjectByID(registry.get());
// paymentInstruction.setDebitLeg_account();
paymentInstruction.setTransactionStatus("STLD");
paymentInstruction.setCreated(Instant.now());
paymentInstruction.setClearingDate(LocalDate.now());
return paymentInstruction;
}
}