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) {
|
||||
if (!dispenseOccurred(tx.bills)) return Promise.resolve()
|
||||
|
||||
const sql = `update devices set
|
||||
${_.size(tx.bills) > 0 ? `cassette1 = cassette1 - $1` : ``}
|
||||
${_.size(tx.bills) > 1 ? `, cassette2 = cassette2 - $2` : ``}
|
||||
${_.size(tx.bills) > 2 ? `, cassette3 = cassette3 - $3` : ``}
|
||||
${_.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 billsStmt = _.join(', ')(_.map(it => `${tx.bills[it].name} = ${tx.bills[it].name} - $${it + 1}`)(_.range(0, _.size(tx.bills))))
|
||||
const returnStmt = _.join(', ')(_.map(bill => `${bill.name}`)(tx.bills))
|
||||
|
||||
const sql = `UPDATE devices SET ${billsStmt} WHERE device_id = $${_.size(tx.bills) + 1} RETURNING ${returnStmt}`
|
||||
|
||||
const values = []
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ function createCashboxBatch (deviceId, cashboxCount) {
|
|||
FROM cash_in_txs
|
||||
WHERE bills.cash_in_txs_id = cash_in_txs.id AND
|
||||
cash_in_txs.device_id = $2 AND
|
||||
bills.destination_unit = 'cashbox' AND
|
||||
bills.cashbox_batch_id IS NULL
|
||||
`
|
||||
const sql3 = `
|
||||
|
|
@ -43,6 +44,7 @@ function updateMachineWithBatch (machineContext, oldCashboxCount) {
|
|||
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
|
||||
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])
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
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)}`
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ import styles from './WizardStep.styles'
|
|||
const useStyles = makeStyles(styles)
|
||||
|
||||
const getCassetesArtworks = () => ({
|
||||
1: {
|
||||
1: cassetteOne
|
||||
},
|
||||
2: {
|
||||
1: cassetteOne,
|
||||
2: cassetteTwo
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ const DenominationsSchema = Yup.object().shape({
|
|||
.max(CURRENCY_MAX),
|
||||
cassette2: Yup.number()
|
||||
.label('Cassette 2')
|
||||
.required()
|
||||
.min(1)
|
||||
.max(CURRENCY_MAX),
|
||||
.max(CURRENCY_MAX)
|
||||
.nullable()
|
||||
.transform(transformNumber),
|
||||
cassette3: Yup.number()
|
||||
.label('Cassette 3')
|
||||
.min(1)
|
||||
|
|
|
|||
|
|
@ -71,8 +71,6 @@ const CashboxHistory = ({ machines, currency, timezone }) => {
|
|||
|
||||
const { data: batchesData, loading: batchesLoading } = useQuery(GET_BATCHES)
|
||||
|
||||
console.log(batchesData)
|
||||
|
||||
/* const [editBatch] = useMutation(EDIT_BATCH, {
|
||||
refetchQueries: () => ['cashboxBatches']
|
||||
}) */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue