/// <summary> /// Set Price List Precision. /// </summary> private void SetPrecision() { if (_M_PriceList_ID != 0) { _precision = MPriceList.GetPricePrecision(Env.GetContext(), GetM_PriceList_ID()); } }
/// <summary> /// Get Parent PriceList /// </summary> /// <returns>v</returns> public MPriceList GetPriceList() { if (_pl == null && GetM_PriceList_ID() != 0) { _pl = MPriceList.Get(GetCtx(), GetM_PriceList_ID(), null); } return(_pl); }
/** * Before Save * @param newRecord new * @return true */ protected override bool BeforeSave(bool newRecord) { if (GetAD_User_ID() == -1) // Summary Project in Dimensions { SetAD_User_ID(0); } // Set Currency if (Is_ValueChanged("M_PriceList_Version_ID") && GetM_PriceList_Version_ID() != 0) { MPriceList pl = MPriceList.Get(GetCtx(), GetM_PriceList_ID(), null); if (pl != null && pl.Get_ID() != 0) { SetC_Currency_ID(pl.GetC_Currency_ID()); } } return(true); }
/// <summary> /// Get Price List (cached) /// </summary> /// <param name="ctx">context</param> /// <param name="M_PriceList_ID">id</param> /// <param name="trxName">transaction</param> /// <returns>PriceList</returns> public static MPriceList Get(Ctx ctx, int M_PriceList_ID, Trx trxName) { int key = M_PriceList_ID; MPriceList retValue = (MPriceList)_cache[key]; try { if (retValue == null) { retValue = new MPriceList(ctx, M_PriceList_ID, trxName); _cache.Add(key, retValue); } } catch { } return(retValue); }
/** * Set default PriceList */ public void SetM_PriceList_ID() { try { MPriceList defaultPL = MPriceList.GetDefault(GetCtx(), false); if (defaultPL == null) { defaultPL = MPriceList.GetDefault(GetCtx(), true); } if (defaultPL != null) { SetM_PriceList_ID(defaultPL.GetM_PriceList_ID()); } } catch (Exception ex) { // MessageBox.Show("MRequisition--SetM_PriceList_ID"); log.Severe(ex.ToString()); } }
} // getDoc_User_ID /// <summary> /// Get Document Currency /// </summary> /// <returns>C_Currency_ID</returns> public int GetC_Currency_ID() { MPriceList pl = MPriceList.Get(GetCtx(), GetM_PriceList_ID(), Get_TrxName()); return(pl.GetC_Currency_ID()); } // getC_Currency_ID
/// <summary> /// Get Default Price List for Client (cached) /// </summary> /// <param name="ctx">context</param> /// <param name="IsSOPriceList">SO or PO</param> /// <returns>PriceList or null</returns> public static MPriceList GetDefault(Ctx ctx, bool IsSOPriceList) { int AD_Client_ID = ctx.GetAD_Client_ID(); MPriceList retValue = null; // Search for it in cache //Iterator<MPriceList> it = _cache.values().iterator(); IEnumerator <MPriceList> it = _cache.Values.GetEnumerator(); while (it.MoveNext()) { retValue = (MPriceList)it.Current; if (retValue.IsDefault() && retValue.GetAD_Client_ID() == AD_Client_ID) { return(retValue); } } //Get from DB retValue = null; StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM M_PriceList " + "WHERE AD_Client_ID=" + AD_Client_ID + " AND IsDefault='Y'"); if (IsSOPriceList) { //pstmt.setString(2, "Y"); sql.Append(" AND IsSOPriceList='Y'"); // YS: Changed from hard code to Parameter } else { //pstmt.setString(2, "N"); sql.Append(" AND IsSOPriceList='N'"); // YS: Changed from hard code to Parameter } sql.Append("ORDER BY M_PriceList_ID"); //String sql = "SELECT * FROM M_PriceList " // + "WHERE AD_Client_ID=" + AD_Client_ID // + " AND IsDefault='Y'" // + " AND IsSOPriceList=?" // YS: Changed from hard code to Parameter // + "ORDER BY M_PriceList_ID"; DataSet ds = null; try { ds = ExecuteQuery.ExecuteDataset(sql.ToString(), null); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; retValue = new MPriceList(ctx, dr, null); } } catch (Exception e) { ds = null; _log.Log(Level.SEVERE, sql.ToString(), e); } // Return value if (retValue != null) { int key = retValue.GetM_PriceList_ID(); _cache.Add(key, retValue); } return(retValue); }
/// <summary> /// Get Price List Precision /// </summary> /// <param name="ctx">context </param> /// <param name="M_PriceList_ID">price list</param> /// <returns>precision</returns> public static int GetPricePrecision(Ctx ctx, int M_PriceList_ID) { MPriceList pl = MPriceList.Get(ctx, M_PriceList_ID, null); return(pl.GetPricePrecision()); }
/** * Prepare Document * @return new status (In Progress or Invalid) */ public String PrepareIt() { try { log.Info(ToString()); _processMsg = ModelValidationEngine.Get().FireDocValidate(this, ModalValidatorVariables.DOCTIMING_BEFORE_PREPARE); if (_processMsg != null) { return(DocActionVariables.STATUS_INVALID); } MRequisitionLine[] lines = GetLines(); // Invalid if (GetAD_User_ID() == 0 || GetM_PriceList_ID() == 0 || GetM_Warehouse_ID() == 0 || lines.Length == 0) { return(DocActionVariables.STATUS_INVALID); } // Std Period open? if (!MPeriod.IsOpen(GetCtx(), GetDateDoc(), MDocBaseType.DOCBASETYPE_PURCHASEREQUISITION)) { _processMsg = "@PeriodClosed@"; return(DocActionVariables.STATUS_INVALID); } // is Non Business Day? if (MNonBusinessDay.IsNonBusinessDay(GetCtx(), GetDateDoc())) { _processMsg = Common.Common.NONBUSINESSDAY; return(DocActionVariables.STATUS_INVALID); } // Add up Amounts int precision = MPriceList.GetStandardPrecision(GetCtx(), GetM_PriceList_ID()); Decimal totalLines = Env.ZERO; for (int i = 0; i < lines.Length; i++) { MRequisitionLine line = lines[i]; Decimal lineNet = Decimal.Multiply(line.GetQty(), line.GetPriceActual()); lineNet = Decimal.Round(lineNet, precision);//, MidpointRounding.AwayFromZero); if (lineNet.CompareTo(line.GetLineNetAmt()) != 0) { line.SetLineNetAmt(lineNet); line.Save(); } totalLines = Decimal.Add(totalLines, line.GetLineNetAmt()); } if (totalLines.CompareTo(GetTotalLines()) != 0) { SetTotalLines(totalLines); Save(); } _justPrepared = true; } catch (Exception ex) { // MessageBox.Show("MRequisition--PrepareIt"); log.Severe(ex.ToString()); } return(DocActionVariables.STATUS_INPROGRESS); }
/// <summary> /// Parent Constructor /// </summary> /// <param name="pl">parent</param> public MPriceListVersion(MPriceList pl) : this(pl.GetCtx(), 0, pl.Get_TrxName()) { SetClientOrg(pl); SetM_PriceList_ID(pl.GetM_PriceList_ID()); }