---
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) {
log.trace("Started generating DepoPaymentInstructionRegister entity...");
DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister();
TradingClearingRegistry tradingClearingRegistry = paymentInstruction.getCreditLeg_accountId() == null ? null :
tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("depoAccountId", paymentInstruction.getCreditLeg_accountId()));
TradingClearingRegistry tradingClearingRegistry = null;
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()));
depoPaymentInstructionRegister.setCreated(Instant.now());
depoPaymentInstructionRegister.setUpdated(Instant.now());
depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId());
if (tradingClearingRegistry == null) {
log.warn("For paymentInstruction[{}].CreditLeg_accountId={} can not find TradingClearingRegistry.",
paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId());
log.warn("For paymentInstruction[{}].CreditLeg_accountId={} or SenderId={} can not find TradingClearingRegistry.",
paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getSenderId());
} else {
depoPaymentInstructionRegister.setTradingClearingRegistryType(tradingClearingRegistry.getTradingClearingRegistryType());
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.annotation.Autowired;
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.payment.PaymentInstruction;
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<Session> sessionMap;
private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
private final Imdg<Company> companyMap;
private final PreClearMap<MoneyPaymentInstructionRegister> preClearMap;
@Autowired
@ -46,6 +48,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
this.moneyPaymentInstructionRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_MoneyPaymentInstructionRegister, MoneyPaymentInstructionRegister.class);
this.paymentInstructionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class);
this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
this.fieldValuesValidator = fieldValuesValidator;
preClearMap = PreClearMap.instanceForLocalDateField(moneyPaymentInstructionRegisterMap, "clearingDate");
}
@ -85,10 +88,14 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
moneyPaymentInstructionRegister.setCreditLegAmount(paymentInstruction.getCreditLeg_amount());
moneyPaymentInstructionRegister.setCreditLegCurrencyCode(paymentInstruction.getCreditLeg_currencyCode());
moneyPaymentInstructionRegister.setDebitLegAccount(paymentInstruction.getDebitLeg_account());
if (paymentInstruction.getSenderId()!=null)
moneyPaymentInstructionRegister.setSender(paymentInstruction.getSenderId().toString());
if (paymentInstruction.getAddresseeId()!=null)
moneyPaymentInstructionRegister.setAddressee(paymentInstruction.getAddresseeId().toString());
if (paymentInstruction.getSenderId() != null) {
Company companyForInjectionBySenderId = companyMap.getSingleObjectByID(paymentInstruction.getSenderId());
moneyPaymentInstructionRegister.setSender(companyForInjectionBySenderId != null ? companyForInjectionBySenderId.getShortName() : null);
}
if (paymentInstruction.getAddresseeId() != null) {
Company companyForInjectionByAddresseeId = companyMap.getSingleObjectByID(paymentInstruction.getAddresseeId());
moneyPaymentInstructionRegister.setAddressee(companyForInjectionByAddresseeId != null ? companyForInjectionByAddresseeId.getShortName() : null);
}
moneyPaymentInstructionRegister.setClearingDate(paymentInstruction.getClearingDate());
moneyPaymentInstructionRegister.setCreated(Instant.now());
moneyPaymentInstructionRegister.setUpdated(moneyPaymentInstructionRegister.getCreated());