chore: format SQL queries
This commit is contained in:
parent
50eb0a0933
commit
e83e74f9d1
1 changed files with 15 additions and 4 deletions
|
|
@ -20,11 +20,22 @@ 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
|
||||||
SELECT id, device_id FROM cash_in_txs ${deviceStatement}
|
FROM bills b
|
||||||
) AS cit ON cit.id = b.cash_in_txs_id ${batchStatement(filters.batch)} ${_.isNil(batchStatement(filters.batch)) ? `WHERE` : `AND`} b.destination_unit = 'cashbox'`
|
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)}
|
||||||
|
${_.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 ${_.replace('WHERE', '', batchStatement(filters.batch))}` : `${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 ${_.replace('WHERE', '', batchStatement(filters.batch))}` : `${batchStatement(filters.batch)}`}`
|
||||||
|
|
||||||
return Promise.all([db.any(sql), db.any(sql2)]).then(
|
return Promise.all([db.any(sql), db.any(sql2)]).then(
|
||||||
([bills, operationalBills]) =>
|
([bills, operationalBills]) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue