# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1553858179 -19800
#      Fri Mar 29 16:46:19 2019 +0530
# Node ID bb5901037a4627c2d41c1e9188f6c4f88e6c1578
# Parent  62dbf29253b16da034050ed5513f427e628cc572
Related to issue 40481 : Updated deposit and withdrawal model for count payment in cashup  while completing cashup

* When closing cashup, in printcashup template only models with countInCashup will be printed
  So countInCashup is updated for cashmanagement deposit and drop models

diff -r 62dbf29253b1 -r bb5901037a46 web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js	Fri Mar 29 10:51:51 2019 +0530
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js	Fri Mar 29 16:46:19 2019 +0530
@@ -215,9 +215,11 @@
         'type': 'deposit'
       }, function (cashMgmts) {
         _.forEach(cashMgmts.models, function (cashMgmt, index) {
-          cashMgmt.set('searchKey', 'cashMgmtDeposit' + index + (_.filter(OB.MobileApp.model.get('payments'), function (pay) {
+          var payment = _.filter(OB.MobileApp.model.get('payments'), function (pay) {
             return pay.payment.id === cashMgmt.get('paymentMethodId');
-          }))[0].payment.searchKey.replace('_', '') + cashMgmt.get('amount'));
+          })[0];
+          cashMgmt.set('countInCashup', payment.paymentMethod.countpaymentincashup);
+          cashMgmt.set('searchKey', 'cashMgmtDeposit' + index + payment.payment.searchKey.replace('_', '') + cashMgmt.get('amount'));
         });
         cashUpReport.set('deposits', cashMgmts.models);
         cashUpReport.set('totalDeposits', _.reduce(cashMgmts.models, function (accum, trx) {
@@ -229,9 +231,11 @@
         'type': 'drop'
       }, function (cashMgmts) {
         _.forEach(cashMgmts.models, function (cashMgmt, index) {
-          cashMgmt.set('searchKey', 'cashMgmtDrop' + index + (_.filter(OB.MobileApp.model.get('payments'), function (pay) {
+          var payment = _.filter(OB.MobileApp.model.get('payments'), function (pay) {
             return pay.payment.id === cashMgmt.get('paymentMethodId');
-          }))[0].payment.searchKey.replace('_', '') + cashMgmt.get('amount'));
+          })[0];
+          cashMgmt.set('countInCashup', payment.paymentMethod.countpaymentincashup);
+          cashMgmt.set('searchKey', 'cashMgmtDeposit' + index + payment.payment.searchKey.replace('_', '') + cashMgmt.get('amount'));
         });
         cashUpReport.set('drops', cashMgmts.models);
         cashUpReport.set('totalDrops', _.reduce(cashMgmts.models, function (accum, trx) {
