} // createGLJournal /// <summary> /// Create Balancing Entry /// </summary> /// <param name="asDefaultAccts">acct schema default accounts</param> /// <param name="journal">journal</param> /// <param name="drTotal">dr</param> /// <param name="crTotal">cr</param> /// <param name="AD_Org_ID">org</param> /// <param name="lineNo">lineno base line no</param> private void CreateBalancing(MAcctSchemaDefault asDefaultAccts, MJournal journal, Decimal drTotal, Decimal crTotal, int AD_Org_ID, int lineNo) { if (journal == null) { throw new ArgumentException("Jornal is null"); } // CR Entry = Gain if (Env.Signum(drTotal) != 0) { MJournalLine line = new MJournalLine(journal); line.SetLine(lineNo + 1); MAccount bas = MAccount.Get(GetCtx(), asDefaultAccts.GetUnrealizedGain_Acct()); MAccount acct = MAccount.Get(GetCtx(), asDefaultAccts.GetAD_Client_ID(), AD_Org_ID, asDefaultAccts.GetC_AcctSchema_ID(), bas.GetAccount_ID(), bas.GetC_SubAcct_ID(), bas.GetM_Product_ID(), bas.GetC_BPartner_ID(), bas.GetAD_OrgTrx_ID(), bas.GetC_LocFrom_ID(), bas.GetC_LocTo_ID(), bas.GetC_SalesRegion_ID(), bas.GetC_Project_ID(), bas.GetC_Campaign_ID(), bas.GetC_Activity_ID(), bas.GetUser1_ID(), bas.GetUser2_ID(), bas.GetUserElement1_ID(), bas.GetUserElement2_ID()); line.SetDescription(Msg.GetElement(GetCtx(), "UnrealizedGain_Acct")); line.SetC_ValidCombination_ID(acct.GetC_ValidCombination_ID()); line.SetAmtSourceCr(drTotal); line.SetAmtAcctCr(drTotal); line.Save(); } // DR Entry = Loss if (Env.Signum(crTotal) != 0) { MJournalLine line = new MJournalLine(journal); line.SetLine(lineNo + 2); MAccount bas = MAccount.Get(GetCtx(), asDefaultAccts.GetUnrealizedLoss_Acct()); MAccount acct = MAccount.Get(GetCtx(), asDefaultAccts.GetAD_Client_ID(), AD_Org_ID, asDefaultAccts.GetC_AcctSchema_ID(), bas.GetAccount_ID(), bas.GetC_SubAcct_ID(), bas.GetM_Product_ID(), bas.GetC_BPartner_ID(), bas.GetAD_OrgTrx_ID(), bas.GetC_LocFrom_ID(), bas.GetC_LocTo_ID(), bas.GetC_SalesRegion_ID(), bas.GetC_Project_ID(), bas.GetC_Campaign_ID(), bas.GetC_Activity_ID(), bas.GetUser1_ID(), bas.GetUser2_ID(), bas.GetUserElement1_ID(), bas.GetUserElement2_ID()); line.SetDescription(Msg.GetElement(GetCtx(), "UnrealizedLoss_Acct")); line.SetC_ValidCombination_ID(acct.GetC_ValidCombination_ID()); line.SetAmtSourceDr(crTotal); line.SetAmtAcctDr(crTotal); line.Save(); } } // createBalancing