} // setS_ResourceAssignment_ID /// <summary> /// Set Product - Callout /// </summary> /// <param name="oldM_Product_ID">old value</param> /// <param name="newM_Product_ID">new value</param> /// <param name="windowNo">window</param> public void SetM_Product_ID(String oldM_Product_ID, String newM_Product_ID, int windowNo) { if (newM_Product_ID == null || newM_Product_ID.Length == 0) { return; } //int M_Product_ID = Integer.parseInt(newM_Product_ID); int M_Product_ID = Util.GetValueOfInt(newM_Product_ID); base.SetM_Product_ID(M_Product_ID); if (M_Product_ID == 0) { return; } // Employee MTimeExpense hdr = new MTimeExpense(GetCtx(), GetS_TimeExpense_ID(), null); int C_BPartner_ID = hdr.GetC_BPartner_ID(); Decimal Qty = GetQty(); Boolean IsSOTrx = true; MProductPricing pp = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(), M_Product_ID, C_BPartner_ID, Qty, IsSOTrx); // int M_PriceList_ID = hdr.GetM_PriceList_ID(); pp.SetM_PriceList_ID(M_PriceList_ID); DateTime?orderDate = GetDateExpense(); pp.SetPriceDate(orderDate); // SetExpenseAmt(pp.GetPriceStd()); SetC_Currency_ID(pp.GetC_Currency_ID()); SetAmt(windowNo, "M_Product_ID"); } // setM_Product_ID
/// <summary> /// Set Product - Callout /// </summary> /// <param name="oldM_Product_ID">old value</param> /// <param name="newM_Product_ID">new value</param> /// <param name="windowNo">window</param> //@UICallout public void SetM_Product_ID(String oldM_Product_ID, String newM_Product_ID, int windowNo) { if (newM_Product_ID == null || newM_Product_ID.Length == 0) { return; } int M_Product_ID = int.Parse(newM_Product_ID); base.SetM_Product_ID(M_Product_ID); if (M_Product_ID == 0) { return; } // int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID"); if (M_PriceList_Version_ID == 0) { return; } int C_BPartner_ID = GetCtx().GetContextAsInt(windowNo, "C_BPartner_ID"); Decimal Qty = GetPlannedQty(); bool IsSOTrx = true; MProductPricing pp = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(), M_Product_ID, C_BPartner_ID, Qty, IsSOTrx); pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID); DateTime?date = GetPlannedDate(); if (date == null) { date = new DateTime(GetCtx().GetContextAsTime(windowNo, "DateContract")); } pp.SetPriceDate(date); // Decimal PriceList = pp.GetPriceList(); SetPriceList(PriceList); Decimal plannedPrice = pp.GetPriceStd(); SetPlannedPrice(plannedPrice); Decimal Discount = pp.GetDiscount(); SetDiscount(Discount); // Decimal plannedAmt = pp.GetLineAmt(GetCurPrecision()); SetPlannedAmt(plannedAmt); // //p_changeVO.setContext(GetCtx(), windowNo, "StdPrecision", pp.GetPrecision()); log.Fine("PlannedQty=" + Qty + " * PlannedPrice=" + plannedPrice + " -> PlannedAmt=" + plannedAmt); }
/** * Set Product - Callout * @param oldM_Product_ID old value * @param newM_Product_ID new value * @param windowNo window * @throws Exception */ //@UICallout public void SetM_Product_ID(String oldM_Product_ID, String newM_Product_ID, int windowNo) { try { if (newM_Product_ID == null || newM_Product_ID.Length == 0) { return; } int M_Product_ID = int.Parse(newM_Product_ID); base.SetM_Product_ID(M_Product_ID); if (M_Product_ID == 0) { SetM_AttributeSetInstance_ID(0); return; } // Set Attribute int M_AttributeSetInstance_ID = GetCtx().GetContextAsInt(Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID"); if (GetCtx().GetContextAsInt(Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID && M_AttributeSetInstance_ID != 0) { SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); } else { SetM_AttributeSetInstance_ID(0); } int C_BPartner_ID = GetC_BPartner_ID(); Decimal Qty = GetQty(); bool isSOTrx = false; MProductPricing pp = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(), M_Product_ID, C_BPartner_ID, Qty, isSOTrx); // int M_PriceList_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_ID"); pp.SetM_PriceList_ID(M_PriceList_ID); int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID"); pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID); //DateTime orderDate = new DateTime(GetCtx().GetContextAsTime(windowNo, "DateRequired")); DateTime orderDate = Convert.ToDateTime(GetCtx().GetContextAsTime(windowNo, "DateRequired")); pp.SetPriceDate(orderDate); // SetPriceActual(pp.GetPriceStd()); //p_changeVO.setContext(getContext(), windowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit()); // not used //p_changeVO.setContext(getContext(), windowNo, "DiscountSchema", pp.isDiscountSchema()); } catch { } }
/** * Set Amount (Callout) * @param windowNo window * @param columnName changed column */ private void SetAmt(int windowNo, String columnName) { try { Decimal qty = GetQty(); // Qty changed - recalc price if (columnName.Equals("Qty") && "Y".Equals(GetCtx().GetContext(windowNo, "DiscountSchema"))) { int M_Product_ID = GetM_Product_ID(); int C_BPartner_ID = GetC_BPartner_ID(); bool isSOTrx = false; MProductPricing pp = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(), M_Product_ID, C_BPartner_ID, qty, isSOTrx); // int M_PriceList_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_ID"); pp.SetM_PriceList_ID(M_PriceList_ID); int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID"); pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID); //DateTime orderDate = new DateTime(getContext().getContextAsTime(windowNo, "DateInvoiced")); DateTime orderDate = Convert.ToDateTime(GetCtx().GetContextAsTime(windowNo, "DateInvoiced")); pp.SetPriceDate(orderDate); // SetPriceActual(pp.GetPriceStd()); } int stdPrecision = GetCtx().GetStdPrecision(); Decimal priceActual = GetPriceActual(); // get values log.Fine("Qty=" + qty + ", Price=" + priceActual + ", Precision=" + stdPrecision); // Multiply Decimal lineNetAmt = Decimal.Multiply(qty, priceActual); if (Env.Scale(lineNetAmt) > stdPrecision) { lineNetAmt = Decimal.Round(lineNetAmt, stdPrecision, MidpointRounding.AwayFromZero); } SetLineNetAmt(lineNetAmt); log.Info("LineNetAmt=" + lineNetAmt); } catch { } }