feat: cashbox history tab
feat: add information fields to cashbox_batches table
This commit is contained in:
parent
642016efeb
commit
21708aa75c
8 changed files with 267 additions and 13 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const db = require('./db')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
function createCashboxBatch (rec) {
|
||||
const sql = 'INSERT INTO cashbox_batches (device_id, created) VALUES ($1, now()) RETURNING *'
|
||||
|
|
@ -15,4 +16,23 @@ function createCashboxBatch (rec) {
|
|||
})
|
||||
}
|
||||
|
||||
module.exports = { createCashboxBatch }
|
||||
function getBatches () {
|
||||
const sql = `SELECT cb.id, cb.device_id, cb.created, cb.operation_type, cb.bill_count_override, cb.performed_by,
|
||||
json_agg(b.*) AS bills FROM cashbox_batches cb LEFT JOIN bills b ON cb.id=b.cashbox_batch_id GROUP BY cb.id`
|
||||
return db.any(sql).then(res => _.map(it => ({
|
||||
id: it.id,
|
||||
deviceId: it.device_id,
|
||||
created: it.created,
|
||||
operationType: it.operation_type,
|
||||
billCountOverride: it.bill_count_override,
|
||||
performedBy: it.performed_by,
|
||||
bills: it.bills
|
||||
}), res))
|
||||
}
|
||||
|
||||
function getBillsByBatchId (id) {
|
||||
const sql = `SELECT * FROM bills WHERE cashbox_batch_id=$1`
|
||||
return db.any(sql, [id])
|
||||
}
|
||||
|
||||
module.exports = { createCashboxBatch, getBatches, getBillsByBatchId }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue