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

petshop-20-calculations.spp

petshop/returns/petshop-20-calculations.spp

Download original file · Petstore source contents

1domain petshop;23atomic calculate prepareReturnRefund(ShopOrder, ReturnRefundAgreement) {4    returnRefundAgreement.refundAmount = shopOrder.total;5}67atomic calculate prepareReturnRequest(ReturnRequestAgreement, ShopOrder) {8    shopOrder.status = OrderStatus.RETURN_REQUESTED;9    shopOrder.reason = returnRequestAgreement.reason;10}1112atomic calculate prepareReturnApproval(ShopOrder, ReturnRefundAgreement) {13    returnRefundAgreement.returnedQuantity = 0;14    for (OrderLine line : shopOrder.lines) {15        returnRefundAgreement.returnedQuantity += line.quantity;16    }17    shopOrder.status = OrderStatus.RETURNED;18}