Attached Files | CashVat_Pos.patch [^] (15,023 bytes) 2016-09-13 13:26 [Show Content] [Hide Content]# HG changeset patch
# User Silambarasan Sekar <silambarasan@qualiantech.com>
# Date 1469180183 -19800
# Fri Jul 22 15:06:23 2016 +0530
# Node ID c5759ccfa5e39c437085df3befd6cacd00e69b16
# Parent 01921790ee465b4866401a9c7cc5129ce34e76fe
Cash Vat in sales order and sales invoice
diff -r 01921790ee46 -r c5759ccfa5e3 src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Thu Sep 01 14:00:14 2016 +0530
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Fri Jul 22 15:06:23 2016 +0530
@@ -38,6 +38,7 @@
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.CashVATUtil;
import org.openbravo.erpCommon.utility.SequenceIdData;
import org.openbravo.erpCommon.utility.Utility;
import org.openbravo.model.ad.access.InvoiceLineTax;
@@ -50,6 +51,7 @@
import org.openbravo.model.common.order.Order;
import org.openbravo.model.common.order.OrderLine;
import org.openbravo.model.common.order.OrderLineOffer;
+import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
@@ -221,6 +223,9 @@
invoice.getDocumentType()));
invoice.setDescription("Created by cash up " + cashUp.getIdentifier());
finishInvoice(invoice, currentDate);
+ if (invoice.isCashVAT()) {
+ createCashVat(invoice);
+ }
executeHooks(invoice, cashUpId);
}
@@ -337,6 +342,18 @@
: doctype.getId(), false, true);
}
+ protected void createCashVat(Invoice invoiceObj) {
+ for (FIN_PaymentSchedule scheduleObj : invoiceObj.getFINPaymentScheduleList()) {
+ for (FIN_PaymentScheduleDetail schDetailObj : scheduleObj
+ .getFINPaymentScheduleDetailInvoicePaymentScheduleList()) {
+ FIN_PaymentDetail paymentDetail = schDetailObj.getPaymentDetails();
+ if (paymentDetail != null)
+ CashVATUtil.createInvoiceTaxCashVAT(paymentDetail, scheduleObj, paymentDetail.getAmount()
+ .add(paymentDetail.getWriteoffAmount()));
+ }
+ }
+ }
+
private void finishInvoice(Invoice oriInvoice, Date currentDate) throws SQLException {
if (oriInvoice == null) {
return;
diff -r 01921790ee46 -r c5759ccfa5e3 src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Thu Sep 01 14:00:14 2016 +0530
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Fri Jul 22 15:06:23 2016 +0530
@@ -30,13 +30,13 @@
(c_invoice_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, issotrx,
documentno, docstatus, docaction, processing, processed, posted, c_doctype_id, c_doctypetarget_id, c_order_id, description, dateordered,
salesrep_id, dateinvoiced, dateacct, c_bpartner_id, c_bpartner_location_id, c_currency_id, paymentrule, c_paymentterm_id, totallines,
- grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, em_aprm_processinvoice)
+ grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, em_aprm_processinvoice, iscashvat)
select get_uuid(), o.ad_client_id, o.ad_org_id, 'Y', now(), ?, now(), ?, 'Y', ?,
'CO', 'RE', 'N', 'Y', 'N', dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
null, null, null, max(o.salesrep_id), to_timestamp(to_char(?), to_char('DD-MM-YYYY HH24:MI:SS')),
to_timestamp(to_char(?), to_char('DD-MM-YYYY HH24:MI:SS')), o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id),
o.c_currency_id, bp.paymentrule, bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id),
- 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, 'RE'
+ 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, 'RE', o.iscashvat
from c_order o, obpos_applications ap, obpos_terminaltype tt, c_doctype dt, c_bpartner bp
where o.em_obpos_applications_id = ap.obpos_applications_id
and ap.obpos_terminaltype_id = tt.obpos_terminaltype_id
@@ -48,7 +48,7 @@
and o.em_obpos_notinvoiceoncashup = 'N'
group by o.ad_client_id, o.ad_org_id, dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_bpartner_id, o.c_bpartner_location_id, o.billto_id, o.c_currency_id, bp.paymentrule,
- bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id
+ bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id, o.iscashvat
]]>
</Sql>
<Parameter name="userId"/>
@@ -67,14 +67,14 @@
(c_invoice_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, issotrx,
documentno, docstatus, docaction, processing, processed, posted, c_doctype_id, c_doctypetarget_id, c_order_id, description, dateordered,
salesrep_id, dateinvoiced, dateacct, c_bpartner_id, c_bpartner_location_id, c_currency_id, paymentrule, c_paymentterm_id, totallines,
- grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, em_aprm_processinvoice)
+ grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, em_aprm_processinvoice, iscashvat)
select get_uuid(), o.ad_client_id, o.ad_org_id, 'Y', now(), ?, now(), ?, 'Y', ?, 'CO', 'RE', 'N', 'Y', 'N',
dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_order_id, max(ad_message_get2('OrderDocumentno', ?)) || ' ' || o.documentno, o.dateordered,
max(o.salesrep_id), to_timestamp(to_char(?), to_char('DD-MM-YYYY HH24:MI:SS')),
to_timestamp(to_char(?), to_char('DD-MM-YYYY HH24:MI:SS')),
o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id), o.c_currency_id, bp.paymentrule,
- bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id), 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, 'RE'
+ bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id), 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, 'RE', o.iscashvat
from c_order o, obpos_applications ap, obpos_terminaltype tt, c_doctype dt, c_bpartner bp
where o.em_obpos_applications_id = ap.obpos_applications_id
and ap.obpos_terminaltype_id = tt.obpos_terminaltype_id
@@ -87,7 +87,7 @@
group by o.ad_client_id, o.ad_org_id, dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_bpartner_id, o.c_bpartner_location_id, o.billto_id, o.c_currency_id, bp.paymentrule,
bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id,
- o.c_order_id, o.dateOrdered, o.documentno
+ o.c_order_id, o.dateOrdered, o.documentno, o.iscashvat
order by o.dateOrdered, o.documentno
]]>
</Sql>
@@ -131,6 +131,7 @@
and o.c_doctype_id in (tt.c_doctype_id, tt.c_doctyperet_id)
and not exists (select 1 from c_orderline ol2 where ol2.qtyinvoiced <> 0 and ol2.c_order_id = o.c_order_id)
and o.em_obpos_notinvoiceoncashup = 'N'
+ and o.iscashvat = i.iscashvat
and i.documentno = ?
and i.c_bpartner_id = o.c_bpartner_id and i.c_bpartner_location_id = o.billto_id
group by i.ad_client_id, i.ad_org_id, i.createdby, i.updatedby,
@@ -179,6 +180,7 @@
and o.c_doctype_id in (tt.c_doctype_id, tt.c_doctyperet_id)
and not exists (select 1 from c_orderline ol2 where ol2.qtyinvoiced <> 0 and ol2.c_order_id = o.c_order_id)
and o.em_obpos_notinvoiceoncashup = 'N'
+ and o.iscashvat = i.iscashvat
and i.documentno = ?
and i.c_order_id = o.c_order_id
group by i.ad_client_id, i.ad_org_id, i.createdby, i.updatedby,
@@ -409,4 +411,4 @@
]]></Sql>
<Parameter name="executionId"/>
</SqlMethod>
-</SqlClass>
+</SqlClass>
\ No newline at end of file
diff -r 01921790ee46 -r c5759ccfa5e3 src/org/openbravo/retail/posterminal/OrderLoader.java
--- a/src/org/openbravo/retail/posterminal/OrderLoader.java Thu Sep 01 14:00:14 2016 +0530
+++ b/src/org/openbravo/retail/posterminal/OrderLoader.java Fri Jul 22 15:06:23 2016 +0530
@@ -1419,6 +1419,9 @@
order.setId(jsonorder.getString("id"));
order.setNewOBObject(true);
}
+ if (jsonorder.has("cashVAT")) {
+ order.setCashVAT(jsonorder.getBoolean("cashVAT"));
+ }
int pricePrecision = order.getCurrency().getObposPosprecision() == null ? order.getCurrency()
.getPricePrecision().intValue() : order.getCurrency().getObposPosprecision().intValue();
BusinessPartner bp = order.getBusinessPartner();
diff -r 01921790ee46 -r c5759ccfa5e3 src/org/openbravo/retail/posterminal/term/Terminal.java
--- a/src/org/openbravo/retail/posterminal/term/Terminal.java Thu Sep 01 14:00:14 2016 +0530
+++ b/src/org/openbravo/retail/posterminal/term/Terminal.java Fri Jul 22 15:06:23 2016 +0530
@@ -40,6 +40,7 @@
import org.openbravo.mobile.core.process.SimpleQueryBuilder;
import org.openbravo.model.ad.domain.ModelImplementation;
import org.openbravo.model.ad.domain.ModelImplementationParameter;
+import org.openbravo.model.common.enterprise.Organization;
import org.openbravo.model.common.enterprise.OrganizationInformation;
import org.openbravo.retail.posterminal.InitialValidations;
import org.openbravo.retail.posterminal.JSONProcessSimple;
@@ -100,13 +101,17 @@
HQLPropertyList regularTerminalHQLProperties = ModelExtensionUtils
.getPropertyExtensions(extensions);
+ String strOrgId = pOSTerminal.getOrganization().getId();
final OrganizationInformation myOrgInfo = pOSTerminal.getOrganization()
.getOrganizationInformationList().get(0);
+ final Organization org = OBDal.getInstance().get(Organization.class, strOrgId);
+ final Organization legalEntity = OBContext.getOBContext()
+ .getOrganizationStructureProvider(org.getClient().getId()).getLegalEntity(org);
String storeAddress = "";
String regionId = "";
- String countryId = "";
+ String countryId = "", orgInfoId = "";
if (myOrgInfo.getLocationAddress() != null
&& myOrgInfo.getLocationAddress().getIdentifier().length() > 0) {
@@ -120,6 +125,12 @@
if (myOrgInfo.getLocationAddress().getCountry() != null) {
countryId = myOrgInfo.getLocationAddress().getCountry().getId();
}
+
+ if (legalEntity != null && legalEntity.getOrganizationInformationList() != null
+ && !legalEntity.getOrganizationInformationList().isEmpty()) {
+ orgInfoId = legalEntity.getId();
+ }
+
String selectOrgImage = "";
String fromOrgImage = "";
String whereOrgImage = "";
@@ -179,7 +190,7 @@
+ "'"
+ countryId
+ "'"
- + " as organizationCountryId, '"
+ + " as organizationCountryId, orginfo.cashVAT as cashVat,'"
+ ProcessHQLQuery.escape(storeAddress)
+ "' as organizationAddressIdentifier, "
+ sessionTimeout
@@ -187,7 +198,11 @@
+ selectOrgImage
+ regularTerminalHQLProperties.getHqlSelect()
+ " from OBPOS_Applications AS pos inner join pos.obposTerminaltype as postype "
+ + ", Organization org "
+ fromOrgImage
+ + " inner join org.organizationInformationList as orginfo with orginfo.id='"
+ + orgInfoId
+ + "'"
+ " where pos.$readableSimpleCriteria and pos.$activeCriteria and pos.searchKey = :searchKey "
+ whereOrgImage;
diff -r 01921790ee46 -r c5759ccfa5e3 web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js Thu Sep 01 14:00:14 2016 +0530
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js Fri Jul 22 15:06:23 2016 +0530
@@ -112,7 +112,8 @@
bplCountryId = receipt.get('bp').get('locationModel') ? receipt.get('bp').get('locationModel').get('countryId') : null,
bplRegionId = receipt.get('bp').get('locationModel') ? receipt.get('bp').get('locationModel').get('regionId') : null,
bpName = receipt.get('bp').get('name') || OB.I18N.getLabel('OBPOS_LblEmptyAddress'),
- bpLocName = receipt.get('bp').get('locName') || OB.I18N.getLabel('OBPOS_LblEmptyAddress');
+ bpLocName = receipt.get('bp').get('locName') || OB.I18N.getLabel('OBPOS_LblEmptyAddress'),
+ isCashVat = OB.MobileApp.model.get('terminal').cashVat;
// SQL build
// the query is ordered by countryId desc and regionId desc
// (so, the first record will be the tax with the same country or
@@ -143,6 +144,9 @@
sql = sql + " and (c_tax.to_country_id = '" + bplCountryId + "' or tz.to_country_id = '" + bplCountryId + "' or (c_tax.to_country_id is null and (not exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id) or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_country_id = '" + bplCountryId + "') or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_country_id is null))))";
sql = sql + " and (c_tax.to_region_id = '" + bplRegionId + "' or tz.to_region_id = '" + bplRegionId + "' or (c_tax.to_region_id is null and (not exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id) or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_region_id = '" + bplRegionId + "') or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_region_id is null))))";
}
+ if (isCashVat) {
+ sql = sql + " and (c_tax.isCashVAT ='" + isCashVat + "' OR (c_tax.isCashVAT = 'false' and (c_tax.isWithholdingTax = 'true' or c_tax.rate=0))) ";
+ }
sql = sql + " order by orderRegionTo, orderRegionFrom, orderCountryTo, orderCountryFrom, c_tax.validFrom desc, c_tax.isdefault desc";
OB.UTIL.HookManager.executeHooks('OBPOS_FindTaxRate', {
diff -r 01921790ee46 -r c5759ccfa5e3 web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js Thu Sep 01 14:00:14 2016 +0530
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js Fri Jul 22 15:06:23 2016 +0530
@@ -3536,6 +3536,7 @@
order.set('isQuotation', false);
order.set('oldId', null);
order.set('session', OB.MobileApp.model.get('session'));
+ order.set('cashVAT', OB.MobileApp.model.get('terminal').cashVat);
order.set('bp', bp);
if (OB.MobileApp.model.hasPermission('EnableMultiPriceList', true)) {
// Set price list for order
Cashvat_Test.patch [^] (15,144 bytes) 2016-09-13 13:26 [Show Content] [Hide Content]# HG changeset patch
# User Silambarasan Sekar <silambarasan@qualiantech.com>
# Date 1473765702 -19800
# Tue Sep 13 16:51:42 2016 +0530
# Node ID 5ed7dacef5b4d0d94d505d92aad2289dfce67d41
# Parent 1e96d6efd9c781e937ea215bb691cb616a25f5ff
Added cashvat test
diff -r 1e96d6efd9c7 -r 5ed7dacef5b4 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/CashVatInSalesOrder.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/CashVatInSalesOrder.java Tue Sep 13 16:51:42 2016 +0530
@@ -0,0 +1,129 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2016 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author SIM
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.receipts;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+public class CashVatInSalesOrder extends WebPOSTerminalHelper {
+
+ @Test
+ public void test() {
+
+ // sales order with cashvat-false
+ disableCashVatTax();
+ disableCashVat();
+
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_AVALANCHETRANSCEIVER);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_INSECTREPELLENT);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "165.00");
+ String receiptNo = BackboneHelper.getDocumentNo();
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ String sql = "SELECT iscashvat FROM c_order WHERE documentno = '" + receiptNo + "'";
+
+ new DatabaseHelperSelect() {
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+
+ final String isCashVat = rs.getString("iscashvat");
+
+ logger.info(String.format(
+ "Verifying that the database record (%s) '%s' is one of the expected", isCashVat, "N"));
+ assertThat("Sales Order has cashvat", isCashVat, equalTo("N"));
+ }
+ }.execute(sql, 1);
+
+ // sales order with cashvat-true
+ enableCashVatTax();
+ enableCashVat();
+
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_AVALANCHETRANSCEIVER);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_INSECTREPELLENT);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "165.00");
+ receiptNo = BackboneHelper.getDocumentNo();
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ sql = "SELECT iscashvat FROM c_order WHERE documentno = '" + receiptNo + "'";
+ new DatabaseHelperSelect() {
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+
+ final String isCashVat = rs.getString("iscashvat");
+
+ logger.info(String.format(
+ "Verifying that the database record (%s) '%s' is one of the expected", isCashVat, "Y"));
+ assertThat("Sales Order has cashvat", isCashVat, equalTo("Y"));
+ }
+ }.execute(sql, 1);
+ }
+
+ private void enableCashVat() {
+ SeleniumHelper.executeScript("OB.MobileApp.model.receipt.set('cashVAT', true)");
+ SeleniumHelper.executeScript("OB.MobileApp.model.get('terminal').cashVat=true");
+ }
+
+ private void disableCashVat() {
+ SeleniumHelper.executeScript("OB.MobileApp.model.receipt.set('cashVAT', false)");
+ SeleniumHelper.executeScript("OB.MobileApp.model.get('terminal').cashVat=false");
+ }
+
+ private void disableCashVatTax() {
+ String updateTax = "update c_tax set istaxexempt='N' , iswithholdingtax='N' where name = 'Entregas IVA 21%' "
+ + "and ad_client_id='39363B0921BB4293B48383844325E84C'";
+ new DatabaseHelperInsertUpdateOrDelete().execute(updateTax, 1);
+ reload();
+ }
+
+ private void enableCashVatTax() {
+ String updateTax = "update c_tax set istaxexempt='Y' , iswithholdingtax='Y' where name = 'Entregas IVA 21%' "
+ + "and ad_client_id='39363B0921BB4293B48383844325E84C'";
+ new DatabaseHelperInsertUpdateOrDelete().execute(updateTax, 1);
+ reload();
+ }
+}
\ No newline at end of file
diff -r 1e96d6efd9c7 -r 5ed7dacef5b4 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/InvoiceWithAndWithOutCashvat.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/InvoiceWithAndWithOutCashvat.java Tue Sep 13 16:51:42 2016 +0530
@@ -0,0 +1,218 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2016 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author SIM
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.receipts;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+public class InvoiceWithAndWithOutCashvat extends WebPOSTerminalHelper {
+
+ String receiptNo, nextReceiptNo, sql;
+
+ @Test
+ public void test() {
+
+ cashUp();
+
+ // sales order with cashvat-true
+ enableCashVatTax();
+ enableCashVat();
+
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_AVALANCHETRANSCEIVER);
+ receiptNo = BackboneHelper.getDocumentNo();
+ verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ cashUp();
+
+ // getting cashvat, documentno, totalpaid, linegrossamount for created invoice
+
+ sql = "select inv.iscashvat as isCashVat, ord.documentno as documentNo, sum(invl.line_gross_amount) as lineGrossAmnt ,"
+ + "sum(inv.totalpaid) as totalPaid from c_invoice inv "
+ + "join c_invoiceline invl on invl.c_invoice_id=inv.c_invoice_id "
+ + "join c_orderline ordl on ordl.c_orderline_id=invl.c_orderline_id "
+ + "join c_order ord on ord.c_order_id = ordl.c_order_id "
+ + "where ord.c_order_id=(select c_order_id from c_order where documentno ='"
+ + receiptNo
+ + "') group by inv.iscashvat, ord.documentno";
+
+ verifyDatabase(sql, "Y", receiptNo);
+
+ // sales order with cashvat-true
+ enableCashVat();
+
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_AVALANCHETRANSCEIVER);
+ receiptNo = BackboneHelper.getDocumentNo();
+ verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ // sales order with cashvat-false
+ disableCashVatTax();
+ disableCashVat();
+
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+ tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_INSECTREPELLENT);
+ nextReceiptNo = BackboneHelper.getDocumentNo();
+ verify(TestIdPack.LABEL_TOTALTOPAY, "14.50");
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ cashUp();
+
+ // getting cashvat, documentno, totalpaid, linegrossamount for created invoice
+
+ sql = "select inv.iscashvat as isCashVat, ord.documentno as documentNo, sum(invl.line_gross_amount) as lineGrossAmnt ,"
+ + "sum(inv.totalpaid) as totalPaid from c_invoice inv "
+ + "join c_invoiceline invl on invl.c_invoice_id=inv.c_invoice_id "
+ + "join c_orderline ordl on ordl.c_orderline_id=invl.c_orderline_id "
+ + "join c_order ord on ord.c_order_id = ordl.c_order_id "
+ + "where ord.c_order_id=(select c_order_id from c_order where documentno ='"
+ + receiptNo
+ + "') group by inv.iscashvat, ord.documentno";
+
+ verifyDatabase(sql, "Y", receiptNo);
+
+ sql = "select inv.iscashvat as isCashVat, ord.documentno as documentNo, sum(invl.line_gross_amount) as lineGrossAmnt ,"
+ + "sum(inv.totalpaid) as totalPaid from c_invoice inv "
+ + "join c_invoiceline invl on invl.c_invoice_id=inv.c_invoice_id "
+ + "join c_orderline ordl on ordl.c_orderline_id=invl.c_orderline_id "
+ + "join c_order ord on ord.c_order_id = ordl.c_order_id "
+ + "where ord.c_order_id=(select c_order_id from c_order where documentno ='"
+ + nextReceiptNo + "') group by inv.iscashvat, ord.documentno";
+
+ verifyDatabase(sql, "N", nextReceiptNo);
+
+ }
+
+ private void verifyDatabase(String query, final String isCashvat, final String documentNo) {
+ new DatabaseHelperSelect() {
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+
+ final String cashvat = rs.getString("isCashVat");
+ final String ordNo = rs.getString("documentNo");
+ final Double grossAmnt = rs.getDouble("lineGrossAmnt");
+ final Double totalPaid = rs.getDouble("totalPaid");
+
+ assertThat("Cashvat is not same", cashvat, equalTo(isCashvat));
+ assertThat("documentno is not same", ordNo, equalTo(documentNo));
+ assertThat("total is not same", grossAmnt, equalTo(totalPaid));
+
+ }
+ }.execute(query, 1);
+ }
+
+ private void cashUp() {
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_CASHUP);
+
+ // step 1 of 4
+ verify(TestIdPack.LABEL_CASHUP_STEP2_TITLE, "Step 1 of 4: Count Cash");
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+ // step 2 of 4
+ verify(TestIdPack.LABEL_CASHUP_STEP3_TITLE, "Step 2 of 4: Count Cash");
+ tap(TestIdPack.BUTTON_CASHUP_CARD_OK);
+ tap(TestIdPack.BUTTON_CASHUP_CASHUSA_OK);
+ tap(TestIdPack.BUTTON_CASHUP_VOUCHER_OK);
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+ // step 3 of 4
+ // cash
+ verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE, "Step 3 of 4: Select Cash to keep");
+ verify(TestIdPack.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ // usa cash
+ verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE, "Step 3 of 4: Select USA Cash to keep");
+ verify(TestIdPack.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ // voucher
+ verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE, "Step 3 of 4: Select Voucher to keep");
+ verify(TestIdPack.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+ // step 4 of 4
+ verify(TestIdPack.LABEL_CASHUP_STEP5_TITLE, "Step 4 of 4: Post, print and close");
+ verify(TestIdPack.LABEL_CASHUP_POSTPRINTANDCLOSE, "Post, Print & Close");
+ tap(TestIdPack.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+ // done
+ verify(TestIdPack.LABEL_POPUP_TITLE, "Good job!");
+ tap(TestIdPack.BUTTON_POPUP_OK);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+ }
+
+ private void enableCashVat() {
+ SeleniumHelper.executeScript("OB.MobileApp.model.receipt.set('cashVAT', true)");
+ SeleniumHelper.executeScript("OB.MobileApp.model.get('terminal').cashVat=true");
+ }
+
+ private void disableCashVat() {
+ SeleniumHelper.executeScript("OB.MobileApp.model.receipt.set('cashVAT', false)");
+ SeleniumHelper.executeScript("OB.MobileApp.model.get('terminal').cashVat=false");
+ }
+
+ private void disableCashVatTax() {
+ String updateTax = "update c_tax set istaxexempt='N' , iswithholdingtax='N' where name = 'Entregas IVA 21%' "
+ + "and ad_client_id='39363B0921BB4293B48383844325E84C'";
+ new DatabaseHelperInsertUpdateOrDelete().execute(updateTax, 1);
+ reload();
+ }
+
+ private void enableCashVatTax() {
+ String updateTax = "update c_tax set istaxexempt='Y' , iswithholdingtax='Y' where name = 'Entregas IVA 21%' "
+ + "and ad_client_id='39363B0921BB4293B48383844325E84C'";
+ new DatabaseHelperInsertUpdateOrDelete().execute(updateTax, 1);
+ reload();
+ }
+}
cashvat-pos-19q2.diff [^] (15,352 bytes) 2019-03-11 19:14 [Show Content] [Hide Content]# HG changeset patch
# User Gorka Gil <gorka.gil@openbravo.com>
# Date 1550237746 -3600
# Fri Feb 15 14:35:46 2019 +0100
# Node ID 01361f74e96b77521152aafc05a9005179f0b18a
# Parent a6452b3b0f6efa5fe8043e5e1044c95c28e860c7
Fixes issue 33973: Cash Vat in sales order and sales invoice
diff -r a6452b3b0f6e -r 01361f74e96b src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Tue Feb 19 10:57:34 2019 +0100
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Fri Feb 15 14:35:46 2019 +0100
@@ -40,6 +40,7 @@
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.CashVATUtil;
import org.openbravo.erpCommon.utility.OBMessageUtils;
import org.openbravo.erpCommon.utility.SequenceIdData;
import org.openbravo.erpCommon.utility.Utility;
@@ -54,6 +55,7 @@
import org.openbravo.model.common.order.Order;
import org.openbravo.model.common.order.OrderLine;
import org.openbravo.model.common.order.OrderLineOffer;
+import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
@@ -276,6 +278,9 @@
invoice.setDocumentNo(
getInvoiceDocumentNo(invoice.getTransactionDocument(), invoice.getDocumentType()));
finishInvoice(invoice, currentDate);
+ if (invoice.isCashVAT()) {
+ createCashVat(invoice);
+ }
executeHooks(invoice, cashUpId);
}
@@ -393,6 +398,19 @@
doctype == null ? "" : doctype.getId(), false, true);
}
+ protected void createCashVat(Invoice invoiceObj) {
+ for (FIN_PaymentSchedule scheduleObj : invoiceObj.getFINPaymentScheduleList()) {
+ for (FIN_PaymentScheduleDetail schDetailObj : scheduleObj
+ .getFINPaymentScheduleDetailInvoicePaymentScheduleList()) {
+ FIN_PaymentDetail paymentDetail = schDetailObj.getPaymentDetails();
+ if (paymentDetail != null) {
+ CashVATUtil.createInvoiceTaxCashVAT(paymentDetail, scheduleObj,
+ paymentDetail.getAmount().add(paymentDetail.getWriteoffAmount()));
+ }
+ }
+ }
+ }
+
private void finishInvoice(Invoice oriInvoice, Date currentDate) throws SQLException {
if (oriInvoice == null) {
return;
diff -r a6452b3b0f6e -r 01361f74e96b src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Tue Feb 19 10:57:34 2019 +0100
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Fri Feb 15 14:35:46 2019 +0100
@@ -58,13 +58,13 @@
(c_invoice_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, issotrx,
documentno, docstatus, docaction, processing, processed, posted, c_doctype_id, c_doctypetarget_id, c_order_id, description, dateordered,
salesrep_id, dateinvoiced, dateacct, c_bpartner_id, c_bpartner_location_id, c_currency_id, paymentrule, c_paymentterm_id, totallines,
- grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, ad_user_id, em_aprm_processinvoice)
+ grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, ad_user_id, em_aprm_processinvoice, iscashvat)
select get_uuid(), o.ad_client_id, o.ad_org_id, 'Y', now(), ?, now(), ?, 'Y', ?,
'CO', 'RE', 'N', 'Y', 'N', dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
null, ?, null, max(o.salesrep_id), to_date(to_char(?), to_char('DD-MM-YYYY')),
to_date(to_char(?), to_char('DD-MM-YYYY')), o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id),
o.c_currency_id, bp.paymentrule, bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id),
- 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, o.ad_user_id, 'RE'
+ 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, o.ad_user_id, 'RE', o.iscashvat
from c_order o, obpos_applications ap, ad_org org, c_doctype dt, c_bpartner bp
where o.em_obpos_applications_id = ap.obpos_applications_id
and ap.ad_org_id = org.ad_org_id
@@ -77,7 +77,7 @@
and o.em_obpos_notinvoiceoncashup = 'N'
group by o.ad_client_id, o.ad_org_id, dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id), o.c_currency_id, bp.paymentrule,
- bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id, o.ad_user_id
+ bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id, o.ad_user_id, o.iscashvat
]]>
</Sql>
<Parameter name="userId"/>
@@ -99,14 +99,14 @@
(c_invoice_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, issotrx,
documentno, docstatus, docaction, processing, processed, posted, c_doctype_id, c_doctypetarget_id, c_order_id, description, dateordered,
salesrep_id, dateinvoiced, dateacct, c_bpartner_id, c_bpartner_location_id, c_currency_id, paymentrule, c_paymentterm_id, totallines,
- grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, ad_user_id, em_aprm_processinvoice)
+ grandtotal, m_pricelist_id, ispaid, totalpaid, outstandingamt, fin_paymentmethod_id, ad_user_id, em_aprm_processinvoice, iscashvat)
select get_uuid(), o.ad_client_id, o.ad_org_id, 'Y', now(), ?, now(), ?, 'Y', ?, 'CO', 'RE', 'N', 'Y', 'N',
dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_order_id, ? || '. ' || max(ad_message_get2('OrderDocumentno', ?)) || ' ' || o.documentno, o.dateordered,
max(o.salesrep_id), to_date(to_char(?), to_char('DD-MM-YYYY')),
to_date(to_char(?), to_char('DD-MM-YYYY')),
o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id), o.c_currency_id, bp.paymentrule,
- bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id), 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, o.ad_user_id, 'RE'
+ bp.c_paymentterm_id, sum(o.totallines), sum(o.grandtotal), max(o.m_pricelist_id), 'Y', sum(o.grandtotal), 0, bp.fin_paymentmethod_id, o.ad_user_id, 'RE', o.iscashvat
from c_order o, obpos_applications ap, ad_org org, c_doctype dt, c_bpartner bp
where o.em_obpos_applications_id = ap.obpos_applications_id
and ap.ad_org_id = org.ad_org_id
@@ -119,7 +119,7 @@
group by o.ad_client_id, o.ad_org_id, dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
o.c_bpartner_id, coalesce(o.billto_id, o.c_bpartner_location_id), o.c_currency_id, bp.paymentrule,
bp.c_paymentterm_id, o.m_pricelist_id, bp.fin_paymentmethod_id, o.ad_user_id,
- o.c_order_id, o.dateOrdered, o.documentno
+ o.c_order_id, o.dateOrdered, o.documentno, o.iscashvat
order by o.dateOrdered, o.documentno
]]>
</Sql>
@@ -165,6 +165,7 @@
and o.c_doctype_id in (org.em_obpos_c_doctype_id, org.em_obpos_c_doctyperet_id)
and not exists (select 1 from c_orderline ol2 where ol2.qtyinvoiced <> 0 and ol2.c_order_id = o.c_order_id)
and o.em_obpos_notinvoiceoncashup = 'N'
+ and o.iscashvat = i.iscashvat
and i.documentno = ?
and i.c_bpartner_id = o.c_bpartner_id and i.c_bpartner_location_id = coalesce(o.billto_id, o.c_bpartner_location_id)
and coalesce(i.ad_user_id, '1') = coalesce(o.ad_user_id, '1')
@@ -216,6 +217,7 @@
and o.c_doctype_id in (org.em_obpos_c_doctype_id, org.em_obpos_c_doctyperet_id)
and not exists (select 1 from c_orderline ol2 where ol2.qtyinvoiced <> 0 and ol2.c_order_id = o.c_order_id)
and o.em_obpos_notinvoiceoncashup = 'N'
+ and o.iscashvat = i.iscashvat
and i.documentno = ?
and i.c_order_id = o.c_order_id
group by i.ad_client_id, i.ad_org_id, i.createdby, i.updatedby,
diff -r a6452b3b0f6e -r 01361f74e96b src/org/openbravo/retail/posterminal/OrderLoader.java
--- a/src/org/openbravo/retail/posterminal/OrderLoader.java Tue Feb 19 10:57:34 2019 +0100
+++ b/src/org/openbravo/retail/posterminal/OrderLoader.java Fri Feb 15 14:35:46 2019 +0100
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Copyright (C) 2012-2019 Openbravo S.L.U.
* Licensed under the Openbravo Commercial License version 1.0
* You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
* or in the legal folder of this module distribution.
@@ -968,6 +968,10 @@
order.set("creationDate", new Date(value));
}
+ if (jsonorder.has("cashVAT")) {
+ order.setCashVAT(jsonorder.getBoolean("cashVAT"));
+ }
+
int pricePrecision = order.getCurrency().getObposPosprecision() == null
? order.getCurrency().getPricePrecision().intValue()
: order.getCurrency().getObposPosprecision().intValue();
diff -r a6452b3b0f6e -r 01361f74e96b src/org/openbravo/retail/posterminal/term/Terminal.java
--- a/src/org/openbravo/retail/posterminal/term/Terminal.java Tue Feb 19 10:57:34 2019 +0100
+++ b/src/org/openbravo/retail/posterminal/term/Terminal.java Fri Feb 15 14:35:46 2019 +0100
@@ -115,13 +115,20 @@
HQLPropertyList regularTerminalHQLProperties = ModelExtensionUtils
.getPropertyExtensions(extensions, jsonsent);
+ String strOrgId = pOSTerminal.getOrganization().getId();
+
final OrganizationInformation myOrgInfo = pOSTerminal.getOrganization()
.getOrganizationInformationList()
.get(0);
+ final Organization org = OBDal.getInstance().get(Organization.class, strOrgId);
+ final Organization legalEntity = OBContext.getOBContext()
+ .getOrganizationStructureProvider(org.getClient().getId())
+ .getLegalEntity(org);
String storeAddress = "";
String regionId = "";
String countryId = "";
+ String orgInfoId = "";
if (myOrgInfo.getLocationAddress() != null
&& myOrgInfo.getLocationAddress().getIdentifier().length() > 0) {
@@ -135,6 +142,12 @@
if (myOrgInfo.getLocationAddress().getCountry() != null) {
countryId = myOrgInfo.getLocationAddress().getCountry().getId();
}
+
+ if (legalEntity != null && legalEntity.getOrganizationInformationList() != null
+ && !legalEntity.getOrganizationInformationList().isEmpty()) {
+ orgInfoId = legalEntity.getId();
+ }
+
String selectOrgImage = "";
String fromOrgImage = "";
String whereOrgImage = "";
@@ -180,12 +193,14 @@
+ lastDocumentNumber + " as lastDocumentNumber, " + lastQuotationDocumentNumber
+ " as lastQuotationDocumentNumber, " + lastReturnDocumentNumber
+ " as lastReturnDocumentNumber, " + "'" + regionId + "'" + " as organizationRegionId, "
- + "'" + countryId + "'" + " as organizationCountryId, '"
+ + "'" + countryId + "'" + " as organizationCountryId, orginfo.cashVAT as cashVat, '"
+ ProcessHQLQuery.escape(storeAddress) + "' as organizationAddressIdentifier, "
+ sessionTimeout + " as sessionTimeout, " + selectOrgImage
+ regularTerminalHQLProperties.getHqlSelect()
- + " from OBPOS_Applications AS pos inner join pos.obposTerminaltype as postype inner join pos.organization AS org, "
+ + " from OBPOS_Applications AS pos inner join pos.obposTerminaltype as postype inner join pos.organization AS org, Organization org2, "
+ "PricingPriceList pricelist " + fromOrgImage
+ + " inner join org2.organizationInformationList as orginfo with orginfo.id='" + orgInfoId
+ + "'"
+ " where pos.$readableSimpleCriteria and pos.$activeCriteria and pos.searchKey =:searchKey and pricelist.id =:pricelistId "
+ whereOrgImage;
diff -r a6452b3b0f6e -r 01361f74e96b web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js Tue Feb 19 10:57:34 2019 +0100
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js Fri Feb 15 14:35:46 2019 +0100
@@ -276,7 +276,8 @@
bpName = receipt.get('bp').get('name') || OB.I18N.getLabel('OBPOS_LblEmptyAddress'),
bpShipLocName = receipt.get('bp').get('shipLocName') || OB.I18N.getLabel('OBPOS_LblEmptyAddress'),
bplCountryId = receipt.get('bp').get('shipCountryId') ? receipt.get('bp').get('shipCountryId') : null,
- bplRegionId = receipt.get('bp').get('shipRegionId') ? receipt.get('bp').get('shipRegionId') : null;
+ bplRegionId = receipt.get('bp').get('shipRegionId') ? receipt.get('bp').get('shipRegionId') : null,
+ isCashVat = OB.MobileApp.model.get('terminal').cashVat;
// SQL build
// the query is ordered by countryId desc and regionId desc
// (so, the first record will be the tax with the same country or
@@ -312,6 +313,9 @@
sql = sql + " and (c_tax.to_country_id = '" + bplCountryId + "' or tz.to_country_id = '" + bplCountryId + "' or (c_tax.to_country_id is null and (not exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id) or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_country_id = '" + bplCountryId + "') or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_country_id is null))))";
sql = sql + " and (c_tax.to_region_id = '" + bplRegionId + "' or tz.to_region_id = '" + bplRegionId + "' or (c_tax.to_region_id is null and (not exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id) or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_region_id = '" + bplRegionId + "') or exists (select 1 from c_tax_zone z where z.c_tax_id = c_tax.c_tax_id and z.to_region_id is null))))";
}
+ if (isCashVat) {
+ sql = sql + " and (c_tax.isCashVAT ='" + isCashVat + "' OR (c_tax.isCashVAT = 'false' and (c_tax.isWithholdingTax = 'true' or c_tax.rate=0))) ";
+ }
sql = sql + " order by orderRegionTo, orderRegionFrom, orderCountryTo, orderCountryFrom, c_tax.validFrom desc, c_tax.isdefault desc";
OB.UTIL.HookManager.executeHooks('OBPOS_FindTaxRate', {
diff -r a6452b3b0f6e -r 01361f74e96b web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js Tue Feb 19 10:57:34 2019 +0100
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js Fri Feb 15 14:35:46 2019 +0100
@@ -7354,6 +7354,7 @@
order.set('isQuotation', false);
order.set('oldId', null);
order.set('session', OB.MobileApp.model.get('session'));
+ order.set('cashVAT', OB.MobileApp.model.get('terminal').cashVat);
order.set('bp', bp);
if (OB.MobileApp.model.hasPermission('EnableMultiPriceList', true)) {
// Set price list for order
|