S++Business systems language
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    Buyer.wallet += PaidCancellationAgreement.refundAmount;10    Merchant.cash -= PaidCancellationAgreement.refundAmount;11}1213atomic calculate prepareOrderInventory(ShopOrder, StockLine[]) {14    StockLine[] = new StockLine[] {15    };16    for (OrderLine line : ShopOrder.lines) {17        boolean exists = false;18        for (StockLine stock : StockLine[]) {19            if (stock.goods.sku == line.goods.sku) {20                exists = true;21            }22        }23        if (!exists) {24            StockLine stock = new StockLine();25            stock.goods = line.goods;26            StockLine[] = append(StockLine[], stock);27        }28    }29}3031atomic update reserveInventory(StockLine[], ShopOrder);