tools: remove unused
This commit is contained in:
parent
44fabd3ed2
commit
a670881325
@ -1,6 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import type { ColumnsType } from 'antd/lib/table';
|
||||
import { formatMoney } from 'tools/format';
|
||||
import type { Risk } from './types';
|
||||
|
||||
export const columns: ColumnsType<Risk> = [
|
||||
@ -14,12 +13,18 @@ export const columns: ColumnsType<Risk> = [
|
||||
key: 'sum',
|
||||
title: 'Страховая сумма',
|
||||
dataIndex: 'sum',
|
||||
render: (value: number) => formatMoney(value, 'RUB'),
|
||||
render: Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
},
|
||||
{
|
||||
key: 'premium',
|
||||
title: 'Страховая премия по риску',
|
||||
dataIndex: 'premium',
|
||||
render: (value: number) => formatMoney(value, 'RUB'),
|
||||
render: Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
},
|
||||
];
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
import type { ColumnsType } from 'antd/lib/table';
|
||||
import { formatMoney } from 'tools/format';
|
||||
import { pipe } from 'tools/function';
|
||||
import { round } from 'tools/number';
|
||||
import type { Payment } from './types';
|
||||
|
||||
export const columns: ColumnsType<Payment> = [
|
||||
@ -17,18 +14,27 @@ export const columns: ColumnsType<Payment> = [
|
||||
key: 'paymentSum',
|
||||
dataIndex: 'paymentSum',
|
||||
title: 'Сумма платежа',
|
||||
render: (value) => pipe(round, formatMoney)(value),
|
||||
render: Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
},
|
||||
{
|
||||
key: 'ndsCompensation',
|
||||
dataIndex: 'ndsCompensation',
|
||||
title: 'НДС к возмещению',
|
||||
render: (value) => pipe(round, formatMoney)(value),
|
||||
render: Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
},
|
||||
{
|
||||
key: 'redemptionAmount',
|
||||
dataIndex: 'redemptionAmount',
|
||||
title: 'Сумма досрочного выкупа',
|
||||
render: (value) => pipe(round, formatMoney)(value),
|
||||
render: Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
},
|
||||
];
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
|
||||
import type { Values } from 'stores/results/types';
|
||||
import { formatMoney, formatNumber, formatPercent } from 'tools/format';
|
||||
import { pipe } from 'tools/function';
|
||||
import { round } from 'tools/number';
|
||||
|
||||
export const id = 'output';
|
||||
export const title = 'Результаты';
|
||||
@ -48,17 +45,32 @@ const moneyFormatters = Object.fromEntries(
|
||||
'resultBonusSafeFinance',
|
||||
'resultPriceUpPr',
|
||||
] as Values[]
|
||||
).map((a) => [a, (value: number) => pipe(round, formatMoney)(value)])
|
||||
).map((a) => [
|
||||
a,
|
||||
// prettier-ignore
|
||||
Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency: 'RUB',
|
||||
}).format,
|
||||
])
|
||||
);
|
||||
|
||||
const percentFormatters = Object.fromEntries(
|
||||
(['resultIRRGraphPerc', 'resultIRRNominalPerc', 'resultFirstPaymentRiskPolicy'] as Values[]).map(
|
||||
(a) => [a, (value: number) => pipe(round, formatPercent)(value)]
|
||||
(a) => [
|
||||
a,
|
||||
// prettier-ignore
|
||||
Intl.NumberFormat('ru', {
|
||||
style: 'percent',
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
const defaultFormatters = {
|
||||
resultTerm: (value: number) => formatNumber(value),
|
||||
resultTerm: Intl.NumberFormat('ru').format,
|
||||
};
|
||||
|
||||
export const formatters = Object.assign(moneyFormatters, percentFormatters, defaultFormatters);
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
export function formatMoney(n = 0, currency = 'RUB') {
|
||||
return Intl.NumberFormat('ru', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
}).format(n);
|
||||
}
|
||||
|
||||
export function formatNumber(n = 0) {
|
||||
return Intl.NumberFormat('ru').format(n);
|
||||
}
|
||||
|
||||
export function formatPercent(n = 0) {
|
||||
return Intl.NumberFormat('ru', {
|
||||
style: 'percent',
|
||||
maximumFractionDigits: 2,
|
||||
}).format(n);
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
export function pipe(...fns) {
|
||||
return (x) => fns.reduce((v, f) => f(v), x);
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
export { round } from 'lodash';
|
||||
Loading…
x
Reference in New Issue
Block a user