From 26832f60875e52c92e80017cb0ff2afa304c4a73 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:07:40 +0500 Subject: [PATCH] FIN-45: Fix fee calc (#365) --- .../tariffs/utils/create-fees-columns.ts | 2 +- .../tariffs/utils/get-inline-decisions.ts | 6 +++--- .../shared/utils/table/format-cash-volume.ts | 17 ++++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/sections/tariffs/utils/create-fees-columns.ts b/src/app/sections/tariffs/utils/create-fees-columns.ts index f53be84d..fc69b5c9 100644 --- a/src/app/sections/tariffs/utils/create-fees-columns.ts +++ b/src/app/sections/tariffs/utils/create-fees-columns.ts @@ -24,7 +24,7 @@ export function createFeesColumns( { field: 'condition', formatter: (d) => - getInlineDecisions(getFees(d)) + getInlineDecisions(getFees(d), filterFee) .filter(filterDecisions(d)) .map((v) => formatLevelPredicate(v)), }, diff --git a/src/app/sections/tariffs/utils/get-inline-decisions.ts b/src/app/sections/tariffs/utils/get-inline-decisions.ts index 03de2477..31751c36 100644 --- a/src/app/sections/tariffs/utils/get-inline-decisions.ts +++ b/src/app/sections/tariffs/utils/get-inline-decisions.ts @@ -67,11 +67,11 @@ export function getInlineDecisions( ): InlineCashFlowSelector[] { return d.reduce((acc, c) => { if (c.value) { + const value = c.value.filter(filterValue); acc.push({ - value: formatCashVolumes(c.value.filter(filterValue).map((v) => v.volume)), + value: formatCashVolumes(value.map((v) => v.volume)), level, - description: c.value - .filter(filterValue) + description: value .sort((a, b) => compareCashVolumes(a.volume, b.volume)) .map( (v) => diff --git a/src/app/shared/utils/table/format-cash-volume.ts b/src/app/shared/utils/table/format-cash-volume.ts index 76637006..fc93c8cc 100644 --- a/src/app/shared/utils/table/format-cash-volume.ts +++ b/src/app/shared/utils/table/format-cash-volume.ts @@ -28,12 +28,15 @@ export function formatCashVolume(d: CashVolume) { (d?.share?.of === 2 ? ' of surplus' : '') + (d?.share?.rounding_method === 1 ? ' (round .5+)' : '') ); - case 'product': - return getUnionValue(d.product).size <= 1 - ? formatCashVolume(getUnionValue(d.product)[0]) - : `${getUnionKey(d.product).slice(0, -3)}(${Array.from(getUnionValue(d.product)) - .sort(compareCashVolumes) - .map((c) => formatCashVolume(c)) - .join(', ')})`; + case 'product': { + const products = Array.from(getUnionValue(d.product)); + if (products.length === 1) { + return formatCashVolume(products[0]); + } + return `${getUnionKey(d.product).slice(0, -3)}(${products + .sort(compareCashVolumes) + .map((c) => formatCashVolume(c)) + .join(', ')})`; + } } }