示例#1
0
        private void ShowOrderLines(DebtorOrderClient order)
        {
            var confrimationText = string.Format(" {0}. {1}:{2},{3}:{4}\r\n{5}", Uniconta.ClientTools.Localization.lookup("SalesOrderCreated"), Uniconta.ClientTools.Localization.lookup("OrderNumber"), order._OrderNumber,
                                                 Uniconta.ClientTools.Localization.lookup("Account"), order._DCAccount, string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"), Uniconta.ClientTools.Localization.lookup("Orderline")), " ?"));

            var confirmationBox = new CWConfirmationBox(confrimationText, string.Empty, false);

            confirmationBox.Closing += delegate
            {
                if (confirmationBox.DialogResult == null)
                {
                    return;
                }

                switch (confirmationBox.ConfirmationResult)
                {
                case CWConfirmationBox.ConfirmationResultEnum.Yes:
                    AddDockItem(TabControls.DebtorOrderLines, order, string.Format("{0}:{1},{2}", Uniconta.ClientTools.Localization.lookup("OrdersLine"), order._OrderNumber, order._DCAccount));
                    break;

                case CWConfirmationBox.ConfirmationResultEnum.No:
                    break;
                }
            };
            confirmationBox.Show();
        }
示例#2
0
        private void JoinAllOrdersToSelectedItem(DebtorOrderClient selectedItem, IEnumerable <DebtorOrderClient> allOrderList)
        {
            EraseYearWindow EraseYearWindowDialog = new EraseYearWindow("", true);

            EraseYearWindowDialog.Closed += async delegate
            {
                if (EraseYearWindowDialog.DialogResult == true)
                {
                    var        ordersApi = new OrderAPI(api);
                    List <int> errors    = new List <int>();
                    foreach (var order in allOrderList)
                    {
                        if (order._OrderNumber == selectedItem._OrderNumber)
                        {
                            continue;
                        }
                        var result = await ordersApi.JoinTwoOrders(order, selectedItem);

                        if (result != Uniconta.Common.ErrorCodes.Succes)
                        {
                            errors.Add(order._OrderNumber);
                        }
                    }
                    if (errors.Count > 0)
                    {
                        var failedOrderNumbers = string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("OrderNumber"), string.Join(",", errors));
                        var message            = string.Format(Uniconta.ClientTools.Localization.lookup("FailedJoinOBJ"), failedOrderNumbers, selectedItem._OrderNumber);
                        UnicontaMessageBox.Show(message, Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
                    }
                    var propValpair = Uniconta.Common.PropValuePair.GenereteWhereElements("OrderNumber", typeof(int), Convert.ToString(selectedItem._OrderNumber));
                    dgJoinMultiOrderGrid.Filter(new Uniconta.Common.PropValuePair[] { propValpair });
                }
            };
            EraseYearWindowDialog.Show();
        }
        private void JoinManyOrders(DebtorOrderClient selectedItem)
        {
            var ordersToBeJoined = dgJoinMultiOrderGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;
            var firstRecord      = ordersToBeJoined.FirstOrDefault();
            var lst = ordersToBeJoined?.GroupBy(x => x.Account).Select(x => x.First()).ToList();

            JoinAllOrdersToSelectedItem(firstRecord, lst);
        }
示例#4
0
        void InitPage(CrudAPI crudapi)
        {
            RemoveMenuItem();
            BusyIndicator                = busyIndicator;
            dAddress.Header              = Uniconta.ClientTools.Localization.lookup("DeliveryAddr");
            layoutControl                = layoutItems;
            PrCategorylookupeditor.api   = Projectlookupeditor.api =
                Employeelookupeditor.api = leAccount.api = lePayment.api = cmbDim1.api = cmbDim2.api =
                    cmbDim3.api          = cmbDim4.api = cmbDim5.api = leTransType.api = leGroup.api = lePostingAccount.api
                                                                                                           = leShipment.api = leLayoutGroup.api = leDeliveryTerm.api = leInvoiceAccount.api = PriceListlookupeditior.api =
                                                                                                                 leRelatedOrder.api = leDeliveryAddress.api = leApprover.api = crudapi;
            cbDeliveryCountry.ItemsSource = Enum.GetValues(typeof(Uniconta.Common.CountryCode));
            AdjustLayout();
            if (editrow == null)
            {
                frmRibbon.DisableButtons("Delete");
                liCreatedTime.Visibility = Visibility.Collapsed;
                editrow = CreateNew() as DebtorOrderClient;
                if (Debtor != null)
                {
                    editrow.SetMaster(Debtor);
                    if (editrow.RowId == 0)
                    {
                        SetFieldFromDebtor(Debtor);
                    }
                    leAccount.IsEnabled = txtName.IsEnabled = false;
                }
                else if (Project != null)
                {
                    editrow.SetMaster(Project);
                    leAccount.IsEnabled           = txtName.IsEnabled = false;
                    Projectlookupeditor.IsEnabled = false;
                }
            }
            else
            {
                BindContact(editrow.Debtor);
            }

            if (editrow.LastInvoice == DateTime.MinValue)
            {
                txtLastInvoice.Text = string.Empty;
            }
            else
            {
                txtLastInvoice.Text = editrow.LastInvoice.ToString("d");
            }

            layoutItems.DataContext  = editrow;
            frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;

            AcItem.ButtonClicked += AcItem_ButtonClicked;
#if !SILVERLIGHT
            txtDelZipCode.EditValueChanged += TxtDelZipCode_EditValueChanged;
            AcItem.ToolTip = string.Format(Uniconta.ClientTools.Localization.lookup("CreateOBJ"), Uniconta.ClientTools.Localization.lookup("Debtor"));
#endif
            StartLoadCache();
        }
示例#5
0
        private ErrorCodes CreateLines(List <string[]> lines, DebtorOrderClient order)
        {
            //TODO: create orderlines on order setting correct pricing using FindPrices

            ErrorCodes result = ErrorCodes.NoSucces;

            openOrderLines(order);

            return(result);
        }
        async void SetFieldFromDebtor(DebtorOrderClient editrow, Debtor debtor)
        {
            if (debtor == null)
            {
                return;
            }
            var loadedOrder = LoadedRow as DCOrder;

            editrow.SetMaster(debtor);
            if (this.Project == null) // no project master
            {
                editrow.PricesInclVat = debtor._PricesInclVat;
            }
            if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null)
            {
                editrow.DeliveryName     = debtor._DeliveryName;
                editrow.DeliveryAddress1 = debtor._DeliveryAddress1;
                editrow.DeliveryAddress2 = debtor._DeliveryAddress2;
                editrow.DeliveryAddress3 = debtor._DeliveryAddress3;
                editrow.DeliveryCity     = debtor._DeliveryCity;
                if (editrow.DeliveryZipCode != debtor._DeliveryZipCode)
                {
                    lookupZipCode           = false;
                    editrow.DeliveryZipCode = debtor._DeliveryZipCode;
                }
                if (debtor._DeliveryCountry != 0)
                {
                    editrow.DeliveryCountry = debtor._DeliveryCountry;
                }
                else
                {
                    editrow.DeliveryCountry = null;
                }
            }
            if (ProjectCache != null)
            {
                Projectlookupeditor.cache = ProjectCache;
            }

            TableField.SetUserFieldsFromRecord(debtor, editrow);
            BindContact(debtor);
            if (installationCache != null)
            {
                leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account);
                leDeliveryAddress.InvalidCache();
            }
            layoutItems.DataContext = null;
            layoutItems.DataContext = editrow;

            await api.Read(debtor);

            editrow.RefreshBalance();
        }
        private void PickingListReport(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi = new InvoiceAPI(api);
            var        debtor = dbOrder.Debtor;
            string     debtorName = string.Empty, accountName = string.Empty;
            bool       showSendByMail = false;

            if (debtor != null)
            {
                debtorName     = debtor._Name ?? dbOrder._DCAccount;
                accountName    = string.Format("{0} ({1})", dbOrder._DCAccount, dbOrder.Name);
                showSendByMail = !string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments;
            }

#if !SILVERLIGHT
            var cwPickingList = new CWGeneratePickingList(accountName, true, true, debtorName, showSendByMail);
            cwPickingList.DialogTableId = 2000000049;
#else
            var cwPickingList = new CWGeneratePickingList();
#endif
            cwPickingList.Closed += async delegate
            {
                if (cwPickingList.DialogResult == true)
                {
                    var selectedDate = cwPickingList.SelectedDate;

#if !SILVERLIGHT
                    var printDoc = cwPickingList.PrintDocument;
#else
                    var printDoc = false;
#endif
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this);
                    invoicePostingResult.SetUpInvoicePosting(dbOrder, null, CompanyLayoutType.PickingList, selectedDate, null, false, cwPickingList.ShowDocument, false, printDoc, cwPickingList.NumberOfPages,
                                                             cwPickingList.SendByEmail, cwPickingList.SendByOutlook, cwPickingList.sendOnlyToThisEmail, cwPickingList.EmailList, false, null, false);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Updatedata(dbOrder, CompanyLayoutType.PickingList);
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            cwPickingList.Show();
        }
示例#8
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();
        }
