Attached Files | grossDiff_posterminal.diff [^] (5,439 bytes) 2019-06-04 10:17 [Show Content] [Hide Content]diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -2138,6 +2138,18 @@
<!--31C36BB5828F4F23A68CBD65631A686F--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--31C36BB5828F4F23A68CBD65631A686F--></AD_MESSAGE>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--><AD_MESSAGE>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <AD_MESSAGE_ID><![CDATA[31C59D44C69E417F8F59C0C0974BEA3D]]></AD_MESSAGE_ID>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <VALUE><![CDATA[OBPOS_GrossDifferenceErrorMsg]]></VALUE>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <MSGTEXT><![CDATA[The sum of the gross of each line does not equal the gross of the order. Click Reload to refresh the page. If the problem persists please contact your System Administrator.]]></MSGTEXT>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--31C59D44C69E417F8F59C0C0974BEA3D--></AD_MESSAGE>
+
<!--328A03FF723548E98809914F98831E60--><AD_MESSAGE>
<!--328A03FF723548E98809914F98831E60--> <AD_MESSAGE_ID><![CDATA[328A03FF723548E98809914F98831E60]]></AD_MESSAGE_ID>
<!--328A03FF723548E98809914F98831E60--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -7553,6 +7565,18 @@
<!--A7CBAF28EE6C42A791DF740B61D77D4C--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--A7CBAF28EE6C42A791DF740B61D77D4C--></AD_MESSAGE>
+<!--A8173931FC504CBE935CAB843580E916--><AD_MESSAGE>
+<!--A8173931FC504CBE935CAB843580E916--> <AD_MESSAGE_ID><![CDATA[A8173931FC504CBE935CAB843580E916]]></AD_MESSAGE_ID>
+<!--A8173931FC504CBE935CAB843580E916--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A8173931FC504CBE935CAB843580E916--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A8173931FC504CBE935CAB843580E916--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A8173931FC504CBE935CAB843580E916--> <VALUE><![CDATA[OBPOS_GrossDifferenceErrorTitle]]></VALUE>
+<!--A8173931FC504CBE935CAB843580E916--> <MSGTEXT><![CDATA[Gross Differences]]></MSGTEXT>
+<!--A8173931FC504CBE935CAB843580E916--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--A8173931FC504CBE935CAB843580E916--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--A8173931FC504CBE935CAB843580E916--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--A8173931FC504CBE935CAB843580E916--></AD_MESSAGE>
+
<!--A847E3FCBDCD4ED98A1FB6671E5A4420--><AD_MESSAGE>
<!--A847E3FCBDCD4ED98A1FB6671E5A4420--> <AD_MESSAGE_ID><![CDATA[A847E3FCBDCD4ED98A1FB6671E5A4420]]></AD_MESSAGE_ID>
<!--A847E3FCBDCD4ED98A1FB6671E5A4420--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
@@ -464,6 +464,36 @@
showMandatoryServices, checkStock;
if (this.disabled === false) {
var receipt = me.model.get('order');
+ //verify that the sum of the gross of each line equals the gross
+ var gross = receipt.get('gross');
+ var linesGross = 0,
+ totalDiscount = 0;
+ var base, isFieldUndefined = false;
+ _.each(receipt.get('lines').models, function (line) {
+ linesGross = OB.DEC.add(linesGross, line.get('gross'));
+ base = line.get('price');
+ _.forEach(line.get('promotions') || [], function (discount) {
+ var discountAmt = discount.actualAmt || discount.amt || 0;
+ discount.basePrice = base;
+ discount.unitDiscount = OB.DEC.div(discountAmt, line.get('qtyToApplyDisc') || line.get('qty'));
+ totalDiscount = OB.DEC.add(totalDiscount, discountAmt);
+ base = OB.DEC.sub(base, discount.unitDiscount);
+ }, this);
+ });
+ linesGross = OB.DEC.sub(linesGross, totalDiscount);
+ var grossDifference = OB.DEC.sub(gross, linesGross);
+ if (OB.DEC.abs(grossDifference) > 0.01 && receipt.get('priceIncludesTax')) {
+ OB.error("The sum of the gross of each line does not equal the gross: " + gross + ", difference: " + grossDifference + ", totalDiscounts: " + totalDiscount);
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_GrossDifferenceErrorTitle'), OB.I18N.getLabel('OBPOS_GrossDifferenceErrorMsg'), [{
+ label: OB.I18N.getLabel('OBPOS_Reload')
+ }], {
+ onHideFunction: function () {
+ window.location.reload();
+ },
+ autoDismiss: false
+ });
+ }
+
if (receipt.get('isQuotation') && receipt.get('bp').id === OB.MobileApp.model.get('terminal').businessPartner && !OB.MobileApp.model.get('terminal').quotation_anonymouscustomer) {
OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('OBPOS_quotationsOrdersWithAnonimousCust'));
return;
issue 41017 source posterminal.patch [^] (5,801 bytes) 2019-06-11 07:54 [Show Content] [Hide Content]# HG changeset patch
Related to issue 41017 : It is possible synchronized tickets with a total gross amount different than lines' total gross amount
diff -r dfe13815d330 -r 81c9f286659b src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Tue Jun 11 11:23:22 2019 +0530
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Tue Jun 11 11:23:44 2019 +0530
@@ -6796,6 +6796,18 @@
<!--8E42D871633343CA89139EF00034D48E--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--8E42D871633343CA89139EF00034D48E--></AD_MESSAGE>
+<!--8E908CFD78214B84AE973FAD33BD27B8--><AD_MESSAGE>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <AD_MESSAGE_ID><![CDATA[8E908CFD78214B84AE973FAD33BD27B8]]></AD_MESSAGE_ID>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <VALUE><![CDATA[OBPOS_GrossDifferenceErrorMsg]]></VALUE>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <MSGTEXT><![CDATA[The sum of the gross of each line does not equal the gross of the order. Click Reload to refresh the page. If the problem persists please contact your System Administrator.]]></MSGTEXT>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--8E908CFD78214B84AE973FAD33BD27B8--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--8E908CFD78214B84AE973FAD33BD27B8--></AD_MESSAGE>
+
<!--8ED043111EAE45CFBF18940C609F85E2--><AD_MESSAGE>
<!--8ED043111EAE45CFBF18940C609F85E2--> <AD_MESSAGE_ID><![CDATA[8ED043111EAE45CFBF18940C609F85E2]]></AD_MESSAGE_ID>
<!--8ED043111EAE45CFBF18940C609F85E2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -8405,6 +8417,18 @@
<!--AC7E602131FB46459180A22D3AAC8A08--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--AC7E602131FB46459180A22D3AAC8A08--></AD_MESSAGE>
+<!--AC85514237834E729C2940836EBDBBE2--><AD_MESSAGE>
+<!--AC85514237834E729C2940836EBDBBE2--> <AD_MESSAGE_ID><![CDATA[AC85514237834E729C2940836EBDBBE2]]></AD_MESSAGE_ID>
+<!--AC85514237834E729C2940836EBDBBE2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--AC85514237834E729C2940836EBDBBE2--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--AC85514237834E729C2940836EBDBBE2--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--AC85514237834E729C2940836EBDBBE2--> <VALUE><![CDATA[OBPOS_GrossDifferenceErrorTitle]]></VALUE>
+<!--AC85514237834E729C2940836EBDBBE2--> <MSGTEXT><![CDATA[Gross Differences]]></MSGTEXT>
+<!--AC85514237834E729C2940836EBDBBE2--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--AC85514237834E729C2940836EBDBBE2--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--AC85514237834E729C2940836EBDBBE2--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--AC85514237834E729C2940836EBDBBE2--></AD_MESSAGE>
+
<!--ACEDA7712B5A43FAA7C97B0B9C6F400D--><AD_MESSAGE>
<!--ACEDA7712B5A43FAA7C97B0B9C6F400D--> <AD_MESSAGE_ID><![CDATA[ACEDA7712B5A43FAA7C97B0B9C6F400D]]></AD_MESSAGE_ID>
<!--ACEDA7712B5A43FAA7C97B0B9C6F400D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r dfe13815d330 -r 81c9f286659b web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js Tue Jun 11 11:23:22 2019 +0530
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-left.js Tue Jun 11 11:23:44 2019 +0530
@@ -494,7 +494,38 @@
var execution = OB.UTIL.ProcessController.start('totalAmountValidation'),
receipt = me.model.get('order'),
receiptLines = receipt.get('lines').models,
- i;
+ i, base, grossDifference, gross = receipt.get('gross'),
+ linesGross = 0,
+ totalDiscount = 0;
+
+ //verify that the sum of the gross of each line equals the gross
+ _.each(receipt.get('lines').models, function (line) {
+ linesGross = OB.DEC.add(linesGross, line.get('gross'));
+ base = line.get('price');
+ _.forEach(line.get('promotions') || [], function (discount) {
+ var discountAmt = discount.actualAmt || discount.amt || 0;
+ discount.basePrice = base;
+ discount.unitDiscount = OB.DEC.div(discountAmt, line.get('qtyToApplyDisc') || line.get('qty'));
+ totalDiscount = OB.DEC.add(totalDiscount, discountAmt);
+ base = OB.DEC.sub(base, discount.unitDiscount);
+ }, this);
+ });
+ if (receipt.get('priceIncludesTax')) {
+ linesGross = OB.DEC.sub(linesGross, totalDiscount);
+ grossDifference = OB.DEC.sub(gross, linesGross);
+ if (OB.DEC.abs(grossDifference) > 0.01) {
+ OB.error("The sum of the gross of each line does not equal the gross: " + gross + ", difference: " + grossDifference + ", totalDiscounts: " + totalDiscount);
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_GrossDifferenceErrorTitle'), OB.I18N.getLabel('OBPOS_GrossDifferenceErrorMsg'), [{
+ label: OB.I18N.getLabel('OBPOS_Reload')
+ }], {
+ onHideFunction: function () {
+ window.location.reload();
+ },
+ autoDismiss: false
+ });
+ }
+ }
+
if (receipt.get('isQuotation') && receipt.get('bp').id === OB.MobileApp.model.get('terminal').businessPartner && !OB.MobileApp.model.get('terminal').quotation_anonymouscustomer) {
OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('OBPOS_quotationsOrdersWithAnonimousCust'));
OB.UTIL.ProcessController.finish('totalAmountValidation', execution);
|