public void IsSet()
        {
            var order = new OrderCarrier();

            using (CalculatorContext.Use(order))
            {
                Assert.Same(order, CalculatorContext.GetCurrentOrderCarrier());
            }

            Assert.Null(CalculatorContext.GetCurrentOrderCarrier());
        }
Example #2
0
        public virtual void CalculateTotalOrderRowsVat(OrderCarrier orderCarrier)
        {
            var totalOrderRowVAT = 0m;

            using (CalculatorContext.Use(orderCarrier))
            {
                foreach (var row in orderCarrier.OrderRows.Where(r => !r.CarrierState.IsMarkedForDeleting))
                {
                    CalculateOrderRowVat(orderCarrier, row);
                    totalOrderRowVAT += row.TotalVATAmount;
                }
            }
            orderCarrier.TotalOrderRowVAT = totalOrderRowVAT;
        }
Example #3
0
        /// <summary>Calculates the specified order carrier.</summary>
        /// <param name="orderCarrier"> The order carrier. </param>
        /// <param name="includeCampaignCalculator"> if set to <c>true</c> [include campaign calculator]. </param>
        /// <param name="securityToken"> The security token. </param>
        public virtual void Calculate(
            OrderCarrier orderCarrier,
            bool includeCampaignCalculator,
            SecurityToken securityToken)
        {
            using (CalculatorContext.Use(orderCarrier))
            {
                deliveryCostCalculator.CalculateFromCarrier(orderCarrier, securityToken);
                feesCalculator.CalculateFromCarrier(orderCarrier, securityToken);
                orderTotalCalculator.CalculateFromCarrier(orderCarrier, securityToken);
                if (includeCampaignCalculator)
                {
                    campaignCalculator.CalculateFromCarrier(orderCarrier, securityToken);
                }

                vatCalculator.CalculateFromCarrier(orderCarrier, securityToken);
                orderGrandTotalCalculator.Calculate(orderCarrier, securityToken);
            }
        }
Example #4
0
        public void CalculateOrderRowVat()
        {
            var row = new OrderRowCarrier
            {
                UnitListPrice = 1.67226891m,
                // Currency decimals in this example = 3
                TotalPrice    = 1.672m,
                VATPercentage = 0.19m,
                Quantity      = 1
            };

            var order = new OrderCarrier();

            using (CalculatorContext.Use(order))
            {
                sut.CalculateOrderRowVat(row);
            }

            Assert.Equal(0.318m, row.TotalVATAmount);
            Assert.Equal(1.99m, row.TotalPriceWithVAT);
        }
Example #5
0
        public void CalculateOrderRowVat2()
        {
            UseCurrency("EUR");
            var row = new OrderRowCarrier
            {
                UnitListPrice = 1.60483871m,
                // Currency decimals in this example = 2
                TotalPrice    = 1.6m,
                VATPercentage = 0.24m,
                Quantity      = 1
            };

            var order = new OrderCarrier();

            using (CalculatorContext.Use(order))
            {
                sut.CalculateOrderRowVat(row);
            }

            Assert.Equal(0.39m, row.TotalVATAmount);
            Assert.Equal(1.99m, row.TotalPriceWithVAT);
        }
        public void CalculateOrderRowTotal_RoundBasedOnContext()
        {
            var order = new OrderCarrier
            {
                OrderRows = new List <OrderRowCarrier>
                {
                    new OrderRowCarrier
                    {
                        UnitListPrice = 1.67226891m,
                        Quantity      = 1
                    }
                }
            };

            var row = order.OrderRows.Single();

            using (CalculatorContext.Use(order))
            {
                sut.CalculateOrderRowTotal(row);
            }

            Assert.Equal(1.672m, row.TotalPrice);
        }