registry-service http://jira.mfd.msk:8088/browse/CLS-634
This commit is contained in:
parent
2572e7ea26
commit
ad0d807b2c
6 changed files with 52 additions and 4 deletions
|
|
@ -41,7 +41,10 @@ public class DepoPaymentInstructionRegisterReportBuilder extends XLSXReportBuild
|
|||
protected DepoPaymentInstructionRegisterReport toRow(PaymentInstruction input) {
|
||||
DepoPaymentInstructionRegisterReport entity = new DepoPaymentInstructionRegisterReport();
|
||||
|
||||
entity.setNumber(input.getId());
|
||||
if (input.getSessionId() == null)
|
||||
entity.setNumber(input.getId());
|
||||
else
|
||||
entity.setNumber(input.getSessionId());
|
||||
entity.setDate(input.getClearingDate());
|
||||
|
||||
if (input.getCreated() != null) entity.setTime(LocalDateTime.from(input.getCreated().atZone(ZoneId.systemDefault())));
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import ru.spcex.platform.enumeration.MoneyFlowSide;
|
|||
import ru.spcex.platform.enumeration.Side;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
|
@ -117,7 +118,7 @@ public class ExecutionRegisterReportBuilder extends XLSXReportBuilder<ExecutionR
|
|||
} else if (input instanceof ExecutionFond fond) {
|
||||
entity.setSettlementDate(fond.getSettlementDate());
|
||||
entity.setSecurity(fond.getSecuritySymbol());
|
||||
entity.setAmount(fond.getSettlementAmount());
|
||||
entity.setAmount(BigDecimalUtil.safeSumBD(fond.getSettlementAmount(), fond.getInterestAmount()));
|
||||
entity.setQuantity(fond.getQuantity());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ public class MoneyPaymentInstructionRegisterReportBuilder extends XLSXReportBuil
|
|||
protected MoneyPaymentInstructionRegisterReport toRow(PaymentInstruction input) {
|
||||
MoneyPaymentInstructionRegisterReport entity = new MoneyPaymentInstructionRegisterReport();
|
||||
|
||||
entity.setNumber(input.getId());
|
||||
if (input.getSessionId() == null)
|
||||
entity.setNumber(input.getId());
|
||||
else
|
||||
entity.setNumber(input.getSessionId());
|
||||
entity.setDate(input.getClearingDate());
|
||||
|
||||
if (input.getCreated() != null) entity.setTime(LocalDateTime.from(input.getCreated().atZone(ZoneId.systemDefault())));
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import ru.spcex.platform.enumeration.AccountType;
|
|||
import ru.spcex.platform.enumeration.TransactionStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -110,7 +111,7 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
|
|||
log.warn("Account id={} not found for paymentInstruction.id={}",
|
||||
paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getId());
|
||||
else {
|
||||
if (AccountType.Depo.equalsByKey(account.getAccountType())) {
|
||||
if (IEnumKey.contains(account.getAccountType(), AccountType.Depo, AccountType.Dtrn)) {
|
||||
depoPaymentInstructions.add(paymentInstruction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class BigDecimalUtil {
|
|||
|
||||
/**
|
||||
* для парсинга вида '-00001234'/'00000123'
|
||||
*
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -44,6 +45,7 @@ public class BigDecimalUtil {
|
|||
|
||||
/**
|
||||
* Для кейсов когда есть String поле с десятичной частью, и хотим ограничить число знаков после запятой
|
||||
*
|
||||
* @param fillZero - дополнить 0 если не хватает знаков дробной части
|
||||
*/
|
||||
public static String limitDecimalPlaces(String number, int decimalPlaces, boolean fillZero) {
|
||||
|
|
@ -75,4 +77,24 @@ public class BigDecimalUtil {
|
|||
return bd == null ? BigDecimal.ZERO : bd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null safe add:
|
||||
*
|
||||
* @param a nullable
|
||||
* @param b nullable
|
||||
* @return если оба числа null то результат ZERO, иначе сложит их.
|
||||
*/
|
||||
public static BigDecimal safeSumBD(BigDecimal a, BigDecimal b) {
|
||||
if (b == null) {
|
||||
if (a == null)
|
||||
return BigDecimal.ZERO;
|
||||
else
|
||||
return a;
|
||||
} else {
|
||||
if (a == null)
|
||||
return b;
|
||||
else
|
||||
return a.add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package ru.spcex.platform.utils.number;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class BigDecimalUtilTest {
|
||||
|
|
@ -21,4 +23,20 @@ class BigDecimalUtilTest {
|
|||
Assertions.assertEquals("123.00", BigDecimalUtil.limitDecimalPlaces("123.", 2, true));
|
||||
Assertions.assertEquals("123.00", BigDecimalUtil.limitDecimalPlaces("123", 2, true));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void safeBD() {
|
||||
Assertions.assertEquals("1", BigDecimalUtil.safeBD(BigDecimal.ONE).toString());
|
||||
Assertions.assertEquals("0", BigDecimalUtil.safeBD(null).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void safeSumBD() {
|
||||
Assertions.assertEquals("11", BigDecimalUtil.safeSumBD(BigDecimal.ONE, BigDecimal.TEN).toString());
|
||||
Assertions.assertEquals("1", BigDecimalUtil.safeSumBD(BigDecimal.ONE, null).toString());
|
||||
Assertions.assertEquals("10", BigDecimalUtil.safeSumBD(null, BigDecimal.TEN).toString());
|
||||
Assertions.assertEquals("0", BigDecimalUtil.safeSumBD(null, null).toString());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue