SDF10/SDF20
This commit is contained in:
parent
79d52d96ab
commit
944d402c8d
4 changed files with 31 additions and 4 deletions
|
|
@ -358,10 +358,12 @@ public class ValidationConfig {
|
|||
ctx.addImdg(IMDGDistributedNames.Map_MoneyMarketSecurity , imdgMoneyMarketSecurity);
|
||||
ctx.addImdg(IMDGDistributedNames.Map_EquitySecurity , equitySecurityImdg);
|
||||
return new ValidatorImpl<>(ctx,
|
||||
Sdf20ValidationRule.Quantity,
|
||||
Sdf20ValidationRule.AccountPresent,
|
||||
Sdf20ValidationRule.CompanyPresent,
|
||||
Sdf20ValidationRule.SecurityPresent,
|
||||
Sdf20ValidationRule.TCRPresent,
|
||||
Sdf20ValidationRule.DS_TPresent,
|
||||
Sdf20ValidationRule.AssetsPresent);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ public class Sdf10Executor {
|
|||
for (SDf10 sDf10 : sdfs) {
|
||||
IValidator validator = sDf10Validator.apply(sDf10);
|
||||
Optional<EnumMessage> err = validator.tillFirstError();
|
||||
Security security = validator.getStored(ValidationStored.SecurityBySecurityCode);
|
||||
if (err.isPresent()) {
|
||||
log.debug("sdf10.id={} validation error: {}", sDf10.getId(), messageResolver.resolve(err.get()));
|
||||
SDf11 errorSdf11;
|
||||
|
|
@ -142,6 +143,7 @@ public class Sdf10Executor {
|
|||
if (needToCreateStatement(err.get())) {
|
||||
stmt = createStatementBySdf10(sDf10,
|
||||
((Company) validator.getStored(ValidationStored.CompanyByTradingCode)).getId(),
|
||||
security != null ? security.getId() : null,
|
||||
validator.getStored(ValidationStored.Sdf10Account));
|
||||
}
|
||||
errorSdf11 = createSdf11(sDf10, now, errorResult);
|
||||
|
|
@ -150,6 +152,7 @@ public class Sdf10Executor {
|
|||
sdf11WasCreated = true;
|
||||
if (stmt != null) {
|
||||
stmt.setOutSDfId(errorSdf11.getId());
|
||||
stmt.setOperationStatus(OperationStatus.Rejected.getKey());
|
||||
statementImdg.insert(stmt);
|
||||
log.debug("Statement created: {}", stmt.getId());
|
||||
}
|
||||
|
|
@ -158,14 +161,17 @@ public class Sdf10Executor {
|
|||
Company company = validator.getStored(ValidationStored.CompanyByTradingCode);
|
||||
Account account = validator.getStored(ValidationStored.Sdf10Account);
|
||||
TradingClearingRegistry tcr = validator.getStored(ValidationStored.Sdf10Tcr);
|
||||
Statement stmt = createStatementBySdf10(sDf10, company.getId(), account);
|
||||
Statement stmt = createStatementBySdf10(sDf10,
|
||||
company.getId(),
|
||||
security.getId(),
|
||||
account);
|
||||
statementImdg.insert(stmt);
|
||||
log.debug("Statement created: {}", stmt.getId());
|
||||
if (InOutDirection.out.getKey().equals(stmt.getInOutDirection()) && isTradingTime()) {
|
||||
requests.add(requestFromStatement(stmt, company.getTradingCode(), tcr.getCode(), sDf10.getSecurityCode()));
|
||||
} else {
|
||||
SDf11 sDf11 = processedApproved(stmt, sDf10, now, sdf11GroupId);
|
||||
createDs_t(tcr, company, validator.getStored(ValidationStored.SecurityBySecurityCode), stmt.getAmount(), sDf10.getOutDocument());
|
||||
createDs_t(tcr, company, security, stmt.getAmount(), sDf10.getOutDocument());
|
||||
sdf11WasCreated = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -332,12 +338,13 @@ public class Sdf10Executor {
|
|||
return sdf11;
|
||||
}
|
||||
|
||||
private Statement createStatementBySdf10(SDf10 sdf10, Long companyId, Account account) {
|
||||
private Statement createStatementBySdf10(SDf10 sdf10, Long companyId, Long securityId, Account account) {
|
||||
Statement stmt = new Statement();
|
||||
stmt.setAddresseeId(companyId);
|
||||
stmt.setSenderId(Sender.Prc.getId());
|
||||
stmt.setStatementType(StatementType.incr.getKey());
|
||||
//fixme stmt.setComment(sdf10.());
|
||||
stmt.setSecurityId(securityId);
|
||||
stmt.setAccountId(account.getId());
|
||||
stmt.setAccount(account.getAccount());
|
||||
BigDecimal amount = BigDecimalUtil.safeBD(new BigDecimal(sdf10.getQuantity())); //fixme safe new BigDecimal
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ public class Sdf20Executor {
|
|||
if (ds_t == null) {
|
||||
log.debug("DS*T were not found for sdf20.id={} creating", sDf20.getId());
|
||||
ds_t = assets.a__t().clone();
|
||||
RegistryManager.zeroState(ds_t);
|
||||
ds_t.setBalance(quantity);
|
||||
ds_t.setRegistryDesignation(RegistryDesignation.D.getKey());
|
||||
ds_t.setRegistryCode(RegistryUtil.clearingCode(ds_t));
|
||||
rgsImdg.insert(ds_t);
|
||||
|
|
@ -124,7 +126,6 @@ public class Sdf20Executor {
|
|||
ds_t.setContract(sDf20.getInDocument());
|
||||
ds_t.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
ds_t.setUpdated(now);
|
||||
ds_t.setBalance(safeBD(ds_t.getBalance()).add(quantity));
|
||||
as_t.setBalance(safeBD(as_t.getBalance()).add(quantity));
|
||||
as_t.setCheckBalance(BigDecimalUtil.parseLeadingZeroes(sDf20.getCloseBalance()));
|
||||
as_t.setUpdated(now);
|
||||
|
|
|
|||
|
|
@ -20,12 +20,29 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
|
|||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static ru.spcex.platform.enumeration.RegistryTradingParams.*;
|
||||
import static ru.spcex.platform.utils.number.BigDecimalUtil.parseLeadingZeroes;
|
||||
import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD;
|
||||
|
||||
public enum Sdf20ValidationRule implements IValidationRule<ImdgValidationContext<SDf20>> {
|
||||
Quantity() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf20> context) {
|
||||
SDf20 validatedObject = context.getValidatedObject();
|
||||
if (TextUtil.isEmpty(validatedObject.getQuantity())) {
|
||||
return of(ClearingError.WrongField, "quantity");
|
||||
}
|
||||
BigDecimal qty = parseLeadingZeroes(validatedObject.getQuantity());
|
||||
if (safeBD(qty).compareTo(BigDecimal.ZERO) < 0) {
|
||||
return of(ClearingError.WrongField, "quantity");
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
AccountPresent() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf20> context) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue