Attached Files | cashupreporthook.patch [^] (3,519 bytes) 2020-07-22 10:31 [Show Content] [Hide Content]---
.../js/components/editcashupreporthook.js | 90 ++++++++++---------
1 file changed, 47 insertions(+), 43 deletions(-)
diff --git a/web/org.openbravo.retail.sessions/js/components/editcashupreporthook.js b/web/org.openbravo.retail.sessions/js/components/editcashupreporthook.js
index d6cecd5..ba62e49 100644
--- a/web/org.openbravo.retail.sessions/js/components/editcashupreporthook.js
+++ b/web/org.openbravo.retail.sessions/js/components/editcashupreporthook.js
@@ -23,50 +23,54 @@ OB.UTIL.HookManager.registerHook('OBPOS_EditCashupReport', function(
var starting = _.filter(args.cashUpReport.get('startings'), function(st) {
return st.get('paymentId') === pay.payment.id;
})[0];
- OB.Dal.find(
- OB.Model.CashManagement,
- {
- glItem: pay.paymentMethod.possGlitemTilldiff,
- paymentMethodId: pay.payment.id
- },
- function(cashMgmts) {
- if (cashMgmts.models.length > 0) {
- if (cashMgmts.models[0].get('type') === 'deposit') {
- starting.set(
- 'amount',
- OB.DEC.add(
- starting.get('amount'),
- cashMgmts.models[0].get('amount')
- )
- );
- args.cashUpReport.set(
- 'totalStartings',
- OB.DEC.add(
- args.cashUpReport.get('totalStartings'),
- cashMgmts.models[0].get('amount')
- )
- );
- } else if (cashMgmts.models[0].get('type') === 'drop') {
- starting.set(
- 'amount',
- OB.DEC.sub(
- starting.get('amount'),
- cashMgmts.models[0].get('amount')
- )
- );
- args.cashUpReport.set(
- 'totalStartings',
- OB.DEC.sub(
- args.cashUpReport.get('totalStartings'),
- cashMgmts.models[0].get('amount')
- )
- );
+ if (starting) {
+ OB.Dal.find(
+ OB.Model.CashManagement,
+ {
+ glItem: pay.paymentMethod.possGlitemTilldiff,
+ paymentMethodId: pay.payment.id
+ },
+ function(cashMgmts) {
+ if (cashMgmts.models.length > 0) {
+ if (cashMgmts.models[0].get('type') === 'deposit') {
+ starting.set(
+ 'amount',
+ OB.DEC.add(
+ starting.get('amount'),
+ cashMgmts.models[0].get('amount')
+ )
+ );
+ args.cashUpReport.set(
+ 'totalStartings',
+ OB.DEC.add(
+ args.cashUpReport.get('totalStartings'),
+ cashMgmts.models[0].get('amount')
+ )
+ );
+ } else if (cashMgmts.models[0].get('type') === 'drop') {
+ starting.set(
+ 'amount',
+ OB.DEC.sub(
+ starting.get('amount'),
+ cashMgmts.models[0].get('amount')
+ )
+ );
+ args.cashUpReport.set(
+ 'totalStartings',
+ OB.DEC.sub(
+ args.cashUpReport.get('totalStartings'),
+ cashMgmts.models[0].get('amount')
+ )
+ );
+ }
}
- }
- callback();
- },
- this
- );
+ callback();
+ },
+ this
+ );
+ } else {
+ callback();
+ }
});
});
--
|