Author: bibryam
Date: Wed May 21 01:08:03 2008 New Revision: 658585 URL: http://svn.apache.org/viewvc?rev=658585&view=rev Log: Applied the patch from JIRA Issue # OFBIZ-1798 "Service for Canceling ItemIssuance". Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml ofbiz/trunk/applications/product/servicedef/services_shipment.xml Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Wed May 21 01:08:03 2008 @@ -1334,6 +1334,64 @@ <field-to-result field-name="acctgTransId" result-name="acctgTransId"/> </simple-method> + <simple-method method-name="createAcctgTransForCanceledSalesShipmentIssuance" short-description="Create an accounting transactions for a canceled sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT"> + <!-- retrieve ledger rounding properties --> + <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/> + <property-to-field resource="arithmetic" property="ledger.rounding" field-name="roundingMode"/> + <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${roundingMode}]"/> + + <entity-one entity-name="ItemIssuance" value-name="itemIssuance"/> + <get-related-one value-name="itemIssuance" relation-name="InventoryItem" to-value-name="inventoryItem"/> + <entity-and entity-name="OrderRole" list-name="billToCustomers"> + <field-map field-name="orderId" env-name="itemIssuance.orderId"/> + <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/> + </entity-and> + <first-from-list list-name="billToCustomers" entry-name="billToCustomer"/> + <!-- TODO: handle serialized inventory --> + <calculate field-name="origAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}"> + <calcop operator="multiply"> + <calcop operator="get" field-name="parameters.canceledQuantity"/> + <calcop operator="get" field-name="inventoryItem.unitCost"/> + </calcop> + </calculate> + <!-- prepare the doble posting (D/C) entries (AcctgTransEntry) --> + <!-- Credit --> + <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/> + <set field="creditEntry.debitCreditFlag" value="C"/> + <set field="creditEntry.glAccountTypeId" value="COGS_ACCOUNT"/> + <set field="creditEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/> + <set field="creditEntry.productId" from-field="inventoryItem.productId"/> + <set field="creditEntry.origAmount" from-field="origAmount"/> + <set field="creditEntry.origCurrencyUomId" from-field="inventoryItem.currencyUomId"/> + <if-not-empty field-name="billToCustomer"> + <set field="creditEntry.partyId" from-field="billToCustomer.partyId"/> + <set field="creditEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/> + </if-not-empty> + <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/> + <!-- Debit --> + <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/> + <set field="debitEntry.debitCreditFlag" value="D"/> + <set field="debitEntry.glAccountTypeId" value="INVENTORY_ACCOUNT"/> + <set field="debitEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/> + <set field="debitEntry.productId" from-field="inventoryItem.productId"/> + <set field="debitEntry.origAmount" from-field="origAmount"/> + <set field="debitEntry.origCurrencyUomId" from-field="inventoryItem.currencyUomId"/> + <if-not-empty field-name="billToCustomer"> + <set field="debitEntry.partyId" from-field="billToCustomer.partyId"/> + <set field="debitEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/> + </if-not-empty> + <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/> + <!-- Set header fields (AcctgTrans) --> + <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/> + <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="SALES_SHIPMENT"/> + <set field="createAcctgTransAndEntriesInMap.shipmentId" from-field="itemIssuance.shipmentId"/> + <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" from-field="acctgTransEntries"/> + <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesInMap"> + <result-to-field result-name="acctgTransId"/> + </call-service> + <field-to-result field-name="acctgTransId" result-name="acctgTransId"/> + </simple-method> + <simple-method method-name="createAcctgTransForShipmentReceipt" short-description="Create an accounting transactions for a shipment receipt (D: INVENTORY_ACCOUNT, C: UNINVOICED_SHIP_RCPT or COGS_ACCOUNT for returns)"> <!-- retrieve ledger rounding properties --> <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/> Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Wed May 21 01:08:03 2008 @@ -33,6 +33,12 @@ <condition field-name="inventoryItemId" operator="is-not-empty"/> <action service="createAcctgTransForSalesShipmentIssuance" mode="sync"/> </eca> + + <!-- create an accounting transactions every time an issuance to sales shipment is canceled --> + <eca service="cancelOrderItemIssuanceFromSalesShipment" event="commit"> + <condition field-name="canceledQuantity" operator="greater" value="0" type="Double"/> + <action service="createAcctgTransForCanceledSalesShipmentIssuance" mode="sync"/> + </eca> <!-- create the accounting transactions for a shipment receipt every time the inventory is received --> <eca service="createShipmentReceipt" event="commit"> Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Wed May 21 01:08:03 2008 @@ -355,10 +355,17 @@ Typically, these services are triggered by SECAs --> <service name="createAcctgTransForSalesShipmentIssuance" engine="simple" auth="true" location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForSalesShipmentIssuance"> - <description>Create an accounting transaction for for a sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)</description> + <description>Create an accounting transaction for a sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)</description> <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/> <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/> </service> + <service name="createAcctgTransForCanceledSalesShipmentIssuance" engine="simple" auth="true" + location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForCanceledSalesShipmentIssuance"> + <description>Create an accounting transaction for a canceled sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)</description> + <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/> + <attribute name="canceledQuantity" type="Double" mode="IN" optional="false"/> + <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/> + </service> <service name="createAcctgTransForInventoryItemCostChange" engine="simple" auth="true" location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForInventoryItemCostChange"> <description>Create accounting transaction when item cost is changed (D: INV_ADJ_VAL, C: INVENTORY_ACCOUNT)</description> Modified: ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml (original) +++ ofbiz/trunk/applications/product/entitydef/entitymodel_shipment.xml Wed May 21 01:08:03 2008 @@ -58,6 +58,7 @@ <field name="issuedDateTime" type="date-time"></field> <field name="issuedByUserLoginId" type="id-vlong"></field> <field name="quantity" type="floating-point"></field> + <field name="cancelQuantity" type="floating-point"></field> <prim-key field="itemIssuanceId"/> <relation type="one" fk-name="ITEM_ISS_INVITM" rel-entity-name="InventoryItem"> <key-map field-name="inventoryItemId"/> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml Wed May 21 01:08:03 2008 @@ -435,4 +435,91 @@ <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/> </simple-method> + <simple-method method-name="cancelOrderItemIssuanceFromSalesShipment" short-description="Cancel an ItemIssuance quantity from Sales Shipment"> + <set value="Cancel Order Item Issuance from Sales Shipment" field="operationName"/> + <check-permission permission="FACILITY" action="_UPDATE"> + <fail-message message="Security Error: to run ${operationName} you must have the FACILITY_UPDATE or FACILITY_ADMIN permission"/> + </check-permission> + + <!-- get ItemIssuance and related entities--> + <entity-one entity-name="ItemIssuance" value-name="itemIssuance"/> + <get-related-one value-name="itemIssuance" relation-name="OrderHeader" to-value-name="orderHeader"/> + <get-related-one value-name="itemIssuance" relation-name="InventoryItem" to-value-name="inventoryItem"/> + + <!-- issuance can be canceled only if the sales shipment is not packed --> + <set from-field="itemIssuance.shipmentId" field="shipmentId"/> + <call-simple-method method-name="checkCanChangeShipmentStatusPacked" xml-resource="org/ofbiz/shipment/shipment/ShipmentServices.xml"/> + <check-errors/> + + <!-- make sure the order is of orderTypeId: SALES_ORDER --> + <if-compare field-name="orderTypeId" map-name="orderHeader" operator="not-equals" value="SALES_ORDER"> + <add-error><fail-message message="Not canceling ItemIssuance because the order is not a Sales Order"/></add-error> + </if-compare> + + <!-- get the quantity that can be cancelled ItemIssuance --> + <calculate field-name="qtyIssuedLeft"> + <calcop field-name="itemIssuance.quantity" operator="subtract"> + <calcop operator="get" field-name="itemIssuance.cancelQuantity"/> + </calcop> + </calculate> + + <!-- if not provided, get the left issued quantity --> + <set from-field="parameters.cancelQuantity" field="toCancelQuantity"/> + <if-empty field-name="toCancelQuantity"> + <set from-field="qtyIssuedLeft" field="toCancelQuantity"/> + </if-empty> + + <!-- make sure specified cancel Quantity is not less than or equal to 0 --> + <if-compare field-name="toCancelQuantity" operator="less-equals" value="0" type="Double"> + <add-error><fail-message message="Not cancelling ItemIssuance [${parameters.itemIssuanceId}] because the quantity to cancel [${toCancelQuantity}] is less than or equal to 0 "/></add-error> + </if-compare> + + <!-- make sure specified quantity is not greater than issued quantity left --> + <if-compare-field field-name="toCancelQuantity" operator="greater" to-field-name="qtyIssuedLeft" type="Double"> + <add-error><fail-message message="Not cancelling ItemIssuanc because the quantity to cancel [${toCancelQuantity}] is greater than the quantity left [${qtyIssuedLeft}] for ItemIssuance [${itemIssuanceId}]"/></add-error> + </if-compare-field> + <check-errors/> + + <!-- update ItemIssuance --> + <calculate field-name="totalCancelQty"> + <calcop operator="add" field-name="itemIssuance.cancelQuantity"/> + <calcop operator="add" field-name="toCancelQuantity"/> + </calculate> + <set from-field="totalCancelQty" field="itemIssuanceUpdate.cancelQuantity"/> + <set from-field="parameters.itemIssuanceId" field="itemIssuanceUpdate.itemIssuanceId"/> + <call-service service-name="updateItemIssuance" in-map-name="itemIssuanceUpdate"/> + + <!-- increment InventoryItem quantityOnHand AND availableToPromise --> + <!-- instead of updating InventoryItem, add an InventoryItemDetail --> + <set from-field="itemIssuance.inventoryItemId" field="createDetailMap.inventoryItemId"/> + <set from-field="itemIssuance.itemIssuanceId" field="createDetailMap.itemIssuanceId"/> + <set from-field="toCancelQuantity" field="createDetailMap.availableToPromiseDiff"/> + <set from-field="toCancelQuantity" field="createDetailMap.quantityOnHandDiff"/> + <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/> + + <!-- reassign inventory reservations --> + <set field="reassignInventoryReservationsCtx.productId" from-field="inventoryItem.productId"/> + <set field="reassignInventoryReservationsCtx.facilityId" from-field="inventoryItem.facilityId"/> + <call-service service-name="reassignInventoryReservations" in-map-name="reassignInventoryReservationsCtx"/> + + <!-- reserve the order item --> + <entity-one entity-name="ProductStore" value-name="productStore" auto-field-map="false"> + <field-map field-name="productStoreId" env-name="orderHeader.productStoreId"/> + </entity-one> + <if-compare value="Y" operator="equals" field-name="productStore.isImmediatelyFulfilled"> + <log level="verbose" message="ProductStore with id ${productStore.productStoreId}, is immediatly fulfilled. Not reseving inventory"/> + <else> + <set field="reserveStoreInventoryMap.productId" from-field="inventoryItem.productId"/> + <set field="reserveStoreInventoryMap.orderId" from-field="itemIssuance.orderId"/> + <set field="reserveStoreInventoryMap.orderItemSeqId" from-field="itemIssuance.orderItemSeqId"/> + <set field="reserveStoreInventoryMap.shipGroupSeqId" from-field="itemIssuance.shipGroupSeqId"/> + <set field="reserveStoreInventoryMap.quantity" from-field="toCancelQuantity"/> + <set field="reserveStoreInventoryMap.productStoreId" from-field="orderHeader.productStoreId"/> + <call-service service-name="reserveStoreInventory" in-map-name="reserveStoreInventoryMap"/> + </else> + </if-compare> + + <field-to-result field-name="toCancelQuantity" result-name="canceledQuantity"/> + </simple-method> + </simple-methods> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=658585&r1=658584&r2=658585&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Wed May 21 01:08:03 2008 @@ -395,6 +395,13 @@ <description>Return InventoryItem Issued to a FixedAssetMaint - for conversion to use as supples/parts</description> <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/> </service> + <service name="cancelOrderItemIssuanceFromSalesShipment" engine="simple" + location="org/ofbiz/shipment/issuance/IssuanceServices.xml" invoke="cancelOrderItemIssuanceFromSalesShipment" auth="true"> + <description>Cancel an ItemIssuance from Sales Shipment</description> + <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/> + <attribute name="cancelQuantity" type="Double" mode="IN" optional="true"/> + <attribute name="canceledQuantity" type="Double" mode="OUT" optional="false"/> + </service> <!-- Pack Order Services --> <service name="packSingleItem" engine="java" |
Free forum by Nabble | Edit this page |