示例#9
0
        public override string CheckMandatoryFields(UnicontaBaseEntity record)
        {
            DebtorOrderClient order = (DebtorOrderClient)record;

            if (String.IsNullOrEmpty(order.YourRef))
            {
                return("Your reference");
            }
            if (String.IsNullOrEmpty(order.CustomsNo))
            {
                return("Customs number");
            }
            return(null);
        }
示例#10
0
        private void GenerateRecordInvoice(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi         = new InvoiceAPI(api);
            var        debtor         = dbOrder.Debtor;
            bool       showSendByMail = true;

            if (debtor != null)
            {
                showSendByMail = (!string.IsNullOrEmpty(debtor.InvoiceEmail) || debtor.EmailDocuments);
            }
            else
            {
                api.LoadCache(typeof(Debtor), true);
            }

            string debtorName   = debtor?.Name ?? dbOrder._DCAccount;
            bool   invoiceInXML = debtor?._InvoiceInXML ?? false;

            UnicontaClient.Pages.CWGenerateInvoice GenrateInvoiceDialog = new UnicontaClient.Pages.CWGenerateInvoice(true, string.Empty, false, true, true, showNoEmailMsg: !showSendByMail, debtorName: debtorName, isDebtorOrder: true, isOrderOrQuickInv: true, InvoiceInXML: invoiceInXML);
#if !SILVERLIGHT
            GenrateInvoiceDialog.DialogTableId = 2000000013;
#endif
            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);
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = true;
                    busyIndicator.IsBusy = false;

                    if (!result)
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgMultiInvGrid);
                    }
                }
            };
            GenrateInvoiceDialog.Show();
        }
        async void SetPrCategory(DebtorOrderClient editrow)
        {
            var cats = api.GetCache(typeof(Uniconta.DataModel.PrCategory)) ?? await api.LoadCache(typeof(Uniconta.DataModel.PrCategory));

            foreach (var rec in (Uniconta.DataModel.PrCategory[])cats.GetNotNullArray)
            {
                if (rec._CatType == CategoryType.OnAccountInvoicing)
                {
                    editrow.PrCategory = rec._Number;
                    if (rec._Default)
                    {
                        break;
                    }
                }
            }
        }
示例#12
0
        async void jumpToDebtor(DebtorOrderClient selectedItem)
        {
            var dc = selectedItem.Debtor;

            if (dc == null)
            {
                await api.CompanyEntity.LoadCache(typeof(Debtor), api, true);

                dc = selectedItem.Debtor;
            }
            var param = new object[2] {
                dc, true
            };

            AddDockItem(TabControls.DebtorAccountPage2, param, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("DebtorAccount"), dc.Account));
        }
示例#13
0
        void PostProjectOrder(DebtorOrderClient order)
        {
            var dialog = new CwPostProjectOrder();

            dialog.DialogTableId = 2000000087;
            dialog.Closed       += async delegate
            {
                if (dialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var invApi        = new Uniconta.API.DebtorCreditor.InvoiceAPI(api);
                    var postingResult = await invApi.PostProjectOrder(order, null, dialog.Date, dialog.Simulation, new GLTransClientTotal(), null, dialog.PostOnlyDelivered);

                    busyIndicator.IsBusy      = false;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg");
                    var ledgerRes = postingResult.ledgerRes;
                    if (ledgerRes == null)
                    {
                        return;
                    }
                    if (ledgerRes.Err != ErrorCodes.Succes)
                    {
                        Utility.ShowJournalError(ledgerRes, dgMultiInvGrid, false);
                    }
                    else if (dialog.Simulation && ledgerRes.SimulatedTrans != null && ledgerRes.SimulatedTrans.Length > 0)
                    {
                        AddDockItem(TabControls.SimulatedTransactions, ledgerRes.SimulatedTrans, Uniconta.ClientTools.Localization.lookup("SimulatedTransactions"), null, true);
                    }
                    else
                    {
                        string msg;
                        if (ledgerRes.JournalPostedlId != 0)
                        {
                            msg = string.Format("{0} {1}={2}", Uniconta.ClientTools.Localization.lookup("JournalHasBeenPosted"), Uniconta.ClientTools.Localization.lookup("JournalPostedId"), ledgerRes.JournalPostedlId);
                        }
                        else
                        {
                            msg = Uniconta.ClientTools.Localization.lookup("JournalHasBeenPosted");
                        }
                        UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message"));
                    }
                }
            };
            dialog.Show();
        }
示例#14
0
        private void PickingListReport(DebtorOrderClient dbOrder)
        {
            InvoiceAPI Invapi     = new InvoiceAPI(api);
            var        debtor     = dbOrder.Debtor;
            string     debtorName = debtor?._Name ?? dbOrder._DCAccount;

            var cwPickingList = new CWGeneratePickingList();

#if !SILVERLIGHT
            cwPickingList.DialogTableId = 2000000049;
#endif
            cwPickingList.Closed += async delegate
            {
                if (cwPickingList.DialogResult == true)
                {
                    var selectedDate = cwPickingList.SelectedDate;

#if !SILVERLIGHT
                    var printDoc = cwPickingList.PrintDocument;
#else
                    var printDoc = false;
#endif
                    var invoicePostingResult = new InvoicePostingPrintGenerator(api, this, dbOrder, null, selectedDate, 0, false, CompanyLayoutType.PickingList, true, printDoc,
                                                                                cwPickingList.NumberOfPages, cwPickingList.EmailList);

                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");
                    busyIndicator.IsBusy      = true;
                    var result = await invoicePostingResult.Execute();

                    busyIndicator.IsBusy = false;

                    if (result)
                    {
                        Updatedata(dbOrder, CompanyLayoutType.PickingList);
                    }
                    else
                    {
                        Utility.ShowJournalError(invoicePostingResult.PostingResult.ledgerRes, dgDebtorOrdersGrid);
                    }
                }
            };
            cwPickingList.Show();
        }
示例#15
0
        public ErrorCodes Execute(UnicontaBaseEntity master, UnicontaBaseEntity currentRow, IEnumerable <UnicontaBaseEntity> source, string command,
                                  string args)
        {
            var lines = GetFileContents(GetFileName());

            var order = new DebtorOrderClient();

            order.SetMaster(currentRow as DebtorClient);
            var orderResult = _crudAPI.Insert(order).Result;

            if (orderResult == ErrorCodes.Succes)
            {
                return(CreateLines(lines, order));
            }
            else
            {
                return(orderResult);
            }
        }
示例#16
0
        private void JoinToSelectedItem(DebtorOrderClient selectedItem)
        {
            var    ordersToBeJoined = dgJoinMultiOrderGrid.GetVisibleRows() as IEnumerable <DebtorOrderClient>;
            var    acc  = selectedItem._DCAccount;
            string acc2 = null;

            foreach (var rec in ordersToBeJoined)
            {
                if (rec._DCAccount != acc)
                {
                    acc2 = rec._DCAccount;
                    break;
                }
            }
            if (acc2 != null)
            {
                string msg = string.Format("{0}\r\n{1}", string.Format(Uniconta.ClientTools.Localization.lookup("DifferentAccountMessage"), acc, acc2),
                                           Uniconta.ClientTools.Localization.lookup("AreYouSureToContinue"));
                var confirmationDialog = new CWConfirmationBox(msg, Uniconta.ClientTools.Localization.lookup("Confirmation"), false);
                confirmationDialog.Closing += delegate
                {
                    if (confirmationDialog.ConfirmationResult == CWConfirmationBox.ConfirmationResultEnum.Yes)
                    {
                        EraseYearWindow EraseYearWindowDialog = new EraseYearWindow("", true);
                        EraseYearWindowDialog.Closed += delegate
                        {
                            if (EraseYearWindowDialog.DialogResult == true)
                            {
                                JoinAllOrdersToSelectedItem(selectedItem, ordersToBeJoined);
                            }
                        };
                        EraseYearWindowDialog.Show();
                    }
                };
                confirmationDialog.Show();
            }
            else
            {
                JoinAllOrdersToSelectedItem(selectedItem, ordersToBeJoined);
            }
        }
示例#17
0
        private ErrorCodes CreateLines(List <string[]> lines, DebtorClient debtorClient)
        {
            var ols   = new List <DebtorOrderLineClient>();
            var items = _crudAPI.Query <InvItemClient>().Result;

            var order = new DebtorOrderClient();

            order.SetMaster(debtorClient);
            var orderres = _crudAPI.Insert(order).Result;

            foreach (string[] s in lines)
            {
                var item = items.First(i => i.Item == s[1]);

                var fp = new FindPrices(order, _crudAPI);
                fp.UseCustomerPrices = true;
                fp.loadPriceList();

                var ol = new DebtorOrderLineClient
                {
                    Qty  = double.Parse(s[2]),
                    Item = item.Item,
                    //Date = DateTime.Parse(s[3]),
                };
                ol.SetMaster(order);

                fp.SetPriceFromItem(ol, item);

                ols.Add(ol);
            }

            var result = _crudAPI.Insert(ols).Result;

            if (result == ErrorCodes.Succes)
            {
                openOrderLines(order);
            }

            return(result);
        }
示例#18
0
        private async void createLines(List <string[]> lines)
        {
            var orders = new List <DebtorOrderClient>();
            var ols    = new List <DebtorOrderLineClient>();
            var items  = await crudAPI.Query <InvItemClient>();

            var debtors = await crudAPI.Query <DebtorClient>();

            foreach (string[] s in lines)
            {
                DebtorOrderClient order;
                order = orders.Where(o => o.Account == s[0]).FirstOrDefault();
                if (order == null)
                {
                    order = new DebtorOrderClient();
                    order.SetMaster(debtors.Where(d => d.Account == s[0]).First());
                    orders.Add(order);
                    var orderres = await crudAPI.Insert(order);
                }

                var item = items.Where(i => i.Item == s[1]).First();

                var fp = new FindPrices(order, crudAPI);
                fp.UseCustomerPrices = true;
                fp.loadPriceList();

                var ol = new DebtorOrderLineClient
                {
                    Qty  = double.Parse(s[2]),
                    Item = item.Item,
                    Date = DateTime.Parse(s[3]),
                };
                ol.SetMaster(order);

                fp.SetPriceFromItem(ol, item);

                await crudAPI.Insert(ol);
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var debtor     = this.CB_Customer.SelectedItem as DebtorClient;
            var invoiceAPI = UnicontaAPIManager.GetInvoiceAPI();

            // Creating DebtorOrder
            var debtorOrder = new DebtorOrderClient
            {
                _Currency = Currencies.DKK,
            };

            debtorOrder.SetMaster(debtor);

            // Creating DebtorOrderLine's
            var debtorOrderLines = new List <DebtorOrderLineClient>();
            var debtorOrderLine  = new DebtorOrderLineClient
            {
                _Item  = "OnSiteSupport",
                _Qty   = 2.0,
                _Price = 890,
            };

            debtorOrderLine.SetMaster(debtorOrder);
            debtorOrderLines.Add(debtorOrderLine);

            // Calling Invoice API.
            var invoiceResult = await invoiceAPI.PostInvoice(debtorOrder, debtorOrderLines, DateTime.Now, 0, false, SendEmail : true, Emails : "*****@*****.**", OnlyToThisEmail : true);

            if (invoiceResult.Err != ErrorCodes.Succes)
            {
                MessageBox.Show($"Failed to send invoice: {invoiceResult.Err.ToString()}");
                return;
            }

            MessageBox.Show($"Invoice has been send InvoiceNumber:{invoiceResult.Header._InvoiceNumber}");
        }
        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();
        }
