예제 #1
0
파일: Item.cs 프로젝트: yasarq/keoghs
        public Item(char sku, decimal unitPrice, IPricing promotion = null)
        {
            if (unitPrice <= 0)
            {
                throw new ArgumentException("Unit price must be greater than zero", nameof(unitPrice));
            }

            PRODUCT   = sku;
            UnitPrice = unitPrice;
            Promotion = promotion;
        }
예제 #2
0
 public CartController(
     ICarts carts,
     IPricing pricing,
     ILogger <CartController> logger,
     IServiceProvider serviceProvider)
 {
     _carts           = carts;
     _pricing         = pricing;
     _logger          = logger;
     _pricing         = pricing;
     _serviceProvider = serviceProvider;
 }
예제 #3
0
 public CartController(
     ICarts carts,
     IPricing pricing,
     IEventEmitter eventEmitter,
     ILogger <CartController> logger)
 {
     _carts        = carts;
     _eventEmitter = eventEmitter;
     _pricing      = pricing;
     _logger       = logger;
     _pricing      = pricing;
 }
예제 #4
0
        /// <summary>
        /// Gets price information for a variation as a Price object. You can get the monetary price from the UnitPrice member.
        /// </summary>
        /// <param name="pricing">The variation.</param>
        /// <param name="market">The market.</param>
        /// <returns></returns>
        public static Price GetPrice(this IPricing pricing, IMarket market)
        {
            if (pricing == null)
            {
                return(null);
            }

            IMarket currentMarket = market;

            if (market == null)
            {
                currentMarket = _currentMarket.Service.GetCurrentMarket();
            }

            return(pricing.GetPrices(injectedPriceLoader.Service).FirstOrDefault(x => x.MarketId == currentMarket.MarketId));
        }
예제 #5
0
 public static Price GetPrice(IPricing pricing)
 {
     return(pricing.GetPrices(injectedPriceLoader.Service).FirstOrDefault(x => x.MarketId == injectedMarketService.Service.GetCurrentMarket().MarketId));
 }
예제 #6
0
 public PointOfSaleTerminal(ICart cart, IPricing prices, IPricingAlgorithm priceCalulationAlgorithm)
 {
     this.prices = prices;
     this.priceCalulationAlgorithm = priceCalulationAlgorithm;
     this.cart = cart;
 }
예제 #7
0
 protected Price GetPrice(IPricing pricing)
 {
     return(pricing.GetPrices(PricingLoader).FirstOrDefault(x => x.MarketId == CurrentMarket.GetCurrentMarket().MarketId));
 }
        // Extra tax for Stockholm
        protected override Money CalculateTaxTotal(
            IOrderGroup orderGroup
            , IMarket market
            , Currency currency)
        {
            // may have use of this
            // could have Cart/PO-property like ... "CheckTaxStandAlone" for forking code (used with the bogus-cart)
            this._orderGroup = orderGroup;
            decimal d = 0;

            if (market.MarketId.Value == "sv")
            {
                // need the shipment with the new stuff... else coding against the old stuff manually
                IShipment        ship      = orderGroup.GetFirstShipment();
                List <ITaxValue> taxValues = new List <ITaxValue>();

                // Could have a generic "sv"-tax and... and onther higher for Stockholm (address.city)
                // .. but then the below is not needed
                // could set the City, Country etc. based on a IP-LookUp or something Market-wise
                // Could have the "Stockholm Market" where taxes and prices are higher

                // ...just for testing
                if (ship.ShippingAddress == null)
                {
                    this.address        = _orderGroupFactory.Service.CreateOrderAddress(orderGroup);
                    address.CountryCode = "sv";
                    address.CountryName = "sv";

                    // Like The Netherlands tourist accommodation tax ... differs between cities
                    // when you set the city in CM-->Admin-->Taxes ... it gets excluded
                    // and no tax is applied... have to find a "WorkAround"
                    // the rest works...
                    address.City         = "Stockholm";
                    address.Id           = "DummyAddress";
                    ship.ShippingAddress = address;
                }

                if (ship.ShippingAddress.City == "Stockholm")
                {
                    //
                    this.peopleFromStockholm = true;
                }

                // Extra tax ...
                if (ship.ShippingAddress.City == "Stockholm")
                {
                    foreach (var item in orderGroup.GetAllLineItems())
                    {
                        ContentReference contentLink = _referenceConverter.GetContentLink(item.Code);

                        IPricing pricing = _contentRepository.Get <EntryContentBase>(contentLink) as IPricing;
                        int      i       = (int)pricing.TaxCategoryId;

                        // An address have to be there if using this ... so we can match the different properties
                        taxValues.AddRange(GetTaxValues(CatalogTaxManager.GetTaxCategoryNameById(i), "sv", address));

                        foreach (var item2 in taxValues)
                        {
                            // extra tax when shipped to Stockholm 10% more
                            d += (decimal)(item2.Percentage + 0.10) * (item.PlacedPrice * item.Quantity);
                        }
                    }
                    //var liAmount = orderGroup.Forms.Sum(x => x.GetAllLineItems().Sum(l => l.PlacedPrice * l.Quantity));
                }
                else
                {
                    foreach (var item in orderGroup.GetAllLineItems())
                    {
                        ContentReference contentLink = _referenceConverter.GetContentLink(item.Code);

                        IPricing pricing = _contentRepository.Get <EntryContentBase>(contentLink) as IPricing;
                        int      i       = (int)pricing.TaxCategoryId;

                        // An address have to be there
                        taxValues.AddRange(GetTaxValues(CatalogTaxManager.GetTaxCategoryNameById(i), "sv", address));

                        foreach (var item2 in taxValues)
                        {
                            // not Stockholm, so no extra tax
                            d += (decimal)(item2.Percentage) * (item.PlacedPrice * item.Quantity);
                        }
                    }
                }

                return(new Money(d, market.DefaultCurrency) / 100);
            }
            else
            {
                return(base.CalculateTaxTotal(orderGroup, market, currency));
            }
        }
예제 #9
0
 public CheckoutController(IUnitRepository unitRepository, IPricing pricingService)  //todo: inject logging
 {
     _unitRepository = unitRepository;
     _pricing        = pricingService;
 }
예제 #10
0
 public CheckoutTest()
 {
     _pricingService = new PricingController(_ruleRepository);
     _checkout       = new CheckoutController(_mockRepository, _pricingService);
 }
예제 #11
0
 public Checkout(IPricing pricing)
 {
     _pricing   = pricing ?? throw new ArgumentException("Invalid null value", "pricing");
     _lineItems = new List <LineItem>();
 }
예제 #12
0
 public PricingTest()
 {
     _pricing = new PricingController(_mockRuleRepository);
 }
 public CreateOfferCommandHandler(IMapper mapper, IOfferRepository offerRepository, IPricing pricingService)
 {
     this._mapper          = mapper;
     this._pricingService  = pricingService;
     this._offerRepository = offerRepository;
 }
예제 #14
0
 public Facade(IGenerateHistory generateHistory, IPricing pricing)
 {
     this.generateHistory = generateHistory;
     this.pricing         = pricing;
 }
예제 #15
0
 public BasketPricingVM()
 {
     basket = new BasketPricingModel();
 }
예제 #16
0
 public VanillaCallPricingVM()
 {
     vanillaCall = new VanillaCallPricingModel();
 }