コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }