Esempio n. 1
0
        /// <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);
        }