Grocery Co Checkout App
> CheckoutApp --help
CheckoutApp
Copyright (C) 2012 Jaison.B
-i, --input-file Required. Order input file
-p, --product-file Required. Product catalog file
-d, --discount-file Required. Promotion input file
--help Display this help screen.
Relative to where the executable is built there is a SampleData folder that can used for testing:
CheckoutApp -i SampleData\orders.txt -p SampleData\products.txt -d SampleData\promotions.txt
CSV is the only supported format
Note: header row is required for csv files to be processed
PRODUCT_ID, PRODUCT_NAME, UNIT_PRICE
111, APPLE, 0.75
222, BANANA, 1.00
333, ORANGE, 0.85
444, BOWTIE PASTA, 2.97
555, CHEDDAR CHEESE, 3.99
PRODUCT_ID, PROMO_TYPE, START_DATE, END_DATE, ELIGIBLE_QUANTITY, PROMO_AMOUNT
111, SalePrice, 2017-01-30, 2017-02-15, 1, 0.50
222, SalePercent, 2017-01-30, 2017-02-15, 1, 10
333, BundleDiscount, 2017-01-30, 2017-02-15, 3, 2.00
444, AddOnPercent, 2017-01-30, 2017-02-15, 1, 50
555, AddOnUnit, 2017-01-30, 2017-02-15, 3, 1
List of Promo Types supported currently:
- SalePrice - discounted price on sale item for e.g. "Apple sale price
$0.75$0.50" - SalePercent - discounted percent on sale item for e.g. "10% off on Bananas"
- BundleDiscount - bundle discounts for e.g. "Buy 3 Oranges for $2.00"
- AddOnPercent - additional promotion for e.g. "Buy One Get 50% off" promo
- AddOnUnit - additional promotion for e.g. "Buy One Get One" promo
PRODUCT_ID, UNITS
111, 7
222, 3
111, -2
333, 6
444, 4
555, 4
- Fractional 'UNITS' is not allowed in the orders input file. It will be rounded up(Math.Ceiling)
- Fractional 'ELIGIBLE_QUANTITY' is not allowed in the promotions input file. It will be rounded down(Math.Floor)
- Currently, promotions will be applied/chained in the order specified in promotions file.As a future enhancement we can introduce something like 'PRIORITY' that will allow us to sort the promotion order.
- If a new promotion is being introduced, it needs to be supported by a valid PromoType and Promotion implementation that supports the price calculation.
- 'START_DATE' and 'END_DATE' is not mandatory and will be defaulted to DateTime.MinValue for START_DATE and DateTime.MaxValue for END_DATE incase not provided in the input file.
- All amounts/prices are converted down to cents(lowest unit). This avoids precision issues when handling currency and all calculations are done using the value. Amounts will be formatted back to dollars only on display.
- A decorator pattern was used for promotions calculaton. It allows lot of flexibility to add more promotions in the future.
- CartFactory is reponsible for processing the input orders file and returning promotions wrapped around IOrderItem to calculate pricing.
sourced through NuGet
- CommandLineParser
- CsvHelper
- Colorful.Console
- Moq - mock library used in tests.