Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Closing Stock Value
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Miscellaneous
Thread ID:
01471551
Message ID:
01471644
Views:
27
>>>>>A SELECT statement doing this is interesting. Just curious what would happen if the closing stock consists of 2 purchases, ie. purchase of 10 @ 12.50 and another purchase of 10 @ 13.00. Out of which only 5 are sold @ whatever rate. Now the closing stock is 15 out of which 5 is @ 12.50 and 10 is @ 13.00.
>>>>>
>>>>
>>>>I asked Tariq to clarify the requirements. He wanted to use the latest rate for the closing stock value. This is what my query is doing. How you'll find out which items were sold otherwise?
>>>>
>>>>In other words, using latest rate is the simplest calculation, although I'm not sure how this problem should be solved in accounting. May be someone who deals with lots of similar problems can show the exact formula to use.
>>>
>>>Yes, Naomi, what I mentioned above, with my experience in accounting and inventory, is what my requirement would be, that would First-In-First-Out (FIFO) method of stock valuation. Of course there is Avg. and Last-In-First-Out (LIFO) methods too.
>>
>>I see, this sounds like a right approach to me. But then I think we need a procedural code - kind of hard write it as a select statement.
>>
>>May be you can post some code you have that deals with this problem.
>
>I was attracted by the SELECT statement approach. I have done this in prg. by simply finding out the closing stock and then going backward (descending sort) of purchase bills for the item for rates.
>
>simplified pseudo code, from the top of my head
>
>
>m.clostock = 15
>m.valuation = 0
>
>select prchbillitems
>set order to descending_item
>
>scan for prchbillitems.iitemid = m.myitemid
>   if m.clostock >= prchbillitems.qty
>      m.valuation = m.valuation + (prchbillitems.qty * prchbillitems.rate)
>      m.clostock = m.clostock - prchbillitems.qty
>   else
>      m.valuation = m.valuation + (m.clostock * prchbillitems.rate)
>      m.clostock = 0
>      exit
>   endif
>endscan
>
Thanks, may be Tariq needs a similar algorithm. I think we also are using similar approach, but not sure where exactly. I know my colleague mentioned FIFO term and I think he intended to assign me this, but don't know what happened with that "project".
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform