diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstruction.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstruction.java index 270b886f6..06b569cc2 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstruction.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstruction.java @@ -338,7 +338,7 @@ public class FormingPaymentInstruction implements ISessionStage { private SDf12 newSDf12(PaymentInstruction paymentInstruction) { log.debug("creating sdf12"); - SDf12 sDf12 = new SDf12(); + SDf12 sDf12 = new SDf12(); //todo remove sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); sDf12.setDirection("DELFREE"); diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionAssets.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionAssets.java index 971a62869..e8bf3cc89 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionAssets.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionAssets.java @@ -295,7 +295,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage { } - Collection sdfTables = sendSdfs(paymentInstructions, sessionId); + Collection sdfTables = sendSdfs(paymentInstructions, sessionId, dtrnAcc); StageResult stageResult = new StageResult<>(null, true); stageResult.setStageResult(new PaymentInfo(paymentInstructions, sdfTables)); return stageResult; @@ -307,7 +307,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage { registryImdg.update(rgs); } - private Collection sendSdfs(List formedPaymentInstructions, Long sessionId) { + private Collection sendSdfs(List formedPaymentInstructions, Long sessionId, Account dtrnAcc) { Collection sentSdfs = new ArrayList<>(); List sDf03Created = new ArrayList<>(); List sDf12Created = new ArrayList<>(); @@ -320,7 +320,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage { sDf03Created.add(sdf03Creator.create(paymentInstruction)); } else if (!InstrumentType.CRNC.equalsByKey(security.getInstrumentType()) && List.of(AccountType.Depo, AccountType.Dtrn).contains(IEnumKey.getEnumByKey(AccountType.class, account.getAccountType()))) { - sDf12Created.add(newSDf12(paymentInstruction)); + sDf12Created.add(newSDf12(paymentInstruction, dtrnAcc)); } } @@ -368,19 +368,25 @@ public class FormingPaymentInstructionAssets implements ISessionStage { return sentSdfs; } - private SDf12 newSDf12(PaymentInstruction paymentInstruction) { + private SDf12 newSDf12(PaymentInstruction paymentInstruction, Account dtrnAcc) { log.debug("creating sdf12"); SDf12 sDf12 = new SDf12(); + if (Objects.equals(paymentInstruction.getDebitLeg_accountId(), dtrnAcc.getId())) { + sDf12.setDirection("RECFREE"); + sDf12.setDepoCodeSender(paymentInstruction.getDebitLeg_account()); + sDf12.setDepoCodeAdressee(paymentInstruction.getCreditLeg_account()); + } else if (Objects.equals(paymentInstruction.getCreditLeg_accountId(), dtrnAcc.getId())) { + sDf12.setDirection("DELFREE"); + sDf12.setDepoCodeSender(paymentInstruction.getCreditLeg_account()); + sDf12.setDepoCodeAdressee(paymentInstruction.getDebitLeg_account()); + } sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); - sDf12.setDirection("DELFREE"); sDf12.setQuantity(BigDecimalUtil.limitDecimalPlaces(paymentInstruction.getCreditLeg_amount().toString(), 2)); Security security = securitySelector.selectSecurityById(paymentInstruction.getCreditLeg_securityId()); if (security != null) { sDf12.setSecurityCode(security.getSecuritySymbol()); } - sDf12.setDepoCodeSender(paymentInstruction.getCreditLeg_account()); - sDf12.setDepoCodeAdressee(paymentInstruction.getDebitLeg_account()); // sDf12.setTransactionNumber(); sDf12.setGenerationTime(Instant.now()); return sDf12; diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDealsFinalMkr.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDealsFinalMkr.java index 065e2581b..af71cf53d 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDealsFinalMkr.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDealsFinalMkr.java @@ -290,7 +290,7 @@ public class FormingPaymentInstructionDealsFinalMkr implements ISessionStage { private SDf12 newSDf12(PaymentInstruction paymentInstruction) { log.debug("creating sdf12"); - SDf12 sDf12 = new SDf12(); + SDf12 sDf12 = new SDf12(); //todo remove sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); sDf12.setDirection("DELFREE"); diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDepositReturn.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDepositReturn.java index d95fdc627..0d7ad5ec0 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDepositReturn.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionDepositReturn.java @@ -310,7 +310,7 @@ public class FormingPaymentInstructionDepositReturn implements ISessionStage { private SDf12 newSDf12(PaymentInstruction paymentInstruction) { log.debug("creating sdf12"); - SDf12 sDf12 = new SDf12(); + SDf12 sDf12 = new SDf12(); //todo remove sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); sDf12.setDirection("DELFREE"); diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionReturnMkr.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionReturnMkr.java index 2331be2fd..f31848c8e 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionReturnMkr.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionReturnMkr.java @@ -341,7 +341,7 @@ public class FormingPaymentInstructionReturnMkr implements ISessionStage { private SDf12 newSDf12(PaymentInstruction paymentInstruction) { log.debug("creating sdf12"); - SDf12 sDf12 = new SDf12(); + SDf12 sDf12 = new SDf12(); //todo remove sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); sDf12.setDirection("DELFREE"); diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionSecondaryT0.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionSecondaryT0.java index 8ce018370..6c6cf7036 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionSecondaryT0.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingPaymentInstructionSecondaryT0.java @@ -286,7 +286,7 @@ public class FormingPaymentInstructionSecondaryT0 implements ISessionStage { private SDf12 newSDf12(PaymentInstruction paymentInstruction) { log.debug("creating sdf12"); - SDf12 sDf12 = new SDf12(); + SDf12 sDf12 = new SDf12(); //todo remove sDf12.setId(idGenerator.nextId()); sDf12.setOutDocument(sDf12.getId().toString()); sDf12.setDirection("DELFREE");