# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1571123128 -19800
#      Tue Oct 15 12:35:28 2019 +0530
# Node ID 6d0a6eec6d0d7608e9a62fef4cdfbc44efac6bac
# Parent  4cecd3da41bbb469316a21f6ecf46cf3e0626a1b
Related to issue 41927 : Added Validation of ProceList when changing Customer

diff -r 4cecd3da41bb -r 6d0a6eec6d0d src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Oct 15 11:36:00 2019 +0530
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Oct 15 12:35:28 2019 +0530
@@ -2990,6 +2990,18 @@
 <!--3CB14CC53C24400992BF1DF967F746E1-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--3CB14CC53C24400992BF1DF967F746E1--></AD_MESSAGE>
 
+<!--3CFD5DBE42FC44FCAADB058D57983514--><AD_MESSAGE>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <AD_MESSAGE_ID><![CDATA[3CFD5DBE42FC44FCAADB058D57983514]]></AD_MESSAGE_ID>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <VALUE><![CDATA[OBPOS_ChangeOfPriceListPriceIncludeTax]]></VALUE>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <MSGTEXT><![CDATA[Customer Price List's Price Includes Tax is not same as Terminal Price List's Price Includes Tax. So Terminal Price List will be used for this receipt]]></MSGTEXT>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--3CFD5DBE42FC44FCAADB058D57983514-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--3CFD5DBE42FC44FCAADB058D57983514--></AD_MESSAGE>
+
 <!--3D07CA2C933B40568DAEB0676324F23E--><AD_MESSAGE>
 <!--3D07CA2C933B40568DAEB0676324F23E-->  <AD_MESSAGE_ID><![CDATA[3D07CA2C933B40568DAEB0676324F23E]]></AD_MESSAGE_ID>
 <!--3D07CA2C933B40568DAEB0676324F23E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3626,6 +3638,18 @@
 <!--49E73EE52E394E1E86751439246F0F4C-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--49E73EE52E394E1E86751439246F0F4C--></AD_MESSAGE>
 
+<!--4A38A808F16846308CF51F2C14A69818--><AD_MESSAGE>
+<!--4A38A808F16846308CF51F2C14A69818-->  <AD_MESSAGE_ID><![CDATA[4A38A808F16846308CF51F2C14A69818]]></AD_MESSAGE_ID>
+<!--4A38A808F16846308CF51F2C14A69818-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4A38A808F16846308CF51F2C14A69818-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4A38A808F16846308CF51F2C14A69818-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4A38A808F16846308CF51F2C14A69818-->  <VALUE><![CDATA[OBPOS_ChangeOfPriceListCurrency]]></VALUE>
+<!--4A38A808F16846308CF51F2C14A69818-->  <MSGTEXT><![CDATA[Customer Price List Currency is not same as Terminal Price List Currency. So Terminal Price List will be used for this receipt]]></MSGTEXT>
+<!--4A38A808F16846308CF51F2C14A69818-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--4A38A808F16846308CF51F2C14A69818-->  <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--4A38A808F16846308CF51F2C14A69818-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--4A38A808F16846308CF51F2C14A69818--></AD_MESSAGE>
+
 <!--4A5D4828F15C4490B1CBE3D58CC65A5D--><AD_MESSAGE>
 <!--4A5D4828F15C4490B1CBE3D58CC65A5D-->  <AD_MESSAGE_ID><![CDATA[4A5D4828F15C4490B1CBE3D58CC65A5D]]></AD_MESSAGE_ID>
 <!--4A5D4828F15C4490B1CBE3D58CC65A5D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -12246,6 +12270,18 @@
 <!--F1366DBECBB1478585C0D6D56007C145-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--F1366DBECBB1478585C0D6D56007C145--></AD_MESSAGE>
 
+<!--F15E00749BA34A32B463047FA4D0F08D--><AD_MESSAGE>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <AD_MESSAGE_ID><![CDATA[F15E00749BA34A32B463047FA4D0F08D]]></AD_MESSAGE_ID>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <VALUE><![CDATA[OBPOS_ChangeOfPriceList]]></VALUE>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <MSGTEXT><![CDATA[Change of Price List]]></MSGTEXT>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--F15E00749BA34A32B463047FA4D0F08D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--F15E00749BA34A32B463047FA4D0F08D--></AD_MESSAGE>
+
 <!--F172370055B64172AF9E4E7C6F034DC8--><AD_MESSAGE>
 <!--F172370055B64172AF9E4E7C6F034DC8-->  <AD_MESSAGE_ID><![CDATA[F172370055B64172AF9E4E7C6F034DC8]]></AD_MESSAGE_ID>
 <!--F172370055B64172AF9E4E7C6F034DC8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 4cecd3da41bb -r 6d0a6eec6d0d src/org/openbravo/retail/posterminal/master/BusinessPartnerProperties.java
