This commit is contained in:
parent
c288a5669f
commit
a950dfcf33
3 changed files with 29 additions and 21 deletions
|
|
@ -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<Account> accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<Company> companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
Imdg<CompanySymbols> companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
Imdg<Security> securityImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Security, Security.class);
|
||||
|
||||
PaymentInstruction paymentInstruction = new PaymentInstruction();
|
||||
paymentInstruction.setSenderId(registry.getCompanyId());
|
||||
paymentInstruction.setAddresseeId(registry.getCounterPartyId());
|
||||
|
||||
Imdg<CompanySymbols> 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<Company> 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<Account> 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<DepoAccount> 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());
|
||||
|
|
|
|||
|
|
@ -349,6 +349,4 @@ public class FormingPaymentInstruction implements ISessionStage {
|
|||
sDf12.setGenerationId(sdf12GroupId);
|
||||
sDf12Imdg.insert(sDf12);
|
||||
}
|
||||
|
||||
// private String defineCompanyName(Function function, )
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue