From 1507dcced9508220f02faaaa963e9920a85d87ff Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Thu, 25 Jan 2024 14:58:39 +0000 Subject: [PATCH] fix: dispense for multiple boxes with same denom --- lib/bill-math.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bill-math.js b/lib/bill-math.js index fa0b8db8..8f5daea5 100644 --- a/lib/bill-math.js +++ b/lib/bill-math.js @@ -138,7 +138,12 @@ const solutionToOriginalUnits = (solution, units) => { const billsLeft = _.flow( _.map(([denomination, provisioned]) => [BN(denomination), provisioned]), - _.fromPairs, + _.reduce((acc, value) => { + acc[value[0]] = (acc[value[0]] || BN(0)).plus(value[1]) + return acc + }, + {} + ) )(solution) return _.map(