Merge pull request #939 from SiIky/fix/iCfPSCAQ/sort_cashbox_batches-dev

fix: sort cashbox batches by date
This commit is contained in:
Rafael Taranto 2021-11-23 09:06:10 +00:00 committed by GitHub
commit 613b947a9d

View file

@ -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))
}