Exemple #1
0
        private void UpdatePriceProperties()
        {
            if (_crudWidgetPrice.Validated && _crudWidgetQuantity.Validated && _crudWidgetDiscount.Validated && _crudWidgetSelectVatRate.Validated)
            {
                PriceProperties priceProperties = PriceProperties.GetPriceProperties(
                    PricePropertiesSourceMode.FromPriceUser,
                    false, //PriceWithVat : Always use PricesWithoutVat in Invoices
                    _articlePrice,
                    FrameworkUtils.StringToDecimal(_entryBoxValidationQuantity.EntryValidation.Text),
                    FrameworkUtils.StringToDecimal(_entryBoxValidationDiscount.EntryValidation.Text),
                    _discountGlobal,
                    _entryBoxSelectVatRate.Value.Value
                    );
                //priceProperties.SendToLog(article.Designation);

                //Update UI / Display with ExchangeRate
                _entryBoxValidationTotalNet.EntryValidation.Text   = FrameworkUtils.DecimalToString(priceProperties.TotalNet * _currencyDisplay.ExchangeRate);
                _entryBoxValidationTotalFinal.EntryValidation.Text = FrameworkUtils.DecimalToString(priceProperties.TotalFinal * _currencyDisplay.ExchangeRate);
            }
            else
            {
                _entryBoxValidationTotalNet.EntryValidation.Text   = FrameworkUtils.DecimalToString(0.0m);
                _entryBoxValidationTotalFinal.EntryValidation.Text = FrameworkUtils.DecimalToString(0.0m);
            }
        }
Exemple #2
0
        //Change Price
        void _buttonKeyChangePrice_Clicked(object sender, EventArgs e)
        {
            decimal oldValueQuantity = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.Quantity;
            decimal oldValuePrice    = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.PriceFinal;

            MoneyPadResult result        = PosMoneyPadDialog.RequestDecimalValue(_sourceWindow, Resx.window_title_dialog_moneypad_product_price, oldValuePrice);
            decimal        newValuePrice = result.Value;

            if (result.Response == ResponseType.Ok && newValuePrice > 0)
            {
                //Create a Fresh Object to Get Input Price and Calc from TotalFinal with Quantity 1, Without Touch Quantity in current Line
                PriceProperties priceProperties = PriceProperties.GetPriceProperties(
                    PricePropertiesSourceMode.FromTotalFinal,
                    CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.PriceWithVat,
                    newValuePrice,
                    1.0m,
                    CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.DiscountArticle,
                    CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.DiscountGlobal,
                    CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.Vat
                    );

                //Update orderDetails
                CurrentOrderDetails.Update(_listStoreModelSelectedIndex, oldValueQuantity, priceProperties.PriceUser);
                //Update TreeView Model Price
                _listStoreModel.SetValue(_treeIter, (int)TicketListColumns.Price, FrameworkUtils.DecimalToString(newValuePrice));
                //Update Total
                decimal totalLine = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.TotalFinal;
                _listStoreModel.SetValue(_treeIter, (int)TicketListColumns.Total, FrameworkUtils.DecimalToString(totalLine));
            }
            UpdateTicketListTotal();
        }
