/// <summary> /// Create Facts (the accounting logic) for /// PJI /// <pre> /// Issue /// ProjectWIP DR /// Inventory CR /// </pre> /// Project Account is either Asset or WIP depending on Project Type /// </summary> /// <param name="?"></param> /// <returns>fact</returns> public override List <Fact> CreateFacts(MAcctSchema as1) { // create Fact Header Fact fact = new Fact(this, as1, Fact.POST_Actual); SetC_Currency_ID(as1.GetC_Currency_ID()); MProject project = new MProject(GetCtx(), _issue.GetC_Project_ID(), null); String ProjectCategory = project.GetProjectCategory(); MProduct product = MProduct.Get(GetCtx(), _issue.GetM_Product_ID()); // Line pointers FactLine dr = null; FactLine cr = null; // Issue Cost Decimal?cost = null; if (_issue.GetM_InOutLine_ID() != 0) { cost = GetPOCost(as1); } else if (_issue.GetS_TimeExpenseLine_ID() != 0) { cost = GetLaborCost(as1); } if (cost == null) // standard Product Costs { cost = _line.GetProductCosts(as1, GetAD_Org_ID(), false); } // Project DR int acctType = ACCTTYPE_ProjectWIP; if (MProject.PROJECTCATEGORY_AssetProject.Equals(ProjectCategory)) { acctType = ACCTTYPE_ProjectAsset; } dr = fact.CreateLine(_line, GetAccount(acctType, as1), as1.GetC_Currency_ID(), cost, null); dr.SetQty((Decimal?)Decimal.Negate(Utility.Util.GetValueOfDecimal(_line.GetQty()))); // Inventory CR acctType = ProductCost.ACCTTYPE_P_Asset; if (product.IsService()) { acctType = ProductCost.ACCTTYPE_P_Expense; } cr = fact.CreateLine(_line, _line.GetAccount(acctType, as1), as1.GetC_Currency_ID(), null, cost); cr.SetM_Locator_ID(_line.GetM_Locator_ID()); cr.SetLocationFromLocator(_line.GetM_Locator_ID(), true); // from Loc // List <Fact> facts = new List <Fact>(); facts.Add(fact); return(facts); }