Ejemplo n.º 1
0
        /// <summary>
        /// le taux de marque permet de calculer la marge directement depuis le prix de vente HT. Pvht * Tmq = la marge
        /// </summary>
        public static decimal GetSellingAmount(VATEnum iResultTypePrice, decimal iNetMarkRatePercentage, decimal iBuyingAmount, decimal iShippingAmountTTC, decimal iVariableFeePercentage, decimal iFixedFeeAmount, decimal iVATRate, ConditionEnum iCondition)
        {
            //TVA sur CA
            if (iCondition == ConditionEnum.UNUSED)
            {
                decimal sellingAmountHT = (iBuyingAmount + (iShippingAmountTTC * iVariableFeePercentage / 100) + iFixedFeeAmount) / (1 - iNetMarkRatePercentage / 100 - (1 + iVATRate / 100) * iVariableFeePercentage / 100);

                //retourne le TTC
                if (iResultTypePrice == VATEnum.TTC)
                {
                    return((sellingAmountHT * (1 + (iVATRate / 100))).Round2());
                }
                //Retourne le HT
                else if (iResultTypePrice == VATEnum.HT)
                {
                    return(sellingAmountHT.Round2());
                }
                else
                {
                    throw new NotSupportedException(iResultTypePrice.ToStringWithEnumName());
                }

                //Prht = Paht + Fv + Ff  avec Prht = pvht(1-tmq)
                //Pvht = (Paht + Lvttc*Tfv +FF)/(1 - tmq - (1+TVA)(Tfv))   avec Pvttc = pvht *(1+TVA)
            }

            //Tva sur marge
            else if (iCondition == ConditionEnum.USED)
            {
                decimal sellingPriceHT = (iBuyingAmount + (iShippingAmountTTC - iBuyingAmount * (iVATRate / 100)) * (iVariableFeePercentage / 100) + iFixedFeeAmount) / (1 - iNetMarkRatePercentage / 100 - (1 + iVATRate / 100) * iVariableFeePercentage / 100);

                //retourne le TTC
                if (iResultTypePrice == VATEnum.TTC)
                {
                    return((sellingPriceHT + (sellingPriceHT - iBuyingAmount) * (iVATRate / 100)).Round2());
                }
                //Retourne le HT
                else if (iResultTypePrice == VATEnum.HT)
                {
                    return((sellingPriceHT).Round2());
                }
                else
                {
                    throw new NotSupportedException(iResultTypePrice.ToStringWithEnumName());
                }

                //Prht = Paht + Fv + Ff   avec Pvttc = Pvht + (pvht - paht)*TVA  avec Prht = pvht(1-tmq)
                //pvht = Paht + (Lvttc - Paht*TVA)Tfv + Ff)/(1-Tmq - (1+tva)Tfv)
            }
            else
            {
                throw new NotSupportedException(iCondition.ToStringWithEnumName());
            }
        }