|
@@ -1323,8 +1323,8 @@ module.exports = app => {
|
|
|
b.qty = this.ctx.helper._.toNumber(b.samount);
|
|
|
b.tp = this.ctx.helper.round(this.ctx.helper.mul(b.qty, b.unit_price), this.ctx.tender.info.decimal.tp);
|
|
|
|
|
|
- const u = cbu.find(x => { return x.id === b.id; });
|
|
|
- b.used_qty = u ? u.used_qty : 0;
|
|
|
+ const u = cbu.filter(x => { return x.cbid === b.id; });
|
|
|
+ b.used_qty = u.length > 0 ? this.ctx.helper.sum(u.map(x => { return x.qty})) : 0;
|
|
|
|
|
|
b.valid_qty = this.ctx.helper.sub(b.qty, b.used_qty);
|
|
|
const cur = this.ctx.helper._.filter(curUsedBills, { cbid: b.id });
|