fix: cashbox batch creation with the new settings
fix: correctly update cassette and stacker count post-cashout tx
This commit is contained in:
parent
460a8cf1fd
commit
4338b3d98e
6 changed files with 15 additions and 18 deletions
|
|
@ -107,17 +107,10 @@ function nextHd (t, isHd, tx) {
|
||||||
function updateCassettes (t, tx) {
|
function updateCassettes (t, tx) {
|
||||||
if (!dispenseOccurred(tx.bills)) return Promise.resolve()
|
if (!dispenseOccurred(tx.bills)) return Promise.resolve()
|
||||||
|
|
||||||
const sql = `update devices set
|
const billsStmt = _.join(', ')(_.map(it => `${tx.bills[it].name} = ${tx.bills[it].name} - $${it + 1}`)(_.range(0, _.size(tx.bills))))
|
||||||
${_.size(tx.bills) > 0 ? `cassette1 = cassette1 - $1` : ``}
|
const returnStmt = _.join(', ')(_.map(bill => `${bill.name}`)(tx.bills))
|
||||||
${_.size(tx.bills) > 1 ? `, cassette2 = cassette2 - $2` : ``}
|
|
||||||
${_.size(tx.bills) > 2 ? `, cassette3 = cassette3 - $3` : ``}
|
const sql = `UPDATE devices SET ${billsStmt} WHERE device_id = $${_.size(tx.bills) + 1} RETURNING ${returnStmt}`
|
||||||
${_.size(tx.bills) > 3 ? `, cassette4 = cassette4 - $4` : ``}
|
|
||||||
where device_id = $${_.size(tx.bills) + 1}
|
|
||||||
returning
|
|
||||||
${_.size(tx.bills) > 0 ? `cassette1` : ``}
|
|
||||||
${_.size(tx.bills) > 1 ? `, cassette2`: ``}
|
|
||||||
${_.size(tx.bills) > 2 ? `, cassette3` : ``}
|
|
||||||
${_.size(tx.bills) > 3 ? `, cassette4` : ``}`
|
|
||||||
|
|
||||||
const values = []
|
const values = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ function createCashboxBatch (deviceId, cashboxCount) {
|
||||||
UPDATE bills SET cashbox_batch_id=$1
|
UPDATE bills SET cashbox_batch_id=$1
|
||||||
FROM cash_in_txs
|
FROM cash_in_txs
|
||||||
WHERE bills.cash_in_txs_id = cash_in_txs.id AND
|
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
|
bills.cashbox_batch_id IS NULL
|
||||||
`
|
`
|
||||||
const sql3 = `
|
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 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
|
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
|
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])
|
bills.cashbox_batch_id IS NULL`, [batchId, deviceId])
|
||||||
const q3 = t.none(`UPDATE empty_unit_bills SET cashbox_batch_id=$1
|
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])
|
WHERE empty_unit_bills.device_id = $2 AND empty_unit_bills.cashbox_batch_id IS NULL`, [batchId, deviceId])
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const getBills = filters => {
|
||||||
|
|
||||||
const sql = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, cit.device_id AS device_id FROM bills b LEFT OUTER JOIN (
|
const sql = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, cit.device_id AS device_id FROM bills b LEFT OUTER JOIN (
|
||||||
SELECT id, device_id FROM cash_in_txs ${deviceStatement}
|
SELECT id, device_id FROM cash_in_txs ${deviceStatement}
|
||||||
) AS cit ON cit.id = b.cash_in_txs_id ${batchStatement(filters.batch)}`
|
) AS cit ON cit.id = b.cash_in_txs_id ${batchStatement(filters.batch)} ${_.isNil(batchStatement(filters.batch)) ? `WHERE` : `AND`} b.destination_unit = 'cashbox'`
|
||||||
|
|
||||||
const sql2 = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, b.device_id FROM empty_unit_bills b ${deviceStatement} ${!_.isNil(filters.deviceId) && !_.isNil(filters.batch) ? `AND` : ``} ${batchStatement(filters.batch)}`
|
const sql2 = `SELECT b.id, b.fiat, b.fiat_code, b.created, b.cashbox_batch_id, b.device_id FROM empty_unit_bills b ${deviceStatement} ${!_.isNil(filters.deviceId) && !_.isNil(filters.batch) ? `AND` : ``} ${batchStatement(filters.batch)}`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ import styles from './WizardStep.styles'
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const getCassetesArtworks = () => ({
|
const getCassetesArtworks = () => ({
|
||||||
|
1: {
|
||||||
|
1: cassetteOne
|
||||||
|
},
|
||||||
2: {
|
2: {
|
||||||
1: cassetteOne,
|
1: cassetteOne,
|
||||||
2: cassetteTwo
|
2: cassetteTwo
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,10 @@ const DenominationsSchema = Yup.object().shape({
|
||||||
.max(CURRENCY_MAX),
|
.max(CURRENCY_MAX),
|
||||||
cassette2: Yup.number()
|
cassette2: Yup.number()
|
||||||
.label('Cassette 2')
|
.label('Cassette 2')
|
||||||
.required()
|
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(CURRENCY_MAX),
|
.max(CURRENCY_MAX)
|
||||||
|
.nullable()
|
||||||
|
.transform(transformNumber),
|
||||||
cassette3: Yup.number()
|
cassette3: Yup.number()
|
||||||
.label('Cassette 3')
|
.label('Cassette 3')
|
||||||
.min(1)
|
.min(1)
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,6 @@ const CashboxHistory = ({ machines, currency, timezone }) => {
|
||||||
|
|
||||||
const { data: batchesData, loading: batchesLoading } = useQuery(GET_BATCHES)
|
const { data: batchesData, loading: batchesLoading } = useQuery(GET_BATCHES)
|
||||||
|
|
||||||
console.log(batchesData)
|
|
||||||
|
|
||||||
/* const [editBatch] = useMutation(EDIT_BATCH, {
|
/* const [editBatch] = useMutation(EDIT_BATCH, {
|
||||||
refetchQueries: () => ['cashboxBatches']
|
refetchQueries: () => ['cashboxBatches']
|
||||||
}) */
|
}) */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue