Exemplo n.º 1
0
        async private void CreateProductionReport(ProductionOrderClient productionOrder)
        {
            var companyClient = Utility.GetCompanyClientUserInstance(api.CompanyEntity);
            var getLogo       = await UtilDisplay.GetLogo(api);

            var productionOrderLines = await api.Query <ProductionOrderLineClient>(productionOrder);

            if (productionOrderLines != null && productionOrderLines.Length > 0)
            {
                var productionReportSource = new ProductionStandardReportClient(companyClient, productionOrder, productionOrderLines, getLogo, Uniconta.ClientTools.Localization.lookup("ProductionOrder"));
                var standardReportSrc      = new IProductionStandardReport[] { productionReportSource };
                var standardPrint          = new StandardPrintReport(api, standardReportSrc, (int)StandardReports.ProductionOrder);
                await standardPrint.InitializePrint();

                if (standardPrint?.Report != null)
                {
                    AddDockItem(TabControls.StandardPrintReportPage, new object[] { new DevExpress.XtraReports.UI.XtraReport[] { standardPrint.Report } },
                                string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), productionOrder.ProductionNumber));
                }
            }
            else
            {
                UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("NoLinesFound"), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OK);
            }
        }
Exemplo n.º 2
0
        async private Task <IEnumerable <IPrintReport> > GeneratePrintReport(IEnumerable <DebtorPaymentStatementList> paymentStatementList, CompanyClient companyClient, DateTime date, byte[] logo, DebtorEmailType debtorEmailType)
        {
            var iprintReportList = new List <IPrintReport>();

            foreach (var debt in paymentStatementList.ToList())
            {
                var selectedItem    = debt as DebtorPaymentStatementList;
                var collectionPrint = await GenerateStandardCollectionReport(companyClient, date, selectedItem, logo, debtorEmailType);

                if (collectionPrint == null)
                {
                    continue;
                }

                var standardReports = new[] { collectionPrint };
                var standardPrint   = new StandardPrintReport(api, standardReports, this.AddInterest ? chkShowCurrency.IsChecked == true ? (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.InterestNoteCurrency :
                                                              (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.InterestNote : chkShowCurrency.IsChecked == true ? (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.CollectionLetterCurrency :
                                                              (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.CollectionLetter);
                await standardPrint.InitializePrint();

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

            return(iprintReportList);
        }
        async private Task <IPrintReport> ValidateStandardPrint(InvoicePostingResult invoicePostingResult, ProjectClient project, CompanyLayoutType layoutType)
        {
            busyIndicator.IsBusy = true;
            busyIndicator.BusyContent = string.Format("{0}..{1}: {2}", Uniconta.ClientTools.Localization.lookup("LoadingMsg"), Uniconta.ClientTools.Localization.lookup("Project"), project?._Number);
            IPrintReport standardPrint = null;

            try
            {
                var debtorInvoicePrint = new DebtorInvoicePrintReport(invoicePostingResult, api, layoutType);
                var isInitializedSuccess = await debtorInvoicePrint.InstantiateFields();

                if (isInitializedSuccess)
                {
                    var standardDebtorInvoice = new DebtorInvoiceReportClient(debtorInvoicePrint.Company, debtorInvoicePrint.Debtor, debtorInvoicePrint.DebtorInvoice, debtorInvoicePrint.InvTransInvoiceLines, debtorInvoicePrint.DebtorOrder,
                                                                              debtorInvoicePrint.CompanyLogo, debtorInvoicePrint.ReportName, isCreditNote: debtorInvoicePrint.IsCreditNote, messageClient: debtorInvoicePrint.MessageClient);
                    standardPrint = new StandardPrintReport(api, new[] { standardDebtorInvoice }, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Invoice);
                    standardPrint = new LayoutPrintReport(api, invoicePostingResult, layoutType);
                }
                await standardPrint.InitializePrint();

                if (standardPrint?.Report == null)
                {
                    standardPrint = new LayoutPrintReport(api, invoicePostingResult, layoutType);
                    await standardPrint.InitializePrint();
                }
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("ProjectMultiLineInvoicePage.ValidateStandardPrint(), CompanyId={0}", api.CompanyId));
            }
            finally { busyIndicator.IsBusy = false; }

            return(standardPrint);
        }
Exemplo n.º 4
0
        private static async Task <IPrintReport> StandardPrint(CreditorInvoiceClient creditorInvoice, CrudAPI crudApi)
        {
            var creditorInvoicePrint = new UnicontaClient.Pages.CreditorPrintReport(creditorInvoice, crudApi);
            var isInitializedSuccess = await creditorInvoicePrint.InstantiateFields();

            if (isInitializedSuccess)
            {
                var standardCreditorInvoice = new CreditorStandardReportClient(creditorInvoicePrint.Company, creditorInvoicePrint.Creditor, creditorInvoicePrint.CreditorInvoice, creditorInvoicePrint.InvTransInvoiceLines, creditorInvoicePrint.CreditorOrder,
                                                                               creditorInvoicePrint.CompanyLogo, creditorInvoicePrint.ReportName, (int)Uniconta.ClientTools.Controls.Reporting.StandardReports.PurchaseInvoice, creditorInvoicePrint.CreditorMessage, creditorInvoicePrint.IsCreditNote);

                var iprintReport = new StandardPrintReport(crudApi, new[] { standardCreditorInvoice }, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.PurchaseInvoice)
                {
                    UseReportCache = true
                };
                await iprintReport.InitializePrint();

                if (iprintReport.Report != null)
                {
                    return(iprintReport);
                }

                var layoutReport = new LayoutPrintReport(crudApi, creditorInvoice);
                await layoutReport.InitializePrint();

                return(layoutReport);
            }
            return(null);
        }
Exemplo n.º 5
0
        public static async Task <IPrintReport> StandardPrint(DebtorInvoiceClient debtorInvoice, CrudAPI crudapi)
        {
            var debtorInvoicePrint   = new UnicontaClient.Pages.DebtorInvoicePrintReport(debtorInvoice, crudapi);
            var isInitializedSuccess = await debtorInvoicePrint.InstantiateFields();

            if (isInitializedSuccess)
            {
                var standardDebtorInvoice = new DebtorInvoiceReportClient(debtorInvoicePrint.Company, debtorInvoicePrint.Debtor, debtorInvoicePrint.DebtorInvoice, debtorInvoicePrint.InvTransInvoiceLines, debtorInvoicePrint.DebtorOrder,
                                                                          debtorInvoicePrint.CompanyLogo, debtorInvoicePrint.ReportName, isCreditNote: debtorInvoicePrint.IsCreditNote, messageClient: debtorInvoicePrint.MessageClient);

                var iprintReport = new StandardPrintReport(crudapi, new[] { standardDebtorInvoice }, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Invoice)
                {
                    UseReportCache = true
                };
                await iprintReport.InitializePrint();

                if (iprintReport.Report != null)
                {
                    return(iprintReport);
                }

                //Call LayoutInvoice
                var layoutReport = new LayoutPrintReport(crudapi, debtorInvoice);
                layoutReport.SetupLayoutPrintFields(debtorInvoicePrint);
                await layoutReport.InitializePrint();

                return(layoutReport);
            }
            return(null);
        }
        private static async Task <IPrintReport> StandardPrint(CreditorInvoiceClient creditorInvoice, CrudAPI crudApi)
        {
            IPrintReport iprintReport         = null;
            var          creditorInvoicePrint = new UnicontaClient.Pages.CreditorPrintReport(creditorInvoice, crudApi);
            var          isInitializedSuccess = await creditorInvoicePrint.InstantiaeFields();

            if (isInitializedSuccess)
            {
                var standardCreditorInvoice = new CreditorStandardReportClient(creditorInvoicePrint.Company, creditorInvoicePrint.Creditor, creditorInvoicePrint.CreditorInvoice, creditorInvoicePrint.InvTransInvoiceLines, null,
                                                                               creditorInvoicePrint.CompanyLogo, creditorInvoicePrint.ReportName, (int)Uniconta.ClientTools.Controls.Reporting.StandardReports.PurchaseInvoice);

                var standardReports = new ICreditorStandardReport[1] {
                    standardCreditorInvoice
                };

                iprintReport = new StandardPrintReport(crudApi, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.PurchaseInvoice);
                await iprintReport.InitializePrint();

                if (iprintReport?.Report == null)
                {
                    iprintReport = new LayoutPrintReport(crudApi, creditorInvoice);
                    await iprintReport.InitializePrint();
                }
            }
            return(iprintReport);
        }
        public static async Task <IPrintReport> StandardPrint(DebtorInvoiceClient debtorInvoice, CrudAPI crudapi)
        {
            IPrintReport iprintReport         = null;
            var          debtorInvoicePrint   = new UnicontaClient.Pages.DebtorInvoicePrintReport(debtorInvoice, crudapi);
            var          isInitializedSuccess = await debtorInvoicePrint.InstantiateFields();

            if (isInitializedSuccess)
            {
                var standardDebtorInvoice = new DebtorInvoiceReportClient(debtorInvoicePrint.Company, debtorInvoicePrint.Debtor, debtorInvoicePrint.DebtorInvoice, debtorInvoicePrint.InvTransInvoiceLines, null,
                                                                          debtorInvoicePrint.CompanyLogo, debtorInvoicePrint.ReportName, isCreditNote: debtorInvoicePrint.IsCreditNote, messageClient: debtorInvoicePrint.MessageClient);

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

                iprintReport = new StandardPrintReport(crudapi, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Invoice);
                await iprintReport.InitializePrint();


                if (iprintReport?.Report == null)
                {
                    iprintReport = new LayoutPrintReport(crudapi, debtorInvoice);
                    await iprintReport.InitializePrint();
                }
            }

            return(iprintReport);
        }
        async private void PrintData()
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
                //Get Company related details
                var companyClient = new CompanyClient();
                StreamingManager.Copy(api.CompanyEntity, companyClient);
                byte[] getLogoBytes = await UtilDisplay.GetLogo(api);

#if SILVERLIGHT
                if (dgDebtorTrans.SelectedItem != null)
                {
                    var selectedItem = dgDebtorTrans.SelectedItem as DebtorStatementList;
                    if (selectedItem.ChildRecords.Count == 0)
                    {
                        return;
                    }

                    var debt = new DebtorClient();
                    StreamingManager.Copy(selectedItem.deb, debt);
                    if (debt != null)
                    {
                        debt.Transactions = selectedItem.ChildRecords;

                        //Setting the Localization for the debtor
                        var debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(UtilDisplay.GetLanguage(debt, api.CompanyEntity));
                        foreach (var rec in debt.Transactions)
                        {
                            rec.LocOb = debtLocalize;
                        }

                        var debtorMessageClient = await Utility.GetDebtorMessageClient(api, debt._Language, DebtorEmailType.AccountStatement);

                        string messageText = debtorMessageClient?._Text;

                        DebtorStatementCustomPrint dbStatementCustomPrint = new DebtorStatementCustomPrint(api, selectedItem, companyClient, debt,
                                                                                                           txtDateFrm.DateTime, txtDateTo.DateTime, getLogoBytes, messageText);

                        object[] obj = new object[1];
                        obj[0] = dbStatementCustomPrint as Controls.CustomPrintTemplateData;
                        if (chkShowCurrency.IsChecked == true)
                        {
                            AddDockItem(TabControls.DebtorStatementCurrencyCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                        }
                        else
                        {
                            AddDockItem(TabControls.DebtorStatementCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                        }
                    }
                }
#else
                IEnumerable <DebtorStatementList> debtorStatementList = (IEnumerable <DebtorStatementList>)dgDebtorTrans.ItemsSource;
                var layoutSelectedDebtorStatementList = new Dictionary <string, List <DebtorStatementList> >();

                var Comp           = api.CompanyEntity;
                var layoutgrpCache = Comp.GetCache(typeof(Uniconta.DataModel.DebtorLayoutGroup));
                if (layoutgrpCache == null)
                {
                    layoutgrpCache = await Comp.LoadCache(typeof(Uniconta.DataModel.DebtorLayoutGroup), api);
                }

                var xtraReports = new List <DevExpress.XtraReports.UI.XtraReport>();
                var iReports    = new List <IPrintReport>();
                var marked      = debtorStatementList.Any(m => m.Mark == true);

                foreach (var db in debtorStatementList)
                {
                    if (db.ChildRecords.Count == 0 || (marked && !db.Mark))
                    {
                        continue;
                    }

                    var statementPrint = await GenerateStandardStatementReport(companyClient, txtDateFrm.DateTime, txtDateTo.DateTime, db, getLogoBytes);

                    if (statementPrint == null)
                    {
                        continue;
                    }

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

                    IPrintReport standardPrint;
                    if (chkShowCurrency.IsChecked == true)
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.StatementCurrency);
                    }
                    else
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Statement);
                    }
                    await standardPrint.InitializePrint();

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

                if (iReports.Count > 0)
                {
                    var dockJName = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Preview"), Uniconta.ClientTools.Localization.lookup("Statement"));
                    AddDockItem(UnicontaTabs.StandardPrintReportPage, new object[] { iReports, Uniconta.ClientTools.Localization.lookup("Statement") }, dockJName);
                }
#endif
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("DebtorStatement.PrintData(), CompanyId={0}", api.CompanyId));
                UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"), MessageBoxButton.OK);
            }
            finally { busyIndicator.IsBusy = false; }
        }
        async private Task <IEnumerable <IPrintReport> > GeneratePrintReport(IEnumerable <DebtorStatementList> statementList, bool marked, bool hasCurrency, bool applyGridFilter)
        {
            var iprintReportList = new List <IPrintReport>();

            //Get Company related details

            var companyClient = api.CompanyEntity.CreateUserType <CompanyClient>();

            StreamingManager.Copy(api.CompanyEntity, companyClient);
            byte[] getLogoBytes = await UtilDisplay.GetLogo(api);

            int rowHandle = -1;

            foreach (var db in statementList)
            {
                rowHandle = rowHandle + 1;

                if (db.ChildRecords.Length == 0 || (marked && !db.Mark))
                {
                    continue;
                }

                if (applyGridFilter)
                {
                    var visibelDetails = dgDebtorTrans.GetVisibleDetail(rowHandle);
                    if (visibelDetails == null || visibelDetails.VisibleItems?.Count == 0)
                    {
                        continue;
                    }
                }

                var lan = UtilDisplay.GetLanguage(db.deb, companyClient);

                //Setting the Localization for the debtor
                var debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(lan);
                foreach (var rec in db.ChildRecords)
                {
                    rec.LocOb = debtLocalize;
                    if (rec._Primo)
                    {
                        rec._Text = debtLocalize.Lookup("Primo");
                    }
                }

                var debtorType = Uniconta.Reports.Utilities.ReportUtil.GetUserType(typeof(DebtorClient), api.CompanyEntity);
                var debt       = Activator.CreateInstance(debtorType) as DebtorClient;
                StreamingManager.Copy(db.deb, debt);
                debt.Transactions = applyGridFilter ? dgDebtorTrans.GetVisibleDetail(rowHandle).VisibleItems.Cast <DebtorTransClientTotal>() : db.ChildRecords;

                if (lastMessage == null || messageLanguage != lan)
                {
                    messageLanguage = lan;
                    var msg = await Utility.GetDebtorMessageClient(api, lan, DebtorEmailType.AccountStatement);

                    if (msg != null)
                    {
                        lastMessage = msg._Text;
                    }
                    else
                    {
                        lastMessage = string.Empty;
                    }
                }

                var statementPrint  = new DebtorStatementReportClient(companyClient, debt, txtDateFrm.DateTime, txtDateTo.DateTime, "Statement", getLogoBytes, lastMessage);
                var standardReports = new[] { statementPrint };
                var standardPrint   = new StandardPrintReport(api, standardReports, hasCurrency ? (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.StatementCurrency : (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Statement);
                await standardPrint.InitializePrint();

                if (standardPrint.Report != null)
                {
                    iprintReportList.Add(standardPrint);
                }
            }
            return(iprintReportList);
        }
Exemplo n.º 10
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;
            }
        }