fix: sort cashbox batches by date
This commit is contained in:
parent
8128f05ffb
commit
d30c381674
1 changed files with 7 additions and 2 deletions
|
|
@ -19,8 +19,13 @@ function createCashboxBatch (deviceId, cashboxCount) {
|
|||
}
|
||||
|
||||
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`
|
||||
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 AS cb
|
||||
LEFT JOIN bills AS b ON cb.id = b.cashbox_batch_id
|
||||
GROUP BY cb.id
|
||||
ORDER BY cb.created DESC
|
||||
`
|
||||
return db.any(sql).then(res => _.map(it => _.mapKeys(ite => _.camelCase(ite), it), res))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue