svn commit: r599516 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml script/org/ofbiz/product/inventory/InventoryServices.xml

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

svn commit: r599516 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml script/org/ofbiz/product/inventory/InventoryServices.xml

jacopoc
Author: jacopoc
Date: Thu Nov 29 08:52:30 2007
New Revision: 599516

URL: http://svn.apache.org/viewvc?rev=599516&view=rev
Log:
Extended the InventoryItemDetail entity to keep track of the unit cost history of an inventory item.

Modified:
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=599516&r1=599515&r2=599516&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Thu Nov 29 08:52:30 2007
@@ -1246,6 +1246,7 @@
       <field name="effectiveDate" type="date-time"></field>
       <field name="quantityOnHandDiff" type="floating-point"></field>
       <field name="availableToPromiseDiff" type="floating-point"></field>
+      <field name="unitCost" type="floating-point"></field>
       <field name="orderId" type="id"></field>
       <field name="orderItemSeqId" type="id"></field>
       <field name="shipGroupSeqId" type="id"></field>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=599516&r1=599515&r2=599516&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Thu Nov 29 08:52:30 2007
@@ -214,8 +214,20 @@
         </if-empty>
         <field-to-result field-name="lookedUpValue.ownerPartyId" result-name="oldOwnerPartyId"/>
         <field-to-result field-name="lookedUpValue.statusId" result-name="oldStatusId"/>
+        <!-- special handling for the unitCost -->
+        <if-compare field-name="parameters.unitCost" operator="less" value="0.0" type="Double">
+            <add-error><fail-message message="Unit cost for inventory item [${lookupPKMap.inventoryItemId}] cannot be negative."/></add-error>
+            <check-errors/>
+        </if-compare>
+        <set field-name="oldUnitCost" from-field="lookedUpValue.unitCost"/>
         <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
         <store-value value-name="lookedUpValue"/>
+        <!-- if the unit cost is changed create an InventoryItemDetail to keep track of unit cost history -->
+        <if-compare-field field-name="parameters.unitCost" operator="not-equals" to-field-name="oldUnitCost">
+            <set field="createInventoryItemDetailInMap.inventoryItemId" from-field="lookedUpValue.inventoryItemId"/>
+            <set field="createInventoryItemDetailInMap.unitCost" from-field="parameters.unitCost"/>
+            <call-service service-name="createInventoryItemDetail" in-map-name="createInventoryItemDetailInMap"/>
+        </if-compare-field>
     </simple-method>
 
     <simple-method method-name="createInventoryItemStatus" short-description="Create an inventory item status record">
@@ -265,7 +277,7 @@
             </else>
         </if-not-empty>
 
-        <!-- if availableToPromiseDiff or quantityOnHandDiff are empty set to 0 -->
+        <!-- if availableToPromiseDiff and quantityOnHandDiff are empty set to 0 -->
         <if-empty field-name="newEntity.availableToPromiseDiff"><set field="newEntity.availableToPromiseDiff" value="0" type="Double"/></if-empty>
         <if-empty field-name="newEntity.quantityOnHandDiff"><set field="newEntity.quantityOnHandDiff" value="0" type="Double"/></if-empty>
 
@@ -277,6 +289,7 @@
 
         <set field="inventoryItem.availableToPromiseTotal" from-field="inventoryItemDetailSummary.availableToPromiseTotal"/>
         <set field="inventoryItem.quantityOnHandTotal" from-field="inventoryItemDetailSummary.quantityOnHandTotal"/>
+        <set field="inventoryItem.unitCost" from-field="inventoryItemDetailSummary.unitCostTotal"/>
         <store-value value-name="inventoryItem"/>
     </simple-method>
 
@@ -420,6 +433,8 @@
         <set from-field="parameters.physicalInventoryId" field="createDetailMap.physicalInventoryId"/>
         <set from-field="parameters.availableToPromiseVar" field="createDetailMap.availableToPromiseDiff"/>
         <set from-field="parameters.quantityOnHandVar" field="createDetailMap.quantityOnHandDiff"/>
+        <set from-field="parameters.varianceReasonId" field="createDetailMap.reasonEnumId"/>
+        <set from-field="parameters.comments" field="createDetailMap.description"/>
         <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
 
         <make-value value-name="newEntity" entity-name="InventoryItemVariance"/>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r599516 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml script/org/ofbiz/product/inventory/InventoryServices.xml

Bilgin Ibryam
Jacopo,

I noticed that in this commit you added this line to updateInventoryItemFromDetail method:
<set field="inventoryItem.unitCost" from-field="inventoryItemDetailSummary.unitCostTotal"/>

i think we should add also this:

Index: applications/product/entitydef/entitymodel.xml
===================================================================
--- applications/product/entitydef/entitymodel.xml (revision 603526)
+++ applications/product/entitydef/entitymodel.xml (working copy)
@@ -1313,6 +1313,7 @@
       <alias entity-alias="IID" name="inventoryItemId" group-by="true"/>
       <alias entity-alias="IID" name="availableToPromiseTotal" field="availableToPromiseDiff" function="sum"/>
       <alias entity-alias="IID" name="quantityOnHandTotal" field="quantityOnHandDiff" function="sum"/>
+      <alias entity-alias="IID" name="unitCostTotal" field="unitCost" function="sum"/>
     </view-entity>
     <view-entity entity-name="InventoryItemDetailForSum" package-name="org.ofbiz.product.inventory"
         title="Inventory Item  And Inventory Item Detail for Summation View Entity">

 
Bilgin