lim-exporter http://jira.mfd.msk:8088/browse/CLS-262 формат чисел
This commit is contained in:
parent
c505292247
commit
374ff0ca34
4 changed files with 49 additions and 2 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package ru.spcex.clearing.lim.exporter.config;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LimFormat {
|
||||
private static final DecimalFormat D_FORMAT_2;
|
||||
static {
|
||||
D_FORMAT_2 = new DecimalFormat("#0.00");
|
||||
// D_FORMAT_2.setMaximumFractionDigits(2);
|
||||
// D_FORMAT_2.setMinimumFractionDigits(2);
|
||||
D_FORMAT_2.setGroupingUsed(false);
|
||||
D_FORMAT_2.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static String toString(Long n) {
|
||||
return String.valueOf(n);
|
||||
}
|
||||
|
||||
public static String toStringD2(BigDecimal n) {
|
||||
if (n == null) return String.valueOf(n);
|
||||
return D_FORMAT_2.format(n);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.spcex.clearing.lim.exporter.config.LimFormat;
|
||||
import ru.spcex.clearing.lim.exporter.config.SFTPConfig;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
|
@ -85,7 +86,7 @@ public class MoneyExporterService extends AbstractExporterService {
|
|||
BigDecimal balance = registryA.getBalance() != null ?
|
||||
registryD != null && registryD.getBalance() != null ? registryA.getBalance().subtract(registryD.getBalance()) : registryA.getBalance() :
|
||||
BigDecimal.ZERO;
|
||||
row.append(balance);
|
||||
row.append(LimFormat.toStringD2(balance));
|
||||
|
||||
row.append("; OPEN_LIMIT = 0.00");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.spcex.clearing.lim.exporter.config.LimFormat;
|
||||
import ru.spcex.clearing.lim.exporter.config.SFTPConfig;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
|
@ -65,7 +66,7 @@ public class SecurityExporterService extends AbstractExporterService {
|
|||
row.append(registry.getTradingClearingRegistry());
|
||||
|
||||
row.append("; OPEN_BALANCE = ");
|
||||
row.append(registry.getBalance());
|
||||
row.append(LimFormat.toStringD2(registry.getBalance()));
|
||||
|
||||
row.append("; OPEN_LIMIT = 0");
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.lim.exporter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.spcex.clearing.lim.exporter.config.LimFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LimFormatTest {
|
||||
@Test
|
||||
void formatBigDecimal2() {
|
||||
assertEquals("null", LimFormat.toStringD2(null));
|
||||
assertEquals("0.00", LimFormat.toStringD2(BigDecimal.valueOf(0.00000000001)));
|
||||
assertEquals("102.43", LimFormat.toStringD2(BigDecimal.valueOf(102.43)));
|
||||
assertEquals("0.50", LimFormat.toStringD2(BigDecimal.valueOf(0.5)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue