petshop-15-store-opening.spp
petshop/catalogue/petshop-15-store-opening.spp
Download original file · Petstore source contents
1domain petshop;23atomic calculate initializeCatalog(4Goods[],5StockLine[],6StockSupply[],7Merchant,8SettlementAccount,9StoreOpeningAgreement10) {11for (Goods product : goodss) {12product.active = true;13switch (product.sku) {14case "CAT-001":15product.price = 1200;16break;17case "FOOD-001":18product.price = 29.90;19break;20case "TOY-001":21product.price = 12.35;22break;23case "DOG-001":24product.price = 1800;25break;26}27}28initializeInventory;29merchant.tradingName = storeOpeningAgreement.tradingName;30merchant.shopName = storeOpeningAgreement.shopName;3132settlementAccount.accountNumber = "EXTERNAL-SETTLEMENT";33}3435Scenario serial initializeStore(36Goods,37Goods[],38StockLine[],39StockSupply[],40Merchant,41SettlementAccount,42StoreOpeningAgreement43) {44configureStoreOpening;45configureMerchantLookup;46findMerchant;47if (!merchant) {48findPerson(merchant);49identify(merchant);50prepareProductSelection;51importCatalogue;52initializeCatalog;53transaction {54insertGoods(goodss);55insertStockLine;56insertStockSupply;57insertMerchant;58insertSettlementAccount;59}60}61}6263atomic calculate configureStoreOpening(StoreOpeningAgreement) {64if (storeOpeningAgreement.tradingName == BLANK) {65storeOpeningAgreement.tradingName = MERCHANT_NAME;66}67if (storeOpeningAgreement.shopName == BLANK) {68storeOpeningAgreement.shopName = SHOP_NAME;69}70}7172atomic calculate configureMerchantLookup(Merchant) {73merchant.customerNumber = "MERCHANT-001";74}