Merge pull request #1183 from chaotixkilla/fix-cashbox-batches-log-NaN-values

Fix possible NaN and null values on cashbox batch logs
This commit is contained in:
Rafael Taranto 2022-04-06 00:50:54 +01:00 committed by GitHub
commit f9ae681453

View file

@ -72,22 +72,25 @@ function getBillsByBatchId (id) {
function logFormatter (data) { function logFormatter (data) {
return _.map( return _.map(
it => { it => {
const bills = _.filter(
ite => !(_.isNil(ite) || _.isNil(ite.fiat_code) || _.isNil(ite.fiat) || _.isNaN(ite.fiat)),
it.bills
)
return { return {
id: it.id, id: it.id,
deviceId: it.deviceId, deviceId: it.deviceId,
created: it.created, created: it.created,
operationType: it.operationType, operationType: it.operationType,
performedBy: it.performedBy, billCount: _.size(bills),
billCount: _.size(it.bills),
fiatTotals: _.reduce( fiatTotals: _.reduce(
(acc, value) => { (acc, value) => {
acc[value.fiat_code] = (acc[value.fiat_code] || 0) + value.fiat acc[value.fiat_code] = (acc[value.fiat_code] || 0) + value.fiat
return acc return acc
}, },
{}, {},
it.bills bills
), ),
billsByDenomination: _.countBy(ite => `${ite.fiat} ${ite.fiat_code}`, it.bills) billsByDenomination: _.countBy(ite => `${ite.fiat} ${ite.fiat_code}`, bills)
} }
}, },
data data