feat: cashbox batch creation on machine cashbox removal

fix: cashbox batch creation with empty cashbox
This commit is contained in:
Sérgio Salgado 2021-04-28 16:41:27 +01:00 committed by Josh Harvey
parent 482e1afc3a
commit 61cc772816
5 changed files with 15 additions and 13 deletions

View file

@ -2,8 +2,8 @@ const db = require('./db')
const _ = require('lodash/fp')
const uuid = require('uuid')
function createCashboxBatch (deviceId) {
console.log('herererere')
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 = `
UPDATE bills SET cashbox_batch_id=$1