client.spp
sdk-tools/samples/custom-services/src/test/composition/serial/client.spp
1domain client;2Role Handover { String receiptNumber; quantum decimal cash; }3Reference Intake from provider.CustodyHandover { String receiptNumber; quantum decimal cash; }4atomic update insertIntake(Intake);5atomic calculate prepareIntake(Receipt, Intake) { intake.receiptNumber = receipt.receiptNumber; }6Role Till { String receiptNumber; quantum decimal cash; }7Contract Receipt { String receiptNumber; decimal amount; decimal funding; }8take Receipt as Handover { mapsame; }9take Receipt as Till { mapsame; }10atomic calculate prepare(Receipt, Handover) {11handover.receiptNumber = receipt.receiptNumber;12}13quantum update receive(Receipt, Handover, Till) { handover.cash -> till.cash : receipt.amount; }14Scenario serial confirm(Receipt, Handover, Till, Intake, Accepted) {15findTill by receipt;16identify(till);17prepareIntake;18stageAccepted;19transaction {20serial {21insertIntake;22findHandover by receipt;23identify(handover);24receive bounds { handover.cash: [0, 0]; till.cash: [0, null]; };25insertAccepted;26}27}28}29Entity Accepted { String receiptNumber; quantum decimal funds; }30atomic update insertAccepted(Accepted);31atomic calculate stageAccepted(Receipt, Accepted) { accepted.receiptNumber = receipt.receiptNumber; }3233atomic calculate chooseMissingReceipt(Receipt) { receipt.receiptNumber = "MISSING"; }34Scenario serial confirmAbsent(Receipt, Handover, Till, Intake, Accepted) {35findTill by receipt;36identify(till);37prepareIntake;38stageAccepted;39transaction {40insertIntake;41chooseMissingReceipt;42prepare;43receive bounds { handover.cash: [null, null]; };44insertAccepted;45}46}47Scenario serial confirmSkipped(Receipt, Handover, Till, Intake, Accepted) {48findTill by receipt;49identify(till);50prepareIntake;51stageAccepted;52transaction {53insertIntake;54chooseMissingReceipt;55findHandover by receipt;56identify(handover);57receive bounds { handover.cash: [null, null]; };58insertAccepted;59}60}6162quantum update skipReceive(Receipt, Handover, Till) {63if (receipt.amount < 0) { handover.cash -> till.cash : receipt.amount; }64}65Scenario serial confirmNoMovement(Receipt, Handover, Till, Intake, Accepted) {66findTill by receipt;67identify(till);68prepareIntake;69prepare;70stageAccepted;71transaction {72insertIntake;73skipReceive bounds { handover.cash: [null, null]; };74insertAccepted;75}76}