feat: add cashin bill counter
fix: fiat amount formatting
This commit is contained in:
parent
219dca7f90
commit
98a2797494
17 changed files with 239 additions and 218 deletions
|
|
@ -1,25 +1,37 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
const db = require('../../db')
|
||||
|
||||
// Get all bills with device id
|
||||
const getBills = () => {
|
||||
return Promise.reject(new Error('This functionality hasn\'t been implemented yet'))
|
||||
/* return db.any(`
|
||||
SELECT d.device_id, b.fiat, b.created, d.cashbox
|
||||
FROM cash_in_txs
|
||||
INNER JOIN bills AS b ON b.cash_in_txs_id = cash_in_txs.id
|
||||
INNER JOIN devices as d ON d.device_id = cash_in_txs.device_id
|
||||
ORDER BY device_id, created DESC`
|
||||
)
|
||||
.then(res => {
|
||||
return res.map(item => ({
|
||||
fiat: item.fiat,
|
||||
deviceId: item.device_id,
|
||||
cashbox: item.cashbox,
|
||||
created: item.created
|
||||
}))
|
||||
}) */
|
||||
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
|
||||
) AS cit ON cit.id = b.cash_in_txs_id`
|
||||
|
||||
return db.any(sql)
|
||||
.then(res => _.map(_.mapKeys(_.camelCase), res))
|
||||
}
|
||||
|
||||
function getLooseBills () {
|
||||
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
|
||||
) AS cit ON cit.id = b.cash_in_txs_id WHERE b.cashbox_batch_id IS NULL`
|
||||
|
||||
return db.any(sql)
|
||||
.then(res => _.map(_.mapKeys(_.camelCase), res))
|
||||
}
|
||||
|
||||
function getLooseBillsByMachine (machineId) {
|
||||
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 WHERE device_id = $1
|
||||
) AS cit ON cit.id = b.cash_in_txs_id WHERE b.cashbox_batch_id IS NULL`
|
||||
|
||||
return db.any(sql, [machineId])
|
||||
.then(res => _.map(_.mapKeys(_.camelCase), res))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getBills
|
||||
getBills,
|
||||
getLooseBills,
|
||||
getLooseBillsByMachine
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue