diff --git a/lib/cash-out/cash-out-helper.js b/lib/cash-out/cash-out-helper.js index 87d79a00..f86086a6 100644 --- a/lib/cash-out/cash-out-helper.js +++ b/lib/cash-out/cash-out-helper.js @@ -43,7 +43,7 @@ const SNAKE_CASE_BILL_FIELDS = [ 'provisioned_recycler_6' ] -const BILL_FIELDS = _.map(_.camelCase, BILL_FIELDS) +const BILL_FIELDS = _.map(_.camelCase, SNAKE_CASE_BILL_FIELDS) module.exports = { redeemableTxs, toObj, toDb, REDEEMABLE_AGE, CASH_OUT_TRANSACTION_STATES } diff --git a/migrations/1696845395350-recycler-rename-settings.js b/migrations/1696845395350-recycler-rename-settings.js index 05cd4353..1e330d90 100644 --- a/migrations/1696845395350-recycler-rename-settings.js +++ b/migrations/1696845395350-recycler-rename-settings.js @@ -2,80 +2,84 @@ const db = require('./db') exports.up = function (next) { var sql = [ - `ALTER TABLE cash_out_actions - RENAME COLUMN provisioned_1f TO provisioned_recycler_1, - RENAME COLUMN provisioned_1r TO provisioned_recycler_2, - RENAME COLUMN provisioned_2f TO provisioned_recycler_3, - RENAME COLUMN provisioned_2r TO provisioned_recycler_4, - RENAME COLUMN provisioned_3f TO provisioned_recycler_5, - RENAME COLUMN provisioned_3r TO provisioned_recycler_6, - RENAME COLUMN dispensed_1f TO dispensed_recycler_1, - RENAME COLUMN dispensed_1r TO dispensed_recycler_2, - RENAME COLUMN dispensed_2f TO dispensed_recycler_3, - RENAME COLUMN dispensed_2r TO dispensed_recycler_4, - RENAME COLUMN dispensed_3f TO dispensed_recycler_5, - RENAME COLUMN dispensed_3r TO dispensed_recycler_6, - RENAME COLUMN rejected_1f TO rejected_recycler_1, - RENAME COLUMN rejected_1r TO rejected_recycler_2, - RENAME COLUMN rejected_2f TO rejected_recycler_3, - RENAME COLUMN rejected_2r TO rejected_recycler_4, - RENAME COLUMN rejected_3f TO rejected_recycler_5, - RENAME COLUMN rejected_3r TO rejected_recycler_6, - RENAME COLUMN denomination_1f TO denomination_recycler_1, - RENAME COLUMN denomination_1r TO denomination_recycler_2, - RENAME COLUMN denomination_2f TO denomination_recycler_3, - RENAME COLUMN denomination_2r TO denomination_recycler_4, - RENAME COLUMN denomination_3f TO denomination_recycler_5, - RENAME COLUMN denomination_3r TO denomination_recycler_6`, - `ALTER TABLE devices - RENAME COLUMN stacker1f TO recycler1, - RENAME COLUMN stacker1r TO recycler2, - RENAME COLUMN stacker2f TO recycler3, - RENAME COLUMN stacker2r TO recycler4, - RENAME COLUMN stacker3f TO recycler5, - RENAME COLUMN stacker3r TO recycler6, - RENAME COLUMN number_of_stackers TO number_of_recyclers`, - `ALTER TABLE cash_out_txs - RENAME COLUMN provisioned_1f TO provisioned_recycler_1, - RENAME COLUMN provisioned_1r TO provisioned_recycler_2, - RENAME COLUMN provisioned_2f TO provisioned_recycler_3, - RENAME COLUMN provisioned_2r TO provisioned_recycler_4, - RENAME COLUMN provisioned_3f TO provisioned_recycler_5, - RENAME COLUMN provisioned_3r TO provisioned_recycler_6, - RENAME COLUMN denomination_1f TO denomination_recycler_1, - RENAME COLUMN denomination_1r TO denomination_recycler_2, - RENAME COLUMN denomination_2f TO denomination_recycler_3, - RENAME COLUMN denomination_2r TO denomination_recycler_4, - RENAME COLUMN denomination_3f TO denomination_recycler_5, - RENAME COLUMN denomination_3r TO denomination_recycler_6`, - `ALTER TYPE cash_unit - RENAME VALUE 'stacker1f' TO 'recycler1', - RENAME VALUE 'stacker1r' TO 'recycler2', - RENAME VALUE 'stacker2f' TO 'recycler3', - RENAME VALUE 'stacker2r' TO 'recycler4', - RENAME VALUE 'stacker3f' TO 'recycler5', - RENAME VALUE 'stacker3r' TO 'recycler6', - `, - `ALTER TYPE cash_unit_operation_type - RENAME VALUE 'cash-stacker-1f-refill' TO 'cash-recycler-1-refill', - RENAME VALUE 'cash-stacker-1f-empty' TO 'cash-recycler-1-empty', - RENAME VALUE 'cash-stacker-1f-count-change' TO 'cash-recycler-1-count-change', - RENAME VALUE 'cash-stacker-1r-refill' TO 'cash-recycler-2-refill', - RENAME VALUE 'cash-stacker-1r-empty' TO 'cash-recycler-2-empty', - RENAME VALUE 'cash-stacker-1r-count-change' TO 'cash-recycler-2-count-change', - RENAME VALUE 'cash-stacker-2f-refill' TO 'cash-recycler-3-refill', - RENAME VALUE 'cash-stacker-2f-empty' TO 'cash-recycler-3-empty', - RENAME VALUE 'cash-stacker-2f-count-change' TO 'cash-recycler-3-count-change', - RENAME VALUE 'cash-stacker-2r-refill' TO 'cash-recycler-4-refill', - RENAME VALUE 'cash-stacker-2r-empty' TO 'cash-recycler-4-empty', - RENAME VALUE 'cash-stacker-2r-count-change' TO 'cash-recycler-4-count-change', - RENAME VALUE 'cash-stacker-3f-refill' TO 'cash-recycler-5-refill', - RENAME VALUE 'cash-stacker-3f-empty' TO 'cash-recycler-5-empty', - RENAME VALUE 'cash-stacker-3f-count-change' TO 'cash-recycler-5-count-change', - RENAME VALUE 'cash-stacker-3r-refill' TO 'cash-recycler-6-refill', - RENAME VALUE 'cash-stacker-3r-empty' TO 'cash-recycler-6-empty', - RENAME VALUE 'cash-stacker-3r-count-change' TO 'cash-recycler-6-count-change', ` + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_1f TO provisioned_recycler_1; + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_1r TO provisioned_recycler_2; + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_2f TO provisioned_recycler_3; + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_2r TO provisioned_recycler_4; + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_3f TO provisioned_recycler_5; + ALTER TABLE cash_out_actions RENAME COLUMN provisioned_3r TO provisioned_recycler_6; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_1f TO dispensed_recycler_1; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_1r TO dispensed_recycler_2; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_2f TO dispensed_recycler_3; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_2r TO dispensed_recycler_4; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_3f TO dispensed_recycler_5; + ALTER TABLE cash_out_actions RENAME COLUMN dispensed_3r TO dispensed_recycler_6; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_1f TO rejected_recycler_1; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_1r TO rejected_recycler_2; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_2f TO rejected_recycler_3; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_2r TO rejected_recycler_4; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_3f TO rejected_recycler_5; + ALTER TABLE cash_out_actions RENAME COLUMN rejected_3r TO rejected_recycler_6; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_1f TO denomination_recycler_1; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_1r TO denomination_recycler_2; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_2f TO denomination_recycler_3; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_2r TO denomination_recycler_4; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_3f TO denomination_recycler_5; + ALTER TABLE cash_out_actions RENAME COLUMN denomination_3r TO denomination_recycler_6; + `, + ` + ALTER TABLE devices RENAME COLUMN stacker1f TO recycler1; + ALTER TABLE devices RENAME COLUMN stacker1r TO recycler2; + ALTER TABLE devices RENAME COLUMN stacker2f TO recycler3; + ALTER TABLE devices RENAME COLUMN stacker2r TO recycler4; + ALTER TABLE devices RENAME COLUMN stacker3f TO recycler5; + ALTER TABLE devices RENAME COLUMN stacker3r TO recycler6; + ALTER TABLE devices RENAME COLUMN number_of_stackers TO number_of_recyclers; + `, + ` + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_1f TO provisioned_recycler_1; + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_1r TO provisioned_recycler_2; + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_2f TO provisioned_recycler_3; + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_2r TO provisioned_recycler_4; + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_3f TO provisioned_recycler_5; + ALTER TABLE cash_out_txs RENAME COLUMN provisioned_3r TO provisioned_recycler_6; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_1f TO denomination_recycler_1; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_1r TO denomination_recycler_2; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_2f TO denomination_recycler_3; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_2r TO denomination_recycler_4; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_3f TO denomination_recycler_5; + ALTER TABLE cash_out_txs RENAME COLUMN denomination_3r TO denomination_recycler_6; + `, + ` + ALTER TYPE cash_unit RENAME VALUE 'stacker1f' TO 'recycler1'; + ALTER TYPE cash_unit RENAME VALUE 'stacker1r' TO 'recycler2'; + ALTER TYPE cash_unit RENAME VALUE 'stacker2f' TO 'recycler3'; + ALTER TYPE cash_unit RENAME VALUE 'stacker2r' TO 'recycler4'; + ALTER TYPE cash_unit RENAME VALUE 'stacker3f' TO 'recycler5'; + ALTER TYPE cash_unit RENAME VALUE 'stacker3r' TO 'recycler6'; + `, + ` + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1f-refill' TO 'cash-recycler-1-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1f-empty' TO 'cash-recycler-1-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1f-count-change' TO 'cash-recycler-1-count-change'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1r-refill' TO 'cash-recycler-2-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1r-empty' TO 'cash-recycler-2-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-1r-count-change' TO 'cash-recycler-2-count-change'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2f-refill' TO 'cash-recycler-3-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2f-empty' TO 'cash-recycler-3-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2f-count-change' TO 'cash-recycler-3-count-change'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2r-refill' TO 'cash-recycler-4-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2r-empty' TO 'cash-recycler-4-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-2r-count-change' TO 'cash-recycler-4-count-change'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3f-refill' TO 'cash-recycler-5-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3f-empty' TO 'cash-recycler-5-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3f-count-change' TO 'cash-recycler-5-count-change'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3r-refill' TO 'cash-recycler-6-refill'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3r-empty' TO 'cash-recycler-6-empty'; + ALTER TYPE cash_unit_operation_type RENAME VALUE 'cash-stacker-3r-count-change' TO 'cash-recycler-6-count-change'; + `, + `UPDATE devices SET number_of_recyclers = number_of_recyclers * 2;` ] db.multi(sql, next) diff --git a/new-lamassu-admin/src/pages/Accounting/Accounting.js b/new-lamassu-admin/src/pages/Accounting/Accounting.js index 0d46d450..09b38d0b 100644 --- a/new-lamassu-admin/src/pages/Accounting/Accounting.js +++ b/new-lamassu-admin/src/pages/Accounting/Accounting.js @@ -178,8 +178,6 @@ const Accounting = () => { ) ?? 0 ).toNumber() - console.log(opData) - return ( !loading && ( <> diff --git a/new-lamassu-admin/src/pages/Cashout/Wizard.js b/new-lamassu-admin/src/pages/Cashout/Wizard.js index 7ca042ee..c6cac4c1 100644 --- a/new-lamassu-admin/src/pages/Cashout/Wizard.js +++ b/new-lamassu-admin/src/pages/Cashout/Wizard.js @@ -18,8 +18,7 @@ const MODAL_HEIGHT = 520 const Wizard = ({ machine, locale, onClose, save, error }) => { // Each stacker counts as two steps, one for front and another for rear - const LAST_STEP = - machine.numberOfCassettes + machine.numberOfRecyclers * 2 + 1 + const LAST_STEP = machine.numberOfCassettes + machine.numberOfRecyclers + 1 const [{ step, config }, setState] = useState({ step: 0, config: { active: true } @@ -63,31 +62,18 @@ const Wizard = ({ machine, locale, onClose, save, error }) => { }), R.range(1, machine.numberOfCassettes + 1) ), - R.chain( - it => [ - { - type: `recycler${it * 2 - 1}`, - model: 'recycler', - display: `Recycler ${it}`, - component: Autocomplete, - inputProps: { - options: options, - labelProp: 'display', - valueProp: 'code' - } - }, - { - type: `recycler${it * 2}`, - model: 'recycler', - display: `Recycler ${it}`, - component: Autocomplete, - inputProps: { - options: options, - labelProp: 'display', - valueProp: 'code' - } + R.map( + it => ({ + type: `recycler${it}`, + model: 'recycler', + display: `Recycler ${it}`, + component: Autocomplete, + inputProps: { + options: options, + labelProp: 'display', + valueProp: 'code' } - ], + }), R.range(1, machine.numberOfRecyclers + 1) ) ) diff --git a/new-lamassu-admin/src/pages/Cashout/helper.js b/new-lamassu-admin/src/pages/Cashout/helper.js index 68614142..611e5fd7 100644 --- a/new-lamassu-admin/src/pages/Cashout/helper.js +++ b/new-lamassu-admin/src/pages/Cashout/helper.js @@ -141,31 +141,28 @@ const getElements = (machines, locale = {}, classes) => { ) R.until( - R.gt( - R.__, - Math.ceil(maxNumberOfRecyclers), - it => { - elements.push({ - names: [`recycler${it * 2 - 1}`, `recycler${it * 2}`], - header: `Recyclers ${it * 2 - 1} ${it * 2}`, - size: 'sm', - stripe: true, - textAlign: 'right', - width: widthsByNumberOfUnits[numberOfCashUnits]?.cassette, - suffix: fiatCurrency, - bold: bold, - input: options?.length > 0 ? Autocomplete : NumberInput, - inputProps: cassetteProps, - doubleHeader: 'Denominations of Cassettes & Recyclers', - isHidden: machine => - it > - machines.find(({ deviceId }) => deviceId === machine.id) - .numberOfRecyclers - }) - return R.add(1, it) - }, - 1 - ) + R.gt(R.__, Math.ceil(maxNumberOfRecyclers / 2)), + it => { + elements.push({ + names: [`recycler${it * 2 - 1}`, `recycler${it * 2}`], + header: `Recyclers ${it * 2 - 1} - ${it * 2}`, + size: 'sm', + stripe: true, + textAlign: 'right', + width: widthsByNumberOfUnits[numberOfCashUnits]?.cassette, + suffix: fiatCurrency, + bold: bold, + input: options?.length > 0 ? Autocomplete : NumberInput, + inputProps: cassetteProps, + doubleHeader: 'Denominations of Cassettes & Recyclers', + isHidden: machine => + it > + machines.find(({ deviceId }) => deviceId === machine.id) + .numberOfRecyclers + }) + return R.add(1, it) + }, + 1 ) return elements diff --git a/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js b/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js index 6aa124ae..29c7494c 100644 --- a/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js +++ b/new-lamassu-admin/src/pages/Maintenance/CashUnitDetails.js @@ -174,9 +174,13 @@ const CashUnitDetails = ({ {R.map(it => ( <>