Exemple #3
0
        //Update TreeView TotalFinal, used when we change Customer Discount, this way we update Total Final for all Articles in TreeView
        public void UpdateTotalFinal()
        {
            bool debug = false;

            try
            {
                if (_treeViewArticles.DataSource.Rows.Count > 0)
                {
                    FIN_Article article;
                    //Get Discount from Select Customer
                    decimal discountGlobal = FrameworkUtils.StringToDecimal(_pagePad2.EntryBoxCustomerDiscount.EntryValidation.Text);
                    decimal exchangeRate   = _pagePad1.EntryBoxSelectConfigurationCurrency.Value.ExchangeRate;

                    //Update DataTable Rows
                    foreach (DataRow item in _treeViewArticles.DataSource.Rows)
                    {
                        article = (FIN_Article)FrameworkUtils.GetXPGuidObject(typeof(FIN_Article), new Guid(item.ItemArray[item.Table.Columns["Oid"].Ordinal].ToString()));

                        //Calc PriceProperties
                        PriceProperties priceProperties = PriceProperties.GetPriceProperties(
                            PricePropertiesSourceMode.FromPriceNet,
                            false,                                                                                                       //PriceWithVat
                            Convert.ToDecimal(item.ItemArray[item.Table.Columns["Price"].Ordinal]),                                      //Price
                            Convert.ToDecimal(item.ItemArray[item.Table.Columns["Quantity"].Ordinal]),                                   //Quantity
                            Convert.ToDecimal(item.ItemArray[item.Table.Columns["Discount"].Ordinal]),                                   //Discount
                            discountGlobal,
                            (item.ItemArray[item.Table.Columns["ConfigurationVatRate.Value"].Ordinal] as FIN_ConfigurationVatRate).Value //VatValue
                            );

                        //Finnally Update DataSourceRow Value with calculated PriceProperties
                        if (debug)
                        {
                            _log.Debug(string.Format("#1:TotalFinal DataSourceRow: [{0}], discountGlobal: [{1}]", FrameworkUtils.DecimalToString(Convert.ToDecimal(_treeViewArticles.DataSourceRow["TotalFinal"])), FrameworkUtils.DecimalToString(discountGlobal)));
                        }
                        //Update Display Values with ExchangeRate Multiplier
                        item["PriceDisplay"] = priceProperties.PriceNet * exchangeRate;
                        item["TotalNet"]     = (priceProperties.TotalNet * exchangeRate);
                        item["TotalFinal"]   = priceProperties.TotalFinal * exchangeRate;
                        item["PriceFinal"]   = priceProperties.PriceFinal * exchangeRate;
                        if (debug)
                        {
                            _log.Debug(string.Format("#2:TotalFinal DataSourceRow: [{0}], discountGlobal: [{1}]", FrameworkUtils.DecimalToString(Convert.ToDecimal(_treeViewArticles.DataSourceRow["TotalFinal"])), FrameworkUtils.DecimalToString(discountGlobal)));
                        }
                    }
                    //Call Refresh, Recreate TreeView from Model
                    _treeViewArticles.Refresh();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Exemple #4
0
        //Change Price
        void _buttonKeyChangePrice_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Get Index of article with correct final price
                _listStoreModelSelectedIndex = _currentOrderDetails.Lines.FindIndex(item => item.ArticleOid == (Guid)_listStoreModel.GetValue(_treeIter,
                                                                                                                                              (int)TicketListColumns.ArticleId) && Math.Round(Convert.ToDecimal(item.Properties.PriceFinal), SettingsApp.DecimalRoundTo) == Convert.ToDecimal(_listStoreModel.GetValue(_treeIter, (int)TicketListColumns.Price)));

                decimal oldValueQuantity = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.Quantity;
                decimal oldValuePrice    = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.PriceFinal;

                MoneyPadResult result        = PosMoneyPadDialog.RequestDecimalValue(_sourceWindow, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_moneypad_product_price"), oldValuePrice);
                decimal        newValuePrice = result.Value;

                if (result.Response == ResponseType.Ok && newValuePrice > 0)
                {
                    //Create a Fresh Object to Get Input Price and Calc from TotalFinal with Quantity 1, Without Touch Quantity in current Line
                    PriceProperties priceProperties = PriceProperties.GetPriceProperties(
                        PricePropertiesSourceMode.FromTotalFinal,
                        CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.PriceWithVat,
                        newValuePrice,
                        1.0m,
                        CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.DiscountArticle,
                        CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.DiscountGlobal,
                        CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.Vat
                        );
                    int countDuplicatedArticles = 0;
                    int i = 0;
                    foreach (var line in _currentOrderDetails.Lines)
                    {
                        if (_listStoreModelSelectedIndex == i)
                        {
                            countDuplicatedArticles++;
                        }
                        if (line.ArticleOid == CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].ArticleOid && line.Properties.PriceUser == priceProperties.PriceUser)
                        {
                            countDuplicatedArticles++;
                        }
                        i++;
                    }

                    if (countDuplicatedArticles > 1)
                    {
                        int oldIndex = _listStoreModelSelectedIndex;
                        _listStoreModelSelectedIndex = _currentOrderDetails.Lines.FindIndex(item => item.ArticleOid == (Guid)_listStoreModel.GetValue(_treeIter, (int)TicketListColumns.ArticleId) &&
                                                                                            item.Properties.PriceFinal == priceProperties.PriceFinal);
                        oldValueQuantity += CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.Quantity;
                        CurrentOrderDetails.Delete(oldIndex);
                        _listStoreModel.Remove(ref _treeIter);
                    }

                    //Update orderDetails
                    CurrentOrderDetails.Update(_listStoreModelSelectedIndex, oldValueQuantity, priceProperties.PriceUser);
                    //Update TreeView Model Price
                    _listStoreModel.SetValue(_treeIter, (int)TicketListColumns.Price, FrameworkUtils.DecimalToString(newValuePrice));
                    //Update Total
                    decimal totalLine = CurrentOrderDetails.Lines[_listStoreModelSelectedIndex].Properties.TotalFinal;
                    _listStoreModel.SetValue(_treeIter, (int)TicketListColumns.Total, FrameworkUtils.DecimalToString(totalLine));
                }
                UpdateTicketListTotal();
                UpdateModel();
                UpdateTicketListButtons();
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }