Attached Files | ticket_24881.diff [^] (4,457 bytes) 2021-07-30 13:59 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/ExtendsCashManagementTaxesHook.java b/src/org/openbravo/retail/posterminal/ExtendsCashManagementTaxesHook.java
new file mode 100644
index 000000000..49927ee04
--- /dev/null
+++ b/src/org/openbravo/retail/posterminal/ExtendsCashManagementTaxesHook.java
@@ -0,0 +1,7 @@
+package org.openbravo.retail.posterminal;
+
+import org.codehaus.jettison.json.JSONArray;
+
+public abstract class ExtendsCashManagementTaxesHook {
+ public abstract void exec(JSONArray jsonarray) throws Exception;
+}
diff --git a/src/org/openbravo/retail/posterminal/master/Cashup.java b/src/org/openbravo/retail/posterminal/master/Cashup.java
index 4979ad99e..441de3428 100644
--- a/src/org/openbravo/retail/posterminal/master/Cashup.java
+++ b/src/org/openbravo/retail/posterminal/master/Cashup.java
@@ -31,6 +31,7 @@ import org.openbravo.mobile.core.process.SimpleQueryBuilder;
import org.openbravo.model.financialmgmt.gl.GLItem;
import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
+import org.openbravo.retail.posterminal.ExtendsCashManagementTaxesHook;
import org.openbravo.retail.posterminal.JSONProcessSimple;
import org.openbravo.retail.posterminal.OBPOSAppCashup;
import org.openbravo.retail.posterminal.OBPOSAppPayment;
@@ -40,10 +41,26 @@ import org.openbravo.retail.posterminal.POSUtils;
import org.openbravo.service.json.DataResolvingMode;
import org.openbravo.service.json.DataToJsonConverter;
import org.openbravo.service.json.JsonConstants;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import java.util.Iterator;
public class Cashup extends JSONProcessSimple {
private static final Logger log = LogManager.getLogger();
+ @Inject
+ @Any
+ private Instance<ExtendsCashManagementTaxesHook> taxesHookInstance;
+
+ private void executeTaxexHooks(Instance<? extends Object> hooks, JSONArray jsonarray) throws Exception {
+
+ for (Iterator<? extends Object> procIter = hooks.iterator(); procIter.hasNext();) {
+ Object proc = procIter.next();
+ ((ExtendsCashManagementTaxesHook) proc).exec(jsonarray); }
+ }
+
+
@Override
public JSONObject exec(JSONObject jsonsent) throws JSONException, ServletException {
JSONObject result = new JSONObject();
@@ -195,6 +212,12 @@ public class Cashup extends JSONProcessSimple {
respArray.put(result);
}
+ try {
+ executeTaxexHooks(taxesHookInstance, respArray);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
return respArray;
}
diff --git a/web/org.openbravo.retail.posterminal/js/utils/cashUpReportUtils.js b/web/org.openbravo.retail.posterminal/js/utils/cashUpReportUtils.js
index ab80471ae..c19e8c394 100644
--- a/web/org.openbravo.retail.posterminal/js/utils/cashUpReportUtils.js
+++ b/web/org.openbravo.retail.posterminal/js/utils/cashUpReportUtils.js
@@ -850,7 +850,7 @@
}, null);
};
- OB.UTIL.getTaxCashUp = function (taxcashups, objToSend, cashUp) {
+ OB.UTIL.getTaxCashUp = function (taxcashups, objToSend, cashUp, composite) {
_.each(taxcashups.models, function (currentTax) {
var cashTaxInfo = {
name: "",
@@ -865,8 +865,13 @@
cashTaxInfo.cashupId = currentTax.get('cashup_id');
cashTaxInfo.id = currentTax.get('id');
objToSend.get('cashTaxInfo').push(cashTaxInfo);
- cashUp.at(0).set('objToSend', JSON.stringify(objToSend));
+ cashUp.at(0).set('objToSend', JSON.stringify(objToSend));
}, this);
+ OB.UTIL.HookManager.executeHooks('OBPOS_GetTaxCashUp', {
+ cashUp: cashUp, taxCashUp: taxcashups.models, objToSend : objToSend
+ }, function(args){
+ composite();
+ });
};
OB.UTIL.composeCashupInfo = function (cashUp, me, callback, tx) {
@@ -918,8 +923,7 @@
'cashup_id': cashUp.at(0).get('id'),
'_orderByClause': 'name asc'
}, function (taxcashups) {
- OB.UTIL.getTaxCashUp(taxcashups, objToSend, cashUp);
- OB.UTIL.saveComposeInfo(me, callback, objToSend, cashUp, tx);
+ OB.UTIL.getTaxCashUp(taxcashups, objToSend, cashUp, function(){OB.UTIL.saveComposeInfo(me, callback, objToSend, cashUp, tx);});
});
});
};
@@ -932,4 +936,4 @@
}
});
};
-}());
\ No newline at end of file
+}());
|