summary |
shortlog |
changelog |
graph |
tags |
bookmarks |
branches |
files |
changeset |
raw |
help

author | Rafa Roda Palacios <rafa.roda@ubiquads.com> |

Thu, 14 Aug 2014 14:22:55 +0200 | |

changeset 24264 | f042a64ea3c7 |

parent 24263 | 5ca94c9c9989 |

child 24265 | 0ddec04e8ce3 |

Fixes issue 26844 Modified MA_PRODUCTION_COST to select the correct costing method in production

src-db/database/model/functions/MA_PRODUCTION_COST.xml | file | annotate | diff | comparison | revisions |

--- a/src-db/database/model/functions/MA_PRODUCTION_COST.xml Thu Aug 14 14:22:11 2014 +0200 +++ b/src-db/database/model/functions/MA_PRODUCTION_COST.xml Thu Aug 14 14:22:55 2014 +0200 @@ -199,8 +199,8 @@ AND ppl.PRODUCTIONTYPE = '-' AND ppl.M_PRODUCTIONPLAN_ID = Cur_ProductionPlan.M_PRODUCTIONPLAN_ID AND c.ISPRODUCTION='Y' - AND ((c.COSTTYPE = 'AVA' AND v_iscostmigrated = 'Y') - OR (c.COSTTYPE = 'AV' AND v_iscostmigrated = 'N'))) LOOP + AND ((c.COSTTYPE = (CASE WHEN (SELECT COUNT(1) FROM M_PRODUCT WHERE M_PRODUCT_ID = ppl.M_PRODUCT_ID AND PRODUCTTYPE = 'I' AND ISSTOCKED = 'Y') > 0 THEN 'AVA' ELSE 'STA' END) AND v_iscostmigrated = 'Y') + OR (c.COSTTYPE IN ('AV','ST') AND v_iscostmigrated = 'N'))) LOOP v_ProductionCost_Tmp := v_ProductionCost_Tmp + COALESCE(Cur_WIP.cost,0); UPDATE M_PRODUCTIONLINE SET calccost = COALESCE(Cur_WIP.cost, 0) @@ -218,8 +218,8 @@ AND ppl.PRODUCTIONTYPE = '-' AND ppl.M_PRODUCTIONPLAN_ID = Cur_ProductionPlan.M_PRODUCTIONPLAN_ID AND c.ISPRODUCTION='N' - AND ((c.COSTTYPE = 'AVA' AND v_iscostmigrated = 'Y') - OR (c.COSTTYPE = 'AV' AND v_iscostmigrated = 'N')) + AND ((c.COSTTYPE = (CASE WHEN (SELECT COUNT(1) FROM M_PRODUCT WHERE M_PRODUCT_ID = ppl.M_PRODUCT_ID AND PRODUCTTYPE = 'I' AND ISSTOCKED = 'Y') > 0 THEN 'AVA' ELSE 'STA' END) AND v_iscostmigrated = 'Y') + OR (c.COSTTYPE IN ('AV','ST') AND v_iscostmigrated = 'N')) AND NOT EXISTS (SELECT 1 FROM M_COSTING, M_PRODUCTIONLINE WHERE M_COSTING.M_PRODUCT_ID = M_PRODUCTIONLINE.M_PRODUCT_ID @@ -228,8 +228,8 @@ AND M_PRODUCTIONLINE.PRODUCTIONTYPE = '-' AND M_PRODUCTIONLINE.M_PRODUCT_ID = c.M_Product_ID AND M_COSTING.ISPRODUCTION='Y' - AND ((M_COSTING.COSTTYPE = 'AVA' AND v_iscostmigrated = 'Y') - OR (M_COSTING.COSTTYPE = 'AV' AND v_iscostmigrated = 'N')))) LOOP + AND ((M_COSTING.COSTTYPE = (CASE WHEN (SELECT COUNT(1) FROM M_PRODUCT WHERE M_PRODUCT_ID = ppl.M_PRODUCT_ID AND PRODUCTTYPE = 'I' AND ISSTOCKED = 'Y') > 0 THEN 'AVA' ELSE 'STA' END) AND v_iscostmigrated = 'Y') + OR (M_COSTING.COSTTYPE IN ('AV','ST') AND v_iscostmigrated = 'N')))) LOOP v_ProductionCost_Tmp := v_ProductionCost_Tmp + COALESCE(Cur_RawMaterial.cost,0); UPDATE M_PRODUCTIONLINE SET calccost = COALESCE(Cur_RawMaterial.cost, 0)