public PointOfSaleTerminal()
        {
            _packsCalculator  = new ProductPackCalculator();
            _simpleCalculator = new SimpleCalculator();

            ResetInitialState();
        }
Ejemplo n.º 2
0
        public string TotalPrice(string basePrice, string discountIndicator, string stateTax, string quantity)
        {
            double _basePrice;
            int    _quantity;
            bool   _discountIndicator;
            double _taxableAmount;

            //if state is not selected - request for selection
            if (string.IsNullOrWhiteSpace(stateTax))
            {
                return("<B>Please select state<B>");
            }

            double.TryParse(basePrice, out _basePrice);
            Int32.TryParse(quantity, out _quantity);
            bool.TryParse(discountIndicator, out _discountIndicator);
            _taxableAmount = _quantity * _basePrice;
            if (_discountIndicator)
            {
                _taxableAmount = _taxableAmount - (_taxableAmount * 0.1);
            }

            IPriceCalculator priceCalculator = _processLocator.GetProcessor <IPriceCalculator>(stateTax);

            return("Your Total Price will be : " + "<b> $" + priceCalculator.PriceWithTax(_taxableAmount).ToString() + "<b>");
        }
Ejemplo n.º 3
0
 public RxPricesController(IRxPriceRepository rxPriceRepository, IPriceCalculator priceCalculator,
                           IWebScraper webScraper)
 {
     _rxPriceRepository = rxPriceRepository;
     _priceCalculator   = priceCalculator;
     _webScraper        = webScraper;
 }
Ejemplo n.º 4
0
 public PriceCalculatorDecorator(
     IPriceCalculator parentResolver,
     PersonStorage personStorage)
 {
     _parentResolver = parentResolver;
     _personStorage  = personStorage;
 }
Ejemplo n.º 5
0
 public OrderImportor(IOrderManager orderManager,
                      IStoreManager storeManager,
                      IProductManager productManager,
                      IShipmentManager shipmentManager,
                      IProductAttributeFormatter productAttributeFormatter,
                      IProductAttributeManager productAttributeManager,
                      ILogisticsManager logisticsManager,
                      ILogger logger,
                      IPriceCalculator priceCalculator,
                      IStateManager stateManager,
                      IAddressManager addressManager,
                      IStateCache stateCache)
 {
     this._orderManager              = orderManager;
     this._storeManager              = storeManager;
     this._productManager            = productManager;
     this._shipmentManager           = shipmentManager;
     this._productAttributeFormatter = productAttributeFormatter;
     this._productAttributeManager   = productAttributeManager;
     this._logisticsManager          = logisticsManager;
     this._logger          = logger;
     this._stateManager    = stateManager;
     this._addressManager  = addressManager;
     this._stateCache      = stateCache;
     this._priceCalculator = priceCalculator;
 }
Ejemplo n.º 6
0
 public ProductServiceTest()
 {
     _productValidator = new ProductValidator();
     _priceCalculator  = new PriceCalculator.PriceCalculator();
     _filterValidator  = new FilterValidator();
     _repoMock         = new Mock <IRepository <Product> >();
 }
Ejemplo n.º 7
0
 // dependency injection of repository.
 public BookingService(BookingRepositoryMongoDB repository,
                       IPaymentGateway paymentGateway,
                       IPriceCalculator priceCalculator)
 {
     this.repository      = repository;
     this.paymentGateway  = paymentGateway;
     this.priceCalculator = priceCalculator;
 }
Ejemplo n.º 8
0
        public PriceCalculatorTests()
        {
            promotionMock = new Mock <IPromotion>(MockBehavior.Strict);
            promotionMock.Setup(p => p.CalculatePrice(It.IsAny <float>(), It.IsAny <int>()))
            .Returns(priceFromPromotion);

            sut = new PriceCalculator();
        }
Ejemplo n.º 9
0
        public BuyNow(IPriceCalculator calculator)
        {
            CompositeEvent(() => OrderWasReserved, x => x.OrderWarReservedStatus, OrderFinalized, StockReserved);

            During(Initial,
                   When(PurchaseOrdered).Then((state, domainEvent) =>
            {
                state.AccountId = domainEvent.AccountId;
                state.OrderId   = domainEvent.OrderId;
                state.Quantity  = domainEvent.Quantity;
                state.SkuId     = domainEvent.SkuId;
                state.UserId    = domainEvent.SourceId;
                state.StockId   = domainEvent.StockId;

                Dispatch(new CreateOrderCommand(state.OrderId, state.UserId));
            }).TransitionTo(CreatingOrder));

            During(CreatingOrder,
                   When(OrderCreated).ThenAsync(async(state, e) =>
            {
                var totalPrice =
                    await calculator.CalculatePrice(state.SkuId, state.Quantity);

                Dispatch(new AddItemToOrderCommand(state.OrderId,
                                                   state.SkuId,
                                                   state.Quantity,
                                                   totalPrice));
            }).TransitionTo(AddingOrderItems));

            During(AddingOrderItems,
                   When(ItemAdded)
                   .Then((state, e) => { Dispatch(new ReserveStockCommand(state.StockId, state.UserId, state.Quantity)); })
                   .TransitionTo(Reserving));

            During(Reserving,
                   When(StockReserved).Then((state, domainEvent) =>
            {
                state.ReserveId = domainEvent.ReserveId;
                Dispatch(new CalculateOrderTotalCommand(state.OrderId));
            }),
                   When(OrderFinalized)
                   .Then(
                       (state, domainEvent) => { Dispatch(new PayForOrderCommand(state.AccountId, domainEvent.TotalPrice, state.OrderId)); }),
                   When(OrderWasReserved).TransitionTo(Paying));


            During(Paying,
                   When(OrderPaid, ctx => ctx.Data.ChangeId == ctx.Instance.OrderId)
                   .Then((state, e) => { Dispatch(new TakeReservedStockCommand(state.StockId, state.ReserveId)); })
                   .TransitionTo(TakingStock));

            During(TakingStock,
                   When(ReserveTaken).Then((state, e) =>
            {
                Dispatch(new CompleteOrderCommand(state.OrderId));
                Dispatch(new CompletePendingOrderCommand(state.UserId, state.OrderId));
            }).Finalize());
        }
        public IInvoicePrinter Calculate()
        {
            IPriceCalculator calculator = _calculatorFactory.Create(_customerType);

            _invoice.Price = calculator.Calculate(_invoice.WashProgram, _currency);
            _discount      = calculator.Discount;

            return(this);
        }
Ejemplo n.º 11
0
        public DefaultCheckout(IPriceCalculator priceCalculator)
        {
            if (priceCalculator == null)
            {
                throw new ArgumentNullException("priceCalculator");
            }

            this.priceCalculator = priceCalculator;
        }
Ejemplo n.º 12
0
 public SearchPriceFilterService(
     RequestModelAccessor requestModelAccessor,
     IPriceCalculator priceCalculator,
     SecurityContextService securityContextService)
 {
     _requestModelAccessor   = requestModelAccessor;
     _priceCalculator        = priceCalculator;
     _securityContextService = securityContextService;
 }
Ejemplo n.º 13
0
 public StoreManager(IPriceCalculator priceCalculator,
                     IPrinter printer,
                     IDaysManager daysManager)
 {
     _priceCalculator        = priceCalculator;
     _printer                = printer;
     _daysManager            = daysManager;
     _daysManager.OnNextDay += DaysManager_OnNextDay;
 }
 public ErpPriceCalculatorDecorator(IPriceCalculator parent, IHttpContextAccessor httpContextAccessor,
                                    DistributedMemoryCacheService distributedMemoryCacheService, DistributedLockService distributedLockService,
                                    ILogger <ErpPriceCalculatorDecorator> logger)
 {
     _parent = parent;
     _httpContextAccessor           = httpContextAccessor;
     _distributedMemoryCacheService = distributedMemoryCacheService;
     _distributedLockService        = distributedLockService;
     _logger = logger;
 }
        public void CalculatePrice(IProcessExecutionContext executionContext, IPriceCalculator priceCalculator)
        {
            var unitPrice = priceCalculator.CalculateUnitPrice(executionContext, this.Fee, this.Quantity);

            if (unitPrice != this.UnitPrice)
            {
                this.UnitPrice  = UnitPrice;
                this.TotalPrice = this.Quantity * unitPrice;
            }
        }
 public PointOfSaleTerminal(ICodeScanner scanner,
                            IOrderList orderList,
                            IPriceCalculator priceCalculator,
                            IPricingService pricingService)
 {
     _scanner         = scanner;
     _orderList       = orderList;
     _priceCalculator = priceCalculator;
     _pricingService  = pricingService;
 }
Ejemplo n.º 17
0
        public void Dispose()
        {
            foreach (var finder in _finders)
            {
                finder.Dispose();
            }

            _priceCalculator = null;
            _finders         = null;
            _history         = null;
        }
Ejemplo n.º 18
0
        public ForwardBackwardOptimalParser(FindOptions options, IPriceCalculator priceCalculator, params IMatchFinder[] finders)
        {
            if (finders.Any(x => x.FindOptions.UnitSize != finders[0].FindOptions.UnitSize))
            {
                throw new InvalidOperationException("All match finder have to have the same unit size.");
            }

            FindOptions      = options;
            _priceCalculator = priceCalculator;
            _finders         = finders;
        }
Ejemplo n.º 19
0
 public ProductService(
     IWcProductService wcProductService,
     IDbProductRepository dbProductRepository,
     IPriceCalculator priceCalculator,
     ILogger <ProductService> logger)
 {
     _wcProductService    = wcProductService;
     _dbProductRepository = dbProductRepository;
     _priceCalculator     = priceCalculator;
     _logger = logger;
 }
Ejemplo n.º 20
0
        public OptimalParser(FindOptions options, IPriceCalculator priceCalculator, params IMatchFinder[] finders)
        {
            if (finders.Any(x => x.FindOptions.UnitSize != finders[0].FindOptions.UnitSize))
            {
                throw new InvalidOperationException("All Match finder have to have the same unit size.");
            }

            FindOptions      = options;
            _priceCalculator = priceCalculator ?? throw new ArgumentNullException(nameof(priceCalculator));
            _finders         = finders;
        }
 public OrderProcessor(
     IPriceCalculator priceCalculator,
     IOrderProcessorStore orderProcessorStore,
     ICreditCardProcessorClient ccClient,
     IClientNotificationService notificationService
     )
 {
     _priceCalculator     = priceCalculator ?? throw new ArgumentNullException(nameof(priceCalculator));
     _orderProcessorStore = orderProcessorStore ?? throw new ArgumentNullException(nameof(orderProcessorStore));
     _ccClient            = ccClient ?? throw new ArgumentNullException(nameof(ccClient));
     _notificationService = notificationService ?? throw new ArgumentNullException(nameof(notificationService));
 }
Ejemplo n.º 22
0
 public SearchPriceFilterService(
     ICampaignHandler campaignHandler,
     RequestModelAccessor requestModelAccessor,
     IPriceCalculator priceCalculator,
     AccountService accountService,
     SecurityContextService securityContextService)
 {
     _campaignHandler        = campaignHandler;
     _requestModelAccessor   = requestModelAccessor;
     _priceCalculator        = priceCalculator;
     _accountService         = accountService;
     _securityContextService = securityContextService;
 }
Ejemplo n.º 23
0
        public CreateOrderOperation(
            IPriceCalculator priceCalculator,
            IInventoryRepository inventoryService,
            IOrderRepository orderRepository,
            ILoggerService loggerService,
            IResponseMessageFactory responseMessageFactory)
        {
            _priceCalculator        = priceCalculator;
            _inventoryService       = inventoryService;
            _orderRepository        = orderRepository;
            _loggerService          = loggerService;
            _responseMessageFactory = responseMessageFactory;

            Operation = Operation.Submit_Order;
        }
Ejemplo n.º 24
0
        public PriceFilterService(
            ICampaignHandler campaignHandler,
            CategoryFilterService categoryFilterService,
            RequestModelAccessor requestModelAccessor,
            IPriceCalculator priceCalculator,
            AccountService accountService,
            SecurityContextService securityContextService)
        {
            _campaignHandler        = campaignHandler;
            _categoryFilterService  = categoryFilterService;
            _requestModelAccessor   = requestModelAccessor;
            _priceCalculator        = priceCalculator;
            _accountService         = accountService;
            _securityContextService = securityContextService;

            _priceListForUser = new Lazy <List <Guid> >(() => GetPriceListForUser());
            _campaignsForUser = new Lazy <List <Guid> >(() => GetCampaignsForUser());
        }
Ejemplo n.º 25
0
 public ProductService(
     IRepository <Product> productRepository,
     IValidator <Filter> filterValidator,
     IPriceCalculator priceCalculator,
     IValidator <Product> productValidator)
 {
     _productRepo = productRepository ??
                    throw new ArgumentNullException(nameof(productRepository),
                                                    "Repository cannot be null.");
     _filterValidator = filterValidator ??
                        throw new ArgumentNullException(nameof(filterValidator),
                                                        "Validator cannot be null.");
     _priceCalc = priceCalculator ??
                  throw new ArgumentNullException(nameof(priceCalculator),
                                                  "Price Calculator cannot be null.");
     _productValidator = productValidator ??
                         throw new ArgumentNullException(nameof(productValidator),
                                                         "Validator cannot be null.");
 }
