Merge remote-tracking branch 'refs/remotes/origin/master' into dev

# Conflicts:
#	clearing-parent/account-service/pom.xml
#	clearing-parent/backend-api/pom.xml
#	clearing-parent/balance-service/pom.xml
#	clearing-parent/classes/pom.xml
#	clearing-parent/cleaning-builders/pom.xml
#	clearing-parent/clearing-service/pom.xml
#	clearing-parent/clearing-validation/pom.xml
#	clearing-parent/company-service/pom.xml
#	clearing-parent/db-scripts/pom.xml
#	clearing-parent/dbf-exporter/pom.xml
#	clearing-parent/dbf-importer/pom.xml
#	clearing-parent/dictionary/pom.xml
#	clearing-parent/extdb-importer/pom.xml
#	clearing-parent/gateway-api/pom.xml
#	clearing-parent/imdg-hist/pom.xml
#	clearing-parent/imdg/pom.xml
#	clearing-parent/lim-exporter/pom.xml
#	clearing-parent/pom.xml
#	clearing-parent/registry-service/pom.xml
#	clearing-parent/reports-service/pom.xml
#	clearing-parent/scheduler-service/pom.xml
#	clearing-parent/securities-service/pom.xml
#	clearing-parent/security-util/pom.xml
#	clearing-parent/swt-exporter/pom.xml
#	clearing-parent/swt-importer/pom.xml
#	clearing-parent/test-clearing/pom.xml
#	clearing-parent/trade-importer/pom.xml
#	clearing-parent/utility-service/pom.xml
#	platform-parent/pom.xml
#	pom.xml
#	z-distr/pom.xml
This commit is contained in:
etreschenkov 2024-08-27 12:26:42 +03:00
commit c38cfaaab9
3 changed files with 33 additions and 14 deletions

View file

@ -480,6 +480,7 @@ public class ValidationConfig {
ctx.addImdg(IMDGDistributedNames.Map_SDf54, sDf54Imdg);
ctx.addImdg(IMDGDistributedNames.Map_PaymentInstruction, pmtImdg);
ctx.addImdg(IMDGDistributedNames.Map_TradingClearingRegistry, imdgTradingClearingRegistry);
ctx.addImdg(IMDGDistributedNames.Map_TradingClearingRegistryList, imdgTradingClearingRegistryList);
return new ValidatorImpl<>(ctx,
Sdf55ValidationRule.Fields,
Sdf55ValidationRule.GenerationIdFound,

View file

@ -187,13 +187,6 @@ public class PaymentInstructionOutboundService {
SDf54 sDf54 = sdf54Creator.create(pmt);
sDf54.setId(idGenerator.nextId());
sDf54.setGenerationId(pmt.getId());
sdf54Imdg.insert(sDf54);
log.debug("new sdf54.id: {}", sDf54.getId());
dmiService.setProcComment(tcr.getId(),
curr,
safeBD(amount).negate(),
sDf54.getDocnm_ref());
assetsMng.process(assets.get().a__b(), assets.get().a__t(), assets.get().a__f(), BigDecimal.ZERO);
if (time.isTradingTime()) {
Supplier<AssetOperationRequest> builder = () -> GatewayRequestCreator.from(pmt,
assets.get().a__b().getTradingCode(),
@ -210,9 +203,16 @@ public class PaymentInstructionOutboundService {
pmt.setTransactionStatus(TransactionStatus.fail.getKey());
pmt.setUpdated(now);
pmtImdg.update(pmt);
return error(req.getId(), ClearingError.GeneralError);
return error(req.getId(), ClearingError.GatewayNotApproved);
}
}
sdf54Imdg.insert(sDf54);
log.debug("new sdf54.id: {}", sDf54.getId());
dmiService.setProcComment(tcr.getId(),
curr,
safeBD(amount).negate(),
sDf54.getDocnm_ref());
assetsMng.process(assets.get().a__b(), assets.get().a__t(), assets.get().a__f(), BigDecimal.ZERO);
SdfClearingRequest exp = new SdfClearingRequest();
exp.setGroupId(sDf54.getGenerationId());
kafkaSender.sendRequestToQueue(Consts.SDF54_PROCESS, exp);

View file

@ -7,6 +7,7 @@ import ru.clearing.classes.statics.data.account.Account;
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
import ru.clearing.classes.statics.data.registry.Registry;
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
import ru.clearing.classes.statics.data.registry.TradingClearingRegistryList;
import ru.clearing.classes.statics.data.sdf.SDf54;
import ru.clearing.classes.statics.data.sdf.SDf55;
import ru.spcex.clearing.error.ClearingError;
@ -14,6 +15,7 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
import ru.spcex.clearing.service.AssetTrio;
import ru.spcex.clearing.service.registry.AssetTBFProcessing;
import ru.spcex.platform.enumeration.CurrencyCode;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
import ru.spcex.platform.utils.enumeration.EnumMessage;
@ -73,20 +75,36 @@ public enum Sdf55ValidationRule implements IValidationRule<ImdgValidationContext
TcrPresent() {
@Override
public Optional<EnumMessage> validate(ImdgValidationContext<StatementRequest> context) {
Imdg<TradingClearingRegistryList> tcrListImdg = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistryList, TradingClearingRegistryList.class);
Imdg<TradingClearingRegistry> tcrImdg = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
PaymentInstruction pmt = context.getStoredObject(ValidationStored.Sdf55PaymentInstruction);
Long accCredId = pmt.getCreditLeg_accountId();
String creditCurrency = pmt.getCreditLeg_currencyCode();
Long addresseeId = pmt.getSenderId();
if (accCredId == null || addresseeId == null) {
return of(ClearingError.RecordNotFound, "TCR - no PI(id=%d)#CreditLeg_accountId/SenderId"
.formatted(pmt.getId()));
.formatted(pmt.getId()));
}
TradingClearingRegistry tcr = tcrImdg.getFirstObjectBySQL(
"moneyAccountId = '%d' and companyId = %d".formatted(accCredId, addresseeId)
);
TradingClearingRegistry tcr = null;
TradingClearingRegistryList tcrList;
String errMsg;
if (CurrencyCode.RUB.equalsByKey(creditCurrency)) {
errMsg = "TCR moneyAccountId = '%d' and companyId = %d".formatted(accCredId, addresseeId);
tcr = tcrImdg.getFirstObjectBySQL(
"moneyAccountId = '%d' and companyId = %d".formatted(accCredId, addresseeId));
} else {
errMsg = "TCR_LIST accountId = '%d' and companyId = %d".formatted(accCredId, addresseeId);
tcrList = tcrListImdg.getFirstObjectBySQL(
"accountId = '%d'".formatted(accCredId)
);
if (tcrList != null) {
tcr = tcrImdg.getFirstObjectBySQL(
"id = '%d' and companyId = %d".formatted(tcrList.getTradingClearingRegistryId(), addresseeId));
}
}
if (tcr == null) {
return of(ClearingError.RecordNotFound, "TCR moneyAccountId = '%d' and companyId = %d"
.formatted(accCredId, addresseeId));
return of(ClearingError.RecordNotFound, errMsg);
}
context.storeObject(ValidationStored.Sdf55Tcr, tcr);
return empty();