private void UpdateDocument(CompanyLayoutType documentType) { bool showUpdateInv = api.CompanyEntity.Storage; var generateDoc = new CWGenerateInvoice(false, documentType.ToString(), false, true, true, false, isQuickPrintVisible: false, isShowUpdateInv: showUpdateInv); #if !SILVERLIGHT generateDoc.DialogTableId = 2000000000; generateDoc.HideOutlookOption(true); #endif generateDoc.Closed += async delegate { if (generateDoc.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var crVisibleOrders = dgMultiInvGrid.GetVisibleRows() as IEnumerable <CreditorOrderClient>; var invoicePostingPrintGenerator = new InvoicePostingPrintGenerator(api, this); invoicePostingPrintGenerator.SetUpInvoicePosting(crVisibleOrders, generateDoc.GenrateDate, !generateDoc.UpdateInventory, documentType, false, false, false, generateDoc.SendByEmail, generateDoc.sendOnlyToThisEmail, generateDoc.Emails, false); await invoicePostingPrintGenerator.Execute(); busyIndicator.IsBusy = false; } }; generateDoc.Show(); }
private void GenerateInvoice(CreditorOrderClient creditorOrderClient) { var accountName = string.Format("{0} ({1})", creditorOrderClient._DCAccount, creditorOrderClient.Name); var creditor = ClientHelper.GetRef(creditorOrderClient.CompanyId, typeof(Uniconta.DataModel.Creditor), creditorOrderClient._DCAccount) as Uniconta.DataModel.Creditor; bool showSendByEmail = creditor != null ? (!string.IsNullOrEmpty(creditor._InvoiceEmail) || creditor._EmailDocuments) : false; CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, true, true, showNoEmailMsg: !showSendByEmail, AccountName: accountName); #if !SILVERLIGHT GenrateInvoiceDialog.DialogTableId = 2000000002; #endif GenrateInvoiceDialog.SetSendAsEmailCheck(false); GenrateInvoiceDialog.SetInvoiceNumber(creditorOrderClient._InvoiceNumber); if (creditorOrderClient._InvoiceDate != DateTime.MinValue) { GenrateInvoiceDialog.SetInvoiceDate(creditorOrderClient._InvoiceDate); } var additionalOrdersList = Utility.GetAdditionalOrders(api, creditorOrderClient); if (additionalOrdersList != null) { GenrateInvoiceDialog.SetAdditionalOrders(additionalOrdersList); } GenrateInvoiceDialog.Closed += async delegate { if (GenrateInvoiceDialog.DialogResult == true) { var isSimulated = GenrateInvoiceDialog.IsSimulation; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this); invoicePostingResult.SetUpInvoicePosting(creditorOrderClient, null, CompanyLayoutType.PurchaseInvoice, GenrateInvoiceDialog.GenrateDate, GenrateInvoiceDialog.InvoiceNumber, isSimulated, GenrateInvoiceDialog.ShowInvoice, false, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, false, null, false); invoicePostingResult.SetAdditionalOrders(GenrateInvoiceDialog.AdditionalOrders?.Cast <DCOrder>().ToList()); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { if (invoicePostingResult.PostingResult.OrderDeleted) { dgCreditorOrdersGrid.UpdateItemSource(3, dgCreditorOrdersGrid.SelectedItem as CreditorOrderClient); } } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgCreditorOrdersGrid); } } }; GenrateInvoiceDialog.Show(); }
private void GenerateOffer() { saveGridLocal(); bool showSendByMail = false; var dbOrder = Order; string debtorName; var debtor = dbOrder.Debtor; if (debtor != null) { debtorName = debtor?._Name ?? dbOrder._DCAccount; showSendByMail = (!string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments); } else if (dbOrder._Prospect == 0) { UtilDisplay.ShowErrorCode(ErrorCodes.AccountIsMissing); return; } else { debtorName = Uniconta.ClientTools.Localization.lookup("Prospect"); showSendByMail = true; } var generateOfferDialog = new CWGenerateInvoice(false, CompanyLayoutType.Offer.ToString(), askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true); #if !SILVERLIGHT generateOfferDialog.DialogTableId = 2000000075; #endif generateOfferDialog.Closed += async delegate { if (generateOfferDialog.DialogResult == true) { var invoicePostingResult = new InvoicePostingPrintGenerator(api, this); invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Offer, generateOfferDialog.GenrateDate, null, true, generateOfferDialog.ShowInvoice, generateOfferDialog.PostOnlyDelivered, generateOfferDialog.InvoiceQuickPrint, generateOfferDialog.NumberOfPages, generateOfferDialog.SendByEmail, generateOfferDialog.SendByOutlook, generateOfferDialog.sendOnlyToThisEmail, generateOfferDialog.Emails, false, null, false); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (!result) { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOfferLineGrid); } } }; generateOfferDialog.Show(); }
private void PrintOffer(DebtorOfferClient dbOrder) { InvoiceAPI Invapi = new InvoiceAPI(api); var debtor = dbOrder.Debtor; bool showSendByMail = true; string debtorName; if (debtor != null) { debtorName = debtor._Name ?? dbOrder._DCAccount; showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail); } else if (dbOrder._Prospect == 0) { UtilDisplay.ShowErrorCode(ErrorCodes.AccountIsMissing); return; } else { debtorName = Uniconta.ClientTools.Localization.lookup("Prospect"); showSendByMail = true; } CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, Uniconta.ClientTools.Localization.lookup("Offer"), askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true); #if !SILVERLIGHT GenrateOfferDialog.DialogTableId = 2000000006; #endif GenrateOfferDialog.Closed += async delegate { if (GenrateOfferDialog.DialogResult == true) { var showOrPrintOffer = GenrateOfferDialog.InvoiceQuickPrint || GenrateOfferDialog.ShowInvoice; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateOfferDialog.GenrateDate, 0, true, CompanyLayoutType.Offer, showOrPrintOffer, GenrateOfferDialog.InvoiceQuickPrint, GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, GenrateOfferDialog.Emails, GenrateOfferDialog.sendOnlyToThisEmail, false, GenrateOfferDialog.PostOnlyDelivered, null); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (!result) { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOffers); } } }; GenrateOfferDialog.Show(); }
private void OrderConfirmation(DebtorOrderClient dbOrder, CompanyLayoutType doctype) { InvoiceAPI Invapi = new InvoiceAPI(api); var debtor = dbOrder.Debtor; bool showSendByMail = true; if (debtor != null) { showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail); } string debtorName = debtor?._Name ?? dbOrder._DCAccount; bool showUpdateInv = api.CompanyEntity.Storage || (doctype == CompanyLayoutType.Packnote && api.CompanyEntity.Packnote); CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, Uniconta.ClientTools.Localization.lookup(doctype.ToString()), isShowInvoiceVisible: true, askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isShowUpdateInv: showUpdateInv, isDebtorOrder: true); #if !SILVERLIGHT if (doctype == CompanyLayoutType.OrderConfirmation) { GenrateOfferDialog.DialogTableId = 2000000009; } else if (doctype == CompanyLayoutType.Packnote) { GenrateOfferDialog.DialogTableId = 2000000018; } #endif GenrateOfferDialog.SetInvPrintPreview(showPrintPreview); GenrateOfferDialog.Closed += async delegate { if (GenrateOfferDialog.DialogResult == true) { showPrintPreview = GenrateOfferDialog.ShowInvoice || GenrateOfferDialog.InvoiceQuickPrint; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateOfferDialog.GenrateDate, 0, !GenrateOfferDialog.UpdateInventory, doctype, showPrintPreview, GenrateOfferDialog.InvoiceQuickPrint, GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, GenrateOfferDialog.Emails, GenrateOfferDialog.sendOnlyToThisEmail, false, GenrateOfferDialog.PostOnlyDelivered, null); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { Updatedata(dbOrder, doctype); } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid); } } }; GenrateOfferDialog.Show(); }
private void GenerateInvoice(CreditorOrderClient dbOrder, bool showProformaInvoice) { var lines = (IEnumerable <DCOrderLineClient>)dgCreditorOrderLineGrid.ItemsSource; if (lines == null || lines.Count() == 0) { return; } var dc = dbOrder.Creditor; if (dc == null || !Utility.IsExecuteWithBlockedAccount(dc)) { return; } if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, dc._Currency)) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), dc.Currency, dbOrder.Currency), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } if (api.CompanyEntity._InvoiceUseQtyNowCre) { foreach (var rec in lines) { rec._QtyNow = rec._Qty; } } if (showProformaInvoice) { ShowProformaInvoice(dbOrder, lines); return; } CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, true, true, showNoEmailMsg: !hasEmail); #if !SILVERLIGHT GenrateInvoiceDialog.DialogTableId = 2000000004; #endif GenrateInvoiceDialog.SetInvoiceNumber(dbOrder._InvoiceNumber); if (dbOrder._InvoiceDate != DateTime.MinValue) { GenrateInvoiceDialog.SetInvoiceDate(dbOrder._InvoiceDate); } GenrateInvoiceDialog.SetInvPrintPreview(showInvoice); GenrateInvoiceDialog.SetSendAsEmailCheck(false); GenrateInvoiceDialog.Closed += async delegate { if (GenrateInvoiceDialog.DialogResult == true) { var isSimulated = GenrateInvoiceDialog.IsSimulation; showInvoice = GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint || GenrateInvoiceDialog.SendByOutlook; if (!isSimulated && GenrateInvoiceDialog.InvoiceNumber == null) { UtilDisplay.ShowErrorCode(ErrorCodes.InvoiceNumberMissing); return; } var invoicePostingResult = SetupInvoicePostingPrintGenerator(dbOrder, lines, GenrateInvoiceDialog.GenrateDate, GenrateInvoiceDialog.InvoiceNumber, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, documents); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { if (!isSimulated) { dgCreditorOrderLineGrid.ItemsSource = new List <CreditorOrderLineClient>(); documents = null; if (attachDocMenu != null) { attachDocMenu.Caption = string.Format(Uniconta.ClientTools.Localization.lookup("AttachOBJ"), Uniconta.ClientTools.Localization.lookup("Documents")); } } if (invoicePostingResult.IsInvoiceGenerated) { if (attachedVoucher != null) { attachedVoucher.PurchaseNumber = Order._OrderNumber; api.UpdateNoResponse(attachedVoucher); } ClearFields(initialOrder); } } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgCreditorOrderLineGrid); } } }; GenrateInvoiceDialog.Show(); }
private void GenerateInvoice(DebtorOrderClient dbOrder) { InvoiceAPI Invapi = new InvoiceAPI(api); bool showSendByMail = false; var debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), dbOrder._DCAccount) as Debtor; if (debtor != null) { var InvoiceAccount = dbOrder._InvoiceAccount ?? debtor._InvoiceAccount; if (InvoiceAccount != null) { debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor; } if (debtor != null) { if (debtor._PricesInclVat != dbOrder._PricesInclVat) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DebtorAndOrderMix"), Uniconta.ClientTools.Localization.lookup("InclVat")), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, debtor._Currency)) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), AppEnums.Currencies.ToString((int)debtor._Currency), dbOrder.Currency), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } showSendByMail = (!string.IsNullOrEmpty(debtor._InvoiceEmail) || debtor._EmailDocuments); } } else { api.LoadCache(typeof(Debtor), true); } string debtorName = debtor?._Name ?? dbOrder._DCAccount; bool invoiceInXML = debtor?._InvoiceInXML ?? false; var accountName = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name); CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true, InvoiceInXML: invoiceInXML, AccountName: accountName); #if !SILVERLIGHT GenrateInvoiceDialog.DialogTableId = 2000000010; #endif if (dbOrder._InvoiceDate != DateTime.MinValue) { GenrateInvoiceDialog.SetInvoiceDate(dbOrder._InvoiceDate); } var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder); if (additionalOrdersList != null) { GenrateInvoiceDialog.SetAdditionalOrders(additionalOrdersList); } GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer); GenrateInvoiceDialog.Closed += async delegate { if (GenrateInvoiceDialog.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var isSimulated = GenrateInvoiceDialog.IsSimulation; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this); invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.Invoice, GenrateInvoiceDialog.GenrateDate, null, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked, null, false); invoicePostingResult.SetAdditionalOrders(GenrateInvoiceDialog.AdditionalOrders?.Cast <DCOrder>().ToList()); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { if (invoicePostingResult.PostingResult.OrderDeleted) { dgDebtorOrdersGrid.UpdateItemSource(3, dgDebtorOrdersGrid.SelectedItem as DebtorOrderClient); } } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid); } } }; GenrateInvoiceDialog.Show(); }
private void GenerateInvoice(DCOrder dbOrder) { InvoiceAPI Invapi = new InvoiceAPI(api); bool showSendByMail = false; var debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), dbOrder._DCAccount) as Debtor; if (debtor != null) { var InvoiceAccount = dbOrder._InvoiceAccount ?? debtor._InvoiceAccount; if (InvoiceAccount != null) { debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor; } if (debtor != null) { if (debtor._PricesInclVat != dbOrder._PricesInclVat) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DebtorAndOrderMix"), Uniconta.ClientTools.Localization.lookup("InclVat")), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, debtor._Currency)) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), AppEnums.Currencies.ToString((int)debtor._Currency), dbOrder.Currency), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } showSendByMail = !string.IsNullOrEmpty(debtor._InvoiceEmail); } } else { api.CompanyEntity.LoadCache(typeof(Debtor), api, true); } string debtorName = debtor?._Name ?? dbOrder._DCAccount; bool invoiceInXML = debtor?._InvoiceInXML ?? false; CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true, InvoiceInXML: invoiceInXML); #if !SILVERLIGHT GenrateInvoiceDialog.DialogTableId = 2000000010; #endif GenrateInvoiceDialog.Closed += async delegate { if (GenrateInvoiceDialog.DialogResult == true) { busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; var showOrPrint = GenrateInvoiceDialog.ShowInvoice || GenrateInvoiceDialog.InvoiceQuickPrint; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, GenrateInvoiceDialog.GenrateDate, 0, GenrateInvoiceDialog.IsSimulation, CompanyLayoutType.Invoice, showOrPrint, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.GenerateOIOUBLClicked, GenrateInvoiceDialog.PostOnlyDelivered, null); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { Task reloadTask = null; if (!GenrateInvoiceDialog.IsSimulation && dbOrder._DeleteLines) { reloadTask = BindGrid(); } if (invoicePostingResult.PostingResult.Header._InvoiceNumber != 0) { var msg = string.Format(Uniconta.ClientTools.Localization.lookup("InvoiceHasBeenGenerated"), invoicePostingResult.PostingResult.Header._InvoiceNumber); msg = string.Format("{0}{1}{2} {3}", msg, Environment.NewLine, Uniconta.ClientTools.Localization.lookup("LedgerVoucher"), invoicePostingResult.PostingResult.Header._Voucher); UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK); #if !SILVERLIGHT if (GenrateInvoiceDialog.GenerateOIOUBLClicked && !GenrateInvoiceDialog.IsSimulation) { GenerateOIOXml(this.api, invoicePostingResult.PostingResult); } #endif } } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid); } } }; GenrateInvoiceDialog.Show(); }
private void OrderConfirmation(CreditorOrderClient dbOrder, CompanyLayoutType doctype) { InvoiceAPI Invapi = new InvoiceAPI(api); var creditor = dbOrder.Creditor; bool showSendByMail = true; if (creditor != null) { showSendByMail = !string.IsNullOrEmpty(creditor._InvoiceEmail); } string creditorName = creditor?._Name ?? dbOrder._DCAccount; var comp = api.CompanyEntity; bool showUpdateInv = comp.Storage || (doctype == CompanyLayoutType.PurchasePacknote && comp.CreditorPacknote); CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, doctype.ToString(), showInputforInvNumber: doctype == CompanyLayoutType.PurchasePacknote ? true : false, isShowInvoiceVisible: true, askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: creditorName, isShowUpdateInv: showUpdateInv); #if !SILVERLIGHT switch (doctype) { case CompanyLayoutType.PurchaseOrder: GenrateOfferDialog.DialogTableId = 2000000003; break; case CompanyLayoutType.PurchasePacknote: GenrateOfferDialog.DialogTableId = 2000000056; break; case CompanyLayoutType.Requisition: GenrateOfferDialog.DialogTableId = 2000000057; break; } #endif GenrateOfferDialog.SetInvPrintPreview(showInvPrintPreview); var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder); if (additionalOrdersList != null) { GenrateOfferDialog.SetAdditionalOrders(additionalOrdersList); } GenrateOfferDialog.Closed += async delegate { if (GenrateOfferDialog.DialogResult == true) { showInvPrintPreview = GenrateOfferDialog.ShowInvoice || GenrateOfferDialog.InvoiceQuickPrint || GenrateOfferDialog.SendByOutlook; string documentNumber = null; if (doctype == CompanyLayoutType.PurchasePacknote) { documentNumber = GenrateOfferDialog.InvoiceNumber; dbOrder._InvoiceNumber = documentNumber; } var openOutlook = doctype == CompanyLayoutType.PurchasePacknote ? GenrateOfferDialog.UpdateInventory && GenrateOfferDialog.SendByOutlook : GenrateOfferDialog.SendByOutlook; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this); invoicePostingResult.SetUpInvoicePosting(dbOrder, null, doctype, GenrateOfferDialog.GenrateDate, documentNumber, !GenrateOfferDialog.UpdateInventory, GenrateOfferDialog.ShowInvoice, false, GenrateOfferDialog.InvoiceQuickPrint, GenrateOfferDialog.NumberOfPages, GenrateOfferDialog.SendByEmail, openOutlook, GenrateOfferDialog.sendOnlyToThisEmail, GenrateOfferDialog.Emails, false, null, false); invoicePostingResult.SetAdditionalOrders(GenrateOfferDialog.AdditionalOrders?.Cast <DCOrder>().ToList()); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (result) { DebtorOrders.Updatedata(dbOrder, doctype); } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgCreditorOrdersGrid); } } }; GenrateOfferDialog.Show(); }
private void GenerateInvoice(ProjectInvoiceProposalClient dbOrder, bool showProformaInvoice) { var savetask = saveGridLocal(); var curpanel = dockCtrl.Activpanel; bool showSendByMail = false; var debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), dbOrder._DCAccount) as Debtor; if (debtor != null) { var InvoiceAccount = dbOrder._InvoiceAccount ?? debtor._InvoiceAccount; if (InvoiceAccount != null) { debtor = ClientHelper.GetRef(dbOrder.CompanyId, typeof(Debtor), InvoiceAccount) as Debtor; } if (debtor != null) { if (debtor._PricesInclVat != dbOrder._PricesInclVat) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DebtorAndOrderMix"), Uniconta.ClientTools.Localization.lookup("InclVat")), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } if (!api.CompanyEntity.SameCurrency(dbOrder._Currency, debtor._Currency)) { var confirmationMsgBox = UnicontaMessageBox.Show(string.Format("{0}.\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("CurrencyMismatch"), AppEnums.Currencies.ToString((int)debtor._Currency), dbOrder.Currency), Uniconta.ClientTools.Localization.lookup("ProceedConfirmation")), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OKCancel); if (confirmationMsgBox != MessageBoxResult.OK) { return; } } showSendByMail = (!string.IsNullOrEmpty(debtor._InvoiceEmail) || debtor._EmailDocuments); } } if (showProformaInvoice) { ShowProformaInvoice(dbOrder); return; } string debtorName = debtor?._Name ?? dbOrder._DCAccount; bool invoiceInXML = debtor?._InvoiceInXML ?? false; var accountName = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name); CWGenerateInvoice GenrateInvoiceDialog = new CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isOrderOrQuickInv: true, isDebtorOrder: true, InvoiceInXML: invoiceInXML, AccountName: accountName); GenrateInvoiceDialog.DialogTableId = 2000000086; if (dbOrder._InvoiceDate != DateTime.MinValue) { GenrateInvoiceDialog.SetInvoiceDate(dbOrder._InvoiceDate); } var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder); if (additionalOrdersList != null) { GenrateInvoiceDialog.SetAdditionalOrders(additionalOrdersList); } GenrateInvoiceDialog.SetOIOUBLLabelText(api.CompanyEntity._OIOUBLSendOnServer); GenrateInvoiceDialog.Closed += async delegate { if (GenrateInvoiceDialog.DialogResult == true) { if (savetask != null) { var err = await savetask; if (err != ErrorCodes.Succes) { return; } } busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait"); busyIndicator.IsBusy = true; InvoiceAPI Invapi = new InvoiceAPI(api); var isSimulated = GenrateInvoiceDialog.IsSimulation; var invoicePostingResult = SetupInvoicePostingPrintGenerator(dbOrder, GenrateInvoiceDialog.GenrateDate, isSimulated, GenrateInvoiceDialog.ShowInvoice, GenrateInvoiceDialog.PostOnlyDelivered, GenrateInvoiceDialog.InvoiceQuickPrint, GenrateInvoiceDialog.NumberOfPages, GenrateInvoiceDialog.SendByEmail, !isSimulated && GenrateInvoiceDialog.SendByOutlook, GenrateInvoiceDialog.sendOnlyToThisEmail, GenrateInvoiceDialog.Emails, GenrateInvoiceDialog.GenerateOIOUBLClicked); invoicePostingResult.SetAdditionalOrders(GenrateInvoiceDialog.AdditionalOrders?.Cast <DCOrder>().ToList()); busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage"); busyIndicator.IsBusy = true; var result = await invoicePostingResult.Execute(); busyIndicator.IsBusy = false; if (!result) { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgProjInvProposedLineGrid); } else { Task reloadTask = null; if (!GenrateInvoiceDialog.IsSimulation && dbOrder._DeleteLines) { reloadTask = Filter(null); } if (reloadTask != null) { CloseOrderLineScreen(reloadTask, curpanel); } } } }; GenrateInvoiceDialog.Show(); }