Feat: save cash balance notifications in DB
Feat: add "detail" row in notifications table migration This makes searching for specific notifications in the code like cashbox number easier because we don't need to scrub the notification message column anymore to search for notifications relating the cashbox 1 for example. Feat: clear notifications on cash cassette balance update
This commit is contained in:
parent
096c4bc87b
commit
d73520c0c0
2 changed files with 35 additions and 2 deletions
|
|
@ -356,6 +356,35 @@ const customerComplianceNotify = (customer, deviceId, code, days = null) => {
|
|||
.catch(console.error)
|
||||
}
|
||||
|
||||
const cashCassettesNotify = (cassettes, deviceId) => {
|
||||
settingsLoader.loadLatest()
|
||||
.then(settings =>
|
||||
[
|
||||
configManager.getNotifications(null, deviceId, settings.config),
|
||||
configManager.getCashOut(deviceId,settings.config).active
|
||||
])
|
||||
.then(([notifications, cashOutEnabled]) => {
|
||||
const cassette1Count = cassettes.cassette1
|
||||
const cassette2Count = cassettes.cassette2
|
||||
const cassette1Threshold = notifications.fiatBalanceCassette1
|
||||
const cassette2Threshold = notifications.fiatBalanceCassette2
|
||||
|
||||
if(cashOutEnabled) {
|
||||
// we only want to add this notification if there isn't one already set and unread in the database
|
||||
Promise.all([queries.getUnreadCassetteNotifications(1), queries.getUnreadCassetteNotifications(2)]).then(res => {
|
||||
if(res[0].length === 0 && cassette1Count < cassette1Threshold) {
|
||||
console.log("Adding fiatBalance alert for cashbox 1 in database - count & threshold: ", cassette1Count, cassette1Threshold )
|
||||
queries.addCashCassetteWarning(1, deviceId)
|
||||
}
|
||||
if(res[1].length === 0 && cassette2Count < cassette2Threshold) {
|
||||
console.log("Adding fiatBalance alert for cashbox 2 in database - count & threshold: ", cassette2Count, cassette2Threshold )
|
||||
queries.addCashCassetteWarning(2, deviceId)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
transactionNotify,
|
||||
checkNotification,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue