feat: cashbox history tab

This commit is contained in:
André Sá 2021-11-12 16:12:52 +00:00
parent 683778cb7b
commit dde26b8dc2
4 changed files with 326 additions and 17 deletions

View file

@ -5,6 +5,7 @@ const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
const got = require('got')
const DataLoader = require('dataloader')
const cashbox = require('../../cashbox-batches')
const machineLoader = require('../../machine-loader')
const customers = require('../../customers')
const { machineAction } = require('../machines')
@ -280,7 +281,18 @@ const typeDefs = gql`
cashbox: Int
}
type CashboxBatch {
id: ID
deviceId: ID
created: Date
operationType: String
customBillCount: Int
performedBy: String
bills: [Bills]
}
type Query {
cashboxBatches: [CashboxBatch]
countries: [Country]
currencies: [Currency]
languages: [Language]
@ -352,6 +364,7 @@ const typeDefs = gql`
toggleClearNotification(id: ID!, read: Boolean!): Notification
clearAllNotifications: Notification
cancelCashOutTransaction(id: ID): Transaction
editBatch(id: ID, performedBy: String): CashboxBatch
}
`
@ -378,6 +391,7 @@ const resolvers = {
latestEvent: parent => machineEventsLoader.load(parent.deviceId)
},
Query: {
cashboxBatches: () => cashbox.getBatches(),
countries: () => countries,
currencies: () => currencies,
languages: () => languages,
@ -449,7 +463,8 @@ const resolvers = {
deletePromoCode: (...[, { codeId }]) => promoCodeManager.deletePromoCode(codeId),
toggleClearNotification: (...[, { id, read }]) => notifierQueries.setRead(id, read),
clearAllNotifications: () => notifierQueries.markAllAsRead(),
cancelCashOutTransaction: (...[, { id }]) => cashOutTx.cancel(id)
cancelCashOutTransaction: (...[, { id }]) => cashOutTx.cancel(id),
editBatch: (...[, { id, performedBy }]) => cashbox.editBatchById(id, performedBy)
}
}