--- a/src/org/openbravo/retail/posterminal/master/BusinessPartnerProperties.java	Tue Oct 15 11:36:00 2019 +0530
+++ b/src/org/openbravo/retail/posterminal/master/BusinessPartnerProperties.java	Tue Oct 15 12:35:28 2019 +0530
@@ -34,6 +34,7 @@
         add(new HQLProperty("bp.taxID", "taxID"));
         add(new HQLProperty("bp.sOBPTaxCategory.id", "taxCategory"));
         add(new HQLProperty("bp.priceList.id", "priceList"));
+        add(new HQLProperty("bp.priceList.currency.id", "priceListCurrency"));
         add(new HQLProperty("bp.paymentMethod.id", "paymentMethod"));
         add(new HQLProperty("bp.paymentTerms.id", "paymentTerms"));
         add(new HQLProperty("bp.invoiceTerms", "invoiceTerms"));
diff -r 4cecd3da41bb -r 6d0a6eec6d0d web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
--- a/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js	Tue Oct 15 11:36:00 2019 +0530
+++ b/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js	Tue Oct 15 12:35:28 2019 +0530
@@ -125,6 +125,63 @@
           } else {
             model.set('generateInvoice', false);
           }
+
+          var updatePriceList = function() {
+            model.set('priceList', OB.MobileApp.model.get('pricelist').id);
+            model.set(
+              'priceIncludesTax',
+              OB.MobileApp.model.get('pricelist').priceIncludesTax
+            );
+            model.set('currency', OB.MobileApp.model.get('pricelist').currency);
+            model.trigger('change:documentNo', model);
+            if (model.get('lines').length > 0) {
+              model.calculateReceipt(function() {
+                model.save(function() {
+                  OB.MobileApp.model.orderList.saveCurrent();
+                });
+              });
+            } else {
+              model.save(function() {
+                OB.MobileApp.model.orderList.saveCurrent();
+              });
+            }
+          };
+
+          if (
+            model.get('isEditable') &&
+            OB.MobileApp.model.hasPermission('EnableMultiPriceList', true)
+          ) {
+            if (
+              model.get('bp').get('priceIncludesTax') !==
+              OB.MobileApp.model.get('pricelist').priceIncludesTax
+            ) {
+              OB.UTIL.showConfirmation.display(
+                OB.I18N.getLabel('OBPOS_ChangeOfPriceList'),
+                OB.I18N.getLabel('OBPOS_ChangeOfPriceListPriceIncludeTax'),
+                null,
+                {
+                  onHideFunction: function() {
+                    updatePriceList();
+                  }
+                }
+              );
+            } else if (
+              model.get('bp').get('priceListCurrency') !==
+              OB.MobileApp.model.get('pricelist').currency
+            ) {
+              OB.UTIL.showConfirmation.display(
+                OB.I18N.getLabel('OBPOS_ChangeOfPriceList'),
+                OB.I18N.getLabel('OBPOS_ChangeOfPriceListCurrency'),
+                null,
+                {
+                  onHideFunction: function() {
+                    updatePriceList();
+                  }
+                }
+              );
+            }
+          }
+
           this.renderCustomer(
             model.get('bp').get('id'),
             model.get('bp').get('_identifier')
diff -r 4cecd3da41bb -r 6d0a6eec6d0d web/org.openbravo.retail.posterminal/js/model/businesspartner.js
--- a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js	Tue Oct 15 11:36:00 2019 +0530
+++ b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js	Tue Oct 15 12:35:28 2019 +0530
@@ -579,6 +579,11 @@
       type: 'TEXT'
     },
     {
+      name: 'priceListCurrency',
+      column: 'priceListCurrency',
+      type: 'TEXT'
+    },
+    {
       name: 'loaded',
       column: 'loaded',
       type: 'TEXT'
