FIN-45: Fix fee calc (#365)

This commit is contained in:
Rinat Arsaev 2024-06-11 15:07:40 +05:00 committed by GitHub
parent 310572e799
commit 26832f6087
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 11 deletions

View File

@ -24,7 +24,7 @@ export function createFeesColumns<T extends object>(
{
field: 'condition',
formatter: (d) =>
getInlineDecisions(getFees(d))
getInlineDecisions(getFees(d), filterFee)
.filter(filterDecisions(d))
.map((v) => formatLevelPredicate(v)),
},

View File

@ -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) =>

View File

@ -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(', ')})`;
}
}
}