Author: mor
Date: Tue Jul 21 13:46:44 2009 New Revision: 796297 URL: http://svn.apache.org/viewvc?rev=796297&view=rev Log: When items received against a PO are canceled, this also cancels the invoice. Added the ability to re-generate the invoice once canceled items are received again. Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=796297&r1=796296&r2=796297&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Tue Jul 21 13:46:44 2009 @@ -1276,7 +1276,11 @@ } // check and make sure we haven't already billed for this issuance or shipment receipt - Map billFields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId); + List<EntityCondition> billFields = FastList.newInstance(); + billFields.add(EntityCondition.makeCondition("orderId", orderId)); + billFields.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); + billFields.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "INVOICE_CANCELLED")); + if (dropShipmentFound) { // Drop shipments have neither issuances nor receipts, so this check is meaningless @@ -1284,13 +1288,13 @@ shippedOrderItems.put(orderId, itemsByOrder); continue; } else if (item.getEntityName().equals("ItemIssuance")) { - billFields.put("itemIssuanceId", item.get("itemIssuanceId")); + billFields.add(EntityCondition.makeCondition("itemIssuanceId", item.get("itemIssuanceId"))); } else if (item.getEntityName().equals("ShipmentReceipt")) { - billFields.put("shipmentReceiptId", item.getString("receiptId")); + billFields.add(EntityCondition.makeCondition("shipmentReceiptId", item.getString("receiptId"))); } List itemBillings = null; try { - itemBillings = delegator.findByAnd("OrderItemBilling", billFields); + itemBillings = delegator.findList("OrderItemBillingAndInvoiceAndItem", EntityCondition.makeCondition(billFields, EntityOperator.AND), null, null, null, false); } catch (GenericEntityException e) { String errMsg = UtilProperties.getMessage(resource, "AccountingProblemLookingUpOrderItemBilling",UtilMisc.toMap("billFields",billFields), locale); Debug.logError(e, errMsg, module); @@ -1335,7 +1339,10 @@ BigDecimal billAvail = (BigDecimal) itemQtyAvail.get(issue.getString("orderItemSeqId")); if (billAvail == null) { - Map lookup = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", issue.get("orderItemSeqId")); + List<EntityCondition> lookup = FastList.newInstance(); + lookup.add(EntityCondition.makeCondition("orderId", orderId)); + lookup.add(EntityCondition.makeCondition("orderItemSeqId", issue.get("orderItemSeqId"))); + lookup.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "INVOICE_CANCELLED")); GenericValue orderItem = null; List billed = null; BigDecimal orderedQty = null; @@ -1353,8 +1360,7 @@ orderItem.set("quantity", purchaseOrderItem.getBigDecimal("quantity")); issueQty = purchaseOrderItem.getBigDecimal("quantity"); } - - billed = delegator.findByAnd("OrderItemBilling", lookup); + billed = delegator.findList("OrderItemBillingAndInvoiceAndItem", EntityCondition.makeCondition(lookup, EntityOperator.AND), null, null, null, false); } catch (GenericEntityException e) { String errMsg = UtilProperties.getMessage(resource, "AccountingProblemGettingOrderItemOrderItemBilling",UtilMisc.toMap("lookup",lookup), locale); Debug.logError(e, errMsg, module); Modified: ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?rev=796297&r1=796296&r2=796297&view=diff ============================================================================== --- ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original) +++ ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Tue Jul 21 13:46:44 2009 @@ -1614,4 +1614,30 @@ <key-map field-name="orderId"/> </view-link> </view-entity> + + <view-entity entity-name="OrderItemBillingAndInvoiceAndItem" + package-name="org.ofbiz.order.order" + title="OrderItemBilling and Invoice and InvoiceItem View Entity"> + <member-entity entity-alias="OIB" entity-name="OrderItemBilling"/> + <member-entity entity-alias="INV" entity-name="Invoice"/> + <member-entity entity-alias="II" entity-name="InvoiceItem"/> + <alias-all entity-alias="OIB"/> + <alias entity-alias="INV" name="statusId"/> + <view-link entity-alias="OIB" rel-entity-alias="INV"> + <key-map field-name="invoiceId"/> + </view-link> + <view-link entity-alias="OIB" rel-entity-alias="II"> + <key-map field-name="invoiceId"/> + <key-map field-name="invoiceItemSeqId"/> + </view-link> + <relation type="one-nofk" rel-entity-name="Invoice"> + <key-map field-name="invoiceId"/> + </relation> + <relation type="one" rel-entity-name="InvoiceItem"> + <key-map field-name="invoiceId"/> + <key-map field-name="invoiceItemSeqId"/> + </relation> + + </view-entity> + </entitymodel> \ No newline at end of file |
Free forum by Nabble | Edit this page |