/// <summary> /// Add fee line on run tab of dunning run window. /// </summary> private void AddFees() { // Only add a fee if it contains InvoiceLines and is not a statement // TODO: Assumes Statement = -9999 and bool onlyInvoices = _level.GetDaysAfterDue().Equals(new Decimal(-9999)); MDunningRunEntry[] entries = _run.GetEntries(true, onlyInvoices); if (entries != null && entries.Length > 0) { for (int i = 0; i < entries.Length; i++) { MDunningRunLine line = new MDunningRunLine(entries[i]); line.SetFee(_C_Currency_ID, _level.GetFeeAmt()); if (!line.Save()) { // Change by mohit to pick error message from last error in mclass. //throw new Exception(GetRetrievedError(line, "Cannot save MDunningRunLine")); //throw new Exception("Cannot save MDunningRunLine"); ValueNamePair vp = VLogger.RetrieveError(); if (vp != null) { log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunLine"), vp.GetName()); } else { log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunLine"), ""); } return; } entries[i].SetQty(Decimal.Subtract(entries[i].GetQty(), new Decimal(1))); } } }
/// <summary> /// Add Fees for every line /// </summary> private void AddFees() { // Only add a fee if it contains InvoiceLines and is not a statement // TODO: Assumes Statement = -9999 and bool onlyInvoices = _level.GetDaysAfterDue().Equals(new Decimal(-9999)); MDunningRunEntry[] entries = _run.GetEntries(true, onlyInvoices); if (entries != null && entries.Length > 0) { for (int i = 0; i < entries.Length; i++) { MDunningRunLine line = new MDunningRunLine(entries[i]); line.SetFee(_C_Currency_ID, _level.GetFeeAmt()); if (!line.Save()) { throw new Exception("Cannot save MDunningRunLine"); } entries[i].SetQty(Decimal.Subtract(entries[i].GetQty(), new Decimal(1))); } } }