svn commit: r628094 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r628094 - /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh

jacopoc
Author: jacopoc
Date: Fri Feb 15 07:57:42 2008
New Revision: 628094

URL: http://svn.apache.org/viewvc?rev=628094&view=rev
Log:
A more complete list of invoice item types is created for purchase and sales invoices; this code can be further improved.

Modified:
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh?rev=628094&r1=628093&r2=628094&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/getInvoiceItemTypes.bsh Fri Feb 15 07:57:42 2008
@@ -19,10 +19,31 @@
 
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityOperator;
+
+import javolution.util.FastList;
 
 invoice = context.get("invoice");
 if (invoice == null) return;
 
-map = delegator.findByAndCache("InvoiceItemTypeMap", UtilMisc.toMap("invoiceTypeId", invoice.get("invoiceTypeId")));
-invoiceItemTypes = EntityUtil.getRelated("InvoiceItemType", map);
+if ("SALES_INVOICE".equals(invoice.get("invoiceTypeId"))) {
+    List parentTypes = FastList.newInstance();
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "INVOICE_ADJ"));
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "INVOICE_ITM_ADJ"));
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "INV_PROD_ITEM"));
+    parentTypesCond = new EntityConditionList(parentTypes, EntityOperator.OR);
+    invoiceItemTypes = delegator.findByCondition("InvoiceItemType", parentTypesCond, null, UtilMisc.toList("parentTypeId", "invoiceItemTypeId"));
+} else if ("PURCHASE_INVOICE".equals(invoice.get("invoiceTypeId"))) {
+    List parentTypes = FastList.newInstance();
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "PINVOICE_ADJ"));
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "PINVOICE_ITM_ADJ"));
+    parentTypes.add(new EntityExpr("parentTypeId", EntityOperator.EQUALS, "PINV_PROD_ITEM"));
+    parentTypesCond = new EntityConditionList(parentTypes, EntityOperator.OR);
+    invoiceItemTypes = delegator.findByCondition("InvoiceItemType", parentTypesCond, null, UtilMisc.toList("parentTypeId", "invoiceItemTypeId"));
+} else {
+    map = delegator.findByAndCache("InvoiceItemTypeMap", UtilMisc.toMap("invoiceTypeId", invoice.get("invoiceTypeId")));
+    invoiceItemTypes = EntityUtil.getRelated("InvoiceItemType", map);
+}
 context.put("invoiceItemTypes", invoiceItemTypes);