示例#21
0
 private void openOrderLines(DebtorOrderClient order)
 {
     //TODO open orderlines tab
 }
        private void CreateMulitOrder(bool IsMultiOrder = true)
        {
            var cwCreateOrder = new CWCreateOrderFromProject(api);

#if !SILVERLIGHT
            cwCreateOrder.DialogTableId = 2000000052;
#endif
            cwCreateOrder.Closed += async delegate
            {
                if (cwCreateOrder.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg");
                    busyIndicator.IsBusy      = true;

                    IList projectList = null;

                    if (!IsMultiOrder)
                    {
                        var Arr = Array.CreateInstance(dgProjectMultiLineGrid.TableTypeUser, 1);
                        Arr.SetValue(dgProjectMultiLineGrid.SelectedItem, 0);
                        projectList = Arr;
                    }
                    else
                    {
                        projectList = dgProjectMultiLineGrid.GetVisibleRows();
                    }

                    var invoiceApi      = new Uniconta.API.Project.InvoiceAPI(api);
                    var debtorOrderType = api.CompanyEntity.GetUserTypeNotNull(typeof(DebtorOrderClient));
                    var errorlist       = new List <string>();
                    DebtorOrderClient debtorOrderInstance = null;
                    foreach (var proj in projectList)
                    {
                        var selectedItem = proj as ProjectClient;
                        debtorOrderInstance = Activator.CreateInstance(debtorOrderType) as DebtorOrderClient;
                        var result = await invoiceApi.CreateOrderFromProject(debtorOrderInstance, selectedItem._Number, CWCreateOrderFromProject.InvoiceCategory, CWCreateOrderFromProject.GenrateDate,
                                                                             CWCreateOrderFromProject.FromDate, CWCreateOrderFromProject.ToDate);

                        if (result != Uniconta.Common.ErrorCodes.Succes)
                        {
                            var error = string.Format("{0}: {1} - {2}", Uniconta.ClientTools.Localization.lookup("Project"), selectedItem._Number, Uniconta.ClientTools.Localization.lookup(result.ToString()));
                            errorlist.Add(error);
                        }
                    }
                    busyIndicator.IsBusy = false;

                    if (errorlist.Count > 1)
                    {
                        var errorDialog = new CWErrorBox(errorlist.ToArray(), true);
                        errorDialog.Show();
                    }
                    else if (!IsMultiOrder && errorlist.Count == 0)
                    {
                        ShowOrderLines(debtorOrderInstance);
                    }
                    else if (errorlist.Count == 1)
                    {
                        UnicontaMessageBox.Show(errorlist[0], Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
                    }

                    else
                    {
                        UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("SalesOrderCreated"), Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK);
                    }
                }
            };
            cwCreateOrder.Show();
        }
示例#23
0
 public DebtorOrderPrintReport(DebtorOrderClient debtOrder, CrudAPI api)
 {
     debtorOrder = debtOrder;
     Debtor      = debtOrder.Debtor;
     crudApi     = api;
 }
