diff --git a/Components/Calculation/Form/Insurance/FinGAPTable/config.ts b/Components/Calculation/Form/Insurance/FinGAPTable/config.ts index fd5545c..d993aed 100644 --- a/Components/Calculation/Form/Insurance/FinGAPTable/config.ts +++ b/Components/Calculation/Form/Insurance/FinGAPTable/config.ts @@ -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 = [ @@ -14,12 +13,18 @@ export const columns: ColumnsType = [ 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, }, ]; diff --git a/Components/Output/PaymentsTable/config.ts b/Components/Output/PaymentsTable/config.ts index b1aead2..8717f3d 100644 --- a/Components/Output/PaymentsTable/config.ts +++ b/Components/Output/PaymentsTable/config.ts @@ -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 = [ @@ -17,18 +14,27 @@ export const columns: ColumnsType = [ 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, }, ]; diff --git a/Components/Output/Results/config.ts b/Components/Output/Results/config.ts index 15ac610..36e170a 100644 --- a/Components/Output/Results/config.ts +++ b/Components/Output/Results/config.ts @@ -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); diff --git a/tools/format.js b/tools/format.js deleted file mode 100644 index 68a4b7f..0000000 --- a/tools/format.js +++ /dev/null @@ -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); -} diff --git a/tools/function.js b/tools/function.js deleted file mode 100644 index 983855b..0000000 --- a/tools/function.js +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable import/prefer-default-export */ - -export function pipe(...fns) { - return (x) => fns.reduce((v, f) => f(v), x); -} diff --git a/tools/number.ts b/tools/number.ts deleted file mode 100644 index 6408519..0000000 --- a/tools/number.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable import/prefer-default-export */ - -export { round } from 'lodash';