Attached Files | SplitInvoice.patch [^] (13,299 bytes) 2016-09-26 12:12 [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 5511902a141463ee2664f4ed0d899105557b19c4
# Parent 027dc930d1761e778089716c0cae4b9f5c9d3cee
Cashvat-SplitInvoice
diff -r 027dc930d176 -r 5511902a1414 src-db/database/sourcedata/AD_PREFERENCE.xml
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml Wed Sep 07 10:43:15 2016 -0600
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml Fri Jul 22 15:06:23 2016 +0530
@@ -429,6 +429,17 @@
<!--84328C76270F4A91AB709B1B75A151B5--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
<!--84328C76270F4A91AB709B1B75A151B5--></AD_PREFERENCE>
+<!--848EA3F7DC984809A1107291BAEB6407--><AD_PREFERENCE>
+<!--848EA3F7DC984809A1107291BAEB6407--> <AD_PREFERENCE_ID><![CDATA[848EA3F7DC984809A1107291BAEB6407]]></AD_PREFERENCE_ID>
+<!--848EA3F7DC984809A1107291BAEB6407--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--848EA3F7DC984809A1107291BAEB6407--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--848EA3F7DC984809A1107291BAEB6407--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--848EA3F7DC984809A1107291BAEB6407--> <VALUE><![CDATA[N]]></VALUE>
+<!--848EA3F7DC984809A1107291BAEB6407--> <PROPERTY><![CDATA[OBPOS_EnableSplitInvoice]]></PROPERTY>
+<!--848EA3F7DC984809A1107291BAEB6407--> <ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST>
+<!--848EA3F7DC984809A1107291BAEB6407--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--848EA3F7DC984809A1107291BAEB6407--></AD_PREFERENCE>
+
<!--86D9FA1641464B0DB09CE966CB6F2835--><AD_PREFERENCE>
<!--86D9FA1641464B0DB09CE966CB6F2835--> <AD_PREFERENCE_ID><![CDATA[86D9FA1641464B0DB09CE966CB6F2835]]></AD_PREFERENCE_ID>
<!--86D9FA1641464B0DB09CE966CB6F2835--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 027dc930d176 -r 5511902a1414 src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/sourcedata/AD_REF_LIST.xml Wed Sep 07 10:43:15 2016 -0600
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml Fri Jul 22 15:06:23 2016 +0530
@@ -467,6 +467,17 @@
<!--56E9EAA1759B416C86AA801E363AA5A8--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
<!--56E9EAA1759B416C86AA801E363AA5A8--></AD_REF_LIST>
+<!--576E51686D38400EBCE6E1F9256C2319--><AD_REF_LIST>
+<!--576E51686D38400EBCE6E1F9256C2319--> <AD_REF_LIST_ID><![CDATA[576E51686D38400EBCE6E1F9256C2319]]></AD_REF_LIST_ID>
+<!--576E51686D38400EBCE6E1F9256C2319--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--576E51686D38400EBCE6E1F9256C2319--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--576E51686D38400EBCE6E1F9256C2319--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--576E51686D38400EBCE6E1F9256C2319--> <VALUE><![CDATA[OBPOS_EnableSplitInvoice]]></VALUE>
+<!--576E51686D38400EBCE6E1F9256C2319--> <NAME><![CDATA[Separate invoice for normal order and returns ]]></NAME>
+<!--576E51686D38400EBCE6E1F9256C2319--> <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--576E51686D38400EBCE6E1F9256C2319--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID>
+<!--576E51686D38400EBCE6E1F9256C2319--></AD_REF_LIST>
+
<!--57786C212D874EA09FE2EEA2D0A4ED58--><AD_REF_LIST>
<!--57786C212D874EA09FE2EEA2D0A4ED58--> <AD_REF_LIST_ID><![CDATA[57786C212D874EA09FE2EEA2D0A4ED58]]></AD_REF_LIST_ID>
<!--57786C212D874EA09FE2EEA2D0A4ED58--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 027dc930d176 -r 5511902a1414 src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Wed Sep 07 10:43:15 2016 -0600
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java Fri Jul 22 15:06:23 2016 +0530
@@ -38,6 +38,8 @@
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.erpCommon.utility.PropertyException;
import org.openbravo.erpCommon.utility.SequenceIdData;
import org.openbravo.erpCommon.utility.Utility;
import org.openbravo.model.ad.access.InvoiceLineTax;
@@ -62,6 +64,7 @@
@Any
private Instance<FinishInvoiceHook> invoiceProcesses;
+ private boolean splitInvoice = false;
private static final Logger log = Logger.getLogger(OrderGroupingProcessor.class);
/**
@@ -88,14 +91,33 @@
Random rnd = new Random();
String strExecutionId = "WebPOS_CashUp_" + String.valueOf(rnd.nextInt(1000000));
+ try {
+ splitInvoice = "Y".equals(Preferences.getPreferenceValue("OBPOS_EnableSplitInvoice", true,
+ OBContext.getOBContext().getCurrentClient(), OBContext.getOBContext()
+ .getCurrentOrganization(), OBContext.getOBContext().getUser(), OBContext
+ .getOBContext().getRole(), null));
+ } catch (PropertyException e1) {
+ log.error("Error getting OBPOS_EnableSplitInvoice preference: " + e1.getMessage(), e1);
+ }
+
if (posTerminal.getObposTerminaltype().isGroupingOrders()) {
- // insert invoice headers
- OrderGroupingProcessorData.insertHeaderGrouping(conn, strUserId, strExecutionId,
- strCurrentDate, cashUpId);
- t1 = System.currentTimeMillis();
- // insert invoice lines
- OrderGroupingProcessorData.insertLinesGrouping(conn, cashUpId, strExecutionId);
- t2 = System.currentTimeMillis();
+ if (splitInvoice) {
+ // split invoice and insert invoice headers
+ OrderGroupingProcessorData.insertHeaderGroupingSplitInvoice(conn, strUserId,
+ strExecutionId, strCurrentDate, cashUpId);
+ t1 = System.currentTimeMillis();
+ // split invoice and insert invoice lines
+ OrderGroupingProcessorData.insertLinesGroupingSplitInvoice(conn, cashUpId, strExecutionId);
+ t2 = System.currentTimeMillis();
+ } else {
+ // insert invoice headers
+ OrderGroupingProcessorData.insertHeaderGrouping(conn, strUserId, strExecutionId,
+ strCurrentDate, cashUpId);
+ t1 = System.currentTimeMillis();
+ // insert invoice lines
+ OrderGroupingProcessorData.insertLinesGrouping(conn, cashUpId, strExecutionId);
+ t2 = System.currentTimeMillis();
+ }
OrderGroupingProcessorData.updateQtyOrderLinesGrouping(conn, strExecutionId);
// insert invoice lines Tax
OrderGroupingProcessorData.insertTaxLinesGrouping(conn, strExecutionId);
diff -r 027dc930d176 -r 5511902a1414 src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Wed Sep 07 10:43:15 2016 -0600
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor_data.xsql Fri Jul 22 15:06:23 2016 +0530
@@ -58,7 +58,44 @@
<Parameter name="currentDate"/>
<Parameter name="cashupId"/>
</SqlMethod>
-
+
+<SqlMethod name="insertHeaderGroupingSplitInvoice" type="preparedStatement" return="rowcount">
+ <SqlMethodComment>Split invoice and insert invoice headers grouping orders</SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ insert into c_invoice
+ (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, 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, 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', 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
+ and o.c_doctype_id = dt.c_doctype_id
+ and o.c_bpartner_id = bp.c_bpartner_id
+ and o.em_obpos_app_cashup_id = ?
+ 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 or ol2.qtydelivered <> ol2.qtyordered) and ol2.c_order_id = o.c_order_id)
+ and o.em_obpos_notinvoiceoncashup = 'N'
+ group by o.ad_client_id, o.ad_org_id,o.c_doctype_id,dt.c_doctypeinvoice_id, dt.c_doctypeinvoice_id,
+ o.c_bpartner_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.iscashvat
+ ]]>
+ </Sql>
+ <Parameter name="userId"/>
+ <Parameter name="userId"/>
+ <Parameter name="executionId"/>
+ <Parameter name="currentDate"/>
+ <Parameter name="currentDate"/>
+ <Parameter name="cashupId"/>
+ </SqlMethod>
+
<SqlMethod name="insertHeaderNoGrouping" type="preparedStatement" return="rowcount">
<SqlMethodComment>Insert invoice headers no grouping orders</SqlMethodComment>
<Sql>
@@ -147,6 +184,56 @@
<Parameter name="cashupId"/>
<Parameter name="executionId"/>
</SqlMethod>
+ <SqlMethod name="insertLinesGroupingSplitInvoice" type="preparedStatement" return="rowcount">
+ <SqlMethodComment>Split invoice and insert invoice lines grouping orders</SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ insert into c_invoiceline
+ (c_invoiceline_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby,
+ c_invoice_id, c_orderline_id, m_inoutline_id, line,
+ description, m_product_id, qtyinvoiced, pricelist, priceactual, pricelimit, linenetamt,
+ c_uom_id, c_tax_id, taxamt, m_attributesetinstance_id, pricestd,
+ taxbaseamt, line_gross_amount, gross_unit_price,
+ c_bpartner_id, grosspricestd, grosspricelist,
+ a_asset_id, c_project_id, user1_id, user2_id, c_costcenter_id)
+ select get_uuid(), i.ad_client_id, i.ad_org_id, 'Y', now(), i.createdby, now(), i.updatedby,
+ i.c_invoice_id, ol.c_orderline_id, max(iol.m_inoutline_id), row_number() over (partition by i.c_invoice_id order by o.documentno, ol.line) * 10 as line,
+ ol.description, ol.m_product_id, ol.qtyordered, ol.pricelist, ol.priceactual, ol.pricelimit, ol.linenetamt,
+ ol.c_uom_id, ol.c_tax_id, 0, ol.m_attributesetinstance_id, ol.pricestd,
+ ol.linenetamt , (case when pl.istaxincluded = 'Y' then ol.line_gross_amount else 0 end), ol.gross_unit_price,
+ ol.c_bpartner_id, ol.grosspricestd, ol.grosspricelist,
+ ol.a_asset_id, ol.c_project_id, ol.user1_id, ol.user2_id, ol.c_costcenter_id
+ from c_order o, m_pricelist pl, obpos_applications ap, obpos_terminaltype tt, c_doctype dt, c_invoice i,
+ c_orderline ol left join m_inoutline iol on ol.c_orderline_id = iol.c_orderline_id
+ where ol.c_order_id = o.c_order_id
+ and o.m_pricelist_id = pl.m_pricelist_id
+ and o.m_pricelist_id = i.m_pricelist_id
+ and o.em_obpos_applications_id = ap.obpos_applications_id
+ and ap.obpos_terminaltype_id = tt.obpos_terminaltype_id
+ and o.c_doctype_id = dt.c_doctype_id
+ and dt.c_doctypeinvoice_id = i.c_doctype_id
+ and o.em_obpos_app_cashup_id = ?
+ and ol.qtydelivered = ol.qtyordered
+ and ol.qtyordered <> 0
+ 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,
+ i.c_invoice_id, ol.c_orderline_id, ol.description, ol.m_product_id,
+ ol.qtyordered, ol.pricelist, ol.priceactual, ol.pricelimit, ol.linenetamt,
+ ol.c_uom_id, ol.c_tax_id, ol.m_attributesetinstance_id, ol.pricestd,
+ ol.linenetamt , ol.line_gross_amount, ol.gross_unit_price,
+ ol.c_bpartner_id, ol.grosspricestd, ol.grosspricelist,
+ ol.a_asset_id, ol.c_project_id, ol.user1_id, ol.user2_id, ol.c_costcenter_id, pl.istaxincluded,
+ o.documentno, ol.line, o.c_order_id
+ order by o.documentno, ol.line
+ ]]>
+ </Sql>
+ <Parameter name="cashupId"/>
+ <Parameter name="executionId"/>
+ </SqlMethod>
<SqlMethod name="insertLinesNoGrouping" type="preparedStatement" return="rowcount" >
<SqlMethodComment>Insert invoice lines no grouping orders</SqlMethodComment>
<Sql>
|