private void SendEmail(DebtorTransOpenClient debtorTransOpen)
        {
            var             postType   = debtorTransOpen.Trans._PostType;
            DebtorEmailType emailType  = DebtorEmailType.InterestNote;
            bool            isInterest = false;

            if (postType != (byte)DCPostType.Collection && postType != (byte)DCPostType.CollectionLetter && postType != (byte)DCPostType.InterestFee && postType != (byte)DCPostType.PaymentCharge)
            {
                if (postType == (byte)DCPostType.Invoice || postType == (byte)DCPostType.Creditnote)
                {
                    AddDockItem(TabControls.Invoices, debtorTransOpen, string.Format("{0}: {1}", postType == (byte)DCPostType.Invoice ? Uniconta.ClientTools.Localization.lookup("Invoice") :
                                                                                     Uniconta.ClientTools.Localization.lookup("Creditnote"), debtorTransOpen.Invoice));
                }

                return;
            }

            if (postType == (byte)DCPostType.InterestFee)
            {
                isInterest = true;
            }
            if (postType == (byte)DCPostType.Collection)
            {
                emailType = DebtorEmailType.Collection;
            }
            else
            {
                CWCollectionLetter collectionLetterWin = new CWCollectionLetter();
                collectionLetterWin.Closed += delegate
                {
                    if (collectionLetterWin.DialogResult == true)
                    {
                        if (!Enum.TryParse(collectionLetterWin.Result, out emailType))
                        {
                            return;
                        }
                    }
                };
                collectionLetterWin.Show();
            }


            var cwSendInvoice = new CWSendInvoice();

#if !SILVERLIGHT
            cwSendInvoice.DialogTableId = 2000000031;
#endif
            cwSendInvoice.Closed += delegate
            {
                var selectedRow = new DebtorTransOpenClient[] { debtorTransOpen };
                var feelist     = new[] { debtorTransOpen.Amount };

                if (cwSendInvoice.DialogResult == true)
                {
                    DebtorPayments.ExecuteDebtorCollection(api, busyIndicator, selectedRow, feelist, null, false, emailType, cwSendInvoice.Emails,
                                                           cwSendInvoice.sendOnlyToThisEmail, isInterest);
                }
            };
            cwSendInvoice.Show();
        }
Exemplo n.º 2
0
        void SendReport(IEnumerable <DebtorTransPayment> paymentList, string emails = null, bool onlyThisEmail = false)
        {
            var dcTransOpenClientlist = paymentList;
            var n = dcTransOpenClientlist.Count();

            if (n > 0)
            {
                var feelist = new double[n];
                int i       = 0;
                foreach (var r in dcTransOpenClientlist)
                {
                    feelist[i++] = r._FeeAmount;
                }

                if (!AddInterest)
                {
                    if (string.IsNullOrEmpty(collectionType))
                    {
#if !SILVERLIGHT
                        var selectedCollectionType = SelectCollectionType();
                        if (selectedCollectionType > -1)
                        {
                            GetResult(dcTransOpenClientlist, feelist, AddInterest, (DebtorEmailType)selectedCollectionType, emails, onlyThisEmail);
                        }
#elif SILVERLIGHT
                        var collectionLetterWin = new CWCollectionLetter();
                        collectionLetterWin.Closed += delegate
                        {
                            if (collectionLetterWin.DialogResult == true)
                            {
                                int indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionLetterWin.Result);
                                GetResult(dcTransOpenClientlist, feelist, AddInterest, (DebtorEmailType)indexDebtorEmailType, emails, onlyThisEmail);
                            }
                            else
                            {
                                busyIndicator.IsBusy = false;
                                return;
                            }
                        };
                        collectionLetterWin.Show();
#endif
                    }
                    else
                    {
                        int indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionType);
                        GetResult(dcTransOpenClientlist, feelist, AddInterest, (DebtorEmailType)indexDebtorEmailType, emails, onlyThisEmail);
                    }
                }
                else
                {
                    GetResult(dcTransOpenClientlist, feelist, AddInterest, DebtorEmailType.InterestNote, emails, onlyThisEmail);
                }
            }
        }
Exemplo n.º 3
0
        private int SelectCollectionType()
        {
            int collectionType = -1;

            CWCollectionLetter collectionLetterWin = new CWCollectionLetter();

            collectionLetterWin.Closed += delegate
            {
                if (collectionLetterWin.DialogResult == true)
                {
                    collectionType = AppEnums.DebtorEmailType.IndexOf(collectionLetterWin.Result);
                }
                else
                {
                    collectionType = -1;
                }
            };
            collectionLetterWin.Show();
            return(collectionType);
        }
Exemplo n.º 4
0
        void SendReport(IEnumerable <DebtorTransPayment> dcTransOpenClientlist, string emails = null, bool onlyThisEmail = false)
        {
            var n = dcTransOpenClientlist.Count();

            if (n > 0)
            {
                double[] chargelist = null;
                var      feelist    = new double[n];
                int      i          = -1;
                foreach (var r in dcTransOpenClientlist)
                {
                    feelist[++i] = r._FeeAmount;
                    if (r._PaymentCharge != 0d)
                    {
                        if (chargelist == null)
                        {
                            chargelist = new double[n];
                        }
                        chargelist[i] = r._PaymentCharge;
                    }
                }

                if (!AddInterest)
                {
                    if (string.IsNullOrEmpty(collectionType))
                    {
#if !SILVERLIGHT
                        var selectedCollectionType = SelectCollectionType();
                        if (selectedCollectionType >= 0)
                        {
                            GetResult(dcTransOpenClientlist, feelist, chargelist, chkShowCurrency.IsChecked == true, (DebtorEmailType)selectedCollectionType, emails, onlyThisEmail);
                        }
#elif SILVERLIGHT
                        var collectionLetterWin = new CWCollectionLetter();
                        collectionLetterWin.Closed += delegate
                        {
                            if (collectionLetterWin.DialogResult == true)
                            {
                                int indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionLetterWin.Result);
                                GetResult(dcTransOpenClientlist, feelist, chargelist, AddInterest, (DebtorEmailType)indexDebtorEmailType, emails, onlyThisEmail);
                            }
                            else
                            {
                                busyIndicator.IsBusy = false;
                                return;
                            }
                        };
                        collectionLetterWin.Show();
#endif
                    }
                    else
                    {
                        int indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionType);
#if !SILVERLIGHT
                        GetResult(dcTransOpenClientlist, feelist, chargelist, chkShowCurrency.IsChecked == true, (DebtorEmailType)indexDebtorEmailType, emails, onlyThisEmail);
#else
                        GetResult(dcTransOpenClientlist, feelist, chargelist, AddInterest, (DebtorEmailType)indexDebtorEmailType, emails, onlyThisEmail);
#endif
                    }
                }
                else
#if !SILVERLIGHT
                { GetResult(dcTransOpenClientlist, feelist, chargelist, chkShowCurrency.IsChecked == true, DebtorEmailType.InterestNote, emails, onlyThisEmail); }
#else
                { GetResult(dcTransOpenClientlist, feelist, chargelist, AddInterest, DebtorEmailType.InterestNote, emails, onlyThisEmail); }
#endif
            }
        }
Exemplo n.º 5
0
        async private void PrintData()
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
                //Get Company related details

                byte[] logo = await UtilDisplay.GetLogo(api);

                var Comp = api.CompanyEntity;

                var companyClient = Comp.CreateUserType <CompanyClient>();
                StreamingManager.Copy(Comp, companyClient);

                lastMessage = null; // just to reload message in case it has changed
                LoadDataForReport();
#if SILVERLIGHT
                if (dgDebtorTranOpenGrid.SelectedItem != null)
                {
                    var selectedAccount = ((DebtorTransPayment)dgDebtorTranOpenGrid.SelectedItem).Account;
                    var selectedItem    = statementList.Where(p => p.AccountNumber == selectedAccount).First() as DebtorPaymentStatementList;

                    if (string.IsNullOrEmpty(collectionType))
                    {
                        CWCollectionLetter cwCollectionLetter = new CWCollectionLetter();
                        cwCollectionLetter.Closed += async delegate
                        {
                            if (cwCollectionLetter.DialogResult == true)
                            {
                                await PrintDebtorPaymentStatementPage(companyClient, logo, selectedItem, cwCollectionLetter.Result);
                            }
                        };
                        cwCollectionLetter.Show();
                    }
                    else
                    {
                        await PrintDebtorPaymentStatementPage(companyClient, logo, selectedItem, collectionType);
                    }
                }
