feat: add cashbox batches log downloader

This commit is contained in:
Sérgio Salgado 2022-03-29 22:50:34 +01:00
parent b8ae64a798
commit f2f34c6ecd
8 changed files with 60 additions and 30 deletions

View file

@ -1,8 +1,11 @@
const { parseAsync } = require('json2csv')
const cashbox = require('../../../cashbox-batches')
const logDateFormat = require('../../../logs').logDateFormat
const resolvers = {
Query: {
cashboxBatches: () => cashbox.getBatches()
cashboxBatches: () => cashbox.getBatches(),
cashboxBatchesCsv: (...[, { from, until, timezone }]) => cashbox.getBatches(from, until).then(data => parseAsync(logDateFormat(timezone, data, ['created'])))
},
Mutation: {
createBatch: (...[, { deviceId, cashboxCount }]) => cashbox.createCashboxBatch(deviceId, cashboxCount),