fix: improve cashbox batches logs
This commit is contained in:
parent
1d5b758e39
commit
463195fc17
2 changed files with 29 additions and 2 deletions
|
|
@ -69,10 +69,36 @@ function getBillsByBatchId (id) {
|
|||
return db.any(sql, [id])
|
||||
}
|
||||
|
||||
function logFormatter (data) {
|
||||
return _.map(
|
||||
it => {
|
||||
return {
|
||||
id: it.id,
|
||||
deviceId: it.deviceId,
|
||||
created: it.created,
|
||||
operationType: it.operationType,
|
||||
performedBy: it.performedBy,
|
||||
billCount: _.size(it.bills),
|
||||
fiatTotals: _.reduce(
|
||||
(acc, value) => {
|
||||
acc[value.fiat_code] = (acc[value.fiat_code] || 0) + value.fiat
|
||||
return acc
|
||||
},
|
||||
{},
|
||||
it.bills
|
||||
),
|
||||
billsByDenomination: _.countBy(ite => `${ite.fiat} ${ite.fiat_code}`, it.bills)
|
||||
}
|
||||
},
|
||||
data
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createCashboxBatch,
|
||||
updateMachineWithBatch,
|
||||
getBatches,
|
||||
getBillsByBatchId,
|
||||
editBatchById
|
||||
editBatchById,
|
||||
logFormatter
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue