S++Business systems language
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}