/// <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> /// Create Invoice Line /// </summary> /// <param name="C_Invoice_ID">invoice</param> /// <param name="C_Currency_ID">currency</param> /// <param name="GrandTotal">total</param> /// <param name="Open">amount</param> /// <param name="DaysDue">days due</param> /// <param name="IsInDispute">in dispute</param> /// <param name="C_BPartner_ID">bp</param> /// <param name="timesDunned">number of dunnings</param> /// <param name="daysAfterLast">days after last dunning</param> private void CreateInvoiceLine(int C_Invoice_ID, int C_Currency_ID, Decimal GrandTotal, Decimal Open, int DaysDue, bool IsInDispute, int C_BPartner_ID, int timesDunned, int daysAfterLast) { MDunningRunEntry entry = _run.GetEntry(C_BPartner_ID, _C_Currency_ID, _SalesRep_ID); if (entry.Get_ID() == 0) { if (!entry.Save()) { throw new Exception("Cannot save MDunningRunEntry"); } } // MDunningRunLine line = new MDunningRunLine(entry); line.SetInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open, new Decimal(0), DaysDue, IsInDispute, timesDunned, daysAfterLast); if (!line.Save()) { throw new Exception("Cannot save MDunningRunLine"); } }
/// <summary> /// Create Invoice Line on run tab of dunning run window. /// </summary> /// <param name="C_Invoice_ID">Invoice ID.</param> /// <param name="C_Currency_ID">Currency ID.</param> /// <param name="GrandTotal">Grand Total.</param> /// <param name="Open">Amount.</param> /// <param name="DaysDue">Days Due.</param> /// <param name="IsInDispute">In Dispute.</param> /// <param name="C_BPartner_ID">Business Partner.</param> /// <param name="timesDunned">Number of times dunning occurred.</param> /// <param name="daysAfterLast">Days after last dunning.</param> private bool CreateInvoiceLine(int C_Invoice_ID, int C_Currency_ID, Decimal GrandTotal, Decimal Open, int DaysDue, bool IsInDispute, int C_BPartner_ID, int timesDunned, int daysAfterLast, int PaySchedule_ID) { MDunningRunEntry entry = _run.GetEntry(C_BPartner_ID, _C_Currency_ID, _SalesRep_ID); if (entry.Get_ID() == 0) { if (!entry.Save()) { // Change by mohit to pick error message from last error in mclass. //throw new Exception(GetRetrievedError(entry, "Cannot save MDunningRunEntry")); //throw new Exception("Cannot save MDunningRunEntry"); ValueNamePair vp = VLogger.RetrieveError(); if (vp != null) { log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunEntry"), vp.GetName()); } else { log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunEntry"), ""); } return(false); } } // MDunningRunLine line = new MDunningRunLine(entry); line.SetInvoice(C_Invoice_ID, C_Currency_ID, GrandTotal, Open, new Decimal(0), DaysDue, IsInDispute, timesDunned, daysAfterLast); line.SetC_InvoicePaySchedule_ID(PaySchedule_ID); 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(false); } return(true); }
/// <summary> /// Create Payment Line on run tab of dunning run window. /// </summary> /// <param name="C_Payment_ID">Payment ID.</param> /// <param name="C_Currency_ID">Currency ID.</param> /// <param name="PayAmt">Amount.</param> /// <param name="openAmt">Open.</param> /// <param name="C_BPartner_ID">Business Partner ID.</param> private bool CreatePaymentLine(int C_Payment_ID, int C_Currency_ID, Decimal PayAmt, Decimal openAmt, int C_BPartner_ID) { MDunningRunEntry entry = _run.GetEntry(C_BPartner_ID, _C_Currency_ID, _SalesRep_ID); if (entry.Get_ID() == 0) { if (!entry.Save()) { // Change by mohit to pick error message from last error in mclass. //throw new Exception(GetRetrievedError(entry, "Cannot save MDunningRunEntry")); //throw new Exception("Cannot save MDunningRunEntry"); //log.SaveError("Cannot save MDunningRunEntry", ""); ValueNamePair vp = VLogger.RetrieveError(); if (vp != null) { string val = vp.GetName(); log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunEntry"), val); } else { log.SaveError(Msg.GetMsg(GetCtx(), "NotSaveDunRunEntry"), ""); } return(false); } } // MDunningRunLine line = new MDunningRunLine(entry); line.SetPayment(C_Payment_ID, C_Currency_ID, PayAmt, openAmt); 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(false); } return(true); }
/// <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))); } } }
/// <summary> /// Create Payment Line /// </summary> /// <param name="C_Payment_ID">payment</param> /// <param name="C_Currency_ID">currency</param> /// <param name="PayAmt">amount</param> /// <param name="openAmt">open</param> /// <param name="C_BPartner_ID">bp</param> private void CreatePaymentLine(int C_Payment_ID, int C_Currency_ID, Decimal PayAmt, Decimal openAmt, int C_BPartner_ID) { MDunningRunEntry entry = _run.GetEntry(C_BPartner_ID, _C_Currency_ID, _SalesRep_ID); if (entry.Get_ID() == 0) { if (!entry.Save()) { throw new Exception("Cannot save MDunningRunEntry"); } } // MDunningRunLine line = new MDunningRunLine(entry); line.SetPayment(C_Payment_ID, C_Currency_ID, PayAmt, openAmt); if (!line.Save()) { throw new Exception("Cannot save MDunningRunLine"); } }