fix: cashbox batches log possible NaN and null values
This commit is contained in:
parent
03cb4a3c4c
commit
24807a70ef
1 changed files with 7 additions and 4 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue