Exemple #1
0
        public static void Release(PrintParameters filter, List <DetailsResult> list)
        {
            if (list.Count > 0)
            {
                bool failed = false;
                ARDunningLetterMaint graph = PXGraph.CreateInstance <ARDunningLetterMaint>();

                int i = 0;
                foreach (DetailsResult res in list)
                {
                    try
                    {
                        ARDunningLetter doc = PXSelect <ARDunningLetter,
                                                        Where <ARDunningLetter.dunningLetterID, Equal <Required <DetailsResult.dunningLetterID> > > > .Select(graph, res.DunningLetterID);

                        ARDunningLetterMaint.ReleaseProcess(graph, doc);
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                    }
                    catch (Exception e)
                    {
                        failed = true;
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(i, e);
                    }

                    i++;
                }

                if (failed)
                {
                    throw new PXException(Messages.OneOrMoreItemsAreNotReleased);
                }
            }
        }
Exemple #2
0
        public static void EmailStatements(PrintParameters filter, List <DetailsResult> list, bool markOnly)
        {
            ARStatementUpdate graph = CreateInstance <ARStatementUpdate>();
            int  i      = 0;
            bool failed = false;

            foreach (DetailsResult it in list)
            {
                try
                {
                    graph.EMailStatement(filter.BranchCD, it.CustomerID, filter.StatementDate, filter.CuryStatements == true? it.CuryID: null, markOnly, filter.ShowAll == true);
                    if (!markOnly)
                    {
                        it.Emailed = true;
                    }

                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetCurrentItem(it);

                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                }
                catch (Exception e)
                {
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(i, e);

                    failed = true;
                }
                i++;
            }
            if (failed)
            {
                throw new PXException(ErrorMessages.MailSendFailed);
            }
        }
Exemple #3
0
        public static void Email(PrintParameters filter, List <DetailsResult> list, bool markOnly)
        {
            ARDunningLetterUpdate graph = CreateInstance <ARDunningLetterUpdate>();
            int  i      = 0;
            bool failed = false;

            foreach (DetailsResult it in list)
            {
                try
                {
                    graph.EMailDL(it.DunningLetterID.Value, markOnly, filter.ShowAll == true);
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetCurrentItem(it);

                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                }
                catch (Exception e)
                {
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(i, e);

                    failed = true;
                }
                i++;
            }
            if (failed)
            {
                throw new PXException(ErrorMessages.MailSendFailed);
            }
        }
Exemple #4
0
        private static void RegenerateStatements(PrintParameters pars, List <DetailsResult> statements)
        {
            var process        = PXGraph.CreateInstance <StatementCycleProcessBO>();
            var cycle          = process.CyclesList.SelectSingle(pars.StatementCycleId);
            var customerSelect = new PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <DetailsResult.customerID> > > >(process);

            int             i         = 0;
            List <Customer> customers = new List <Customer>();

            foreach (DetailsResult res in statements)
            {
                if (ARStatementProcess.CheckForUnprocessedPPD(process, pars.StatementCycleId, pars.StatementDate, res.CustomerID))
                {
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(i,
                                                                                    new PXSetPropertyException(Messages.UnprocessedPPDExists, PXErrorLevel.RowError));
                }
                else
                {
                    Customer customer = customerSelect.SelectSingle(res.CustomerID);
                    if (customer != null)
                    {
                        customers.Add(customer);
                    }
                }
                i++;
            }

            if (cycle == null || customers.Any() == false)
            {
                return;
            }
            StatementCycleProcessBO.RegenerateStatements(process, cycle, customers);
        }
        public static void Print(PrintParameters filter, List <DetailsResult> list, bool markOnly)
        {
            bool failed = false;
            ARDunningLetterUpdate     graph = PXGraph.CreateInstance <ARDunningLetterUpdate>();
            PXReportRequiredException ex    = null;

            foreach (DetailsResult t in list)
            {
                int?            L   = t.DunningLetterID;
                ARDunningLetter doc = graph.DL.Select(L.Value);
                PXFilteredProcessing <DetailsResult, PrintParameters> .SetCurrentItem(t);

                if (doc.Released == false || doc.Voided == true)
                {
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(CA.Messages.DocumentStatusInvalid);

                    failed = true;
                    continue;
                }
                if (markOnly)
                {
                    if (filter.ShowAll != true)
                    {
                        doc.DontPrint = true;
                        graph.docs.Cache.Update(doc);
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                    }
                }
                else
                {
                    Dictionary <string, string> d = new Dictionary <string, string>();
                    d["ARDunningLetter.DunningLetterID"] = L.ToString();

                    if (doc.Printed != true)
                    {
                        doc.Printed = true;
                        graph.docs.Cache.Update(doc);
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                    }
                    ex = PXReportRequiredException.CombineReport(ex, GetCustomerReportID(graph, "AR661000", t), d);
                }
            }


            graph.Save.Press();

            if (ex != null)
            {
                throw ex;
            }

            if (failed)
            {
                throw new PXException(Messages.OneOrMoreItemsAreNotProcessed);
            }
        }
        private static void _createPayments(List <ARInvoice> list, PayBillsFilter filter, CurrencyInfo info)
        {
            bool           failed = false;
            ARPaymentEntry pe     = PXGraph.CreateInstance <ARPaymentEntry>();

            list.Sort((in1, in2) =>
            {
                if (in1.CustomerID != in2.CustomerID)
                {
                    return(((IComparable)in1.CustomerID).CompareTo(in2.CustomerID));
                }
                return(((IComparable)in1.PMInstanceID).CompareTo(in2.PMInstanceID));
            }
                      );
            for (int i = 0; i < list.Count; i++)
            {
                ARInvoice doc       = list[i];
                ARPayment pmt       = null;
                bool      docFailed = false;
                try
                {
                    pe.CreatePayment(doc, info, filter.PayDate, filter.PayFinPeriodID, false);
                    pmt = pe.Document.Current;
                    if (pmt != null)
                    {
                        pmt.Hold = false;

                        FinPeriodIDAttribute.SetPeriodsByMaster <ARPayment.finPeriodID>(pe.Document.Cache, pmt, filter.PayFinPeriodID);
                    }
                    pe.Save.Press();
                }
                catch (Exception e)
                {
                    PXFilteredProcessing <ARInvoice, PayBillsFilter> .SetError(i, e.Message);

                    docFailed = failed = true;
                }

                if (!docFailed)
                {
                    PXFilteredProcessing <ARInvoice, PayBillsFilter> .SetInfo(i, PXMessages.LocalizeFormatNoPrefixNLA(Messages.ARPaymentIsCreatedProcessingINProgress, pmt.RefNbr));
                }
            }
            if (failed)
            {
                throw new PXException(Messages.CreationOfARPaymentFailedForSomeInvoices);
            }
        }
        public static void Print(PrintParameters filter, List <DetailsResult> list, bool markOnly)
        {
            bool failed = false;
            ARDunningLetterUpdate     graph = PXGraph.CreateInstance <ARDunningLetterUpdate>();
            PXReportRequiredException reportRedirectException             = null;
            Dictionary <string, PXReportRequiredException> reportsToPrint = new Dictionary <string, PXReportRequiredException>();

            foreach (DetailsResult res in list)
            {
                int?            letterID = res.DunningLetterID;
                ARDunningLetter doc      = graph.DL.Select(letterID.Value);
                PXFilteredProcessing <DetailsResult, PrintParameters> .SetCurrentItem(res);

                if (doc.Released == false || doc.Voided == true)
                {
                    PXFilteredProcessing <DetailsResult, PrintParameters> .SetError(CA.Messages.DocumentStatusInvalid);

                    failed = true;
                    continue;
                }
                if (markOnly)
                {
                    if (filter.ShowAll != true)
                    {
                        doc.DontPrint = true;
                        graph.docs.Cache.Update(doc);
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                    }
                }
                else
                {
                    Dictionary <string, string> reportParameters = new Dictionary <string, string>();
                    reportParameters["ARDunningLetter.DunningLetterID"] = letterID.ToString();

                    if (doc.Printed != true)
                    {
                        doc.Printed = true;
                        graph.docs.Cache.Update(doc);
                        PXFilteredProcessing <DetailsResult, PrintParameters> .SetProcessed();
                    }

                    string actualReportID = GetCustomerReportID(graph, ARReports.DunningLetterReportID, res);

                    reportRedirectException = PXReportRequiredException.CombineReport(reportRedirectException, actualReportID, reportParameters);

                    reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint, reportParameters, filter, new NotificationUtility(graph).SearchPrinter, ARNotificationSource.Customer, ARReports.DunningLetterReportID, actualReportID, doc.BranchID);
                }
            }

            graph.Save.Press();

            if (reportRedirectException != null)
            {
                PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint);

                throw reportRedirectException;
            }

            if (failed)
            {
                throw new PXException(Messages.OneOrMoreItemsAreNotProcessed);
            }
        }
Exemple #8
0
        public static void CreatePayments(List <ARInvoice> list, PayBillsFilter filter, CurrencyInfo info)
        {
            Dictionary <ARPayment, List <int> > pmtRows = new Dictionary <ARPayment, List <int> >();

            bool             failed  = false;
            ARPaymentEntry   pe      = PXGraph.CreateInstance <ARPaymentEntry>();
            List <ARPayment> paylist = new List <ARPayment>();

            list.Sort((in1, in2) =>
            {
                if (in1.CustomerID != in2.CustomerID)
                {
                    return(((IComparable)in1.CustomerID).CompareTo(in2.CustomerID));
                }
                return(((IComparable)in1.PMInstanceID).CompareTo(in2.PMInstanceID));
            }
                      );
            for (int i = 0; i < list.Count; i++)
            {
                ARInvoice doc       = list[i];
                ARPayment pmt       = null;
                bool      docFailed = false;
                try
                {
                    pe.CreatePayment(doc, info, filter.PayDate, filter.PayFinPeriodID, false);
                    pmt = pe.Document.Current;
                    if (pmt != null)
                    {
                        if (!paylist.Contains(pmt))
                        {
                            if (String.IsNullOrEmpty(pmt.ExtRefNbr))
                            {
                                pe.Document.Current.ExtRefNbr = string.Format(Messages.ARAutoPaymentRefNbrFormat, filter.PayDate.Value);
                            }
                            paylist.Add(pmt);
                        }
                        if (!pmtRows.ContainsKey(pmt))
                        {
                            pmtRows[pmt] = new List <int>();
                        }
                        pmtRows[pmt].Add(i);

                        pmt.Hold        = false;
                        pmt.FinPeriodID = filter.PayFinPeriodID;
                    }
                    pe.Save.Press();
                }
                catch (Exception e)
                {
                    PXFilteredProcessing <PayBillsFilter, ARInvoice> .SetError(i, e.Message);

                    docFailed = failed = true;
                }

                if (!docFailed)
                {
                    PXFilteredProcessing <PayBillsFilter, ARInvoice> .SetInfo(i, string.Format(Messages.ARPaymentIsCreatedProcessingINProgress, pmt.RefNbr));
                }
            }
            if (failed)
            {
                throw new PXException(Messages.CreationOfARPaymentFailedForSomeInvoices);
            }
        }