Merge pull request #1182 from chaotixkilla/fix-improve-cashbox-batches-logs
Improve cashbox batches logs
This commit is contained in:
commit
03cb4a3c4c
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ const logDateFormat = require('../../../logs').logDateFormat
|
|||
const resolvers = {
|
||||
Query: {
|
||||
cashboxBatches: () => cashbox.getBatches(),
|
||||
cashboxBatchesCsv: (...[, { from, until, timezone }]) => cashbox.getBatches(from, until).then(data => parseAsync(logDateFormat(timezone, data, ['created'])))
|
||||
cashboxBatchesCsv: (...[, { from, until, timezone }]) => cashbox.getBatches(from, until)
|
||||
.then(data => parseAsync(logDateFormat(timezone, cashbox.logFormatter(data), ['created'])))
|
||||
},
|
||||
Mutation: {
|
||||
createBatch: (...[, { deviceId, cashboxCount }]) => cashbox.createCashboxBatch(deviceId, cashboxCount),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue