Need to modfy createInventoryItemVariance

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

Need to modfy createInventoryItemVariance

joelfradkin@gmail.com
Currently createInventoryItemVariance is in minilang and deals with individual rows for each inventory item.
I modified my physical inventory screen to only have one row per product.
I get a product id and a variance amount.
I need to come up with a routine I hit so it removes the oldest items first.
If adding inventory back I am guessing I need to cap at the items original qty and then move to the next item (or maybe just go over the orignal qty?).
In any case I need to ensure I adjust the oldest with QTY, and then get the next if available.
I can see some examples where iterate is used, but I will need to keep a running total of the variance and find the by date and move to the next one, or if it no longer has qty move to the next available or over adjust if no new records to get.
Any advice on how to code and if its ok to overload the qty, or if its better to create a new item to adjust? just not sure I guess I could use the last price etc.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: Need to modfy createInventoryItemVariance

Pierre Smits
Joel,

If you feel that an improvement issue is warranted, feel free to create and
motivate it in JIRA.

Regards,

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com

On Tue, Oct 21, 2014 at 4:32 PM, [hidden email] <
[hidden email]> wrote:

> Currently createInventoryItemVariance is in minilang and deals with
> individual rows for each inventory item.
> I modified my physical inventory screen to only have one row per product.
> I get a product id and a variance amount.
> I need to come up with a routine I hit so it removes the oldest items
> first.
> If adding inventory back I am guessing I need to cap at the items original
> qty and then move to the next item (or maybe just go over the orignal
> qty?).
> In any case I need to ensure I adjust the oldest with QTY, and then get the
> next if available.
> I can see some examples where iterate is used, but I will need to keep a
> running total of the variance and find the by date and move to the next
> one,
> or if it no longer has qty move to the next available or over adjust if no
> new records to get.
> Any advice on how to code and if its ok to overload the qty, or if its
> better to create a new item to adjust? just not sure I guess I could use
> the
> last price etc.
>
>
>
> -----
> Joel Fradkin
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/Need-to-modfy-createInventoryItemVariance-tp4657198.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Need to modfy createInventoryItemVariance

joelfradkin@gmail.com
Not sure that is open for discussion.

I was asking for specific minilang help, but I am working on it, so hopefully i can get it. I am more happy in java or groovy, but I think it can be done. If I can figure it out, I can always try to move it, but not comfortable doing it unless I come up short.

So as far as if I should do a jirra in regards to the physical inventory adjustment in facility?
My opinion showing item details is pretty clear and doing adjustment (possibly multiple lines for the same product) is not hard. My users felt it was not user friendly and want one line per product showing the total, so they can use this screen for physical inventory. Perhaps it would be better to add a physical inventory screen with just one line (like what I am doing)? I was also asked if I could not add a location and order. For say some one taking inventory in a bar where the bottles are always in the same order. It gets a bit more complex. For example If they have the same product in the freezer and in the kitchen. It might need to take inventory counts in multiple locations (same facility) and do the adjustment on the total. I am sure all these ideas have been discussed. I think OFBiz gives the such great tools to start with. Making the adjustment for using a differnt stocking qty and supplier quantity was pretty easy. I did  find out I missed an important aspect as accounting is not getting good numbers. My point is I am not sure this is jirra worthy, its kinda up to the implementation. Maybe lots of folks feel like having multiple stocking locations and a physical inventory modification screen that is easy to use is important? If so let me know and I will try to come up with a specification (leaving the current screen as is as it is great for just modification of a specific inventory item), but detailing what might be good to add for doing physical inventory.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: Need to modfy createInventoryItemVariance

joelfradkin@gmail.com
joelfradkin@gmail.com wrote
Not sure that is open for discussion.
Sorry I meant to say Not sure; that is open for discussion.
Joel Fradkin
Reply | Threaded
Open this post in threaded view
|

Re: Need to modfy createInventoryItemVariance

joelfradkin@gmail.com
In reply to this post by joelfradkin@gmail.com
If any one is interested, I finished and it works, removing the oldest inventory first.

    <simple-method method-name="createPhysicalInventoryAndVariance" short-description="Create a PhysicalInventory and an InventoryItemVariance">
   
        <entity-condition entity-name="InventoryItem" list="inventoryItemList">
            <condition-list combine="or">
                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/>
                <condition-expr field-name="quantityOnHandTotal" operator="not-equals" value="0"/>
            </condition-list>
                  <order-by field-name="datetimeReceived"/>
        </entity-condition>
        <set field="MyVariance" from-field="parameters.quantityOnHandVar" type="BigDecimal"/>
        <set field="MyCompareValue" value="1" type="BigDecimal"/>
        <iterate list="inventoryItemList" entry="inventoryItem">
           <set field="parameters.inventoryItemId" from-field="inventoryItem.inventoryItemId"/>
           <if-not-empty field="parameters.quantityOnHandVar">                             
           <if-compare field="parameters.quantityOnHandVar" operator="not-equals" value="0">
              <if-compare field="parameters.quantityOnHandVar" operator="greater" value="0">
                 
                 <set from-field="parameters.quantityOnHandVar" field="parameters.availableToPromiseVar"/>
                 <set-service-fields service-name="createPhysicalInventory" map="parameters" to-map="createPhysicalInventoryMap"/>
                 <call-service service-name="createPhysicalInventory" in-map-name="createPhysicalInventoryMap">
                    <result-to-field result-name="physicalInventoryId" field="parameters.physicalInventoryId"/>
                    <result-to-result result-name="physicalInventoryId" service-result-name="physicalInventoryId"/>
                 </call-service>
                 <set-service-fields service-name="createInventoryItemVariance" map="parameters" to-map="createInventoryItemVarianceMap"/>
                 <call-service service-name="createInventoryItemVariance" in-map-name="createInventoryItemVarianceMap"/>
                 <set field="parameters.quantityOnHandVar" value="0" type="BigDecimal"/>
              </if-compare> 
              <if-compare field="parameters.quantityOnHandVar" operator="less" value="0"> 
                 <set field="MyCompareValue" from-field = "${inventoryItem.quantityOnHandTotal + parameters.quantityOnHandVar}" type="BigDecimal" default-value="0"/>
                 <if-compare field="MyCompareValue" operator="greater-equals" value="0"  type="BigDecimal">
                   
                    <set from-field="parameters.quantityOnHandVar" field="parameters.availableToPromiseVar"/>
                    <set-service-fields service-name="createPhysicalInventory" map="parameters" to-map="createPhysicalInventoryMap"/>
                    <call-service service-name="createPhysicalInventory" in-map-name="createPhysicalInventoryMap">
                       <result-to-field result-name="physicalInventoryId" field="parameters.physicalInventoryId"/>
                       <result-to-result result-name="physicalInventoryId" service-result-name="physicalInventoryId"/>
                    </call-service>
                    <set-service-fields service-name="createInventoryItemVariance" map="parameters" to-map="createInventoryItemVarianceMap"/>
                    <call-service service-name="createInventoryItemVariance" in-map-name="createInventoryItemVarianceMap"/>
                    <set field="parameters.quantityOnHandVar" value="0" type="BigDecimal"/>
                 </if-compare>
                 <if-compare field="parameters.quantityOnHandVar" operator="not-equals" value="0">
                 
                    <if-compare field="inventoryItem.quantityOnHandTotal" operator="greater" value="0">
                       <set field="MyVariance" from-field="inventoryItem.quantityOnHandTotal" type="BigDecimal"/>   
                       <set field="MyVariance" value="${MyVariance * -1}"/>
                       <set field="parameters.quantityOnHandVar" value="${MyVariance}" type="BigDecimal"/>
                       <set from-field="parameters.quantityOnHandVar" field="parameters.availableToPromiseVar"/>
                       <set-service-fields service-name="createPhysicalInventory" map="parameters" to-map="createPhysicalInventoryMap"/>
                       <call-service service-name="createPhysicalInventory" in-map-name="createPhysicalInventoryMap">
                          <result-to-field result-name="physicalInventoryId" field="parameters.physicalInventoryId"/>
                          <result-to-result result-name="physicalInventoryId" service-result-name="physicalInventoryId"/>
                       </call-service>
                       <set-service-fields service-name="createInventoryItemVariance" map="parameters" to-map="createInventoryItemVarianceMap"/>
                       <call-service service-name="createInventoryItemVariance" in-map-name="createInventoryItemVarianceMap"/>
                       <set field="parameters.quantityOnHandVar" from-field="MyCompareValue"/>
                    </if-compare>
                 </if-compare>
              </if-compare>
           </if-compare>
           </if-not-empty>
        </iterate>
       
        <set from-field="parameters.quantityOnHandVar" field="parameters.availableToPromiseVar"/>
        <set-service-fields service-name="createPhysicalInventory" map="parameters" to-map="createPhysicalInventoryMap"/>
        <call-service service-name="createPhysicalInventory" in-map-name="createPhysicalInventoryMap">
           <result-to-field result-name="physicalInventoryId" field="parameters.physicalInventoryId"/>
           <result-to-result result-name="physicalInventoryId" service-result-name="physicalInventoryId"/>
        </call-service>
        <set-service-fields service-name="createInventoryItemVariance" map="parameters" to-map="createInventoryItemVarianceMap"/>
        <call-service service-name="createInventoryItemVariance" in-map-name="createInventoryItemVarianceMap"/>
    </simple-method>
Joel Fradkin