Hi all,
I want to customize the inventory Valuation report (1001) to have one more field "Unit Cost". This unit cost should be take the rate from the last purchase invoice of that item within that month. For eg. if I will give date filter as 01-Apr-2010..30-Apr-2010 then it it should give me the rate from the given date and not the recent rate.
So I have written the below mentioned code to fetch the last rate but how and where i should write the date filter to get the rate from the entered date filter.
StartDate->Date // value is comming from date filter
EndDate->Date // value is comming from date filter
rate ->Decimal
PurchInvLine.RESET;
PurchInvLine.SETRANGE("No.","Value Entry"."Item No.");
//PurchInvLine.SETRANGE("Posting Date",Startdate,EndDate);
PurchInvLine.SETFILTER(Quantity,'>0');
IF PurchInvLine.FINDLAST THEN
Rate := PurchInvLine."Unit Cost";
This filter is not working
PurchInvLine.SETRANGE("Posting Date",Startdate,EndDate);
can anybody tell me where to put the date filter
Comments
http://ssdynamics.co.in
I have commented that line because there was no effect of that line. I am getting the same result with or without that line of code.
Do you know what does means of this line?
As far as I know, it will set a filter for the given date range. And it will show Rate from those transactions only between the date range.
In my requirement if there is no transaction for a particular item between that range then it should take the rate from its previous month's transaction.
Then you should use '0D' insteat of StartDate.
Why Can't you use Last Direct Cost on the Item card?
http://ssdynamics.co.in
what will happen, if i want to see the report of past date (say 1 year or 2 year back), it will always show me the current Unit Cost...
Here's the code I used
P.S. The key can be further optimized.
http://ssdynamics.co.in
hi thanx for the reply but in your code why you have written why r u multiplying the Quantity with Quantity (Base)
Also, if there is no transaction for an item in the given month then it will show the rate as 0 but i want to find the Rate for that item as well from the previous transactions available.
for eg. if there is no transaction for item say "item 1" between 01-04-2010 and 30-04-2010 then the report should search of the rate between 01-03-2010 and 30-03-2010 if not found then again it should go search between 01-02-2010 and 30-02-2010 and so on.
so, should i put the same filter in else part by subtracting Startdate and EndDate by one month but if there is no record then how will it go to the previous month again.
kindly suggest.
and this code has been written to achieve "Direct Unit Cost" based on "base unit of measure"
thanx a lot..
But still I am confused how PurchInvLine.Quantity*PurchInvLine."Quantity (base) will work because both these fields contain the same value.
for eg.. If value of QTY is 10, it will become 100 before dividing with "Direct Unit Cost"...
let's see
base UOM = KG
UOM = QTL
if you select QTL in unit of measure in line then your Quantity is 1 in line and base Quantity will be 100.
in your case both comes same cause of you have selected base unit of measure in line.
hope now it's clear....!