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 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 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) || debtor.EmailDocuments); } string debtorName = debtor?._Name ?? dbOrder._DCAccount; bool showUpdateInv = api.CompanyEntity.Storage || (doctype == CompanyLayoutType.Packnote && api.CompanyEntity.Packnote); var accountName = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name); CWGenerateInvoice GenrateOfferDialog = new CWGenerateInvoice(false, doctype.ToString(), isShowInvoiceVisible: true, askForEmail: true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isShowUpdateInv: showUpdateInv, isDebtorOrder: true, AccountName: accountName); #if !SILVERLIGHT if (doctype == CompanyLayoutType.OrderConfirmation) { GenrateOfferDialog.DialogTableId = 2000000009; } else if (doctype == CompanyLayoutType.Packnote) { GenrateOfferDialog.DialogTableId = 2000000018; } #endif GenrateOfferDialog.SetInvPrintPreview(showPrintPreview); var additionalOrdersList = Utility.GetAdditionalOrders(api, dbOrder); if (additionalOrdersList != null) { GenrateOfferDialog.SetAdditionalOrders(additionalOrdersList); } GenrateOfferDialog.Closed += async delegate { if (GenrateOfferDialog.DialogResult == true) { showPrintPreview = GenrateOfferDialog.ShowInvoice || GenrateOfferDialog.InvoiceQuickPrint || GenrateOfferDialog.SendByOutlook; var invoicePostingResult = new InvoicePostingPrintGenerator(api, this); var openOutlook = doctype == CompanyLayoutType.Packnote ? GenrateOfferDialog.UpdateInventory && GenrateOfferDialog.SendByOutlook : GenrateOfferDialog.SendByOutlook; invoicePostingResult.SetUpInvoicePosting(dbOrder, null, doctype, GenrateOfferDialog.GenrateDate, null, !GenrateOfferDialog.UpdateInventory, GenrateOfferDialog.ShowInvoice, GenrateOfferDialog.PostOnlyDelivered, 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) { Updatedata(dbOrder, doctype); } else { Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid); } } }; GenrateOfferDialog.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(); }