async private Task <DebtorCollectionReportClient> GenerateStandardCollectionReport(CompanyClient companyClient, DateTime dueDate, DebtorPaymentStatementList selectedItem, byte[] logo, DebtorEmailType debtorEmailType) { var dbClientTotal = selectedItem.ChildRecords.FirstOrDefault(); var debtorType = Uniconta.Reports.Utilities.ReportUtil.GetUserType(typeof(DebtorClient), api.CompanyEntity); var debtorClient = Activator.CreateInstance(debtorType) as DebtorClient; StreamingManager.Copy(dbClientTotal.Debtor, debtorClient); var lan = UtilDisplay.GetLanguage(debtorClient, companyClient); if (lastMessage == null || messageLanguage != lan) { messageLanguage = lan; var res = await Utility.GetDebtorMessageClient(api, lan, debtorEmailType); if (res != null) { lastMessage = res._Text; } else { lastMessage = string.Empty; } } debtorClient.OpenTransactions = selectedItem.ChildRecords.ToArray(); string _reportName = StandardReportUtility.GetLocalizedReportName(debtorClient, companyClient, debtorEmailType.ToString()); return(new DebtorCollectionReportClient(companyClient, debtorClient, dueDate, logo, this.AddInterest, _reportName, lastMessage)); }
async private Task PrintDebtorPaymentStatementPage(CompanyClient companyClient, byte[] logo, DebtorPaymentStatementList selectedItem, string emailType) { int indexDebtorEmailType = AppEnums.DebtorEmailType.IndexOf(emailType); var debtorEmailType = (DebtorEmailType)indexDebtorEmailType; var dbClientTotal = selectedItem.ChildRecords.FirstOrDefault(); if (dbClientTotal != null) { var debtorClient = new DebtorClient(); StreamingManager.Copy(dbClientTotal.Debtor, debtorClient); var lan = UtilDisplay.GetLanguage(debtorClient, companyClient); if (lastMessage == null || messageLanguage != lan) { messageLanguage = lan; var res = await Utility.GetDebtorMessageClient(api, lan, debtorEmailType); if (res != null) { lastMessage = res._Text; } else { lastMessage = string.Empty; } } var dbStatementCustomPrint = new DebtorPaymentStatementCustPrint(api, selectedItem, companyClient, debtorClient, txtDateFrm.DateTime, txtDateTo.DateTime, logo, debtorEmailType.ToString(), this.AddInterest, lastMessage); object[] obj = new object[1]; obj[0] = dbStatementCustomPrint as CustomPrintTemplateData; AddDockItem(TabControls.DebtorPaymentStatementPrintPage, obj, true, string.Format("{0}: {1},{2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.Name, selectedItem.AccountNumber)); } }
void LoadDataForReport() { statementList.Clear(); var visibleRows = dgDebtorTranOpenGrid.GetVisibleRows() as ICollection <DebtorTransPayment>; if (visibleRows.Count > 0) { string currentItem = null; DebtorPaymentStatementList masterDbPymtStatement = null; List <DebtorTransPayment> dbTransClientChildList = new List <DebtorTransPayment>(20); double SumAmount = 0d, SumAmountCur = 0d, CollectionAmount = 0d, SumFee = 0d; Uniconta.ClientTools.Localization debtLocalize = null; var listOpenTrans = visibleRows.OrderBy(p => p.Account); foreach (var trans in listOpenTrans) { if (trans.Account != currentItem) { if (masterDbPymtStatement != null && CollectionAmount > 0) { masterDbPymtStatement.ChildRecords = dbTransClientChildList.ToArray(); statementList.Add(masterDbPymtStatement); } else { foreach (var rec in dbTransClientChildList) { rec._FeeAmount = 0d; } } currentItem = trans.Account; var dbt = (Debtor)accountCache.Get(currentItem); var lan = UtilDisplay.GetLanguage(dbt, api.CompanyEntity); debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(lan); masterDbPymtStatement = new DebtorPaymentStatementList(); if (dbt != null) { masterDbPymtStatement.AccountNumber = dbt._Account; masterDbPymtStatement.Name = dbt._Name; } SumAmount = SumAmountCur = CollectionAmount = SumFee = 0d; dbTransClientChildList.Clear(); } trans.Trans.LocOb = debtLocalize; SumAmount += trans._AmountOpen; trans._SumAmount = SumAmount; masterDbPymtStatement._SumAmount = SumAmount; SumFee += trans._FeeAmount; masterDbPymtStatement._sumFeeAmount = SumFee; CollectionAmount += (trans._AmountOpen + trans._FeeAmount); masterDbPymtStatement._collectionAmount = CollectionAmount; SumAmountCur += trans._AmountOpenCur; trans._SumAmount = SumAmountCur; masterDbPymtStatement._SumAccountCur = SumAmountCur; dbTransClientChildList.Add(trans); } if (masterDbPymtStatement != null && CollectionAmount > 0) { masterDbPymtStatement.ChildRecords = dbTransClientChildList.ToArray(); statementList.Add(masterDbPymtStatement); } } }
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 void PrintData() { busyIndicator.IsBusy = true; busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); try { #if SILVERLIGHT //Get Company related details var companyClient = new CompanyClient(); StreamingManager.Copy(api.CompanyEntity, companyClient); byte[] getLogoBytes = await UtilDisplay.GetLogo(api); if (dgDebtorTrans.SelectedItem != null) { var selectedItem = dgDebtorTrans.SelectedItem as DebtorStatementList; if (selectedItem.ChildRecords.Length == 0) { return; } var debt = new DebtorClient(); StreamingManager.Copy(selectedItem.deb, debt); debt.Transactions = selectedItem.ChildRecords; //Setting the Localization for the debtor var lan = UtilDisplay.GetLanguage(debt, companyClient); var debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(lan); foreach (var rec in debt.Transactions) { rec.LocOb = debtLocalize; if (rec._Primo) { rec._Text = debtLocalize.Lookup("Primo"); } } 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; } } DebtorStatementCustomPrint dbStatementCustomPrint = new DebtorStatementCustomPrint(api, selectedItem, companyClient, debt, txtDateFrm.DateTime, txtDateTo.DateTime, getLogoBytes, lastMessage); 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 var debtorStatementList = dgDebtorTrans.VisibleItems.Cast <DebtorStatementList>(); var marked = debtorStatementList.Any(m => m.Mark == true); var iReports = await GeneratePrintReport(debtorStatementList.ToList(), marked, chkShowCurrency.IsChecked == true, true); 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); } 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); }