From 3213513f54414679c5aa76c2bdcdff4f4520acc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Tue, 14 Dec 2021 12:32:09 +0000 Subject: [PATCH] refactor: rename cash box/cassette batch operations type --- lib/cashbox-batches.js | 6 +++--- migrations/1617967601902-add-batches-type.js | 18 +++++++++--------- .../src/pages/Maintenance/CashboxHistory.js | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/cashbox-batches.js b/lib/cashbox-batches.js index c3b8ba99..dfc9d2a6 100644 --- a/lib/cashbox-batches.js +++ b/lib/cashbox-batches.js @@ -5,8 +5,8 @@ const uuid = require('uuid') function createCashboxBatch (deviceId, cashboxCount) { if (_.isEqual(0, cashboxCount)) throw new Error('Cashbox is empty. Cashbox batch could not be created.') - const sql = `INSERT INTO cashbox_batches (id, device_id, created, operation_type) VALUES ($1, $2, now(), 'cash-in-empty') RETURNING *` - const sql2 = ` + const sql = `INSERT INTO cashbox_batches (id, device_id, created, operation_type) VALUES ($1, $2, now(), 'cash-box-empty') RETURNING *` + const sql2 = ` UPDATE bills SET cashbox_batch_id=$1 FROM cash_in_txs WHERE bills.cash_in_txs_id = cash_in_txs.id AND @@ -29,7 +29,7 @@ function updateMachineWithBatch (machineContext, oldCashboxCount) { return db.tx(t => { const deviceId = machineContext.deviceId const batchId = uuid.v4() - const q1 = t.none(`INSERT INTO cashbox_batches (id, device_id, created, operation_type) VALUES ($1, $2, now(), 'cash-in-empty')`, [batchId, deviceId]) + const q1 = t.none(`INSERT INTO cashbox_batches (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 diff --git a/migrations/1617967601902-add-batches-type.js b/migrations/1617967601902-add-batches-type.js index 20d64368..97532908 100644 --- a/migrations/1617967601902-add-batches-type.js +++ b/migrations/1617967601902-add-batches-type.js @@ -3,15 +3,15 @@ var db = require('./db') exports.up = function (next) { var sqls = [ `CREATE TYPE cashbox_batch_type AS ENUM( - 'cash-in-empty', - 'cash-out-1-refill', - 'cash-out-1-empty', - 'cash-out-2-refill', - 'cash-out-2-empty', - 'cash-out-3-refill', - 'cash-out-3-empty', - 'cash-out-4-refill', - 'cash-out-4-empty' + 'cash-box-empty', + 'cash-cassette-1-refill', + 'cash-cassette-1-empty', + 'cash-cassette-2-refill', + 'cash-cassette-2-empty', + 'cash-cassette-3-refill', + 'cash-cassette-3-empty', + 'cash-cassette-4-refill', + 'cash-cassette-4-empty' )`, `ALTER TABLE cashbox_batches ADD COLUMN operation_type cashbox_batch_type NOT NULL`, `ALTER TABLE cashbox_batches ADD COLUMN bill_count_override SMALLINT`, diff --git a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js index 2a98fd35..f0171370 100644 --- a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js +++ b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js @@ -93,14 +93,14 @@ const CashboxHistory = ({ machines, currency }) => { (ret, i) => R.pipe( R.assoc( - `cash-out-${i}-refill`, + `cash-cassette-${i}-refill`, <> Cash-out {i} refill ), R.assoc( - `cash-out-${i}-empty`, + `cash-cassette-${i}-empty`, <> Cash-out {i} emptied @@ -108,7 +108,7 @@ const CashboxHistory = ({ machines, currency }) => { ) )(ret), { - 'cash-in-empty': ( + 'cash-box-empty': ( <> Cash-in emptied