From 54b0f080508be6cffeb2e9a4a46de959376af243 Mon Sep 17 00:00:00 2001 From: ialbert Date: Fri, 18 Oct 2024 16:04:20 +0300 Subject: [PATCH] =?UTF-8?q?sdf54=20=D0=BF=D0=BE=D0=BB=D1=8F=20SCLIENTN1,?= =?UTF-8?q?=20INN=5FDEB,=20KPP=5FDEB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spcex/clearing/service/Sdf54Creator.java | 19 +++++++++++-------- .../PaymentInstructionOutboundService.java | 12 +++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/Sdf54Creator.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/Sdf54Creator.java index 92b397139..4429c4c7a 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/Sdf54Creator.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/Sdf54Creator.java @@ -68,6 +68,9 @@ public class Sdf54Creator { Status.Active.getKey(), pmt.getCreditLeg_currencyCode() )); + if (anltAcc == null) { + throw new IllegalStateException("couldn't fill acc_deb - no ANLT account for " + pmt.getCreditLeg_currencyCode()); + } // c_acc_deb = c_acc_deb == null ? paymentInstruction.getCreditLeg_account() : c_acc_deb; c_acc_cred = c_acc_cred == null ? pmt.getDebitLeg_account() : c_acc_cred; @@ -77,6 +80,9 @@ public class Sdf54Creator { sDf54.setId(idGenerator.nextId()); sDf54.setSeg_type("V"); + Long debCompanyId = anltAcc.getCompanyId(); + sDf54.setAcc_deb(anltAcc.getAccount()); + //********************** String tranBic = selectSymbolValue(Sender.Prc.getId(), CompanySymbol.BIC); if (tranBic == null) { @@ -103,22 +109,19 @@ public class Sdf54Creator { sDf54::setSbanknam5); sDf54.setOp_type("01"); sDf54.setOp_order("5"); - String innDeb = selectSymbolValue(Sender.One.getId(), CompanySymbol.INN); + String innDeb = selectSymbolValue(debCompanyId, CompanySymbol.INN); if (innDeb == null) { - log.warn("CompanySymbols INN not found for companyId={}", Sender.One.getId()); + log.warn("CompanySymbols INN not found for companyId={}", debCompanyId); } else { sDf54.setInn_deb(innDeb); } - String kppDeb = selectSymbolValue(Sender.One.getId(), CompanySymbol.CPP); + String kppDeb = selectSymbolValue(debCompanyId, CompanySymbol.CPP); if (kppDeb == null) { - log.warn("CompanySymbols CPP not found for companyId={}", Sender.One.getId()); + log.warn("CompanySymbols CPP not found for companyId={}", debCompanyId); } else { sDf54.setKpp_deb(kppDeb); } - if (anltAcc != null) { - sDf54.setAcc_deb(anltAcc.getAccount()); - } Account accDebAcc = accountImdg.getSingleObjectByID(pmt.getDebitLeg_accountId()); if (accDebAcc == null || !AccountStatus.ACTIVE.equalsByKey(accDebAcc.getStatus())) { log.warn("paymentInstruction[{}].DebitLeg_accountId={} account not exist or not active.", pmt.getId(), pmt.getDebitLeg_accountId()); @@ -177,7 +180,7 @@ public class Sdf54Creator { sDf54.setC_acc_cred(c_acc_cred); { - Company company1 = companyImdg.getSingleObjectByID(Sender.One.getId()); + Company company1 = companyImdg.getSingleObjectByID(debCompanyId); if (company1 != null) { // "АО СПВБ" company.shortName[id = 1] String sclientn; if (LocaleUtil.isRus(locale)) { diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/payment/PaymentInstructionOutboundService.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/payment/PaymentInstructionOutboundService.java index 666230273..a79b3bab1 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/payment/PaymentInstructionOutboundService.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/service/payment/PaymentInstructionOutboundService.java @@ -56,6 +56,7 @@ import ru.spcex.platform.utils.enumeration.EnumMessage; import ru.spcex.platform.utils.enumeration.IEnumId; import ru.spcex.platform.utils.enumeration.IMessageResolver; import ru.spcex.platform.utils.localization.SpringPropertiesLocalizer; +import ru.spcex.platform.utils.log.ExceptionUtils; import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD; import ru.spcex.platform.utils.text.TextUtil; import ru.spcex.platform.utils.validation.IValidator; @@ -195,7 +196,16 @@ public class PaymentInstructionOutboundService { } log.debug("assets found and balance is ok. am*b.id={}, am*t.id={}, am*f.id={}", assets.get().a__b().getId(), assets.get().a__t().getId(), assets.get().a__f().getId()); - SDf54 sDf54 = sdf54Creator.create(pmt); + SDf54 sDf54 = null; + try { + sDf54 = sdf54Creator.create(pmt); + } catch (IllegalStateException e) { + log.error(ExceptionUtils.getStackTrace(e)); + pmt.setTransactionStatus(TransactionStatus.fail.getKey()); + pmt.setUpdated(now); + pmtImdg.update(pmt); + return error(req.getId(), ClearingError.GeneralError); + } sDf54.setId(idGenerator.nextId()); sDf54.setGenerationId(pmt.getId()); if (time.isTradingTime()) {