diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/builder/PaymentInstructionBuilder.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/builder/PaymentInstructionBuilder.java index 594e28833..c902fe6e0 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/builder/PaymentInstructionBuilder.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/builder/PaymentInstructionBuilder.java @@ -5,6 +5,7 @@ import ru.clearing.classes.statics.data.company.Company; import ru.clearing.classes.statics.data.company.CompanySymbols; import ru.clearing.classes.statics.data.payment.PaymentInstruction; import ru.clearing.classes.statics.data.registry.Registry; +import ru.clearing.classes.statics.data.security.Security; import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.platform.enumeration.CompanySymbol; import ru.spcex.platform.enumeration.InOutDirection; @@ -36,11 +37,15 @@ public class PaymentInstructionBuilder { } public PaymentInstruction build() { + Imdg accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class); + Imdg companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class); + Imdg companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class); + Imdg securityImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Security, Security.class); + PaymentInstruction paymentInstruction = new PaymentInstruction(); paymentInstruction.setSenderId(registry.getCompanyId()); paymentInstruction.setAddresseeId(registry.getCounterPartyId()); - Imdg companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class); CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of( "companyId", registry.getCompanyId(), "companySymbol", CompanySymbol.BIC.getKey()) @@ -60,7 +65,6 @@ public class PaymentInstructionBuilder { paymentInstruction.setAdresseeBic(counterCompanySymbols.getCompanySymbolValue()); } - Imdg companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class); Company company = companyImdg.getSingleObjectByID(registry.getCompanyId()); if (company != null) { paymentInstruction.setPayeeBankName(company.getShortName()); @@ -69,17 +73,14 @@ public class PaymentInstructionBuilder { paymentInstruction.setSettlementDate(registry.getSettlementDate()); paymentInstruction.setCreditLeg_amount(registry.getBalance()); paymentInstruction.setDebitLeg_amount(registry.getBalance()); - paymentInstruction.setCreditLeg_accountId(registry.getAccountId()); - Imdg accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class); - Account account = accountImdg.getSingleObjectByID(registry.getAccountId()); + paymentInstruction.setCreditLeg_accountId(registry.getAccountId());//fixme контрагента? + Account account = accountImdg.getSingleObjectByID(paymentInstruction.getCreditLeg_accountId()); if (account != null) { paymentInstruction.setCreditLeg_account(account.getAccount()); } - paymentInstruction.setDebitLeg_accountId(registry.getAccountId()); - -// Imdg depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class); + paymentInstruction.setDebitLeg_accountId(registry.getAccountId()); //fixme компании? account = accountImdg.getSingleObjectByID(paymentInstruction.getDebitLeg_accountId()); if (account != null) { paymentInstruction.setDebitLeg_account(account.getAccount()); @@ -88,6 +89,15 @@ public class PaymentInstructionBuilder { paymentInstruction.setCreditLeg_direction(InOutDirection.out.getKey()); paymentInstruction.setDebitLeg_direction(InOutDirection.in.getKey()); + Security security = securityImdg.getSingleObjectByID(registry.getSecurityId()); + if (security != null) { + //fixme тут точно что-то не то +// paymentInstruction.setCreditLeg_currencyCode(security.getSecuritySymbol()); + paymentInstruction.setCreditLeg_securityId(security.getId()); +// paymentInstruction.setDebitLeg_currencyCode(security.getSecuritySymbol()); + paymentInstruction.setDebitLeg_securityId(security.getId()); + } + paymentInstruction.setTransactionStatus("STLD"); paymentInstruction.setCreated(Instant.now()); 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 e03df0611..7865f8fd5 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 @@ -349,6 +349,4 @@ public class FormingPaymentInstruction implements ISessionStage { sDf12.setGenerationId(sdf12GroupId); sDf12Imdg.insert(sDf12); } - -// private String defineCompanyName(Function function, ) } diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingRegistersOnOS.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingRegistersOnOS.java index 1329f7232..11e9cb01d 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingRegistersOnOS.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FormingRegistersOnOS.java @@ -89,10 +89,10 @@ public class FormingRegistersOnOS implements ISessionStage { } Registry createRegistryFor(Registry forRegistry) { - Registry newRegistry = (Registry) forRegistry.clone();// cloneable + Registry newRegistry = forRegistry.clone(); newRegistry.setId(idSequence.nextId()); newRegistry.setCreated(Instant.now()); - newRegistry.setUpdated(newRegistry.getCreated()); + newRegistry.setUpdated(null); String newRegDestination; if (RegistryDesignation.O.equalsByKey(forRegistry.getRegistryDesignation())) { @@ -104,15 +104,15 @@ public class FormingRegistersOnOS implements ISessionStage { } newRegistry.setRegistryDesignation(newRegDestination); - String newRegistryInstrumentType; // по ТЗ не меняется - if (RegistryInstrumentType.S.equalsByKey(forRegistry.getRegistryInstrumentType())) { - newRegistryInstrumentType = RegistryInstrumentType.S.getKey(); - } else if (RegistryInstrumentType.M.equalsByKey(forRegistry.getRegistryInstrumentType())) { - newRegistryInstrumentType = RegistryInstrumentType.M.getKey(); - } else { - throw new IllegalArgumentException("RegistryInstrumentType=" + forRegistry.getRegistryInstrumentType()); - } - newRegistry.setRegistryInstrumentType(newRegistryInstrumentType); +// String newRegistryInstrumentType; // по ТЗ не меняется +// if (RegistryInstrumentType.S.equalsByKey(forRegistry.getRegistryInstrumentType())) { +// newRegistryInstrumentType = RegistryInstrumentType.S.getKey(); +// } else if (RegistryInstrumentType.M.equalsByKey(forRegistry.getRegistryInstrumentType())) { +// newRegistryInstrumentType = RegistryInstrumentType.M.getKey(); +// } else { +// throw new IllegalArgumentException("RegistryInstrumentType=" + forRegistry.getRegistryInstrumentType()); +// } +// newRegistry.setRegistryInstrumentType(newRegistryInstrumentType); newRegistry.setRegistryCode(RegistryUtil.clearingCode(newRegistry)); return newRegistry;