Skip to content

Commit

Permalink
Merge pull request #1216 from RafaelTaranto/feat/multiple-cashboxes-a…
Browse files Browse the repository at this point in the history
…veiro

feat: aveiro with multiple cashboxes
  • Loading branch information
RafaelTaranto authored Nov 12, 2024
2 parents 7b35435 + a061ca8 commit f1d401c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,7 @@ Brain.prototype.initValidator = function initValidator () {
console.log('Bill validator connected.')
},
{
numberOfCashboxes: this.rootConfig.billValidator.cashboxes ?? 1,
cassettes: this.trader.cassettes,
recyclers: this.trader.recyclers,
}
Expand Down
34 changes: 20 additions & 14 deletions lib/gsr50/gsr50.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ Gsr50.prototype.processUnitEvent = function processUnitEvent(data) {
}
}

Gsr50.prototype.run = function run (cb, { cassettes, recyclers }) {
Gsr50.prototype.run = function run (cb, { numberOfCashboxes, cassettes, recyclers }) {
const self = this

this.wss = new WebSocketServer({ port: 9001, host: 'localhost' })
this.numberOfCashboxes = numberOfCashboxes

this.wss.on('connection', function (ws) {
self.ws = ws
Expand Down Expand Up @@ -284,17 +285,22 @@ Gsr50.prototype.getDeviceCashUnits = function getDeviceCashUnits () {
Gsr50.prototype.setDeviceCashUnits = function setDeviceCashUnits (cassettes, recyclers) {
return this.getDeviceCashUnits()
.then(res => {
let units = {
cashbox: {
Number: 8,
Mode: CASH_UNIT_MODES.CashIn,
Position: CASH_UNIT_POSITIONS.cashbox1,
Currency: {
CurrencyCode: this.fiatCode
}
}
}

let units = _.reduce(
(acc, value) => {
return Object.assign(acc, {
// cashbox1 is not being used in the c# code, keeping for compatibility
[value === 0 ? 'cashbox' : `cashbox${value + 1}`]: {
Mode: CASH_UNIT_MODES.CashIn,
Position: CASH_UNIT_POSITIONS.cashbox1 + value,
Currency: {
CurrencyCode: this.fiatCode
}
}
})
},
_.range(0, this.numberOfCashboxes)
)

if (cassettes) {
units = _.reduce(
(acc, value) => {
Expand All @@ -315,8 +321,8 @@ Gsr50.prototype.setDeviceCashUnits = function setDeviceCashUnits (cassettes, rec
_.range(0, _.size(cassettes))
)
}
if (recyclers) {

if (recyclers) {
units = _.reduce(
(acc, value) => {
const realName = RECYCLER_NAMES[value.name]
Expand Down

0 comments on commit f1d401c

Please sign in to comment.