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),

View file

@ -12,12 +12,13 @@ const typeDef = gql`
}
type Query {
cashboxBatches: [CashboxBatch]
cashboxBatches: [CashboxBatch] @auth
cashboxBatchesCsv(from: Date, until: Date, timezone: String): String @auth
}
type Mutation {
createBatch(deviceId: ID, cashboxCount: Int): CashboxBatch
editBatch(id: ID, performedBy: String): CashboxBatch
createBatch(deviceId: ID, cashboxCount: Int): CashboxBatch @auth
editBatch(id: ID, performedBy: String): CashboxBatch @auth
}
`