sdf57 checkBalance and expected balance
This commit is contained in:
parent
a65ac4b9b6
commit
0fb88db608
1 changed files with 33 additions and 10 deletions
|
|
@ -583,7 +583,8 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
}
|
||||
|
||||
private void calcBalance(Registry rgs, Statement statement, SDf57 sdf57) {
|
||||
BigDecimal expectedBalance = checkBalanceSendNotification(rgs, sdf57);
|
||||
checkBalanceSendNotification(rgs, sdf57);
|
||||
BigDecimal checkBalance = getCheckBalance(rgs, sdf57);
|
||||
InOutDirection inOutDirection = IEnumKey.getEnumByKey(InOutDirection.class, statement.getInOutDirection());
|
||||
//считаю balance при создании нулевым и исхожу из этого
|
||||
//При добавлении (на базе изменения statement по sDf57):
|
||||
|
|
@ -604,17 +605,15 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
}
|
||||
AccountType accType = IEnumKey.getEnumByKey(AccountType.class, rgs.getAccountType());
|
||||
if (!AccountType.Info.equals(accType)) {
|
||||
rgs.setCheckBalance(expectedBalance);
|
||||
rgs.setCheckBalance(checkBalance);
|
||||
rgs.setDiffBalance(safeBD(rgs.getBalance()).subtract(safeBD(rgs.getCheckBalance())));
|
||||
}
|
||||
rgs.setBalanceDimension(BalanceDimension.MONY.getKey()); //fixme ! смотри описание и ссылка на начало html'ки
|
||||
}
|
||||
|
||||
private BigDecimal checkBalanceSendNotification(Registry r, SDf57 sdf57) {
|
||||
private void checkBalanceSendNotification(Registry r, SDf57 sdf57) {
|
||||
AccountType accType = IEnumKey.getEnumByKey(AccountType.class, r.getAccountType());
|
||||
BigDecimal expectedBalance = BigDecimalUtil.safeSumBD(
|
||||
BigDecimalUtil.parse(sdf57.getKt_in()),
|
||||
BigDecimalUtil.parse(sdf57.getDt_in()));
|
||||
BigDecimal expectedBalance = getExpectedBalance(r, sdf57);
|
||||
if (!AccountType.Info.equals(accType)) {
|
||||
if (safeBD(r.getBalance()).compareTo(expectedBalance) != 0) {
|
||||
notification.sendNotification(
|
||||
|
|
@ -623,13 +622,37 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
Priority.HIGH);
|
||||
}
|
||||
}
|
||||
return BigDecimalUtil.safeSumBD(
|
||||
BigDecimalUtil.parse(sdf57.getKt_out()),
|
||||
BigDecimalUtil.parse(sdf57.getDt_out()));
|
||||
}
|
||||
|
||||
private BigDecimal getCheckBalance(Registry rgs, SDf57 sDf57) {
|
||||
if (rgs.getAccount().equals(sDf57.getAcc_deb().trim())) {
|
||||
return BigDecimalUtil.parse(sDf57.getDt_out());
|
||||
}
|
||||
if (rgs.getAccount().equals(sDf57.getAcc_kr().trim())) {
|
||||
return BigDecimalUtil.parse(sDf57.getKt_out());
|
||||
} else {
|
||||
log.warn("{}.id={} sdf57.id={} couldn't determine value for 'out' check balance, setting 0.",
|
||||
rgs.getRegistryCode(), rgs.getId(), sDf57.getId());
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal getExpectedBalance(Registry rgs, SDf57 sDf57) {
|
||||
if (rgs.getAccount().equals(sDf57.getAcc_deb().trim())) {
|
||||
return BigDecimalUtil.parse(sDf57.getDt_in());
|
||||
}
|
||||
if (rgs.getAccount().equals(sDf57.getAcc_kr().trim())) {
|
||||
return BigDecimalUtil.parse(sDf57.getKt_in());
|
||||
} else {
|
||||
log.warn("{}.id={} sdf57.id={} couldn't determine value for 'in' check balance, setting 0.",
|
||||
rgs.getRegistryCode(), rgs.getId(), sDf57.getId());
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReg(Statement s, Registry r, SDf57 sdf57) {
|
||||
BigDecimal expectedBalance = checkBalanceSendNotification(r, sdf57);
|
||||
checkBalanceSendNotification(r, sdf57);
|
||||
BigDecimal expectedBalance = getCheckBalance(r, sdf57);
|
||||
InOutDirection direction = IEnumKey.getEnumByKey(InOutDirection.class, s.getInOutDirection());
|
||||
switch (direction) {
|
||||
case in -> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue