public static TaxRate ToWebModel(this VirtoCommerceDomainTaxModelTaxRate serviceModel, Currency currency)
        {
            var retVal = new TaxRate(currency);
            retVal.Rate = new Money(serviceModel.Rate.Value, currency);
            if (serviceModel.Line != null)
            {
                retVal.Line = new TaxLine(currency);
                retVal.Line.InjectFrom(serviceModel.Line);
                retVal.Line.Amount = new Money(serviceModel.Line.Amount.Value, currency);
                retVal.Line.Price = new Money(serviceModel.Line.Price.Value, currency);
            }

            return retVal;
        }
Esempio n. 2
0
        public void ApplyTaxRates(IEnumerable <TaxRate> taxRates)
        {
            TaxPercentRate = 0m;
            var paymentTaxRate = taxRates.FirstOrDefault(x => x.Line.Id != null && x.Line.Id.EqualsInvariant(Code ?? ""));

            if (paymentTaxRate != null && paymentTaxRate.Rate.Amount > 0)
            {
                var amount = Total.Amount > 0 ? Total.Amount : Price.Amount;
                if (amount > 0)
                {
                    TaxPercentRate = TaxRate.TaxPercentRound(paymentTaxRate.Rate.Amount / amount);
                }
            }
        }
Esempio n. 3
0
        public void ApplyTaxRates(IEnumerable <TaxRate> taxRates)
        {
            TaxPercentRate = 0m;
            var taxLineId = BuildTaxLineId();
            var taxRate   = taxRates.FirstOrDefault(x => x.Line.Id == taxLineId);

            if (taxRate != null && taxRate.Rate.Amount > 0)
            {
                var amount = Total.Amount > 0 ? Total.Amount : Price.Amount;
                if (amount > 0)
                {
                    TaxPercentRate = TaxRate.TaxPercentRound(taxRate.Rate.Amount / amount);
                }
            }
        }
Esempio n. 4
0
        public void ApplyTaxRates(IEnumerable <TaxRate> taxRates)
        {
            var shipmentTaxRate = taxRates.FirstOrDefault(x => x.Line.Quantity == Quantity);

            if (shipmentTaxRate != null)
            {
                if (shipmentTaxRate.PercentRate > 0)
                {
                    TaxPercentRate = shipmentTaxRate.PercentRate;
                }
                else
                {
                    if (ActualPrice.Amount > 0)
                    {
                        TaxPercentRate = TaxRate.TaxPercentRound(shipmentTaxRate.Rate.Amount / ActualPrice.Amount);
                    }
                }

                TaxDetails = shipmentTaxRate.Line.TaxDetails;
            }
        }