示例#24
0
        public void InsertSalgsfakturaer()
        {
            int?lastFakid = null;
            DebtorOrderClient recOrder = null;

            var rec_regnskab = Program.qryAktivRegnskab();
            var qrySFak      = from sfv in Program.karFakturavarer_s
                               join sf in Program.karFakturaer_s on new { fakid = sfv.Fakid } equals new { fakid = sf.fakid }
            where sf.faknr != 0 && sf.faktype == 0
            orderby sfv.Fakid, sfv.Line
                select new
            {
                Regnskabid  = rec_regnskab.Rid,
                Sk          = "S",
                Fakid       = sfv.Fakid,
                Faknr       = sf.faknr,
                Dato        = sf.dato,
                forfdato    = sf.forfdato,
                debitornr   = sf.debitornr,
                Faklinnr    = sfv.Line,
                Varenr      = sfv.Varenr,
                Tekst       = sfv.VareTekst,
                Konto       = sfv.Bogfkonto,
                Momskode    = KarKontoplan.getMomskode(sfv.Bogfkonto),
                Antal       = sfv.Antal,
                Enhed       = sfv.Enhed,
                Pris        = sfv.Pris,
                Rabat       = sfv.Rabat,
                Moms        = sfv.Moms,
                Nettobelob  = sfv.Nettobelob,
                Bruttobelob = sfv.Bruttobelob,
            };

            int antal = qrySFak.Count();

            var api = UCInitializer.GetBaseAPI;

            //var col3 = await api.Query<DebtorOrderClient>();
            //var col4 = await api.Query<DebtorOrderLineClient>();

            foreach (var s in qrySFak)
            {
                if ((!(s.Fakid == 0)) && (lastFakid != s.Fakid))
                {
                    try
                    {
                        var crit = new List <PropValuePair>();
                        var pair = PropValuePair.GenereteWhereElements("OrderNumber", typeof(int), s.Fakid.ToString());
                        crit.Add(pair);
                        var taskDebtorOrder = api.Query <DebtorOrderClient>(null, crit);
                        taskDebtorOrder.Wait();
                        var col = taskDebtorOrder.Result;
                        if (col.Count() == 0)
                        {
                            recOrder = new DebtorOrderClient()
                            {
                                OrderNumber  = s.Fakid,
                                Account      = s.debitornr.ToString(),
                                InvoiceDate  = s.Dato,
                                DeliveryDate = s.Dato,
                            };
                            var taskInsertDebtorOrder = api.Insert(recOrder);
                            taskInsertDebtorOrder.Wait();
                            var err = taskInsertDebtorOrder.Result;
                        }
                        else
                        {
                            recOrder = col[0];
                        }
                    }
                    catch { }
                }

                DebtorOrderLineClient recOrderLine = new DebtorOrderLineClient()
                {
                    Text           = s.Tekst,
                    Qty            = (double)s.Antal,
                    Price          = (double)s.Pris,
                    PostingAccount = KarNyKontoplan.NytKontonr(s.Konto)
                };
                recOrderLine.SetMaster(recOrder);
                var taskInsertDebtorOrderLine = api.Insert(recOrderLine);
                taskInsertDebtorOrderLine.Wait();
                var err1 = taskInsertDebtorOrderLine.Result;
            }
        }
        async Task CreateOrderLinesFromInvoice(DebtorOrderClient order, DebtorInvoiceClient invoice, bool checkIfCreditNote)
        {
            var orderlines = new List <DebtorOrderLineClient>();

            order.Lines = orderlines;
            var invoiceLines = await api.Query <DebtorInvoiceLines>(invoice);

            if (invoiceLines == null || invoiceLines.Length == 0)
            {
                return;
            }

            Array.Sort(invoiceLines, new InvLineSort());

            orderlines.Capacity = invoiceLines.Length;
            int    lineNo = 0;
            double sign   = checkIfCreditNote ? -1d : 1d;

            foreach (var invoiceline in invoiceLines)
            {
                var line = new DebtorOrderLineClient();
                line.SetMaster(order);

                line._LineNumber  = ++lineNo;
                line._Item        = invoiceline._Item;
                line._DiscountPct = invoiceline._DiscountPct;
                line._Discount    = invoiceline._Discount;
                line._Qty         = invoiceline.InvoiceQty * sign;
                line._Price       = (invoiceline.CurrencyEnum != null ? invoiceline._PriceCur : invoiceline._Price);
                if (line._Price != 0)
                {
                    line._Price += invoiceline._PriceVatPart;
                }

                if (line._Qty * line._Price == 0)
                {
                    line._AmountEntered = ((invoiceline.CurrencyEnum != null ? invoiceline._AmountCur : invoiceline._Amount) + invoiceline._PriceVatPart) * sign;
                }

                line._Dim1      = invoiceline._Dim1;
                line._Dim2      = invoiceline._Dim2;
                line._Dim3      = invoiceline._Dim3;
                line._Dim4      = invoiceline._Dim4;
                line._Dim5      = invoiceline._Dim5;
                line._Employee  = invoiceline._Employee;
                line._Note      = invoiceline._Note;
                line._Text      = invoiceline._Text;
                line._Unit      = invoiceline._Unit;
                line._Variant1  = invoiceline._Variant1;
                line._Variant2  = invoiceline._Variant2;
                line._Variant3  = invoiceline._Variant3;
                line._Variant4  = invoiceline._Variant4;
                line._Variant5  = invoiceline._Variant5;
                line._Warehouse = invoiceline._Warehouse;
                line._Location  = invoiceline._Location;

                var selectedItem = (InvItem)items?.Get(invoiceline._Item);
                if (selectedItem != null)
                {
                    line._Item          = selectedItem._Item;
                    line._CostPriceLine = selectedItem._CostPrice;
                    if (selectedItem._Unit != 0)
                    {
                        line._Unit = selectedItem._Unit;
                    }
                }

                orderlines.Add(line);
            }
            dcOrderlineGrid.ItemsSource = debtorOrderLines = null;
            dcOrderlineGrid.ItemsSource = debtorOrderLines = orderlines;
            dcOrderlineGrid.Visibility  = Visibility.Visible;
        }
