When using Average Costing
-Purchase Receipt updates current cost
-Enter/Match invoice price variance only affects gl
When using FIFO
-Purchase Receipt updates current Cost (Every invoice changes the currcost, if you are unlucky and get a rounding entry in the iv00102, this large value can end up as your current cost)
-Enter/Match invoice updates current cost to invoice cost + landed cost, and affects gl
------------------------------------------------------------
CREATE VIEW [dbo].[BI_INV_LastRcvCost0]
AS
SELECT dbo.IV10200.ITEMNMBR, MAX(dbo.IV10200.ADJUNITCOST) AS LastRcvCost, LastRcvDt.LastRcvDate
FROM dbo.IV10200 INNER JOIN
(SELECT ITEMNMBR, MAX(DATERECD) AS LastRcvDate
FROM dbo.IV10200 AS IV10200_1
GROUP BY ITEMNMBR) AS LastRcvDt ON dbo.IV10200.ITEMNMBR = LastRcvDt.ITEMNMBR AND dbo.IV10200.DATERECD = LastRcvDt.LastRcvDate
GROUP BY dbo.IV10200.QTYRECVD, dbo.IV10200.ITEMNMBR, LastRcvDt.LastRcvDate
HAVING (dbo.IV10200.QTYRECVD > 1)
GO
------------------------------------------------------------
CREATE VIEW [dbo].[BI_INV_LastRcvCost]
AS
SELECT dbo.IV00101.ITEMNMBR, MAX(CASE WHEN LastRcvCost IS NULL THEN Currcost WHEN LastRcvCost = 0 THEN Currcost ELSE LastRcvCost END) AS LastRcvCost, MAX(CASE WHEN LastRcvDate IS NULL
THEN '1900-01-01' ELSE LastRcvDate END) AS LastRcvDt
FROM dbo.IV00101 LEFT OUTER JOIN
dbo.BI_INV_LastRcvCost0 ON dbo.IV00101.ITEMNMBR = dbo.BI_INV_LastRcvCost0.ITEMNMBR
GROUP BY dbo.IV00101.ITEMNMBR
GO
---------------------------------------------------------------
No comments:
Post a Comment