} // setC_Currency_ID /// <summary> /// Set Rate /// </summary> private void SetRate() { // Source info int C_Currency_ID = GetC_Currency_ID(); int C_ConversionType_ID = GetC_ConversionType_ID(); if (C_Currency_ID == 0 || C_ConversionType_ID == 0) { return; } DateTime?DateAcct = GetDateAcct(); if (DateAcct == null) { DateAcct = DateTime.Now;// new Timestamp(System.currentTimeMillis()); } // int C_AcctSchema_ID = GetC_AcctSchema_ID(); MAcctSchema a = MAcctSchema.Get(GetCtx(), C_AcctSchema_ID); int AD_Client_ID = GetAD_Client_ID(); int AD_Org_ID = GetAD_Org_ID(); Decimal?CurrencyRate = (Decimal?)MConversionRate.GetRate(C_Currency_ID, a.GetC_Currency_ID(), DateAcct, C_ConversionType_ID, AD_Client_ID, AD_Org_ID); log.Fine("rate = " + CurrencyRate); //if (CurrencyRate.Value == null) //{ // CurrencyRate = Env.ZERO; //} SetCurrencyRate(CurrencyRate.Value); } // setRate
} // setC_Currency_ID /// <summary> /// set rate /// </summary> /// <param name="windowNo"></param> private void SetRate(int windowNo) { // Source info int?C_Currency_ID = GetC_Currency_ID(); int?C_ConversionType_ID = GetC_ConversionType_ID(); if (C_Currency_ID == 0 || C_ConversionType_ID == 0) { return; } DateTime?DateAcct = GetDateAcct(); if (DateAcct == null) { DateAcct = DateTime.Now;// new Timestamp(System.currentTimeMillis()); } // int? C_AcctSchema_ID = GetCtx().GetContextAsInt(windowNo, "C_AcctSchema_ID"); MAcctSchema ass = MAcctSchema.Get(GetCtx(), C_AcctSchema_ID.Value); int? AD_Client_ID = GetAD_Client_ID(); int? AD_Org_ID = GetAD_Org_ID(); Decimal?CurrencyRate = (Decimal?)MConversionRate.GetRate(C_Currency_ID.Value, ass.GetC_Currency_ID(), DateAcct, C_ConversionType_ID.Value, AD_Client_ID.Value, AD_Org_ID.Value); log.Fine("rate = " + CurrencyRate); if (CurrencyRate == null) { CurrencyRate = Env.ZERO; } SetCurrencyRate(CurrencyRate); SetAmt(windowNo); } // setRate
/// <summary> /// Get PO Price from PriceList - and convert it to AcctSchema Currency /// </summary> /// <param name="as1">accounting schema</param> /// <param name="onlyPOPriceList">use only PO price list</param> /// <returns>po price</returns> private Decimal?GetPriceList(MAcctSchema as1, bool onlyPOPriceList) { StringBuilder sql = new StringBuilder( "SELECT pl.C_Currency_ID, pp.PriceList, pp.PriceStd, pp.PriceLimit " + "FROM M_PriceList pl, M_PriceList_Version plv, M_ProductPrice pp " + "WHERE pl.M_PriceList_ID = plv.M_PriceList_ID" + " AND plv.M_PriceList_Version_ID = pp.M_PriceList_Version_ID" + " AND pp.M_Product_ID=" + _M_Product_ID); if (onlyPOPriceList) { sql.Append(" AND pl.IsSOPriceList='N'"); } sql.Append(" ORDER BY pl.IsSOPriceList ASC, plv.ValidFrom DESC"); int C_Currency_ID = 0; Decimal? PriceList = null; Decimal? PriceStd = null; Decimal? PriceLimit = null; IDataReader idr = null; try { idr = DataBase.DB.ExecuteReader(sql.ToString(), null, null); if (idr.Read()) { C_Currency_ID = Utility.Util.GetValueOfInt(idr[0]); //.getInt(1); PriceList = Utility.Util.GetValueOfDecimal(idr[1]); //.getBigDecimal(2); PriceStd = Utility.Util.GetValueOfDecimal(idr[2]); //.getBigDecimal(3); PriceLimit = Utility.Util.GetValueOfDecimal(idr[3]); //.getBigDecimal(4); } idr.Close(); } catch (Exception e) { log.Log(Level.SEVERE, sql.ToString(), e); } // nothing found if (C_Currency_ID == 0) { return(null); } Decimal?price = PriceLimit; // best bet if (price == null || price.Equals(Env.ZERO)) { price = PriceStd; } if (price == null || price.Equals(Env.ZERO)) { price = PriceList; } // Convert if (price != null && !price.Equals(Env.ZERO)) { price = MConversionRate.Convert(as1.GetCtx(), Utility.Util.GetValueOfDecimal(price), C_Currency_ID, as1.GetC_Currency_ID(), as1.GetAD_Client_ID(), 0); } return(price); }
/// <summary> /// Factory: default combination /// </summary> /// <param name="ctx"></param> /// <param name="C_AcctSchema_ID">accounting schema</param> /// <param name="optionalNull">if true the optional values are null</param> /// <param name="trxName"></param> /// <returns>Account</returns> public static MAccount GetDefault(Ctx ctx, int C_AcctSchema_ID, bool optionalNull, Trx trxName) { MAcctSchema acctSchema = new MAcctSchema(ctx, C_AcctSchema_ID, trxName); return(GetDefault(acctSchema, optionalNull)); }
public static bool CreateCostElementDetail(Ctx ctx, int AD_Client_ID, int AD_Org_ID, MProduct Product, int M_ASI_ID, MAcctSchema mas, int M_costElement_ID, string windowName, MCostDetail cd, decimal amt, decimal qty) { try { MCostElementDetail ced = new MCostElementDetail(ctx, 0, cd.Get_Trx()); ced.SetAD_Client_ID(AD_Client_ID); ced.SetAD_Org_ID(AD_Org_ID); ced.SetC_AcctSchema_ID(mas.GetC_AcctSchema_ID()); ced.SetM_CostElement_ID(M_costElement_ID); ced.SetM_Product_ID(Product.GetM_Product_ID()); ced.SetM_AttributeSetInstance_ID(M_ASI_ID); ced.SetQty(qty); ced.SetAmt(amt); //Refrences ced.SetC_OrderLine_ID(cd.GetC_OrderLine_ID()); ced.SetM_InOutLine_ID(cd.GetM_InOutLine_ID()); if (windowName == "Material Receipt" || windowName == "Customer Return" || windowName == "Shipment" || windowName == "Return To Vendor") { // not to bind Invoiceline refernece on cost element detail } else { ced.SetC_InvoiceLine_ID(cd.GetC_InvoiceLine_ID()); } ced.Set_Value("VAFAM_AssetDisposal_ID", cd.Get_Value("VAFAM_AssetDisposal_ID")); ced.SetM_InventoryLine_ID(cd.GetM_InventoryLine_ID()); ced.SetM_MovementLine_ID(cd.GetM_MovementLine_ID()); ced.SetC_ProjectIssue_ID(cd.GetC_ProjectIssue_ID()); ced.SetIsSOTrx(cd.IsSOTrx()); ced.SetA_Asset_ID(cd.GetA_Asset_ID()); ced.SetM_ProductionLine_ID(cd.GetM_ProductionLine_ID()); ced.SetM_WorkOrderResourceTxnLine_ID(cd.GetM_WorkOrderResourceTxnLine_ID()); ced.SetM_WorkOrderTransactionLine_ID(cd.GetM_WorkOrderTransactionLine_ID()); if (Env.IsModuleInstalled("VAMFG_")) { if (ced.Get_ColumnIndex("VAMFG_M_WrkOdrRscTxnLine_ID") > -1) { ced.Set_Value("VAMFG_M_WrkOdrRscTxnLine_ID", cd.GetVAMFG_M_WrkOdrRscTxnLine_ID()); } if (ced.Get_ColumnIndex("VAMFG_M_WrkOdrTrnsctionLine_ID") > -1) { ced.Set_Value("VAMFG_M_WrkOdrTrnsctionLine_ID", cd.GetVAMFG_M_WrkOdrTrnsctionLine_ID()); } } ced.SetM_Warehouse_ID(cd.GetM_Warehouse_ID()); if (!ced.Save()) { ValueNamePair pp = VLogger.RetrieveError(); _log.Info("Error Occured during costing " + pp.ToString()); return(false); } } catch (Exception ex) { _log.Info("Error Occured during costing " + ex.ToString()); return(false); } return(true); }
/// <summary> /// Get Cost Queue Records in Lifo/Fifo order /// </summary> /// <param name="product">product</param> /// <param name="M_ASI_ID">costing level ASI</param> /// <param name="mas">accounting schema</param> /// <param name="Org_ID">costing level org</param> /// <param name="ce">Cost Element</param> /// <param name="trxName">transaction</param> /// <returns>cost queue or null</returns> public static MCostQueue[] GetQueue(MProduct product, int M_ASI_ID, MAcctSchema mas, int Org_ID, MCostElement ce, Trx trxName) { List <MCostQueue> list = new List <MCostQueue>(); String sql = "SELECT * FROM M_CostQueue " + "WHERE AD_Client_ID=@client AND AD_Org_ID=@org" + " AND M_Product_ID=@prod" + " AND M_CostType_ID=@ct AND C_AcctSchema_ID=@accs" + " AND M_CostElement_ID=@ce"; if (M_ASI_ID != 0) { sql += " AND M_AttributeSetInstance_ID=@asi"; } sql += " AND CurrentQty<>0 " + "ORDER BY M_AttributeSetInstance_ID "; if (!ce.IsFifo()) { sql += "DESC"; } try { SqlParameter[] param = null; if (M_ASI_ID != 0) { param = new SqlParameter[7]; } else { param = new SqlParameter[6]; } param[0] = new SqlParameter("@client", product.GetAD_Client_ID()); param[1] = new SqlParameter("@org", Org_ID); param[2] = new SqlParameter("@prod", product.GetM_Product_ID()); param[3] = new SqlParameter("@ct", mas.GetM_CostType_ID()); param[4] = new SqlParameter("@accs", mas.GetC_AcctSchema_ID()); param[5] = new SqlParameter("@ce", ce.GetM_CostElement_ID()); if (M_ASI_ID != 0) { param[6] = new SqlParameter("@asi", M_ASI_ID); } DataSet ds = DataBase.DB.ExecuteDataset(sql, param, trxName); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new MCostQueue(product.GetCtx(), dr, trxName)); } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } MCostQueue[] costQ = new MCostQueue[list.Count]; costQ = list.ToArray(); return(costQ); }
/// <summary> /// Update/Create initial Cost Record. /// Check first for Purchase Price List, /// then Product Purchase Costs /// and then Price List /// </summary> /// <param name="as1">accounting schema</param> /// <param name="create">create record</param> /// <returns>costs</returns> private Decimal?UpdateCostsOld(MAcctSchema as1, bool create) { // Create Zero Record if (create) { StringBuilder sql = new StringBuilder("INSERT INTO M_Product_Costing " + "(M_Product_ID,C_AcctSchema_ID," + " AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy," + " CurrentCostPrice,CostStandard,FutureCostPrice," + " CostStandardPOQty,CostStandardPOAmt,CostStandardCumQty,CostStandardCumAmt," + " CostAverage,CostAverageCumQty,CostAverageCumAmt," + " PriceLastPO,PriceLastInv, TotalInvQty,TotalInvAmt) " + "VALUES ("); sql.Append(_M_Product_ID).Append(",").Append(as1.GetC_AcctSchema_ID()).Append(",") .Append(as1.GetAD_Client_ID()).Append(",").Append(as1.GetAD_Org_ID()).Append(",") .Append("'Y',SysDate,0,SysDate,0, 0,0,0, 0,0,0,0, 0,0,0, 0,0, 0,0)"); int no = DataBase.DB.ExecuteQuery(sql.ToString(), null, _trx); if (no == 1) { log.Fine("CostingCreated"); } } // Try to find non ZERO Price String costSource = "PriceList-PO"; Decimal?costs = GetPriceList(as1, true); if (costs == null || costs.Equals(Env.ZERO)) { costSource = "PO Cost"; costs = GetPOCost(as1); } if (costs == null || costs.Equals(Env.ZERO)) { costSource = "PriceList"; costs = GetPriceList(as1, false); } // if not found use $1 (to be able to do material transactions) if (costs == null || costs.Equals(Env.ZERO)) { costSource = "Not Found"; costs = 1;//new Decimal(1); } // update current costs StringBuilder sql1 = new StringBuilder("UPDATE M_Product_Costing "); sql1.Append("SET CurrentCostPrice=").Append(costs) .Append(" WHERE M_Product_ID=").Append(_M_Product_ID) .Append(" AND C_AcctSchema_ID=").Append(as1.GetC_AcctSchema_ID()); int no1 = DataBase.DB.ExecuteQuery(sql1.ToString(), null, _trx); if (no1 == 1) { log.Fine(costSource + " - " + costs); } return(costs); }
/// <summary> ///Get primary Acct Schema /// </summary> /// <returns>acct schema</returns> public MAcctSchema GetMAcctSchema() { if (_acctSchema == null && GetC_AcctSchema_ID() != 0) { _acctSchema = new MAcctSchema(GetCtx(), GetC_AcctSchema_ID(), null); } return(_acctSchema); }
/// <summary> /// Get Product Costs per UOM for Accounting Schema in Accounting Schema Currency. /// - if costType defined - cost /// - else CurrentCosts /// </summary> /// <param name="as1"></param> /// <param name="costType">if null uses Accounting Schema Costs - see AcctSchema.COSTING_*</param> /// <returns>product costs</returns> private Decimal?GetProductItemCostOld(MAcctSchema as1, String costType) { Decimal? current = null; Decimal? cost = null; String cm = as1.GetCostingMethod(); StringBuilder sql = new StringBuilder("SELECT CurrentCostPrice,"); // 1 // if ((costType == null && MAcctSchema.COSTINGMETHOD_AveragePO.Equals(cm)) || MAcctSchema.COSTINGMETHOD_AveragePO.Equals(costType)) { sql.Append("COSTAVERAGE"); // 2 } else if ((costType == null && MAcctSchema.COSTINGMETHOD_LastPOPrice.Equals(cm)) || MAcctSchema.COSTINGMETHOD_LastPOPrice.Equals(costType)) { sql.Append("PRICELASTPO"); } else // AcctSchema.COSTING_STANDARD { sql.Append("COSTSTANDARD"); } sql.Append(" FROM M_Product_Costing WHERE M_Product_ID=" + _M_Product_ID + " AND C_AcctSchema_ID=" + as1.GetC_AcctSchema_ID()); IDataReader idr = null; try { idr = DataBase.DB.ExecuteReader(sql.ToString(), null, null); if (idr.Read()) { current = Utility.Util.GetValueOfDecimal(idr[0]); //.getBigDecimal(1); cost = Utility.Util.GetValueOfDecimal(idr[1]); //.getBigDecimal(2); } idr.Close(); } catch (Exception e) { log.Log(Level.SEVERE, sql.ToString(), e); } // Return Costs if (costType != null && cost != null && !cost.Equals(Env.ZERO)) { log.Fine("Costs=" + cost); return(cost); } else if (current != null && !current.Equals(Env.ZERO)) { log.Fine("Current=" + current); return(current); } // Create/Update Cost Record bool create = (cost == null && current == null); return(UpdateCostsOld(as1, create)); }
/// <summary> /// Get PO Cost from Purchase Info - and convert it to AcctSchema Currency /// </summary> /// <param name="as1">accounting schema</param> /// <returns>po cost</returns> private Decimal?GetPOCost(MAcctSchema as1) { String sql = "SELECT C_Currency_ID, PriceList,PricePO,PriceLastPO " + "FROM M_Product_PO WHERE M_Product_ID=" + _M_Product_ID + "ORDER BY IsCurrentVendor DESC"; int C_Currency_ID = 0; Decimal? PriceList = null; Decimal? PricePO = null; Decimal? PriceLastPO = null; IDataReader idr = null; try { idr = DataBase.DB.ExecuteReader(sql, null, null); if (idr.Read()) { C_Currency_ID = Utility.Util.GetValueOfInt(idr[0]); //.getInt(1); PriceList = Utility.Util.GetValueOfDecimal(idr[1]); //.getBigDecimal(2); PricePO = Utility.Util.GetValueOfDecimal(idr[2]); //.getBigDecimal(3); PriceLastPO = Utility.Util.GetValueOfDecimal(idr[3]); //.getBigDecimal(4); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); idr = null; } log.Log(Level.SEVERE, sql, e); } // nothing found if (C_Currency_ID == 0) { return(null); } Decimal?cost = PriceLastPO; // best bet if (cost == null || cost.Equals(Env.ZERO)) { cost = PricePO; } if (cost == null || cost.Equals(Env.ZERO)) { cost = PriceList; } // Convert - standard precision!! - should be costing precision if (cost != null && !cost.Equals(Env.ZERO)) { cost = MConversionRate.Convert(as1.GetCtx(), Utility.Util.GetValueOfDecimal(cost), C_Currency_ID, as1.GetC_Currency_ID(), as1.GetAD_Client_ID(), as1.GetAD_Org_ID()); } return(cost); }
/// <summary> /// Dispose /// </summary> public void Dispose() { ASchemas = null; ASchema = null; // whereInfo.Clear(); whereInfo = null; // Env.ClearWinContext(windowNo); }
/// <summary> /// Is Period Open for Doc Base Type in selected Organization /// </summary> /// <param name="DocBaseType">document base type</param> /// <param name="dateAcct">accounting date</param> /// <returns>error message or null</returns> /// <date>07-March-2011</date> /// <writer>raghu</writer> public String IsOpen(String DocBaseType, DateTime?dateAcct, int AD_Org_ID) { if (!IsActive()) { _log.Warning("Period not active: " + GetName()); return("@C_Period_ID@ <> @IsActive@"); } MAcctSchema as1 = null; if (AD_Org_ID > 0) { as1 = MOrg.Get(GetCtx(), AD_Org_ID).GetAcctSchema(); } else { as1 = MClient.Get(GetCtx(), GetAD_Client_ID()).GetAcctSchema(); } if (as1 != null && as1.IsAutoPeriodControl()) { if (!as1.IsAutoPeriodControlOpen(dateAcct)) { return("@PeriodClosed@ - @AutoPeriodControl@"); } // We are OK DateTime today = DateTime.Now.Date; if (IsInPeriod(today) && as1.GetC_Period_ID() != GetC_Period_ID()) { as1.SetC_Period_ID(GetC_Period_ID()); as1.Save(); } return(null); } // Standard Period Control if (DocBaseType == null) { log.Warning(GetName() + " - No DocBaseType"); return("@NotFound@ @DocBaseType@"); } MPeriodControl pc = GetPeriodControl(DocBaseType, AD_Org_ID); if (pc == null) { log.Warning(GetName() + " - Period Control not found for " + DocBaseType); return("@NotFound@ @C_PeriodControl_ID@: " + DocBaseType); } log.Fine(GetName() + ": " + DocBaseType); if (pc.IsOpen()) { return(null); } return("@PeriodClosed@ - @C_PeriodControl_ID@ (" + DocBaseType + ", " + dateAcct + ")"); }
/// <summary> /// Is Period Open for Doc Base Type /// </summary> /// <param name="docBaseType">document base type</param> /// <returns>true if open</returns> public bool IsOpen(String docBaseType) { if (!IsActive()) { _log.Warning("Period not active: " + GetName()); return(false); } MAcctSchema mas = MClient.Get(GetCtx(), GetAD_Client_ID()).GetAcctSchema(); if (mas != null && mas.IsAutoPeriodControl()) { // if (as.getC_Period_ID() == getC_Period_ID()) // return true; DateTime today = DateTime.Now;// new DateTime(CommonFunctions.CurrentTimeMillis()); DateTime first = TimeUtil.AddDays(today, -mas.GetPeriod_OpenHistory()); DateTime last = TimeUtil.AddDays(today, mas.GetPeriod_OpenFuture()); //if (today.before(first)) if (today < first) { log.Warning("Today before first day - " + first); return(false); } //if (today.after(last)) if (today > last) { log.Warning("Today after last day - " + first); return(false); } // We are OK if (IsInPeriod(today)) { mas.SetC_Period_ID(GetC_Period_ID()); mas.Save(); } return(true); } // Standard Period Control if (docBaseType == null) { log.Warning(GetName() + " - No DocBaseType"); return(false); } MPeriodControl pc = GetPeriodControl(docBaseType); if (pc == null) { log.Warning(GetName() + " - Period Control not found for " + docBaseType); return(false); } log.Fine(GetName() + ": " + docBaseType); return(pc.IsOpen()); }
/// <summary> /// Parent Constructor /// </summary> /// <param name="as1">accounting schema</param> public MAcctSchemaElement(MAcctSchema as1) : this(as1.GetCtx(), 0, as1.Get_TrxName()) { SetClientOrg(as1); SetC_AcctSchema_ID(as1.GetC_AcctSchema_ID()); // setC_Element_ID (0); // setElementType (null); // setName (null); // setSeqNo (0); }
/// <summary> /// Parent Constructor /// </summary> /// <param name="product">product</param> /// <param name="M_AttributeSetInstance_ID">Attribute Set Instance</param> /// <param name="mas">Acct Schema</param> /// <param name="AD_Org_ID">org</param> /// <param name="M_CostElement_ID">cost element</param> /// <param name="trxName">transaction</param> public MCostQueue(MProduct product, int M_AttributeSetInstance_ID, MAcctSchema mas, int AD_Org_ID, int M_CostElement_ID, Trx trxName) : this(product.GetCtx(), 0, trxName) { SetClientOrg(product.GetAD_Client_ID(), AD_Org_ID); SetC_AcctSchema_ID(mas.GetC_AcctSchema_ID()); SetM_CostType_ID(mas.GetM_CostType_ID()); SetM_Product_ID(product.GetM_Product_ID()); SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); SetM_CostElement_ID(M_CostElement_ID); }
/// <summary> /// Is used to check costing method belongs to PO costing method like (Average PO, Weighted Average PO or Last PO) /// Firts we check costing method on Product category, if not found then we will check on Primary Accounting Schema /// </summary> /// <param name="ctx">current context</param> /// <param name="AD_Client_ID">Client reference</param> /// <param name="M_Product_ID">Product whom costing method is to be determine</param> /// <param name="trxName">Transaction</param> /// <returns>True/False</returns> public static bool IsPOCostingmethod(Ctx ctx, int AD_Client_ID, int M_Product_ID, Trx trxName) { MProductCategory pc = null; bool isPOcostingMethod = false; string costingMethod = null; MClient client = MClient.Get(ctx, AD_Client_ID); MProduct product = MProduct.Get(ctx, M_Product_ID); if (product != null) { pc = MProductCategory.Get(product.GetCtx(), product.GetM_Product_Category_ID()); if (pc != null) { // check costing method from product category costingMethod = pc.GetCostingMethod(); if (costingMethod == "C") { costingMethod = Util.GetValueOfString(DB.ExecuteScalar(@"SELECT costingmethod FROM M_CostElement WHERE M_CostElement_ID IN (SELECT CAST(M_Ref_CostElement AS INTEGER) FROM M_CostElementLine WHERE M_CostElement_ID=" + pc.GetM_CostElement_ID() + @" ) AND CostingMethod IS NOT NULL", null, trxName)); } } if (String.IsNullOrEmpty(costingMethod)) { // check costing method against primary accounting schema MClientInfo clientInfo = MClientInfo.Get(ctx, AD_Client_ID); MAcctSchema actSchema = MAcctSchema.Get(ctx, clientInfo.GetC_AcctSchema1_ID()); if (actSchema != null) { costingMethod = actSchema.GetCostingMethod(); if (costingMethod == "C") { costingMethod = Util.GetValueOfString(DB.ExecuteScalar(@"SELECT costingmethod FROM M_CostElement WHERE M_CostElement_ID IN (SELECT CAST(M_Ref_CostElement AS INTEGER) FROM M_CostElementLine WHERE M_CostElement_ID=" + actSchema.GetM_CostElement_ID() + @" ) AND CostingMethod IS NOT NULL", null, trxName)); } } } } if (costingMethod.Equals(COSTINGMETHOD_WeightedAveragePO) || costingMethod.Equals(COSTINGMETHOD_AveragePO) || costingMethod.Equals(COSTINGMETHOD_LastPOPrice)) { isPOcostingMethod = true; } else { isPOcostingMethod = false; } return(isPOcostingMethod); }
protected override bool BeforeDelete() { MAcctSchema[] ass = MAcctSchema.GetClientAcctSchema(GetCtx(), GetAD_Client_ID()); for (int i = 0; i < ass.Length; i++) { if (ass[i].GetM_CostType_ID() == GetM_CostType_ID()) { log.SaveError("CannotDelete", Msg.GetElement(GetCtx(), "C_AcctSchema_ID") + " - " + ass[i].GetName()); return(false); } } return(true); } // beforeDelete
/// <summary> /// This function is used to get Accounting Schema either binded on Organization or Primary Accounting SChema /// </summary> /// <param name="ctx">ctx</param> /// <param name="Ad_Client_ID">AD_Client_ID</param> /// <param name="AD_Org_ID">Org ID</param> /// <returns>C_AcctSchema ID</returns> public static int GetDefaultActSchema(Ctx ctx, int Ad_Client_ID, int AD_Org_ID) { MAcctSchema acctSchema = null; if (AD_Org_ID > 0) { acctSchema = MOrg.Get(ctx, AD_Org_ID).GetAcctSchema(); } if (acctSchema == null) { acctSchema = MClient.Get(ctx, Ad_Client_ID).GetAcctSchema(); } return(acctSchema.GetC_AcctSchema_ID()); }
/// <summary> /// Get Primary Accounting Schema /// </summary> /// <returns>Acct Schema or null</returns> internal MAcctSchema GetAcctSchema() { if (info == null) { info = MOrgInfo.Get(GetCtx(), GetAD_Client_ID(), Get_TrxName()); } if (info != null) { int C_AcctSchema_ID = info.GetC_AcctSchema_ID(); if (C_AcctSchema_ID != 0) { return(MAcctSchema.Get(GetCtx(), C_AcctSchema_ID)); } } return(null); }
/// <summary> /// Get AccountSchema of Client /// </summary> /// <param name="ctx">context</param> /// <param name="C_AcctSchema_ID">schema id</param> /// <param name="trxName">optional trx</param> /// <returns>Accounting schema</returns> public static MAcctSchema Get(Ctx ctx, int C_AcctSchema_ID, Trx trxName) { // Check Cache int key = C_AcctSchema_ID; MAcctSchema retValue = (MAcctSchema)_cache[key]; if (retValue != null) { return(retValue); } retValue = new MAcctSchema(ctx, C_AcctSchema_ID, trxName); if (trxName == null) { _cache.Add(key, retValue); } return(retValue); } // get
/// <summary> /// Constructor /// </summary> /// <param name="ctx"></param> /// <param name="windowNo"></param> /// <param name="ad_Client_ID"></param> /// <param name="ad_Table_ID"></param> public AcctViewerData(Ctx ctx, int windowNo1, int ad_Client_ID, int ad_Table_ID) { windowNo = windowNo1; AD_Client_ID = ad_Client_ID; if (AD_Client_ID == 0) { AD_Client_ID = ctx.GetContextAsInt(windowNo, "AD_Client_ID"); } if (AD_Client_ID == 0) { AD_Client_ID = ctx.GetContextAsInt("AD_Client_ID"); } AD_Table_ID = ad_Table_ID; // ASchemas = MAcctSchema.GetClientAcctSchema(ctx, AD_Client_ID); ASchema = ASchemas[0]; _ctx = ctx; }
/// <summary> /// Get/Create Cost Queue Record. /// CostingLevel is not validated /// </summary> /// <param name="product">product</param> /// <param name="M_AttributeSetInstance_ID">real asi</param> /// <param name="mas">accounting schema</param> /// <param name="AD_Org_ID">real org</param> /// <param name="M_CostElement_ID">element</param> /// <param name="trxName">transaction</param> /// <returns>cost queue or null</returns> public static MCostQueue Get(MProduct product, int M_AttributeSetInstance_ID, MAcctSchema mas, int AD_Org_ID, int M_CostElement_ID, Trx trxName) { MCostQueue costQ = null; String sql = "SELECT * FROM M_CostQueue " + "WHERE AD_Client_ID=@client AND AD_Org_ID=@org" + " AND M_Product_ID=@pro" + " AND M_AttributeSetInstance_ID=@asi" + " AND M_CostType_ID=@ct AND C_AcctSchema_ID=@accs" + " AND M_CostElement_ID=@ce"; try { SqlParameter[] param = new SqlParameter[7]; param[0] = new SqlParameter("@client", product.GetAD_Client_ID()); param[1] = new SqlParameter("@org", AD_Org_ID); param[2] = new SqlParameter("@pro", product.GetM_Product_ID()); param[3] = new SqlParameter("@asi", M_AttributeSetInstance_ID); param[4] = new SqlParameter("@ct", mas.GetM_CostType_ID()); param[5] = new SqlParameter("@accs", mas.GetC_AcctSchema_ID()); param[6] = new SqlParameter("@ce", M_CostElement_ID); DataSet ds = DataBase.DB.ExecuteDataset(sql, param); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { costQ = new MCostQueue(product.GetCtx(), dr, trxName); } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } // New if (costQ == null) { costQ = new MCostQueue(product, M_AttributeSetInstance_ID, mas, AD_Org_ID, M_CostElement_ID, trxName); } return(costQ); }
/// <summary> /// Factory: Return ArrayList of Account Schema Elements /// </summary> /// <param name="as1">Accounting Schema</param> /// <returns>ArrayList with Elements</returns> public static MAcctSchemaElement[] GetAcctSchemaElements(MAcctSchema as1) { int key = as1.GetC_AcctSchema_ID(); MAcctSchemaElement[] retValue = (MAcctSchemaElement[])s_cache[key]; if (retValue != null) { return(retValue); } _log.Fine("C_AcctSchema_ID=" + as1.GetC_AcctSchema_ID()); List <MAcctSchemaElement> list = new List <MAcctSchemaElement>(); // String sql = "SELECT * FROM C_AcctSchema_Element " + "WHERE C_AcctSchema_ID=" + as1.GetC_AcctSchema_ID() + " AND IsActive='Y' ORDER BY SeqNo"; try { DataSet ds = DataBase.DB.ExecuteDataset(sql, null, as1.Get_TrxName()); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; MAcctSchemaElement ase = new MAcctSchemaElement(as1.GetCtx(), dr, as1.Get_TrxName()); _log.Fine(" - " + ase); if (ase.IsMandatory() && ase.GetDefaultValue() == 0) { _log.Log(Level.SEVERE, "No default value for " + ase.GetName()); } list.Add(ase); } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } retValue = new MAcctSchemaElement[list.Count]; retValue = list.ToArray(); s_cache.Add(key, retValue); return(retValue); }
} // setCurrencyRate /// <summary> /// Set Accounted Amounts /// </summary> /// <param name="windowNo">window no</param> private void SetAmt(int windowNo) { // Get Target Currency & Precision from C_AcctSchema.C_Currency_ID int? C_AcctSchema_ID = GetCtx().GetContextAsInt(windowNo, "C_AcctSchema_ID"); MAcctSchema ass = MAcctSchema.Get(GetCtx(), C_AcctSchema_ID.Value); int? Precision = ass.GetStdPrecision(); Decimal?CurrencyRate = GetCurrencyRate(); if (CurrencyRate == null) { CurrencyRate = Env.ONE; SetCurrencyRate(CurrencyRate); } // AmtAcct = AmtSource * CurrencyRate ==> Precision Decimal?AmtSourceDr = GetAmtSourceDr(); if (AmtSourceDr == null) { AmtSourceDr = Env.ZERO; } Decimal?AmtSourceCr = GetAmtSourceCr(); if (AmtSourceCr == null) { AmtSourceCr = Env.ZERO; } Decimal?AmtAcctDr = (Decimal.Multiply(AmtSourceDr.Value, CurrencyRate.Value)); //AmtAcctDr = AmtAcctDr.setScale(Precision, BigDecimal.ROUND_HALF_UP); AmtAcctDr = Decimal.Round(AmtAcctDr.Value, Precision.Value, MidpointRounding.AwayFromZero); SetAmtAcctDr(AmtAcctDr); Decimal?AmtAcctCr = Decimal.Multiply(AmtSourceCr.Value, CurrencyRate.Value); AmtAcctCr = Decimal.Round(AmtAcctCr.Value, Precision.Value, MidpointRounding.AwayFromZero); SetAmtAcctCr(AmtAcctCr); } // setAmt
/// <summary> /// Get Total Costs (amt*qty) in Accounting Schema Currency /// </summary> /// <param name="as1">accounting schema</param> /// <param name="AD_Org_ID"></param> /// <param name="costingMethod">if null uses Accounting Schema - AcctSchema.COSTINGMETHOD_*</param> /// <param name="C_OrderLine_ID">optional order line</param> /// <param name="zeroCostsOK">zero/no costs are OK</param> /// <returns>cost or null, if qty or costs cannot be determined</returns> public Decimal?GetProductCosts(MAcctSchema as1, int AD_Org_ID, String costingMethod, int C_OrderLine_ID, bool zeroCostsOK) { if (_qty == null) { log.Fine("No Qty"); return(null); } // No Product if (_product == null) { log.Fine("No Product"); return(null); } // Decimal?cost = MCost.GetCurrentCost(_product, _M_AttributeSetInstance_ID, as1, AD_Org_ID, costingMethod, Utility.Util.GetValueOfDecimal(_qty), C_OrderLine_ID, zeroCostsOK, _trx); if (cost == null || cost == 0) { log.Fine("No Costs"); return(null); } return(cost); }
public static bool InsertForeignCostMatchOrder(Ctx ctx, MOrderLine orderLine, decimal matchQty, int ASI, Trx trx) { int acctSchema_ID = 0; int M_CostElement_ID = 0; int AD_Org_ID = 0; int M_ASI_ID = 0; MProduct product = null; MAcctSchema acctSchema = null; MCostForeignCurrency foreignCost = null; dynamic pc = null; String cl = null; MOrder order = null; try { order = new MOrder(ctx, orderLine.GetC_Order_ID(), trx); if (!order.IsSOTrx() && !order.IsReturnTrx()) { acctSchema_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT asch.c_acctschema_id FROM c_acctschema asch INNER JOIN ad_clientinfo ci ON ci.c_acctschema1_id = asch.c_acctschema_id WHERE ci.ad_client_id = " + order.GetAD_Client_ID())); acctSchema = new MAcctSchema(ctx, acctSchema_ID, trx); if (acctSchema.GetC_Currency_ID() != order.GetC_Currency_ID()) { // Get Costing Element of Av. PO M_CostElement_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT M_CostElement_ID FROM M_CostElement WHERE AD_Client_ID = " + order.GetAD_Client_ID() + " AND IsActive = 'Y' AND CostingMethod = 'A'")); product = new MProduct(ctx, orderLine.GetM_Product_ID(), trx); if (product != null && product.GetProductType() == "I" && product.GetM_Product_ID() > 0) // for Item Type product { pc = MProductCategory.Get(product.GetCtx(), product.GetM_Product_Category_ID()); // Get Costing Level if (pc != null) { cl = pc.GetCostingLevel(); } if (cl == null) { cl = acctSchema.GetCostingLevel(); } if (cl == "C" || cl == "B") { AD_Org_ID = 0; } else { AD_Org_ID = order.GetAD_Org_ID(); } if (cl != "B") { M_ASI_ID = 0; } else { M_ASI_ID = ASI; } foreignCost = MCostForeignCurrency.Get(product, M_ASI_ID, AD_Org_ID, M_CostElement_ID, order.GetC_BPartner_ID(), order.GetC_Currency_ID()); foreignCost.SetC_Order_ID(order.GetC_Order_ID()); foreignCost.SetCumulatedQty(Decimal.Add(foreignCost.GetCumulatedQty(), matchQty)); foreignCost.SetCumulatedAmt(Decimal.Add(foreignCost.GetCumulatedAmt(), Decimal.Multiply(orderLine.GetPriceActual(), matchQty))); if (foreignCost.GetCumulatedQty() != 0) { foreignCost.SetCostPerUnit(Decimal.Round(Decimal.Divide(foreignCost.GetCumulatedAmt(), foreignCost.GetCumulatedQty()), acctSchema.GetCostingPrecision())); } else { foreignCost.SetCostPerUnit(0); } if (!foreignCost.Save(trx)) { ValueNamePair pp = VLogger.RetrieveError(); _log.Severe("Error occured during updating M_Cost_ForeignCurrency. Error name : " + pp.GetName() + " AND Error Value : " + pp.GetValue() + " , For Invoice line : " + orderLine.GetC_OrderLine_ID() + " , AND Ad_Client_ID : " + orderLine.GetAD_Client_ID()); return(false); } } } } } catch (Exception ex) { _log.Log(Level.SEVERE, "", ex); return(false); } return(true); }
public static bool InsertForeignCostAverageInvoice(Ctx ctx, MInvoice invoice, MInvoiceLine invoiceLine, Trx trx) { int acctSchema_ID = 0; int M_CostElement_ID = 0; int AD_Org_ID = 0; int M_ASI_ID = 0; MProduct product = null; MAcctSchema acctSchema = null; MCostForeignCurrency foreignCost = null; dynamic pc = null; String cl = null; try { // if cost is calculated then not to calculate again if (invoiceLine.IsFutureCostCalculated()) { return(true); } acctSchema_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT asch.c_acctschema_id FROM c_acctschema asch INNER JOIN ad_clientinfo ci ON ci.c_acctschema1_id = asch.c_acctschema_id WHERE ci.ad_client_id = " + invoice.GetAD_Client_ID())); acctSchema = new MAcctSchema(ctx, acctSchema_ID, trx); if (acctSchema.GetC_Currency_ID() != invoice.GetC_Currency_ID()) { // Get Costing Element of Av. Invoice M_CostElement_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT M_CostElement_ID FROM M_CostElement WHERE AD_Client_ID = " + invoice.GetAD_Client_ID() + " AND IsActive = 'Y' AND CostingMethod = 'I'")); product = new MProduct(ctx, invoiceLine.GetM_Product_ID(), trx); if (product != null && product.GetProductType() == "I" && product.GetM_Product_ID() > 0) // for Item Type product { pc = MProductCategory.Get(product.GetCtx(), product.GetM_Product_Category_ID()); // Get Costing Level if (pc != null) { cl = pc.GetCostingLevel(); } if (cl == null) { cl = acctSchema.GetCostingLevel(); } if (cl == "C" || cl == "B") { AD_Org_ID = 0; } else { AD_Org_ID = invoice.GetAD_Org_ID(); } if (cl != "B") { M_ASI_ID = 0; } else { M_ASI_ID = invoiceLine.GetM_AttributeSetInstance_ID(); } foreignCost = MCostForeignCurrency.Get(product, M_ASI_ID, AD_Org_ID, M_CostElement_ID, invoice.GetC_BPartner_ID(), invoice.GetC_Currency_ID()); foreignCost.SetC_Invoice_ID(invoice.GetC_Invoice_ID()); foreignCost.SetCumulatedQty(Decimal.Add(foreignCost.GetCumulatedQty(), invoiceLine.GetQtyInvoiced())); foreignCost.SetCumulatedAmt(Decimal.Add(foreignCost.GetCumulatedAmt(), invoiceLine.GetLineNetAmt())); if (foreignCost.GetCumulatedQty() != 0) { foreignCost.SetCostPerUnit(Decimal.Round(Decimal.Divide(foreignCost.GetCumulatedAmt(), foreignCost.GetCumulatedQty()), acctSchema.GetCostingPrecision())); } else { foreignCost.SetCostPerUnit(0); } if (!foreignCost.Save(trx)) { ValueNamePair pp = VLogger.RetrieveError(); _log.Severe("Error occured during updating M_Cost_ForeignCurrency. Error name : " + pp.GetName() + " AND Error Value : " + pp.GetValue() + " , For Invoice line : " + invoiceLine.GetC_InvoiceLine_ID() + " , AND Ad_Client_ID : " + invoiceLine.GetAD_Client_ID()); return(false); } else { invoiceLine.SetIsFutureCostCalculated(true); if (!invoiceLine.Save(trx)) { ValueNamePair pp = VLogger.RetrieveError(); _log.Severe("Error occured during updating Is Foreign Cost On C_invoice. Error name : " + pp.GetName() + " AND Error Value : " + pp.GetValue() + " , For Invoice line : " + invoiceLine.GetC_InvoiceLine_ID() + " , AND Ad_Client_ID : " + invoiceLine.GetAD_Client_ID()); return(false); } } } } } catch (Exception ex) { _log.Log(Level.SEVERE, "", ex); return(false); } return(true); }
} // getClientAcctSchema // by amit 23-12-2015 public static MAcctSchema[] GetClientAcctSchemas(Ctx ctx, int AD_Client_ID, Trx trxName) { // Check Cache int key = AD_Client_ID; if (_schema.ContainsKey(key)) { return((MAcctSchema[])_schema[key]); } // Create New List <MAcctSchema> list = new List <MAcctSchema>(); MClientInfo info = MClientInfo.Get(ctx, AD_Client_ID, trxName); MAcctSchema ass = MAcctSchema.Get(ctx, info.GetC_AcctSchema1_ID(), trxName); if (ass.Get_ID() != 0 && trxName == null) { list.Add(ass); } // Other String sql = "SELECT C_AcctSchema_ID FROM C_AcctSchema acs " + "WHERE IsActive='Y'"; if (AD_Client_ID != 0) { sql += " AND AD_Client_ID=" + AD_Client_ID; } sql += " ORDER BY C_AcctSchema_ID"; IDataReader dr = null; try { dr = DataBase.DB.ExecuteReader(sql, null, trxName); while (dr.Read()) { int id = Utility.Util.GetValueOfInt(dr[0].ToString()); if (id != info.GetC_AcctSchema1_ID()) // already in list { ass = MAcctSchema.Get(ctx, id, trxName); if (ass.Get_ID() != 0 && trxName == null) { list.Add(ass); } } } dr.Close(); dr = null; } catch (System.Data.Common.DbException e) { if (dr != null) { dr.Close(); } _log.Log(Level.SEVERE, sql, e); } finally { if (dr != null) { dr.Close(); dr = null; } } // Save MAcctSchema[] retValue = new MAcctSchema[list.Count]; retValue = list.ToArray(); if (trxName == null) { _schema.Add(key, retValue); } return(retValue); } // getClientAcctSchema
/** * Get Charge Account * @param C_Charge_ID charge * @param as account schema * @param amount amount for expense(+)/revenue(-) * @return Charge Account or null */ public static MAccount GetAccount(int C_Charge_ID, MAcctSchema aSchema, Decimal amount) { if (C_Charge_ID == 0 || aSchema == null) { return(null); } int acct_index = 1; // Expense (positive amt) if (amount < 0) { acct_index = 2; // Revenue (negative amt) } String sql = "SELECT CH_Expense_Acct, CH_Revenue_Acct FROM C_Charge_Acct WHERE C_Charge_ID=" + C_Charge_ID + " AND C_AcctSchema_ID=" + aSchema.GetC_AcctSchema_ID(); int Account_ID = 0; IDataReader dr = null; try { // PreparedStatement pstmt = DataBase.prepareStatement(sql, null); // pstmt.setInt (1, C_Charge_ID); // pstmt.setInt (2, aSchema.getC_AcctSchema_ID()); // ResultSet dr = pstmt.executeQuery(); dr = DataBase.DB.ExecuteReader(sql, null, null); if (dr.Read()) { Account_ID = Utility.Util.GetValueOfInt(dr[acct_index - 1].ToString()); } dr.Close(); //pstmt.close(); } catch (SqlException e) { if (dr != null) { dr.Close(); } _log.Log(Level.SEVERE, sql, e); return(null); } finally { if (dr != null) { dr.Close(); } } // No account if (Account_ID == 0) { _log.Severe("NO account for C_Charge_ID=" + C_Charge_ID); return(null); } // Return Account MAccount acct = MAccount.Get(aSchema.GetCtx(), Account_ID); return(acct); } // getAccount
} // afterDelete /** Update combination and optionally **/ private bool GetOrCreateCombination(Boolean newRecord) { int Account_ID = 0, C_SubAcct_ID = 0, M_Product_ID = 0, C_BPartner_ID = 0, AD_Org_ID = 0, AD_OrgTrx_ID = 0, C_LocFrom_ID = 0, C_LocTo_ID = 0, C_SalesRegion_ID = 0, C_Project_ID = 0, C_Campaign_ID = 0, C_Activity_ID = 0, User1_ID = 0, User2_ID = 0; if (GetC_ValidCombination_ID() == 0 || (!newRecord && (Is_ValueChanged("Account_ID") || Is_ValueChanged("M_Product_ID") || Is_ValueChanged("C_BPartner_ID") || Is_ValueChanged("AD_Org_ID") || Is_ValueChanged("C_Project_ID") || Is_ValueChanged("C_Campaign_ID") || Is_ValueChanged("C_Activity_ID")))) { MJournal gl = new MJournal(GetCtx(), GetGL_Journal_ID(), Get_TrxName()); // Validate all mandatory combinations are set MAcctSchema asc = MAcctSchema.Get(GetCtx(), gl.GetC_AcctSchema_ID()); MAcctSchemaElement[] elements = MAcctSchemaElement.GetAcctSchemaElements(asc); for (int i = 0; i < elements.Length; i++) { MAcctSchemaElement elem = elements[i]; String et = elem.GetElementType(); if (MAcctSchemaElement.ELEMENTTYPE_Account.Equals(et) && Get_ColumnIndex("Account_ID") > 0) { Account_ID = Util.GetValueOfInt(Get_Value("Account_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Account.Equals(et) && Get_ColumnIndex("C_SubAcct_ID") > 0) { C_SubAcct_ID = Util.GetValueOfInt(Get_Value("C_SubAcct_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Activity.Equals(et) && Get_ColumnIndex("C_Activity_ID") > 0) { C_Activity_ID = Util.GetValueOfInt(Get_Value("C_Activity_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_BPartner.Equals(et) && Get_ColumnIndex("C_BPartner_ID") > 0) { C_BPartner_ID = Util.GetValueOfInt(Get_Value("C_BPartner_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Campaign.Equals(et) && Get_ColumnIndex("C_BPartner_ID") > 0) { C_BPartner_ID = Util.GetValueOfInt(Get_Value("C_BPartner_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Organization.Equals(et)) { AD_Org_ID = GetAD_Org_ID(); } if (MAcctSchemaElement.ELEMENTTYPE_OrgTrx.Equals(et) && Get_ColumnIndex("AD_OrgTrx_ID") > 0) { AD_OrgTrx_ID = Util.GetValueOfInt(Get_Value("AD_OrgTrx_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Product.Equals(et) && Get_ColumnIndex("C_LocFrom_ID") > 0) { C_LocFrom_ID = Util.GetValueOfInt(Get_Value("C_LocFrom_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Product.Equals(et) && Get_ColumnIndex("C_LocTo_ID") > 0) { C_LocTo_ID = Util.GetValueOfInt(Get_Value("C_LocTo_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Product.Equals(et) && Get_ColumnIndex("M_Product_ID") > 0) { M_Product_ID = Util.GetValueOfInt(Get_Value("M_Product_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Project.Equals(et) && Get_ColumnIndex("C_Project_ID") > 0) { C_Project_ID = Util.GetValueOfInt(Get_Value("C_Project_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_Project.Equals(et) && Get_ColumnIndex("C_Campaign_ID") > 0) { C_Campaign_ID = Util.GetValueOfInt(Get_Value("C_Campaign_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_SalesRegion.Equals(et) && Get_ColumnIndex("C_SalesRegion_ID") > 0) { C_SalesRegion_ID = Util.GetValueOfInt(Get_Value("C_SalesRegion_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_UserList1.Equals(et) && Get_ColumnIndex("User1_ID") > 0) { User1_ID = Util.GetValueOfInt(Get_Value("User1_ID")); } if (MAcctSchemaElement.ELEMENTTYPE_UserList2.Equals(et) && Get_ColumnIndex("User2_ID") > 0) { User2_ID = Util.GetValueOfInt(Get_Value("User2_ID")); } } MAccount acct = MAccount.Get(GetCtx(), GetAD_Client_ID(), AD_Org_ID, gl.GetC_AcctSchema_ID(), Account_ID, C_SubAcct_ID, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (acct != null) { acct.Save(Get_TrxName()); // get ID from transaction SetC_ValidCombination_ID(acct.Get_ID()); //if (acct.GetAlias() != null && acct.GetAlias().length > 0) // setAlias_ValidCombination_ID(acct.get_ID()); //else // setAlias_ValidCombination_ID(0); } } else { fillDimensionsFromCombination(); } return(true); }