Esempio n. 1
0
        public void Add(fin_article pArticle, Guid pPlaceOid, Guid pTableOid, PriceType pPriceType, decimal pQuantity, fin_configurationvatexemptionreason pVatExemptionReason)
        {
            ArticleBagKey        articleBagKey;
            ArticleBagProperties articleBagProps;

            //Get Place Object to extract TaxSellType Normal|TakeWay
            pos_configurationplace configurationPlace = (pos_configurationplace)GlobalFramework.SessionXpo.GetObjectByKey(typeof(pos_configurationplace), pPlaceOid);
            TaxSellType            taxSellType        = (configurationPlace.MovementType.VatDirectSelling) ? TaxSellType.TakeAway : TaxSellType.Normal;

            PriceProperties priceProperties = FrameworkUtils.GetArticlePrice(pArticle, taxSellType);

            //Prepare articleBag Key and Props
            articleBagKey = new ArticleBagKey(
                pArticle.Oid,
                pArticle.Designation,
                priceProperties.PriceNet,
                priceProperties.DiscountArticle,
                priceProperties.Vat,
                pVatExemptionReason.Oid
                );
            articleBagProps = new ArticleBagProperties(
                pPlaceOid,
                pTableOid,
                pPriceType,
                pArticle.Code,
                pQuantity,
                pArticle.UnitMeasure.Acronym
                );

            //Send to Bag
            Add(articleBagKey, articleBagProps);
        }
Esempio n. 2
0
        /// <summary>
        /// Used to Update Article Bag Price Properties, Prices, Totals etc, All Other Fields that not are Sent via Key and Props
        /// </summary>
        /// <param name="pKey"></param>
        /// <param name="pProps"></param>
        /// <returns></returns>
        public void UpdateKeyProperties(ArticleBagKey pKey)
        {
            bool debug = false;

            //Get Fresh PriceProperties Helper Object to Calc
            PriceProperties priceProperties = PriceProperties.GetPriceProperties(
                PricePropertiesSourceMode.FromPriceNet,
                false,
                pKey.Price,
                this[pKey].Quantity,
                pKey.Discount,
                this._discountGlobal,
                pKey.Vat
                );

            this[pKey].PriceWithDiscount       = priceProperties.PriceWithDiscount;
            this[pKey].PriceWithDiscountGlobal = priceProperties.PriceWithDiscountGlobal;
            this[pKey].TotalGross    = priceProperties.TotalGross;
            this[pKey].TotalNet      = priceProperties.TotalNet;
            this[pKey].TotalDiscount = priceProperties.TotalDiscount;
            this[pKey].TotalTax      = priceProperties.TotalTax;
            this[pKey].TotalFinal    = priceProperties.TotalFinal;
            this[pKey].PriceFinal    = priceProperties.PriceFinal;

            if (debug)
            {
                priceProperties.SendToLog("");
                _log.Debug(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}",
                                         this[pKey].Code, pKey.Designation, this[pKey].Quantity, this[pKey].TotalGross, this[pKey].PriceWithDiscount, this[pKey].PriceWithDiscountGlobal, this[pKey].TotalGross, this[pKey].TotalNet, this[pKey].TotalDiscount, this[pKey].TotalTax, this[pKey].TotalFinal));
            }
        }
Esempio n. 3
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Add From ArticleBag Key/Props

        //NEW: Override/Replace Dictionary Add with() Custom Add()
        new public void Add(ArticleBagKey pKey, ArticleBagProperties pProps)
        {
            //Init local vars
            ArticleBagKey        key   = pKey;
            ArticleBagProperties props = pProps;

            //Get Fresh PriceProperties Helper Object to used for Addition (Vat and Totals)
            PriceProperties addPriceProperties = PriceProperties.GetPriceProperties(
                PricePropertiesSourceMode.FromPriceNet,
                false,
                pKey.Price,
                pProps.Quantity,
                pKey.Discount,
                this._discountGlobal,
                pKey.Vat
                );

            //If Key doesnt exists Add it
            if (!this.ContainsKey(key))
            {
                base.Add(key, props);
            }
            //Else Update Key, Increase Quantity
            else
            {
                this[key].Quantity += props.Quantity;
            }

            //Refresh Current Key Price Properties after Add Quantity)
            UpdateKeyProperties(key);

            //TaxBag Add Key
            if (!_taxBag.ContainsKey(key.Vat))
            {
                //Get Designation from Key
                //Get VatRate formated for filter, in sql server gives error without this it filters 23,0000 and not 23.0000 resulting in null vatRate
                string sql         = string.Format("SELECT Designation FROM fin_configurationvatrate WHERE VALUE = '{0}'", FrameworkUtils.DecimalToString(key.Vat, GlobalFramework.CurrentCultureNumberFormat));
                string designation = GlobalFramework.SessionXpo.ExecuteScalar(sql).ToString();
                //Now Add New Key with Designation
                _taxBag.Add(key.Vat, new TaxBagProperties(designation, addPriceProperties.TotalTax, addPriceProperties.TotalNet));
            }
            //Update Key, Add Vat
            else
            {
                _taxBag[key.Vat].Total     += addPriceProperties.TotalTax;
                _taxBag[key.Vat].TotalBase += addPriceProperties.TotalNet;
            }

            _totalQuantity += addPriceProperties.Quantity;
            _totalNet      += addPriceProperties.TotalNet;
            _totalGross    += addPriceProperties.TotalGross;
            _totalTax      += addPriceProperties.TotalTax;
            _totalDiscount += addPriceProperties.TotalDiscount;
            _totalFinal    += addPriceProperties.TotalFinal;
        }
Esempio n. 4
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        //Used to Remove PartialPayments from ArticleBag
        public void Remove(ArticleBagKey pKey, decimal pRemoveQuantity)
        {
            //Get PriceProperties Helper Object to Remove from current Key
            PriceProperties removePriceProperties = PriceProperties.GetPriceProperties(
                PricePropertiesSourceMode.FromPriceNet,
                false,
                pKey.Price,
                pRemoveQuantity,
                pKey.Discount,
                this._discountGlobal,
                pKey.Vat
                );

            //Decrease Quantity
            this[pKey].Quantity -= pRemoveQuantity;

            // SplitPayment : Sometimes we get 0.000000000000001, that makes key dont be removed because its not < 0
            // To prevent this we must round value before compare using DecimalFormatStockQuantity
            string  roundedFormat   = $"{{0:{SettingsApp.DecimalFormatStockQuantity}}}";//{0:0.00000000}
            decimal roundedQuantity = Convert.ToDecimal(string.Format(roundedFormat, this[pKey].Quantity));

            //if (this[pKey].Quantity <= 0)
            if (roundedQuantity <= 0)
            {
                this.Remove(pKey);
            }
            else
            {
                //Refresh Current Key Price Properties after Add Quantity)
                UpdateKeyProperties(pKey);
            }

            //Calc Article Grand Totals
            _totalQuantity -= removePriceProperties.Quantity;
            _totalNet      -= removePriceProperties.TotalNet;
            _totalGross    -= removePriceProperties.TotalGross;
            _totalTax      -= removePriceProperties.TotalTax;
            _totalDiscount -= removePriceProperties.TotalDiscount;
            _totalFinal    -= removePriceProperties.TotalFinal;

            //TaxBag Update
            _taxBag[pKey.Vat].Total     -= removePriceProperties.TotalTax;
            _taxBag[pKey.Vat].TotalBase -= removePriceProperties.TotalNet;
        }
Esempio n. 5
0
        public static PriceProperties GetPriceProperties(PricePropertiesSourceMode pSourceMode, bool pPriceWithVat, decimal pSource, decimal pQuantity, decimal pDiscountArticle, decimal pDiscountGlobal, decimal pVat)
        {
            PriceProperties result = new PriceProperties(pSourceMode, pPriceWithVat, pSource, pQuantity, pDiscountArticle, pDiscountGlobal, pVat);

            return(result);
        }