S++Core systems, human-reviewable
DEMO SOURCE · SPP / APP / PHYRead the book

petshop-10-services.spp

petshop/order/petshop-10-services.spp

Download original file · Petstore source contents

1domain petshop;23atomic query listOrders(key Buyer, ShopOrder[]);45atomic update releaseUnpaidInventory(StockLine[], UnpaidCancellationAgreement);67atomic update releasePaidInventory(StockLine[], PaidCancellationAgreement);8quantum update refundCancellationFunds(Buyer, Merchant, PaidCancellationAgreement) {9    merchant.cash -> buyer.wallet : paidCancellationAgreement.refundAmount;10}1112atomic calculate prepareOrderInventory(ShopOrder, StockLine[]) {13    stockLines = new StockLine[] {14    };15    for (OrderLine line : shopOrder.lines) {16        boolean exists = false;17        for (StockLine stock : stockLines) {18            if (stock.goods.sku == line.goods.sku) {19                exists = true;20            }21        }22        if (!exists) {23            StockLine stock = new StockLine();24            stock.goods = line.goods;25            stockLines = append(stockLines, stock);26        }27    }28}2930atomic update reserveInventory(StockLine[], ShopOrder);3132readonly Scenario serial readShopOrderLine(OrderLine) {33    findOrderLine;34    identify(orderLine);35}