---
1 and 2 bullet points
This commit is contained in:
aalehin 2023-10-06 11:30:56 +03:00
parent 53810fd4f1
commit 76a1b74c4b
2 changed files with 17 additions and 8 deletions

View file

@ -94,15 +94,17 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) { private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) {
log.trace("Started generating DepoPaymentInstructionRegister entity..."); log.trace("Started generating DepoPaymentInstructionRegister entity...");
DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister(); DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister();
TradingClearingRegistry tradingClearingRegistry = paymentInstruction.getCreditLeg_accountId() == null ? null : TradingClearingRegistry tradingClearingRegistry = null;
tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("depoAccountId", paymentInstruction.getCreditLeg_accountId())); if (paymentInstruction.getCreditLeg_accountId() != null && paymentInstruction.getSenderId() != null) {
tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", paymentInstruction.getSenderId(), "depoAccountId", paymentInstruction.getCreditLeg_accountId()));
}
InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getFirstObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction())); InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getFirstObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction()));
depoPaymentInstructionRegister.setCreated(Instant.now()); depoPaymentInstructionRegister.setCreated(Instant.now());
depoPaymentInstructionRegister.setUpdated(Instant.now()); depoPaymentInstructionRegister.setUpdated(Instant.now());
depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId()); depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId());
if (tradingClearingRegistry == null) { if (tradingClearingRegistry == null) {
log.warn("For paymentInstruction[{}].CreditLeg_accountId={} can not find TradingClearingRegistry.", log.warn("For paymentInstruction[{}].CreditLeg_accountId={} or SenderId={} can not find TradingClearingRegistry.",
paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId()); paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getSenderId());
} else { } else {
depoPaymentInstructionRegister.setTradingClearingRegistryType(tradingClearingRegistry.getTradingClearingRegistryType()); depoPaymentInstructionRegister.setTradingClearingRegistryType(tradingClearingRegistry.getTradingClearingRegistryType());
depoPaymentInstructionRegister.setTradingClearingRegistry(tradingClearingRegistry.getCode()); depoPaymentInstructionRegister.setTradingClearingRegistry(tradingClearingRegistry.getCode());

View file

@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.clearing.classes.statics.data.company.Company;
import ru.clearing.classes.statics.data.misc.Session; import ru.clearing.classes.statics.data.misc.Session;
import ru.clearing.classes.statics.data.payment.PaymentInstruction; import ru.clearing.classes.statics.data.payment.PaymentInstruction;
import ru.clearing.classes.statics.data.register.MoneyPaymentInstructionRegister; import ru.clearing.classes.statics.data.register.MoneyPaymentInstructionRegister;
@ -35,6 +36,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
private final Imdg<PaymentInstruction> paymentInstructionMap; private final Imdg<PaymentInstruction> paymentInstructionMap;
private final Imdg<Session> sessionMap; private final Imdg<Session> sessionMap;
private final Function<Map<String, ?>, IValidator> fieldValuesValidator; private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
private final Imdg<Company> companyMap;
private final PreClearMap<MoneyPaymentInstructionRegister> preClearMap; private final PreClearMap<MoneyPaymentInstructionRegister> preClearMap;
@Autowired @Autowired
@ -46,6 +48,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
this.moneyPaymentInstructionRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_MoneyPaymentInstructionRegister, MoneyPaymentInstructionRegister.class); this.moneyPaymentInstructionRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_MoneyPaymentInstructionRegister, MoneyPaymentInstructionRegister.class);
this.paymentInstructionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class); this.paymentInstructionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class);
this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class); this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
this.fieldValuesValidator = fieldValuesValidator; this.fieldValuesValidator = fieldValuesValidator;
preClearMap = PreClearMap.instanceForLocalDateField(moneyPaymentInstructionRegisterMap, "clearingDate"); preClearMap = PreClearMap.instanceForLocalDateField(moneyPaymentInstructionRegisterMap, "clearingDate");
} }
@ -85,10 +88,14 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
moneyPaymentInstructionRegister.setCreditLegAmount(paymentInstruction.getCreditLeg_amount()); moneyPaymentInstructionRegister.setCreditLegAmount(paymentInstruction.getCreditLeg_amount());
moneyPaymentInstructionRegister.setCreditLegCurrencyCode(paymentInstruction.getCreditLeg_currencyCode()); moneyPaymentInstructionRegister.setCreditLegCurrencyCode(paymentInstruction.getCreditLeg_currencyCode());
moneyPaymentInstructionRegister.setDebitLegAccount(paymentInstruction.getDebitLeg_account()); moneyPaymentInstructionRegister.setDebitLegAccount(paymentInstruction.getDebitLeg_account());
if (paymentInstruction.getSenderId()!=null) if (paymentInstruction.getSenderId() != null) {
moneyPaymentInstructionRegister.setSender(paymentInstruction.getSenderId().toString()); Company companyForInjectionBySenderId = companyMap.getSingleObjectByID(paymentInstruction.getSenderId());
if (paymentInstruction.getAddresseeId()!=null) moneyPaymentInstructionRegister.setSender(companyForInjectionBySenderId != null ? companyForInjectionBySenderId.getShortName() : null);
moneyPaymentInstructionRegister.setAddressee(paymentInstruction.getAddresseeId().toString()); }
if (paymentInstruction.getAddresseeId() != null) {
Company companyForInjectionByAddresseeId = companyMap.getSingleObjectByID(paymentInstruction.getAddresseeId());
moneyPaymentInstructionRegister.setAddressee(companyForInjectionByAddresseeId != null ? companyForInjectionByAddresseeId.getShortName() : null);
}
moneyPaymentInstructionRegister.setClearingDate(paymentInstruction.getClearingDate()); moneyPaymentInstructionRegister.setClearingDate(paymentInstruction.getClearingDate());
moneyPaymentInstructionRegister.setCreated(Instant.now()); moneyPaymentInstructionRegister.setCreated(Instant.now());
moneyPaymentInstructionRegister.setUpdated(moneyPaymentInstructionRegister.getCreated()); moneyPaymentInstructionRegister.setUpdated(moneyPaymentInstructionRegister.getCreated());