示例#26
0
 private void openOrderLines(DebtorOrderClient order)
 {
     UnicontaTabs.OpenTab(UnicontaTabs.DebtorOrdersLine, new object[] { order });
 }
示例#27
0
 public void SetOrder(DebtorOrderClient order)
 {
     this.order = order;
     this.TB_OrderNumber.Text = "OrderNumber: " + this.order.OrderNumber;
 }
示例#28
0
        private async void B_Orders_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var orders = CSVUtils.ParseOrders(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Orders.csv");

            // Creating SQLCache's
            SQLCache customerCache = crudAPI.CompanyEntity.GetCache(typeof(DebtorClient));

            if (customerCache == null)
            {
                customerCache = await crudAPI.CompanyEntity.LoadCache(typeof(DebtorClient), crudAPI);
            }

            SQLCache inventoryCache = crudAPI.CompanyEntity.GetCache(typeof(InvItemClient));

            if (inventoryCache == null)
            {
                inventoryCache = await crudAPI.CompanyEntity.LoadCache(typeof(InvItemClient), crudAPI);
            }

            // Creating Insert List
            var newDebtorOrderClients = new List <DebtorOrderClient>();

            foreach (var order in orders)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(order.AccountNumber) + 20000).ToString();

                // Finding customer in cache
                var customer = customerCache.Get(accountNumber) as DebtorClient;

                var newDebtorOrderClient = new DebtorOrderClient
                {
                    _Created = order.CreatedDate
                };
                newDebtorOrderClient.SetMaster(customer);
                newDebtorOrderClients.Add(newDebtorOrderClient);
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorOrderClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import orders {errorCode.ToString()}");
            }

            // Creating order lines
            var newDebtorOrderLineClients = new List <DebtorOrderLineClient>();
            var inventoryList             = inventoryCache.GetRecords as InvItemClient[];

            var index = 0;

            foreach (var debtorOrder in newDebtorOrderClients)
            {
                var orderItems = orders[index].Items;
                foreach (var item in orderItems)
                {
                    var inventoryItem = inventoryList.FirstOrDefault(i => i.Name == item.ItemName);

                    var orderLine = new DebtorOrderLineClient
                    {
                        _Item  = inventoryItem.Item,
                        _Qty   = 1,
                        _Price = inventoryItem.SalesPrice1
                    };
                    orderLine.SetMaster(debtorOrder);
                    newDebtorOrderLineClients.Add(orderLine);
                }
                ;

                index++;
            }
            ;

            // Calling insert API
            var errorCode2 = await crudAPI.Insert(newDebtorOrderLineClients);

            if (errorCode2 != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import order lines {errorCode2.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }