/// <summary> /// Load Invoice Line /// </summary> /// <param name="journal"></param> /// <returns>DocLine Array</returns> private DocLine[] LoadLines(MJournal journal) { List <DocLine> list = new List <DocLine>(); MJournalLine[] lines = journal.GetLines(false); for (int i = 0; i < lines.Length; i++) { MJournalLine line = lines[i]; DocLine docLine = new DocLine(line, this); // -- Source Amounts docLine.SetAmount(line.GetAmtSourceDr(), line.GetAmtSourceCr()); // -- Converted Amounts docLine.SetConvertedAmt(_C_AcctSchema_ID, line.GetAmtAcctDr(), line.GetAmtAcctCr()); // -- Account MAccount account = line.GetAccount(); docLine.SetAccount(account); // -- Quantity docLine.SetQty(line.GetQty(), false); // -- Date docLine.SetDateAcct(journal.GetDateAcct()); // -- Organization of Line was set to Org of Account list.Add(docLine); } // Return Array int size = list.Count; DocLine[] dls = new DocLine[size]; dls = list.ToArray(); return(dls); }
/// <summary> /// Load Invoice Line /// </summary> /// <param name="journal"></param> /// <returns>DocLine Array</returns> private DocLine[] LoadLines(MJournal journal) { MAcctSchema mSc = new MAcctSchema(GetCtx(), _C_AcctSchema_ID, null); List <DocLine> list = new List <DocLine>(); MJournalLine[] lines = journal.GetLines(false); record_Id = lines[0].GetGL_Journal_ID(); for (int i = 0; i < lines.Length; i++) { MJournalLine line = lines[i]; if (line.GetElementType() == null) { DocLine docLine = new DocLine(line, this); // -- Source Amounts docLine.SetAmount(line.GetAmtAcctDr(), line.GetAmtAcctCr()); // -- Converted Amounts // no need to update converted amount here //docLine.SetConvertedAmt(_C_AcctSchema_ID, line.GetAmtAcctDr(), line.GetAmtAcctCr()); // -- Account MAccount account = line.GetAccount(); docLine.SetAccount(account); // -- Quantity docLine.SetQty(line.GetQty(), false); // -- Date docLine.SetDateAcct(journal.GetDateAcct()); // -- Organization of Line was set to Org of Account list.Add(docLine); } else { string sql = "SELECT * FROM GL_LineDimension WHERE GL_JournalLine_ID=" + line.Get_ID(); DataSet ds = DB.ExecuteDataset(sql); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int m = 0; m < ds.Tables[0].Rows.Count; m++) { DataRow dr = ds.Tables[0].Rows[m]; X_GL_LineDimension lDim = new X_GL_LineDimension(GetCtx(), dr, null); DocLine docLine = new DocLine(lDim, this); // -- Source Amounts decimal cRate = line.GetCurrencyRate(); if (cRate == 0) { cRate = 1; } decimal amtAcctCr = 0; decimal amtAcctDr = 0; //MAcctSchema mSc = new MAcctSchema(GetCtx(), _C_AcctSchema_ID, null); if (line.GetAmtSourceDr() != 0) { amtAcctDr = lDim.GetAmount() * cRate; docLine.SetAmount(amtAcctDr, 0); amtAcctDr = Decimal.Round(amtAcctDr, mSc.GetStdPrecision()); } else { amtAcctCr = lDim.GetAmount() * cRate; docLine.SetAmount(0, amtAcctCr); amtAcctCr = Decimal.Round(amtAcctCr, mSc.GetStdPrecision()); } // -- Converted Amounts // no need to update converted amount here //docLine.SetConvertedAmt(_C_AcctSchema_ID, amtAcctDr, amtAcctCr); // -- Account MAccount account = line.GetAccount(); docLine.SetAccount(account); // -- Quantity docLine.SetQty(lDim.GetQty(), false); // -- Date docLine.SetDateAcct(journal.GetDateAcct()); // -- User Dimension docLine = SetUserDimension(lDim, docLine); // -- Organization of Line was set to Org of Account list.Add(docLine); } } } } // Return Array int size = list.Count; DocLine[] dls = new DocLine[size]; dls = list.ToArray(); return(dls); }