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) {9merchant.cash -> buyer.wallet : paidCancellationAgreement.refundAmount;10}1112atomic calculate prepareOrderInventory(ShopOrder, StockLine[]) {13stockLines = new StockLine[] {14};15for (OrderLine line : shopOrder.lines) {16boolean exists = false;17for (StockLine stock : stockLines) {18if (stock.goods.sku == line.goods.sku) {19exists = true;20}21}22if (!exists) {23StockLine stock = new StockLine();24stock.goods = line.goods;25stockLines = append(stockLines, stock);26}27}28}2930atomic update reserveInventory(StockLine[], ShopOrder);3132readonly Scenario serial readShopOrderLine(OrderLine) {33findOrderLine;34identify(orderLine);35}