diff --git a/demos/examples/order-allocation/before.bosatsu b/demos/examples/order-allocation/after.bosatsu index 52b0eb68..80009b49 100644 --- a/demos/examples/order-allocation/before.bosatsu +++ b/demos/examples/order-allocation/after.bosatsu @@ -65,12 +65,7 @@ def is_complete(allocation: Allocation) -> Bool: eq_Int(backordered, 0) def cart_preview(sku: String, stock: Stock, requested: Int) -> CartPreview: - allocation = Allocation( - nonnegative(requested), - min_int(nonnegative(requested), sellable_units(stock)), - nonnegative(requested).sub(min_int(nonnegative(requested), sellable_units(stock))), - sellable_units(stock).sub(min_int(nonnegative(requested), sellable_units(stock))), - ) + allocation = allocation_plan(stock, requested) CartPreview(sku, allocation, is_complete(allocation)) def checkout_order(order_id: String, stock: Stock, requested: Int) -> CheckoutDecision: @@ -78,12 +73,7 @@ def checkout_order(order_id: String, stock: Stock, requested: Int) -> CheckoutDe CheckoutDecision(order_id, allocation, is_complete(allocation)) def support_replacement(case_id: String, stock: Stock, requested: Int) -> SupportReplacement: - allocation = Allocation( - nonnegative(requested), - min_int(nonnegative(requested), sellable_units(stock)), - nonnegative(requested).sub(min_int(nonnegative(requested), sellable_units(stock))), - sellable_units(stock).sub(min_int(nonnegative(requested), sellable_units(stock))), - ) + allocation = allocation_plan(stock, requested) status = if is_complete(allocation): Ready else: PartiallyBackordered SupportReplacement(case_id, allocation, status)