PINION
PINION
The open source enterprise register engine.
Main Features
public class DiningPlan : Tender, IItemTender, IOrderTender { public ITenderApplication Apply(OrderLine orderLine) { return orderLine.Price() > 10 ? Accept(orderLine.Price()) : NotApplicable(); } public ITenderApplication Apply(Order order) { return Accept(order.GrossTotal() * 0.15M); } }
Tender Flexability
Coupons, discounts, dining plans, cash, BOGOs… it is all tender types. Pinion gives you the flexibility to create your own tender types without needing to register it with the engine. Furthermore, Pinion offers the flexibility of having an item-level tender, an order-level tender, or both!
public class EarringDiscount : Tender, IItemTender<MyCustomItem> { public ITenderApplication Apply(OrderLine<MyCustomItem> orderLine) { if (orderLine.Item.Category != "earring") return NotApplicable(); if (!orderLine.Item.IsDiscountable) return Reject("Item is not discountable"); return Accept(orderLine.Price() * 0.2M); } public ITenderApplication Apply(OrderLine orderLine) => Apply(new (orderLine)); }
Item Adaptability
Item models can be seamlessly templated into tenders without the need to use overloads or a templated register engine.
ITender[] tenders = new ITender[] { new BogoTender<CustomItemModel>(), new CashTender(5.99M), new CouponTender(10M), new DiscountTender(15) }; CustomItemModel[] items = new CustomItemModel[] { new CustomItemModel(5.99M, "eggs"), new CustomItemModel(12M, "milk"), new CustomItemModel(2.58M, "cheese"), new CustomItemModel(20.56M, "steak"), }; var result = Engine.Execute(tenders, items, EngineMode.Generous);
Incredible Simplicity
After creating your tenders, using your custom item model, and getting your items; it is as simple as calling the register engine statically. The engine offers multiple algorithmic modes for applying tenders, however, if you use none it will be un-opinionated and let you do your own prioritization-by-ordering. After the engine runs you will get a Pinion order model with your original item model referenced in for your simplicity!