Merge pull request #933 from SiIky/feat/iCfPSCAQ/cashbox-history-backport

feat: cashbox history backport
This commit is contained in:
Rafael Taranto 2021-11-23 09:08:27 +00:00 committed by GitHub
commit 60e939a4b9
16 changed files with 952 additions and 23 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')
@ -273,14 +274,25 @@ const typeDefs = gql`
valid: Boolean
}
type Bills {
type Bill {
fiat: Int
deviceId: ID
created: Date
cashbox: Int
}
type CashboxBatch {
id: ID
deviceId: ID
created: Date
operationType: String
customBillCount: Int
performedBy: String
bills: [Bill]
}
type Query {
cashboxBatches: [CashboxBatch]
countries: [Country]
currencies: [Currency]
languages: [Language]
@ -315,7 +327,7 @@ const typeDefs = gql`
notifications: [Notification]
alerts: [Notification]
hasUnreadNotifications: Boolean
bills: [Bills]
bills: [Bill]
}
type SupportLogsResponse {
@ -352,6 +364,8 @@ const typeDefs = gql`
toggleClearNotification(id: ID!, read: Boolean!): Notification
clearAllNotifications: Notification
cancelCashOutTransaction(id: ID): Transaction
createBatch(deviceId: ID, cashboxCount: Int): CashboxBatch
editBatch(id: ID, performedBy: String): CashboxBatch
}
`
@ -378,6 +392,7 @@ const resolvers = {
latestEvent: parent => machineEventsLoader.load(parent.deviceId)
},
Query: {
cashboxBatches: () => cashbox.getBatches(),
countries: () => countries,
currencies: () => currencies,
languages: () => languages,
@ -449,7 +464,9 @@ 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),
createBatch: (...[, { deviceId, cashboxCount }]) => cashbox.createCashboxBatch(deviceId, cashboxCount),
editBatch: (...[, { id, performedBy }]) => cashbox.editBatchById(id, performedBy)
}
}