fix: cashbox batch creation with the new settings

fix: correctly update cassette and stacker count post-cashout tx
This commit is contained in:
Sérgio Salgado 2023-05-06 06:25:16 +01:00
parent 460a8cf1fd
commit 4338b3d98e
6 changed files with 15 additions and 18 deletions

View file

@ -11,7 +11,8 @@ function createCashboxBatch (deviceId, cashboxCount) {
UPDATE bills SET cashbox_batch_id=$1
FROM cash_in_txs
WHERE bills.cash_in_txs_id = cash_in_txs.id AND
cash_in_txs.device_id = $2 AND
cash_in_txs.device_id = $2 AND
bills.destination_unit = 'cashbox' AND
bills.cashbox_batch_id IS NULL
`
const sql3 = `
@ -42,7 +43,8 @@ function updateMachineWithBatch (machineContext, oldCashboxCount) {
const q1 = t.none(`INSERT INTO cash_unit_operation (id, device_id, created, operation_type) VALUES ($1, $2, now(), 'cash-box-empty')`, [batchId, deviceId])
const q2 = t.none(`UPDATE bills SET cashbox_batch_id=$1 FROM cash_in_txs
WHERE bills.cash_in_txs_id = cash_in_txs.id AND
cash_in_txs.device_id = $2 AND
cash_in_txs.device_id = $2 AND
bills.destination_unit = 'cashbox' AND
bills.cashbox_batch_id IS NULL`, [batchId, deviceId])
const q3 = t.none(`UPDATE empty_unit_bills SET cashbox_batch_id=$1
WHERE empty_unit_bills.device_id = $2 AND empty_unit_bills.cashbox_batch_id IS NULL`, [batchId, deviceId])