Ejemplo n.º 26
0
        /// <summary>
        /// This method is used to get the price calculator based on the discount Type (BOGO, GROUP and SALE) in this case.
        /// This acts as an Abstract Factory provider and can be extended to more discount types (like Boxing Day Sale, New year sale and so on)
        /// New Discount types can be added to Factory without affecting Kiosk project.
        /// </summary>
        /// <param name="discountType">Type of discount</param>
        /// <returns>PriceCalculator</returns>
        public static IPriceCalculator GetPriceCalculator(string discountType)
        {
            IPriceCalculator priceCalculator = null;

            switch (discountType)
            {
            case "BOGO":
                priceCalculator = new BOGOPriceCalculator();
                break;

            case "GROUP":
                priceCalculator = new GroupDiscountPriceCalculator();
                break;

            case "SALE":
                priceCalculator = new RegularPriceCalculator();
                break;
            }
            return(priceCalculator);
        }
Ejemplo n.º 27
0
        public void Setup()
        {
            Mock <Microsoft.Extensions.Logging.ILogger> mockLogger =
                new Mock <Microsoft.Extensions.Logging.ILogger>();

            var mockProductRepository = new Mock <IProductRepository>();

            mockProductRepository.Setup(m => m.GetProductItems(It.IsAny <IList <int> >()))
            .Returns((IList <int> productIds) =>
            {
                var products = new List <IProductItem>();
                foreach (var id in productIds)
                {
                    products.Add(new ProductItem()
                    {
                        ProductId = id, Price = 8
                    });
                }
                return(products);
            });

            _priceCalculator = new PriceCalculator(mockLogger.Object, mockProductRepository.Object, null);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// This method applies the appropriate discounts on each of the scanned item
        /// The discount is applied by invoking the corresponding Discount Type interface
        /// </summary>
        public void CheckOut()
        {
            try
            {
                //Assign product details to each scanned item
                AssignProductDetailsToScannedItems();
                //get unique scanned items
                var uniqueProductIds = scannedItems.Select(i => i.ProductId).Distinct().ToList();

                //Apply the discount for each set of unique scanned items
                uniqueProductIds.ForEach(pId =>
                {
                    //If the scanned item is not present in the Product catalog then price will not be calculated
                    //If the scanned item is not present in the Product catalog then Product id = 0
                    if (pId != 0)
                    {
                        var items        = scannedItems.FindAll(item => item.ProductId == pId);
                        var discountType = Products.Find(p => p.ProductId == pId).DiscountType;

                        calculator = PriceCalculatorFactory.GetPriceCalculator(discountType);
                        if (calculator != null)
                        {
                            var discount = Discounts.Find(dis => dis.ProductId == pId);
                            //Call the Calculator
                            calculator.CalculatePrice(items, discount);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Exception during Checkout process", ex);
            }

            PrintReceipt();
        }
 public void Setup()
 {
     offer1 = new Mock<IOffer>();
     offerRepository = new Mock<IOfferRepository>();
     priceCalculator = new PriceCalculator.BusinessLogic.PriceCalculator(offerRepository.Object);
 }
Ejemplo n.º 30
0
 public ProductDtoBuilder(IPriceCalculator priceCalculator)
 {
     _priceCalculator = priceCalculator;
 }
 public ERPPriceCalculatorDecorator(IPriceCalculator parent)
 {
     _parent = parent;
 }
 public CheckoutService(ITimeService timeService, IPriceCalculator priceCalculator)
 {
     _timeService = timeService;
     _priceCalculator = priceCalculator;
 }
 public PointOfSaleProduct(string productCode, IPriceCalculator priceCalculator)
 {
     ProductCode = productCode;
     PriceCalculator = priceCalculator;
 }
Ejemplo n.º 34
0
 public BasketManager(IPriceCalculator priceCalculator, IProductRepository productRepository)
 {
     this.priceCalculator = priceCalculator;
     this.productRepository = productRepository;
 }
 private void DoAddProduct(string productCode, IPriceCalculator priceCalculator)
 {
     products.Add(new PointOfSaleProduct(productCode, priceCalculator));
 }