#else
                int indexDebtorEmailType = 0;

                if (string.IsNullOrEmpty(collectionType))
                {
                    indexDebtorEmailType = SelectCollectionType();
                }
                else
                {
                    indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionType);
                }
                if (indexDebtorEmailType == -1)
                {
                    return;
                }

                var debtorEmailType = (DebtorEmailType)indexDebtorEmailType;
                var date            = BasePage.GetSystemDefaultDate();

                var xtraReports = await GeneratePrintReport(statementList, companyClient, date, logo, debtorEmailType);

                if (xtraReports.Count() > 0)
                {
                    var reportName = AddInterest ? Uniconta.ClientTools.Localization.lookup("InterestNote") : Uniconta.ClientTools.Localization.lookup("CollectionLetter");
                    var dockName   = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Preview"), reportName);
                    AddDockItem(UnicontaTabs.StandardPrintReportPage, new object[] { xtraReports, reportName }, dockName);
                }
#endif
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("DebtorPayment.PrintData(), CompanyId={0}", api.CompanyId));
                UnicontaMessageBox.Show(ex);
            }
            finally
            {
                busyIndicator.IsBusy = false;
            }
        }
Exemplo n.º 6
0
        async private void PrintData()
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
                //Get Company related details

                byte[] logo = await UtilDisplay.GetLogo(api);

                var Comp = api.CompanyEntity;

                var companyClient = new CompanyClient();
                StreamingManager.Copy(api.CompanyEntity, companyClient);

                LoadDataForReport();
#if SILVERLIGHT
                if (dgDebtorTranOpenGrid.SelectedItem != null)
                {
                    var selectedAccount = ((DebtorTransPayment)dgDebtorTranOpenGrid.SelectedItem).Account;
                    var selectedItem    = statementList.Where(p => p.AccountNumber == selectedAccount).First() as DebtorPaymentStatementList;
                    if (selectedItem.ChildRecords.Count == 0)
                    {
                        return;
                    }

                    if (string.IsNullOrEmpty(collectionType))
                    {
                        CWCollectionLetter cwCollectionLetter = new CWCollectionLetter();
                        cwCollectionLetter.Closed += async delegate
                        {
                            if (cwCollectionLetter.DialogResult == true)
                            {
                                await PrintDebtorPaymentStatementPage(companyClient, logo, selectedItem, cwCollectionLetter.Result);
                            }
                        };
                        cwCollectionLetter.Show();
                    }
                    else
                    {
                        await PrintDebtorPaymentStatementPage(companyClient, logo, selectedItem, collectionType);
                    }
                }
#else
                var layoutSelectedDebtorCollectionList = new Dictionary <string, List <IDebtorStandardReport> >();
                var comp           = api.CompanyEntity;
                var layoutgrpCache = comp.GetCache(typeof(DebtorLayoutGroup)) ?? await comp.LoadCache(typeof(DebtorLayoutGroup), api);

                var xtraReports = new List <IPrintReport>();

                int indexDebtorEmailType = 0;

                if (string.IsNullOrEmpty(collectionType))
                {
                    indexDebtorEmailType = SelectCollectionType();
                }
                else
                {
                    indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(collectionType);
                }
                if (indexDebtorEmailType == -1)
                {
                    return;
                }

                var debtorEmailType = (DebtorEmailType)indexDebtorEmailType;

                foreach (var debt in statementList.ToList())
                {
                    var selectedItem = debt as DebtorPaymentStatementList;
                    if (selectedItem.ChildRecords.Count == 0)
                    {
                        continue;
                    }

                    var collectionPrint = await GenerateStandardCollectionReport(companyClient, BasePage.GetSystemDefaultDate(), selectedItem, logo, debtorEmailType);

                    if (collectionPrint == null)
                    {
                        continue;
                    }

                    var standardReports = new IDebtorStandardReport[1] {
                        collectionPrint
                    };

                    IPrintReport standardPrint;
                    if (this.AddInterest)
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.InterestNote);
                    }
                    else
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.CollectionLetter);
                    }
                    await standardPrint.InitializePrint();

                    if (standardPrint.Report != null)
                    {
                        xtraReports.Add(standardPrint);
                    }
                }

                if (xtraReports.Count > 0)
                {
                    var reportName = AddInterest ? Uniconta.ClientTools.Localization.lookup("InterestNote") : Uniconta.ClientTools.Localization.lookup("CollectionLetter");
                    var dockName   = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Preview"), reportName);
                    AddDockItem(UnicontaTabs.StandardPrintReportPage, new object[] { xtraReports, reportName }, dockName);
                }
#endif
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("DebtorPayment.PrintData(), CompanyId={0}", api.CompanyId));
                UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"), MessageBoxButton.OK);
            }
            finally
            {
                busyIndicator.IsBusy = false;
            }
        }