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); }
/// <summary> /// Initialization for CreditorInvoice client /// </summary> /// <param name="creditorInvoiceClient">Invoice client </param> /// <param name="api">Api instance</param> /// <param name="companyLayoutType">Layout type</param> public CreditorPrintReport(CreditorInvoiceClient creditorInvoiceClient, CrudAPI api, CompanyLayoutType companyLayoutType = CompanyLayoutType.PurchaseInvoice) { CreditorInvoice = creditorInvoiceClient; crudApi = api; isRePrint = false; layoutType = companyLayoutType; }
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); }
async public Task <bool> InstantiateFields() { try { var crudApi = this.crudApi; var Comp = crudApi.CompanyEntity; var creditorInvoiceLineUserType = ReportUtil.GetUserType(typeof(CreditorInvoiceLines), Comp); var creditorInvoiceUserType = ReportUtil.GetUserType(typeof(CreditorInvoiceClient), Comp); if (!isRePrint) { var invApi = new InvoiceAPI(crudApi); var invoiceLIneInstance = Activator.CreateInstance(creditorInvoiceLineUserType) as CreditorInvoiceLines; InvTransInvoiceLines = (CreditorInvoiceLines[])await invApi.GetInvoiceLines(CreditorInvoice, invoiceLIneInstance); } else { //for Gettting user firlds for Creditor Invoice var dcInvoice = (DCInvoiceClient)invoicePostingResult.Header; CreditorInvoice = new CreditorInvoiceClient(); StreamingManager.Copy(dcInvoice, CreditorInvoice); var linesCount = invoicePostingResult.Lines.Count(); if (linesCount > 0) { var lines = invoicePostingResult.Lines; InvTransInvoiceLines = Array.CreateInstance(creditorInvoiceLineUserType, linesCount) as CreditorInvoiceLines[]; int i = 0; foreach (var invtrans in invoicePostingResult.Lines) { CreditorInvoiceLines creditorInvoiceLines; if (invtrans.GetType() != creditorInvoiceLineUserType) { creditorInvoiceLines = Activator.CreateInstance(creditorInvoiceLineUserType) as CreditorInvoiceLines; StreamingManager.Copy(invtrans, creditorInvoiceLines); } else { creditorInvoiceLines = invtrans as CreditorInvoiceLines; } InvTransInvoiceLines[i++] = creditorInvoiceLines; } } } //For Getting User-Fields for CreditorInvoice CreditorInvoiceClient creditorInvoiceClientUser; if (CreditorInvoice.GetType() != creditorInvoiceUserType) { creditorInvoiceClientUser = Activator.CreateInstance(creditorInvoiceUserType) as CreditorInvoiceClient; StreamingManager.Copy(CreditorInvoice, creditorInvoiceClientUser); } else { creditorInvoiceClientUser = CreditorInvoice as CreditorInvoiceClient; } CreditorInvoice = creditorInvoiceClientUser; //for Gettting user fields for Creditor var dcCahce = Comp.GetCache(typeof(Uniconta.DataModel.Creditor)) ?? await crudApi.LoadCache(typeof(Uniconta.DataModel.Creditor)); var cred = dcCahce.Get(CreditorInvoice._DCAccount); var creditorUserType = ReportUtil.GetUserType(typeof(CreditorClient), Comp); if (creditorUserType != cred?.GetType()) { var creditorClientUser = Activator.CreateInstance(creditorUserType) as CreditorClient; if (cred != null) { StreamingManager.Copy((UnicontaBaseEntity)cred, creditorClientUser); } Creditor = creditorClientUser; } else { Creditor = cred as CreditorClient; } if (Comp.Contacts) { var contactCache = Comp.GetCache(typeof(Contact)) ?? await crudApi.LoadCache(typeof(Contact)); var contactCacheFilter = new ContactCacheFilter(contactCache, Creditor.__DCType(), Creditor._Account); if (contactCacheFilter.Any()) { try { Creditor.Contacts = contactCacheFilter.Cast <ContactClient>().ToArray(); } catch { } } } UnicontaClient.Pages.DebtorOrders.SetDeliveryAdress(creditorInvoiceClientUser, Creditor, crudApi); /*In case debtor order is null, fill from DCInvoice*/ if (CreditorOrder == null) { var creditorOrderUserType = ReportUtil.GetUserType(typeof(CreditorOrderClient), Comp); var creditorOrderUser = Activator.CreateInstance(creditorOrderUserType) as CreditorOrderClient; creditorOrderUser.CopyFrom(creditorInvoiceClientUser, Creditor); CreditorOrder = creditorOrderUser; } Company = Utility.GetCompanyClientUserInstance(Comp); var InvCache = Comp.GetCache(typeof(InvItem)) ?? await crudApi.LoadCache(typeof(InvItem)); CompanyLogo = await Uniconta.ClientTools.Util.UtilDisplay.GetLogo(crudApi); Language lang = ReportGenUtil.GetLanguage(Creditor, Comp); InvTransInvoiceLines = LayoutPrintReport.SetInvTransLines(CreditorInvoice, InvTransInvoiceLines, InvCache, crudApi, creditorInvoiceLineUserType, lang, false); var lineTotal = CreditorInvoice._LineTotal; IsCreditNote = CreditorInvoice._LineTotal < -0.0001d && layoutType == CompanyLayoutType.PurchaseInvoice; ReportName = IsCreditNote ? "CreditNote" : layoutType.ToString(); CreditorMessage = isMultiInvoice? LayoutPrintReport.GetDebtorMessageClient(debtorMessageLookup, lang, GetEmailTypeForCreditor())?._Text: await GetMessageClientText(lang); return(true); } catch (Exception ex) { crudApi.ReportException(ex, "Error Occured in CreditorPrintReport"); return(false); } }