@hyperscale0/hsx 1.0.218 → 1.0.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/src/examples-bundle.js +15 -15
- package/dist/src/examples-bundle.js.map +1 -1
- package/examples/cards.hsx +35 -18
- package/examples/collections.hsx +45 -20
- package/examples/escrow.hsx +23 -16
- package/examples/financing.hsx +32 -12
- package/examples/insurance.hsx +29 -14
- package/examples/lending.hsx +46 -20
- package/examples/library.hsx +68 -12
- package/examples/marketplace.hsx +26 -11
- package/examples/money.hsx +45 -10
- package/examples/rental-deposit.hsx +25 -13
- package/examples/repair-approval.hsx +69 -25
- package/examples/reporting.hsx +36 -10
- package/examples/savings.hsx +20 -10
- package/examples/serviced.hsx +91 -21
- package/examples/wallet.hsx +21 -9
- package/package.json +4 -4
- package/src/examples-bundle.ts +15 -15
package/examples/serviced.hsx
CHANGED
|
@@ -1,25 +1,95 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// Dammam delivery van finance funds a 69,000 SAR van with 10% down and 36 monthly instalments.
|
|
2
|
+
// It records reminders, late charges, hardship extensions, early repayment and financed returns.
|
|
3
|
+
program car_financing "Dammam delivery van finance"
|
|
3
4
|
use escrow
|
|
4
5
|
use financing
|
|
5
6
|
use collections
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
party dealer: business
|
|
8
|
+
|
|
9
|
+
// The dealer invoices 60,000 SAR plus 15% VAT. Set price to 69,000 SAR.
|
|
10
|
+
// The company keeps a 1% dealer fee, 690 SAR, with 103.50 SAR VAT on that fee.
|
|
11
|
+
object car "Delivery van finance" {
|
|
12
|
+
fields { make: text, model: text, year: integer, vin: text, price: money }
|
|
13
|
+
columns: [make, model, year, vin, price]
|
|
14
|
+
attach sale = escrow.hold {
|
|
15
|
+
payer: actor, payee: dealer
|
|
16
|
+
fee: { seller: 1%, tax: 15% }, deliver_within: 14d, accept_within: 3d
|
|
17
|
+
expose create as agree_van_purchase
|
|
18
|
+
expose fund as pay_cash_instead
|
|
19
|
+
expose deliver as confirm_delivery
|
|
20
|
+
expose accept as accept_van
|
|
21
|
+
expose dispute as dispute_van
|
|
22
|
+
expose verify_return as verify_returned_van
|
|
23
|
+
expose refund as refund_after_finance_unwind
|
|
24
|
+
expose refund_undelivered as refund_missing_cash_purchase
|
|
25
|
+
expose settle_release as resolve_for_dealer
|
|
26
|
+
expose settle_return as resolve_for_buyer
|
|
27
|
+
expose settle_refund as finish_buyer_refund
|
|
28
|
+
expose cancel as cancel_and_return_down_payment
|
|
29
|
+
}
|
|
30
|
+
attach limits = financing.limits {
|
|
31
|
+
borrower: actor, per_borrower: 250000 SAR
|
|
32
|
+
expose create as request_borrower_limit
|
|
33
|
+
expose approve as approve_borrower_limit
|
|
34
|
+
}
|
|
35
|
+
attach ceiling = financing.portfolio_limit {
|
|
36
|
+
limit: 10000000 SAR
|
|
37
|
+
expose create as create_lending_budget
|
|
38
|
+
expose approve as approve_lending_budget
|
|
39
|
+
}
|
|
40
|
+
// Down payment is 6,900 SAR. Capital is 62,100 SAR; total flat profit is
|
|
41
|
+
// 5,278.50 SAR. Financing service fee: 0%, tax: 0% on principal repayments.
|
|
42
|
+
// Supply 36 future monthly dates. Approve limits before collecting and funding.
|
|
43
|
+
attach plan = financing.installments {
|
|
44
|
+
borrower: actor, capital: operator, share: 0%
|
|
45
|
+
months: 36, pricing: flat_total, profit_rate: 8.5%, down_payment: 10%
|
|
46
|
+
apply: fines_profit_principal, payoff_rebate: 100%, write_off_after: 90d
|
|
47
|
+
refund_within: 30d, payoff_quote_expiry: 1h, returned_goods: refund_all
|
|
48
|
+
max_extension: 60d, max_amendments: 2, amendment_expiry: 7d
|
|
49
|
+
funds: sale, limits: limits, portfolio: ceiling
|
|
50
|
+
expose create as finance
|
|
51
|
+
expose sign as sign_contract
|
|
52
|
+
expose collect_down_payment as pay_down_payment
|
|
53
|
+
expose disburse as fund_van_escrow
|
|
54
|
+
expose cancel as decline_finance_quote
|
|
55
|
+
expose void as cancel_signed_finance
|
|
56
|
+
expose payoff as repay_early
|
|
57
|
+
expose complete as close_repaid_finance
|
|
58
|
+
// Before an active-plan unwind, refund collected payments and fines,
|
|
59
|
+
// and waive assessed fines. Then refund any remaining escrow balance.
|
|
60
|
+
expose unwind as unwind_returned_van_finance
|
|
61
|
+
expose unwind_undelivered as unwind_missing_van_finance
|
|
62
|
+
expose unwind_paid as unwind_repaid_van_finance
|
|
63
|
+
}
|
|
64
|
+
// Create one assessment against the overdue slice. The clock assesses after
|
|
65
|
+
// three days; repayments collect it. cap bounds evidenced recovery COSTS,
|
|
66
|
+
// not the 50 SAR fine. Any charge VAT is invoiced outside this header.
|
|
67
|
+
attach late = financing.late_charge {
|
|
68
|
+
on: plan, grace: 3d, fine: 50 SAR, cap: 25 SAR
|
|
69
|
+
fines_to: operator, costs_to: operator, borrower: actor
|
|
70
|
+
expose create as record_late_assessment
|
|
71
|
+
expose cancel as cancel_proposed_assessment
|
|
72
|
+
expose refund as refund_collected_fine
|
|
73
|
+
}
|
|
74
|
+
attach reminders = collections.reminder {
|
|
75
|
+
on: plan, operator: operator, before_days: 3, overdue_days: 1
|
|
76
|
+
max_per_day: 1, send_from: 9, send_until: 18, timezone: "Asia/Riyadh"
|
|
77
|
+
expose create as schedule_instalment_reminders
|
|
78
|
+
expose dispatch as send_payment_reminder
|
|
79
|
+
}
|
|
25
80
|
}
|
|
81
|
+
|
|
82
|
+
expose car.plan.payment.create as record_repayment
|
|
83
|
+
expose car.plan.payment.pay as pay_instalment
|
|
84
|
+
expose car.plan.payment.refund as refund_mistaken_repayment
|
|
85
|
+
expose car.plan.payoff_quote.create as request_payoff_quote
|
|
86
|
+
expose car.plan.amendment.create as propose_hardship_extension
|
|
87
|
+
expose car.plan.amendment.accept as accept_hardship_extension
|
|
88
|
+
expose car.plan.amendment.decline as decline_hardship_extension
|
|
89
|
+
expose car.plan.amendment.withdraw as withdraw_hardship_extension
|
|
90
|
+
expose car.plan.write_off_request.create as request_overdue_write_off
|
|
91
|
+
expose car.plan.write_off_request.apply as approve_overdue_write_off
|
|
92
|
+
expose car.plan.write_off_request.cancel as cancel_write_off_request
|
|
93
|
+
expose car.late.waiver_request.create as request_fine_waiver
|
|
94
|
+
expose car.late.waiver_request.apply as approve_fine_waiver
|
|
95
|
+
expose car.late.waiver_request.cancel as cancel_fine_waiver
|
package/examples/wallet.hsx
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// Madinah pottery studio lets members prepay for visits at 172.50 SAR each.
|
|
2
|
+
// A reserved visit can be charged, cancelled or released at expiry; unused credit can be withdrawn.
|
|
3
|
+
program workshop_credits "Madinah pottery studio"
|
|
3
4
|
use wallet
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Top-up fee: 0%. Loading and withdrawing credit have tax 0% here because
|
|
7
|
+
// they do not sell a visit. Each visit is 150 SAR plus 15% VAT, invoiced by
|
|
8
|
+
// the studio outside wallet.spend, which posts the gross amount to the studio.
|
|
9
|
+
object membership "Pottery membership" {
|
|
6
10
|
fields { memberName: text, membershipNumber: text }
|
|
7
11
|
columns: [memberName, membershipNumber]
|
|
8
12
|
attach balance = wallet.balance {
|
|
13
|
+
holder: owner, spend_limit: 172.50 SAR, topup_fee: 0%
|
|
9
14
|
expose create as create_balance
|
|
10
|
-
holder: owner
|
|
11
15
|
expose activate as open_balance
|
|
16
|
+
// For example, top up 690 SAR for four visits.
|
|
12
17
|
expose topup as add_credit
|
|
13
|
-
expose withdraw as
|
|
14
|
-
expose
|
|
18
|
+
expose withdraw as withdraw_unused_credit
|
|
19
|
+
expose freeze as freeze_balance
|
|
20
|
+
expose unfreeze as restore_balance
|
|
21
|
+
expose close as close_empty_balance
|
|
22
|
+
expose operator_close as close_empty_membership
|
|
15
23
|
}
|
|
24
|
+
// Supply amount: 172.50 SAR and expiresAt: the booked visit time.
|
|
25
|
+
// Each spend has its own inputs; a second visit cannot inherit the first.
|
|
16
26
|
attach visit = wallet.spend {
|
|
17
|
-
expose create as create_visit
|
|
18
27
|
wallet: balance, payee: operator, holder: owner
|
|
19
28
|
economics pay { purpose: earning, sourceParty: owner }
|
|
20
|
-
expose
|
|
29
|
+
expose create as book_visit
|
|
30
|
+
expose reserve as reserve_visit_credit
|
|
21
31
|
expose pay as charge_visit
|
|
22
|
-
expose cancel as
|
|
32
|
+
expose cancel as cancel_reserved_visit
|
|
23
33
|
}
|
|
34
|
+
// Expiry returns a reservation to the wallet. A paid spend has no refund
|
|
35
|
+
// action in this header; resolve cancellations before charging the visit.
|
|
24
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperscale0/hsx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.233",
|
|
4
4
|
"description": "The strictly typed HSX language: compile total financial programs into canonical UDL.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hsx",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"examples:bundle": "bun scripts/bundle-examples.ts"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@hyperscale0/adl": "1.0.
|
|
88
|
-
"@hyperscale0/udl": "1.0.
|
|
87
|
+
"@hyperscale0/adl": "1.0.233",
|
|
88
|
+
"@hyperscale0/udl": "1.0.233",
|
|
89
89
|
"fast-sha256": "1.3.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"Amir Ayub",
|
|
98
98
|
"Sara AlBakaawi"
|
|
99
99
|
],
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "fc3eebb3f523883f1a496ab47c0170fe5891afb3"
|
|
101
101
|
}
|
package/src/examples-bundle.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// Generated by open/hsx/scripts/bundle-examples.ts. Do not edit by hand.
|
|
2
2
|
import type { HsxExample } from "./examples.ts";
|
|
3
3
|
export const examples: HsxExample[] = [
|
|
4
|
-
{"id":"cards","title":"
|
|
5
|
-
{"id":"collections","title":"
|
|
6
|
-
{"id":"escrow","title":"
|
|
7
|
-
{"id":"financing","title":"
|
|
8
|
-
{"id":"insurance","title":"
|
|
9
|
-
{"id":"lending","title":"
|
|
10
|
-
{"id":"library","title":"
|
|
11
|
-
{"id":"marketplace","title":"
|
|
12
|
-
{"id":"money","title":"
|
|
13
|
-
{"id":"rental-deposit","title":"
|
|
14
|
-
{"id":"repair-approval","title":"
|
|
15
|
-
{"id":"reporting","title":"
|
|
16
|
-
{"id":"savings","title":"
|
|
17
|
-
{"id":"serviced","title":"
|
|
18
|
-
{"id":"wallet","title":"
|
|
4
|
+
{"id":"cards","title":"Riyadh catering cards","summary":"Riyadh catering cards lets staff reserve supplier purchases up to 5,000 SAR each. Supplier cancellation releases the reservation; captured purchases support a full refund or a reviewed dispute.","headers":["cards"],"source":"// Riyadh catering cards lets staff reserve supplier purchases up to 5,000 SAR each.\n// Supplier cancellation releases the reservation; captured purchases support a full refund or a reviewed dispute.\nprogram team_expense_cards \"Riyadh catering cards\"\nuse cards\nparty supplier: business\n\n// Bind supplier to the food wholesaler. Staff customers own their card records.\n// Card fee: 0%, tax: 0% on card access because the caterer charges staff nothing.\n// A supplier invoice might be 2,000 SAR plus 15% VAT, paid as one 2,300 SAR\n// authorization. cards does not calculate or remit the supplier's invoice VAT.\nobject employee \"Catering expense card\" {\n fields { employeeName: text, department: text }\n columns: [employeeName, department]\n attach holder = cards.cardholder {\n holder: owner\n expose create as enrol_employee\n expose activate as activate_employee\n expose suspend as suspend_employee\n expose resume as restore_employee\n expose close as close_employee_access\n expose operator_close as remove_employee_access\n }\n attach card = cards.card {\n holder: holder, person: owner, issuer: operator, spend_limit: 5000 SAR\n expose create as issue_card\n expose activate as activate_card\n expose freeze as freeze_lost_card\n expose unfreeze as restore_found_card\n expose issuer_freeze as block_card\n expose issuer_unfreeze as unblock_card\n expose cancel as cancel_card\n expose issuer_cancel as retire_employee_card\n }\n // Supply the gross invoice amount and expiresAt, such as 24 hours after\n // ordering. Pending and approved authorizations expire without capture.\n attach payment = cards.authorization {\n card: card, merchant: supplier, issuer: operator\n expose create as request_supplier_payment\n expose approve as approve_payment\n expose decline as decline_payment\n expose capture as capture_delivered_order\n expose reverse as cancel_supplier_reservation\n }\n attach receipt = cards.transaction {\n authorization: payment\n expose create as record_captured_purchase\n expose refund as refund_supplier_purchase\n }\n attach complaint = cards.dispute {\n transaction: receipt, issuer: operator, within: 30d\n expose create as dispute_supplier_purchase\n expose review as review_purchase_dispute\n expose win as uphold_dispute_and_refund\n }\n // A dispute unresolved after 30 days becomes lost. A refund always needs\n // the supplier's funds; the card header does not prove card-network settlement.\n}\n"},
|
|
5
|
+
{"id":"collections","title":"Jeddah cafe equipment finance","summary":"Jeddah cafe equipment finance lends 24,000 SAR over 12 months and refers debt seven days overdue. Its agency earns 10% of each recovery from the lender, with at most four contacts per 30 days.","headers":["collections","financing"],"source":"// Jeddah cafe equipment finance lends 24,000 SAR over 12 months and refers debt seven days overdue.\n// Its agency earns 10% of each recovery from the lender, with at most four contacts per 30 days.\nprogram business_collections \"Jeddah cafe equipment finance\"\nuse collections\nuse financing\nparty agency: business\n\n// Bind agency to the collector. The cafe owns the facility. Set price to\n// 24,000 SAR: 6% flat profit is 1,440 SAR, repaid in twelve 2,120 SAR payments.\n// Loan fee: 0%, tax: 0% on principal. The agency invoices 15% VAT on its\n// recovery service outside collections.case, which posts only the 10% fee.\nobject facility \"Cafe equipment facility\" {\n fields { businessName: text, purpose: text, price: money }\n columns: [businessName, purpose, price]\n attach allowance = financing.limits {\n borrower: owner, per_borrower: 100000 SAR\n expose create as request_borrower_limit\n expose approve as approve_borrower\n }\n attach budget = financing.portfolio_limit {\n limit: 2000000 SAR\n expose create as create_lending_budget\n expose approve as approve_budget\n }\n // Approve both limits and provide twelve future due dates before disbursement.\n attach loan = financing.installments {\n borrower: owner, capital: operator, share: 0%\n months: 12, pricing: flat_total, profit_rate: 6%, disburse_to: borrower\n payoff_rebate: 100%, refund_within: 30d, write_off_after: 90d\n limits: allowance, portfolio: budget\n expose create as quote_equipment_loan\n expose sign as sign_loan\n expose disburse as release_loan\n expose cancel as decline_loan_quote\n expose void as cancel_unfunded_loan\n expose payoff as repay_early\n expose complete as close_repaid_loan\n }\n // Select matching plan, overdue slice and pending payment when opening.\n // Recovery pays that payment, not necessarily the whole remaining debt.\n attach recovery = collections.case {\n on: loan, agency: agency, capital: operator, overdue: 7d, fee: 10%\n expose create as refer_overdue_instalment\n expose assign as assign_agency\n expose recover as collect_referred_payment\n expose recall as recall_collection_case\n expose return_uncollected as return_uncollected_case\n }\n attach contact = collections.contact {\n case: recovery, agency: agency\n max_contacts: 4, window: 30d, contact_from: 9, contact_until: 18\n timezone: \"Asia/Riyadh\"\n expose create as record_collection_contact\n }\n}\n\nexpose facility.contact.outcome.create as record_contact_outcome\nexpose facility.loan.payment.create as record_repayment\nexpose facility.loan.payment.pay as pay_instalment\nexpose facility.loan.payment.refund as refund_mistaken_repayment\nexpose facility.loan.payoff_quote.create as request_payoff_quote\n// A disputed contact can be recorded, then capital can recall the case.\n// Uncollectible principal needs a separate capital decision after 90 days.\nexpose facility.loan.write_off_request.create as request_overdue_write_off\nexpose facility.loan.write_off_request.apply as approve_overdue_write_off\nexpose facility.loan.write_off_request.cancel as cancel_write_off_request\n"},
|
|
6
|
+
{"id":"escrow","title":"Khobar used laptops","summary":"Khobar used laptops holds a buyer's 2,300 SAR until the laptop arrives and passes inspection. Delivery has seven days; the buyer has 48 hours to accept or dispute before the operator reviews the sale.","headers":["escrow"],"source":"// Khobar used laptops holds a buyer's 2,300 SAR until the laptop arrives and passes inspection.\n// Delivery has seven days; the buyer has 48 hours to accept or dispute before the operator reviews the sale.\nprogram used_device_sales \"Khobar used laptops\"\nuse escrow\nparty seller: business\n\n// Bind seller to the refurbisher. Set price to the agreed gross invoice, for\n// example 2,300 SAR. The company keeps 5%, 115 SAR, plus 15% VAT on that fee.\n// Seller receives 2,167.75 SAR. Any VAT on the laptop is on the seller's invoice.\nobject device \"Laptop purchase\" {\n fields { model: text, condition: text, serialNumber: text, price: money }\n columns: [model, condition, serialNumber, price]\n attach sale = escrow.hold {\n payer: owner, payee: seller\n fee: { seller: 5%, tax: 15% }\n deliver_within: 7d, accept_within: 48h\n dispute: { refund_after: return_verified }\n expose create as agree_purchase\n expose fund as pay_for_laptop\n expose deliver as confirm_delivery\n expose accept as accept_laptop\n expose dispute as report_problem\n expose verify_return as verify_returned_laptop\n expose refund as refund_buyer\n expose refund_undelivered as refund_missing_delivery\n expose settle_release as resolve_in_seller_favour\n expose settle_return as resolve_in_buyer_favour\n expose settle_refund as finish_buyer_refund\n expose cancel as cancel_unpaid_purchase\n }\n}\n"},
|
|
7
|
+
{"id":"financing","title":"Riyadh language academy finance","summary":"Riyadh language academy finance pays 6,900 SAR tuition to the academy at enrolment. The student repays three monthly instalments of 2,300 SAR with no financing profit or late fee.","headers":["financing"],"source":"// Riyadh language academy finance pays 6,900 SAR tuition to the academy at enrolment.\n// The student repays three monthly instalments of 2,300 SAR with no financing profit or late fee.\nprogram tuition_instalments \"Riyadh language academy finance\"\nuse financing\nparty academy: business\n\n// Bind academy to the training business. Its 6,000 SAR course plus 15% VAT\n// is invoiced outside this plan. Set price to the gross 6,900 SAR invoice.\n// Financing fee: 0%, tax: 0% on principal repayments; no separate service is sold.\nobject enrolment \"Language course finance\" {\n fields { student: text, course: text, price: money }\n columns: [student, course, price]\n attach allowance = financing.limits {\n borrower: owner, per_borrower: 12000 SAR\n expose create as request_student_allowance\n expose approve as approve_student\n }\n attach budget = financing.portfolio_limit {\n limit: 500000 SAR\n expose create as create_tuition_budget\n expose approve as approve_budget\n }\n // Approve both limits before funding. Supply three future monthly dates\n // and a unique settlementIdentity. Funding must precede the first due date.\n attach tuition = financing.installments {\n borrower: owner, capital: operator, seller: academy\n months: 3, pricing: flat_total, profit_rate: 0%, share: 0%\n disburse_to: seller, limits: allowance, portfolio: budget\n payoff_rebate: 100%, refund_within: 30d, write_off_after: 90d\n max_extension: 30d, max_amendments: 1, amendment_expiry: 7d\n expose create as quote_tuition_plan\n expose sign as sign_tuition_plan\n expose disburse as pay_academy\n expose cancel as decline_tuition_quote\n expose void as cancel_unfunded_plan\n expose payoff as repay_early\n expose complete as close_repaid_plan\n }\n}\n\nexpose enrolment.tuition.payment.create as record_student_payment\nexpose enrolment.tuition.payment.pay as pay_instalment\nexpose enrolment.tuition.payment.refund as refund_mistaken_payment\nexpose enrolment.tuition.payoff_quote.create as request_payoff_quote\n// A hardship extension adds no profit and needs the student's acceptance.\nexpose enrolment.tuition.amendment.create as propose_payment_extension\nexpose enrolment.tuition.amendment.accept as accept_payment_extension\nexpose enrolment.tuition.amendment.decline as decline_payment_extension\nexpose enrolment.tuition.amendment.withdraw as withdraw_payment_extension\nexpose enrolment.tuition.write_off_request.create as request_overdue_write_off\nexpose enrolment.tuition.write_off_request.apply as approve_overdue_write_off\nexpose enrolment.tuition.write_off_request.cancel as cancel_write_off_request\n"},
|
|
8
|
+
{"id":"insurance","title":"Jeddah device cover","summary":"Jeddah device cover sells a 1,725 SAR tablet and a 115 SAR annual protection period. The retailer keeps 10% of each premium; cancelled future periods reverse that commission and the insurer's portion.","headers":["insurance","money"],"source":"// Jeddah device cover sells a 1,725 SAR tablet and a 115 SAR annual protection period.\n// The retailer keeps 10% of each premium; cancelled future periods reverse that commission and the insurer's portion.\nprogram device_insurance \"Jeddah device cover\"\nuse insurance\nuse money\n\n// The retailer invoices the tablet at 1,500 SAR plus 15% VAT outside\n// money.transfer. Purchase fee: 0%. The transfer pays the gross 1,725 SAR.\n// The insurer invoices 100 SAR plus 15% VAT for the premium outside\n// insurance.cover, which has no tax setting.\n// At 115 SAR premium, commission is 11.50 SAR and insurer cash is 103.50 SAR.\nobject device \"Insured tablet\" {\n fields { model: text, serialNumber: text, purchaseDate: date }\n columns: [model, serialNumber, purchaseDate, coverExpiresAt]\n attach purchase = money.transfer {\n payer: owner, payee: operator, amount: 1725 SAR\n economics pay { purpose: earning, sourceParty: owner }\n expose create as create_purchase\n expose pay as pay_for_tablet\n expose cancel as cancel_unpaid_purchase\n }\n // Bind the insurer's registered adapter before launch. conformance_boundary\n // is only the sandbox adapter. Set the cover expiry to the policy end date.\n attach protection = insurance.cover {\n holder: owner, broker: operator, adapter: \"conformance_boundary\"\n covers: purchase, premium: 115 SAR, commission: 10%, claim_limit: 1500 SAR\n rename { expiresAt: coverExpiresAt }\n expose create as request_cover\n expose activate as activate_cover\n expose cancel as cancel_and_refund_future_cover\n }\n // Supply loss evidence, the claim amount and its decision expiry.\n // The 1,500 SAR limit applies to all approved and paid claims on the cover.\n attach claim = insurance.claim {\n cover: protection, inspector: operator\n expose create as report_damage\n expose approve as approve_claim\n expose deny as deny_claim\n expose pay as pay_claim\n }\n}\n\n// Create the annual period with startsAt and endsAt, then collect its premium.\n// Cancelling cover refunds only paid periods that have not started.\nexpose device.protection.slice.create as create_premium_period\nexpose device.protection.slice.collect as pay_cover_premium\n"},
|
|
9
|
+
{"id":"lending","title":"Qassim bakery funding","summary":"Qassim bakery funding raises 30,000 SAR for ovens from investors who commit at least 1,000 SAR each. An unclosed round refunds its wallets at expiry; funded loans distribute repayments or record investor losses.","headers":["lending","financing","wallet"],"source":"// Qassim bakery funding raises 30,000 SAR for ovens from investors who commit at least 1,000 SAR each.\n// An unclosed round refunds its wallets at expiry; funded loans distribute repayments or record investor losses.\nprogram community_business_lending \"Qassim bakery funding\"\nuse lending\nuse financing\nuse wallet\n\n// Set price to 30,000 SAR. The bakery owns the record; investors act as actor.\n// Company fee: 5% of collected profit, with 15% VAT on that fee, at distribution.\n// Principal and wallet loads have fee 0% and tax 0%; no service is sold there.\nobject business \"Bakery oven funding\" {\n fields { businessName: text, purpose: text, price: money }\n columns: [businessName, purpose, price, fundingClosesAt]\n attach allowance = financing.limits {\n borrower: owner, per_borrower: 100000 SAR\n expose create as request_bakery_limit\n expose approve as approve_borrower\n }\n attach budget = financing.portfolio_limit {\n limit: 2000000 SAR\n expose create as create_funding_budget\n expose approve as approve_budget\n }\n // Twelve future monthly dates, 6% annual profit on the declining balance.\n // Close the fully subscribed round before separately disbursing the loan.\n attach loan = financing.installments {\n borrower: owner, capital: operator, share: 0%\n months: 12, pricing: amortizing, profit_rate: 6%, disburse_to: borrower\n payoff_rebate: 100%, refund_within: 30d, write_off_after: 90d\n limits: allowance, portfolio: budget\n expose create as quote_bakery_loan\n expose sign as sign_loan\n expose disburse as release_loan\n expose cancel as decline_loan_quote\n expose void as cancel_unfunded_loan\n expose payoff as repay_early\n expose complete as close_repaid_loan\n }\n attach investor_balance = wallet.balance {\n holder: actor, spend_limit: 7500 SAR, topup_fee: 0%\n expose create as create_investor_balance\n expose activate as open_wallet\n expose topup as add_funds\n expose withdraw as withdraw_available_funds\n expose close as close_empty_wallet\n }\n attach funding = lending.round {\n borrower: owner, plan: loan, minimum_ticket: 1000 SAR, investor_cap: 25%\n rename { closesAt: fundingClosesAt }\n expose create as open_funding_round\n expose close as close_fully_funded_round\n }\n attach investment = lending.commitment {\n round: funding, wallet: investor_balance, investor: actor\n expose create as commit_investment\n expose withdraw as withdraw_before_close\n }\n // For each recorded cash settlement, prepare once and create one share per\n // funded commitment. The fee applies to profit, never returned principal.\n attach returns = lending.distribution {\n round: funding, receipt: loan.settlement, mode: cash, fee: 5%, tax: 15%\n expose create as record_cash_settlement\n expose prepare_cash as calculate_investor_returns\n expose distribute_cash as pay_investor_wallets\n }\n // Loss distribution moves claims only. It does not debit another cash fee.\n attach losses = lending.distribution {\n round: funding, receipt: loan.settlement, mode: loss, fee: 0%, tax: 0%\n expose create as record_loss_settlement\n expose prepare_loss as calculate_investor_losses\n expose distribute_loss as allocate_investor_losses\n }\n}\n\nexpose business.loan.payment.create as record_repayment\nexpose business.loan.payment.pay as pay_instalment\nexpose business.loan.payment.refund as refund_mistaken_repayment\nexpose business.loan.payoff_quote.create as request_payoff_quote\nexpose business.loan.write_off_request.create as request_overdue_write_off\nexpose business.loan.write_off_request.apply as approve_overdue_write_off\nexpose business.loan.write_off_request.cancel as cancel_write_off_request\nexpose business.returns.share.create as create_return_share\nexpose business.losses.share.create as create_loss_share\n"},
|
|
10
|
+
{"id":"library","title":"Riyadh used van finance","summary":"Riyadh used van finance funds a 34,500 SAR van over three monthly instalments. The dealer is paid after delivery and acceptance; a verified return unwinds financing before the buyer gets a refund.","headers":["escrow","financing"],"source":"// Riyadh used van finance funds a 34,500 SAR van over three monthly instalments.\n// The dealer is paid after delivery and acceptance; a verified return unwinds financing before the buyer gets a refund.\nprogram cars \"Riyadh used van finance\"\nuse escrow\nuse financing\nparty dealer: business\n\n// Bind dealer to the vehicle seller. Set price to its gross 34,500 SAR invoice;\n// vehicle VAT stays on that invoice. The platform fee is 2% plus 15% VAT\n// on the fee: 690 SAR and 103.50 SAR. The dealer receives 33,706.50 SAR.\nobject car \"Financed van purchase\" {\n fields { make: text, model: text, year: integer, vin: text, price: money }\n columns: [make, model, year, vin, price]\n attach sale = escrow.hold {\n payer: actor, payee: dealer\n fee: { seller: 2%, tax: 15% }\n deliver_within: 7d, accept_within: 3d\n expose create as agree_van_purchase\n expose fund as pay_cash_instead\n expose deliver as confirm_van_delivery\n expose accept as accept_van\n expose dispute as dispute_van_condition\n expose verify_return as verify_returned_van\n expose refund as refund_buyer_after_unwind\n expose refund_undelivered as refund_undelivered_cash_purchase\n expose settle_release as resolve_for_dealer\n expose settle_return as resolve_for_buyer\n expose settle_refund as finish_buyer_refund\n expose cancel as cancel_unfunded_purchase\n }\n // Limits are shared across purchases. Approve each once before disbursement.\n attach limits = financing.limits {\n borrower: actor, per_borrower: 60000 SAR\n expose create as request_borrower_limit\n expose approve as approve_borrower_limit\n }\n attach ceiling = financing.portfolio_limit {\n limit: 1500000 SAR\n expose create as create_lending_budget\n expose approve as approve_lending_budget\n }\n // At 34,500 SAR, 2.5% flat profit is 862.50 SAR for the whole term.\n // Financing fee: 0%, tax: 0% on principal; no separate financing service fee.\n // Supply three future monthly dates and a unique settlementIdentity.\n attach plan = financing.installments {\n borrower: actor, capital: operator, share: 0%\n months: 3, pricing: flat_total, profit_rate: 2.5%\n funds: sale, limits: limits, portfolio: ceiling\n returned_goods: refund_all, refund_within: 30d, write_off_after: 90d\n expose create as finance\n expose sign as sign_finance_agreement\n expose disburse as fund_van_escrow\n expose cancel as decline_finance_quote\n expose void as cancel_signed_finance\n expose payoff as repay_early\n expose complete as close_repaid_finance\n // Refund paid instalments before unwinding an active plan. Then refund\n // the escrow remainder. A live plan blocks the escrow's direct refund.\n expose unwind as unwind_returned_van_finance\n expose unwind_undelivered as unwind_missing_van_finance\n expose unwind_paid as unwind_repaid_van_finance\n }\n}\n\nexpose car.plan.payment.create as record_repayment\nexpose car.plan.payment.pay as pay_instalment\nexpose car.plan.payment.refund as refund_mistaken_repayment\nexpose car.plan.payoff_quote.create as request_payoff_quote\nexpose car.plan.write_off_request.create as request_overdue_write_off\nexpose car.plan.write_off_request.apply as approve_overdue_write_off\nexpose car.plan.write_off_request.cancel as cancel_write_off_request\n"},
|
|
11
|
+
{"id":"marketplace","title":"Riyadh design market","summary":"Riyadh design market sells a 2,000 SAR restaurant menu project with delivery in seven days. The company keeps 10% plus 15% VAT on its fee; the designer receives 1,770 SAR after client acceptance.","headers":["marketplace","escrow"],"source":"// Riyadh design market sells a 2,000 SAR restaurant menu project with delivery in seven days.\n// The company keeps 10% plus 15% VAT on its fee; the designer receives 1,770 SAR after client acceptance.\nprogram freelance_marketplace \"Riyadh design market\"\nuse marketplace\nuse escrow\nparty designer: business\n\n// Bind designer to the design studio. The client owns the project record.\n// Set price to 2,000 SAR and use the same field for offer, order and escrow.\n// Any VAT on the designer's work belongs on its own invoice.\nobject project \"Menu design project\" {\n fields { brief: text, deliverable: text, price: money }\n columns: [brief, deliverable, price]\n attach offer = marketplace.listing {\n seller: designer\n rename { title: deliverable, price: price }\n expose create as draft_offer\n expose publish as publish_offer\n expose withdraw as withdraw_offer\n expose sell as close_sold_offer\n }\n attach order = marketplace.order {\n listing: offer, buyer: owner, fulfiller: designer\n rename { price: price }\n expose create as request_design\n expose commit as place_order\n expose fulfill as finish_order\n expose cancel as cancel_order\n }\n // Finishing the order does not release money. Run the payment actions too.\n attach payment = escrow.hold {\n payer: owner, payee: designer\n fee: { seller: 10%, tax: 15% }\n deliver_within: 7d, accept_within: 3d\n dispute: { refund_after: return_verified }\n expose create as create_payment\n expose fund as fund_project\n expose deliver as submit_work\n expose accept as accept_work\n expose dispute as dispute_work\n expose verify_return as verify_rejected_work\n expose refund as refund_client\n expose refund_undelivered as refund_missed_delivery\n expose settle_release as resolve_for_designer\n expose settle_return as resolve_for_client\n expose settle_refund as finish_client_refund\n expose cancel as cancel_unpaid_project\n }\n}\n"},
|
|
12
|
+
{"id":"money","title":"Riyadh tutoring studio","summary":"Riyadh tutoring studio charges 172.50 SAR for a private Arabic lesson. A paid booking can be refunded before the lesson or if the tutor cannot teach.","headers":["money"],"source":"// Riyadh tutoring studio charges 172.50 SAR for a private Arabic lesson.\n// A paid booking can be refunded before the lesson or if the tutor cannot teach.\nprogram tutoring_studio \"Riyadh tutoring studio\"\nuse money\n\n// The customer is the object's owner. Fee: 0% on top of the lesson price.\n// The studio invoices 150 SAR plus 15% VAT, 22.50 SAR, outside this transfer.\n// money.transfer sends the gross price to the studio without splitting VAT.\ninstrument lesson_booking(payment: ref<money.transfer>, student: party) {\n summary: \"Confirm a paid lesson, record teaching or refund the student.\"\n fields { payment: ref<payment>, startsAt: date }\n lifecycle { states: [booked, taught, refunded], initial: booked }\n action create {\n actor: { party: student }\n requires self.payment in [paid]\n requires unique \"paid_lesson\" on [self.payment]\n requires self.startsAt > self.now\n }\n action teach {\n from: booked, to: taught, actor: { party: programOperator }\n due: { at: self.startsAt }\n subject { lessonNotes: text }\n }\n action cancel {\n from: booked, to: refunded, actor: { party: student }\n deadline: { at: self.startsAt }\n moves self.payment.amount from programOperator to student\n }\n action tutor_unavailable {\n from: booked, to: refunded, actor: { party: programOperator }\n subject { cancellationReason: text }\n moves self.payment.amount from programOperator to student\n }\n}\n\nobject lesson \"Arabic lesson\" {\n fields { student: text, tutor: text, startsAt: date }\n columns: [student, tutor, startsAt]\n attach payment = money.transfer {\n payer: owner, payee: operator, amount: 172.50 SAR\n economics pay { purpose: earning, sourceParty: owner }\n expose create as create_payment\n expose pay as pay_for_lesson\n expose cancel as cancel_unpaid_lesson\n }\n attach booking = lesson_booking {\n payment: payment, student: owner\n rename { startsAt: startsAt }\n expose create as confirm_paid_lesson\n expose teach as record_lesson_taught\n expose cancel as cancel_and_refund_lesson\n expose tutor_unavailable as refund_cancelled_lesson\n }\n}\n"},
|
|
13
|
+
{"id":"rental-deposit","title":"Dammam equipment hire","summary":"Dammam equipment hire holds a 1,000 SAR deposit for a business renter. Return the deposit in full, or deduct a single 50 SAR late charge plus 7.50 SAR VAT.","headers":[],"source":"// Dammam equipment hire holds a 1,000 SAR deposit for a business renter.\n// Return the deposit in full, or deduct a single 50 SAR late charge plus 7.50 SAR VAT.\nprogram equipment_rental \"Dammam equipment hire\"\nparty renter: business\n\n// Bind renter to the business hiring the equipment. The deposit has fee 0%\n// and tax 0% because it stays refundable principal. The late service has 15% VAT.\ninstrument deposit {\n summary: \"Hold security until return, with one disclosed late charge.\"\n fields {\n renter: account of renter\n held: account of self\n amount: money = 1000 SAR\n lateFee: money = 50 SAR\n lateTax: money = rate(self.lateFee, 15%)\n startsAt: date\n dueAt: date\n refund: money?\n }\n lifecycle { states: [pending, funded, returned, cancelled], initial: pending }\n action create {\n actor: { party: renter }\n requires self.dueAt > self.now\n requires self.startsAt > self.now\n requires self.dueAt > self.startsAt\n }\n action fund {\n from: pending, to: funded, actor: { party: renter }\n deadline: { at: self.startsAt }\n moves self.amount from self.renter to self.held\n }\n action return_on_time {\n from: funded, to: returned, actor: { party: programOperator }\n deadline: { at: self.dueAt }\n subject { returnReference: text }\n moves self.held.balance from self.held to self.renter\n }\n action return_late {\n from: funded, to: returned, actor: { party: programOperator }\n due: { at: self.dueAt }\n subject { returnReference: text }\n calculate: [{ target: refund, op: subtract, base: { field: self.held.balance }, subtract: [{ field: self.lateFee }, { field: self.lateTax }] }]\n moves self.lateFee from self.held to programOperator\n moves self.lateTax from self.held to programTax\n moves self.refund from self.held to self.renter\n }\n action refund_before_pickup {\n from: funded, to: cancelled, actor: { party: renter }\n deadline: { at: self.startsAt }\n moves self.held.balance from self.held to self.renter\n }\n action cancel { from: pending, to: cancelled, actor: { party: renter } }\n}\n\nobject rental \"Equipment deposit\" {\n fields { equipment: text, serialNumber: text, renterName: text }\n columns: [equipment, serialNumber, renterName, startsAt, dueAt]\n attach security = deposit {\n rename { startsAt: startsAt, dueAt: dueAt }\n expose create as agree_rental\n expose fund as pay_deposit\n expose return_on_time as return_equipment\n expose return_late as return_equipment_late\n expose refund_before_pickup as cancel_before_pickup\n expose cancel as cancel_unpaid_rental\n }\n}\n\nhide deposit.create\nhide deposit.fund\nhide deposit.return_on_time\nhide deposit.return_late\nhide deposit.refund_before_pickup\nhide deposit.cancel\n"},
|
|
14
|
+
{"id":"repair-approval","title":"Jeddah phone repair","summary":"Jeddah phone repair quotes 350 SAR plus 52.50 SAR VAT for a screen replacement. The customer approves and funds the repair; acceptance pays the shop, while a failed repair returns all 402.50 SAR.","headers":[],"source":"// Jeddah phone repair quotes 350 SAR plus 52.50 SAR VAT for a screen replacement.\n// The customer approves and funds the repair; acceptance pays the shop, while a failed repair returns all 402.50 SAR.\nprogram repair_shop \"Jeddah phone repair\"\n\n// Fee: 0% beyond the repair price. The shop keeps 350 SAR and posts 15% VAT.\ninstrument assessment(customer: party) {\n summary: \"Inspect, approve, hold payment and settle a screen repair.\"\n fields {\n held: account of self\n price: money = 350 SAR\n vat: money = rate(self.price, 15%)\n total: money = sum(self.price, self.vat)\n quoteExpiresAt: date\n repairDueAt: date\n inspectedAt: date?\n approvedAt: date?\n }\n lifecycle { states: [submitted, inspected, approved, ready_for_collection, disputed, completed, refunded, rejected, expired], initial: submitted }\n action create {\n actor: { party: customer }\n requires self.quoteExpiresAt > self.now\n requires self.repairDueAt > self.quoteExpiresAt\n }\n action inspect {\n from: submitted, to: inspected, actor: { party: programOperator }\n deadline: { at: self.quoteExpiresAt }\n subject { inspectionNotes: text }\n set: { inspectedAt: { field: self.now } }\n }\n action approve {\n from: inspected, to: approved, actor: { party: customer }\n deadline: { at: self.quoteExpiresAt }\n subject { approvalReference: text }\n set: { approvedAt: { field: self.now } }\n moves self.total from customer to self.held\n }\n action reject { from: [submitted, inspected], to: rejected, actor: { party: customer } }\n action expire { from: [submitted, inspected], to: expired, actor: clock, due: { at: self.quoteExpiresAt } }\n action complete {\n from: approved, to: ready_for_collection, actor: { party: programOperator }\n deadline: { at: self.repairDueAt }\n subject { completionNotes: text }\n }\n action accept {\n from: ready_for_collection, to: completed, actor: { party: customer }\n moves self.price from self.held to programOperator\n moves self.vat from self.held to programTax\n }\n action dispute {\n from: ready_for_collection, to: disputed, actor: { party: customer }\n subject { faultDescription: text }\n }\n action refund {\n from: [approved, ready_for_collection, disputed], to: refunded, actor: { party: programOperator }\n subject { refundReason: text }\n moves self.held.balance from self.held to customer\n }\n action refund_overdue {\n from: approved, to: refunded, actor: { party: customer }\n due: { at: self.repairDueAt }\n moves self.held.balance from self.held to customer\n }\n action accept_resolution {\n from: disputed, to: completed, actor: { party: customer }\n subject { resolutionReference: text }\n moves self.price from self.held to programOperator\n moves self.vat from self.held to programTax\n }\n}\n\nobject repair \"Screen repair\" {\n fields { item: text, serialNumber: text, problem: text }\n columns: [item, serialNumber, problem, quoteExpiresAt, repairDueAt]\n attach review = assessment {\n customer: owner\n rename { quoteExpiresAt: quoteExpiresAt, repairDueAt: repairDueAt }\n expose create as request_repair\n expose inspect as inspect_repair\n expose approve as approve_and_pay\n expose reject as decline_quote\n expose complete as mark_ready_for_collection\n expose accept as accept_repair\n expose dispute as report_failed_repair\n expose refund as refund_repair\n expose refund_overdue as refund_missed_deadline\n expose accept_resolution as accept_repair_resolution\n }\n}\n"},
|
|
15
|
+
{"id":"reporting","title":"Tabuk workshop equipment finance","summary":"Tabuk workshop equipment finance lends 46,000 SAR and reports monthly repayments and arrears. Ageing bands at 30, 60 and 90 days distinguish overdue balances from loans written off after 90 days.","headers":["reporting","financing"],"source":"// Tabuk workshop equipment finance lends 46,000 SAR and reports monthly repayments and arrears.\n// Ageing bands at 30, 60 and 90 days distinguish overdue balances from loans written off after 90 days.\nprogram equipment_loan_reports \"Tabuk workshop equipment finance\"\nuse reporting\nuse financing\n\n// Set price to 46,000 SAR, the workshop's 40,000 SAR equipment invoice plus\n// 15% VAT charged by its supplier outside this loan. Profit is 6% annually on\n// the declining balance. Loan fee: 0%, tax: 0% on principal repayments.\n// Reports have no customer fee or tax; they are the lender's internal records.\nobject purchase \"Workshop equipment loan\" {\n fields { businessName: text, equipment: text, invoiceReference: text, price: money }\n columns: [businessName, equipment, invoiceReference, price]\n attach allowance = financing.limits {\n borrower: owner, per_borrower: 200000 SAR\n expose create as request_workshop_limit\n expose approve as approve_business\n }\n attach budget = financing.portfolio_limit {\n limit: 5000000 SAR\n expose create as create_lending_budget\n expose approve as approve_budget\n }\n // Create twelve future monthly dates and approve both limits before funding.\n attach loan = financing.installments {\n borrower: owner, capital: operator, share: 0%\n months: 12, pricing: amortizing, profit_rate: 6%, disburse_to: borrower\n payoff_rebate: 100%, refund_within: 30d, write_off_after: 90d\n limits: allowance, portfolio: budget\n expose create as quote_equipment_loan\n expose sign as sign_purchase_loan\n expose disburse as fund_purchase\n expose cancel as decline_loan_quote\n expose void as cancel_unfunded_loan\n expose payoff as repay_early\n expose complete as close_repaid_loan\n }\n // Report requests use reporting routes. This attachment declares their\n // datasets and retention; it neither collects money nor sends a reminder.\n attach reports = reporting.portfolio {\n on: loan, default_days: 90, retention_years: 10\n aging_first_days: 30, aging_second_days: 60, aging_third_days: 90\n expose create as enable_portfolio_reports\n }\n}\n\nexpose purchase.loan.payment.create as record_repayment\nexpose purchase.loan.payment.pay as pay_instalment\nexpose purchase.loan.payment.refund as refund_mistaken_repayment\nexpose purchase.loan.payoff_quote.create as request_payoff_quote\n// Write-off is a capital decision, not an automatic consequence of a report.\nexpose purchase.loan.write_off_request.create as request_overdue_write_off\nexpose purchase.loan.write_off_request.apply as approve_overdue_write_off\nexpose purchase.loan.write_off_request.cancel as cancel_write_off_request\n"},
|
|
16
|
+
{"id":"savings","title":"Al Khobar shopkeepers circle","summary":"Al Khobar shopkeepers circle collects 500 SAR from each of six members every month. Each member receives one 3,000 SAR pot in order; missed contributions remain payable and an unfunded pot waits.","headers":["savings"],"source":"// Al Khobar shopkeepers circle collects 500 SAR from each of six members every month.\n// Each member receives one 3,000 SAR pot in order; missed contributions remain payable and an unfunded pot waits.\nprogram neighbourhood_savings \"Al Khobar shopkeepers circle\"\nuse savings\n\n// Fee: 0%. Tax: 0% because this circle only returns members' principal and\n// charges no service. The organiser keeps none of the 18,000 SAR contributed.\nobject group \"Shopkeepers savings circle\" {\n fields { groupName: text, purpose: text }\n columns: [groupName, purpose]\n attach circle = savings.circle {\n contribution: 500 SAR, members: 6, starts: 2027-01-01\n // At creation supply circleDates: the first of January through June 2027.\n expose create as agree_circle_calendar\n expose disband as cancel_unstarted_circle\n expose close as close_completed_circle\n }\n attach membership = savings.membership {\n circle: circle, member: actor\n // Assign a distinct seat from 1 to 6 to each member at creation.\n expose create as join_circle\n expose activate as confirm_membership_schedule\n expose withdraw as leave_cancelled_circle\n }\n}\n\n// Create periods 1 through 6 for EVERY member before activating membership.\n// The clock activates the circle when all six have joined. Then confirm each\n// membership. Contributions and payouts run on that calendar, including after\n// a member has received their pot. A missed collection is not a promised retry.\nexpose group.membership.contribution.create as schedule_member_contribution\n"},
|
|
17
|
+
{"id":"serviced","title":"Dammam delivery van finance","summary":"Dammam delivery van finance funds a 69,000 SAR van with 10% down and 36 monthly instalments. It records reminders, late charges, hardship extensions, early repayment and financed returns.","headers":["escrow","financing","collections"],"source":"// Dammam delivery van finance funds a 69,000 SAR van with 10% down and 36 monthly instalments.\n// It records reminders, late charges, hardship extensions, early repayment and financed returns.\nprogram car_financing \"Dammam delivery van finance\"\nuse escrow\nuse financing\nuse collections\nparty dealer: business\n\n// The dealer invoices 60,000 SAR plus 15% VAT. Set price to 69,000 SAR.\n// The company keeps a 1% dealer fee, 690 SAR, with 103.50 SAR VAT on that fee.\nobject car \"Delivery van finance\" {\n fields { make: text, model: text, year: integer, vin: text, price: money }\n columns: [make, model, year, vin, price]\n attach sale = escrow.hold {\n payer: actor, payee: dealer\n fee: { seller: 1%, tax: 15% }, deliver_within: 14d, accept_within: 3d\n expose create as agree_van_purchase\n expose fund as pay_cash_instead\n expose deliver as confirm_delivery\n expose accept as accept_van\n expose dispute as dispute_van\n expose verify_return as verify_returned_van\n expose refund as refund_after_finance_unwind\n expose refund_undelivered as refund_missing_cash_purchase\n expose settle_release as resolve_for_dealer\n expose settle_return as resolve_for_buyer\n expose settle_refund as finish_buyer_refund\n expose cancel as cancel_and_return_down_payment\n }\n attach limits = financing.limits {\n borrower: actor, per_borrower: 250000 SAR\n expose create as request_borrower_limit\n expose approve as approve_borrower_limit\n }\n attach ceiling = financing.portfolio_limit {\n limit: 10000000 SAR\n expose create as create_lending_budget\n expose approve as approve_lending_budget\n }\n // Down payment is 6,900 SAR. Capital is 62,100 SAR; total flat profit is\n // 5,278.50 SAR. Financing service fee: 0%, tax: 0% on principal repayments.\n // Supply 36 future monthly dates. Approve limits before collecting and funding.\n attach plan = financing.installments {\n borrower: actor, capital: operator, share: 0%\n months: 36, pricing: flat_total, profit_rate: 8.5%, down_payment: 10%\n apply: fines_profit_principal, payoff_rebate: 100%, write_off_after: 90d\n refund_within: 30d, payoff_quote_expiry: 1h, returned_goods: refund_all\n max_extension: 60d, max_amendments: 2, amendment_expiry: 7d\n funds: sale, limits: limits, portfolio: ceiling\n expose create as finance\n expose sign as sign_contract\n expose collect_down_payment as pay_down_payment\n expose disburse as fund_van_escrow\n expose cancel as decline_finance_quote\n expose void as cancel_signed_finance\n expose payoff as repay_early\n expose complete as close_repaid_finance\n // Before an active-plan unwind, refund collected payments and fines,\n // and waive assessed fines. Then refund any remaining escrow balance.\n expose unwind as unwind_returned_van_finance\n expose unwind_undelivered as unwind_missing_van_finance\n expose unwind_paid as unwind_repaid_van_finance\n }\n // Create one assessment against the overdue slice. The clock assesses after\n // three days; repayments collect it. cap bounds evidenced recovery COSTS,\n // not the 50 SAR fine. Any charge VAT is invoiced outside this header.\n attach late = financing.late_charge {\n on: plan, grace: 3d, fine: 50 SAR, cap: 25 SAR\n fines_to: operator, costs_to: operator, borrower: actor\n expose create as record_late_assessment\n expose cancel as cancel_proposed_assessment\n expose refund as refund_collected_fine\n }\n attach reminders = collections.reminder {\n on: plan, operator: operator, before_days: 3, overdue_days: 1\n max_per_day: 1, send_from: 9, send_until: 18, timezone: \"Asia/Riyadh\"\n expose create as schedule_instalment_reminders\n expose dispatch as send_payment_reminder\n }\n}\n\nexpose car.plan.payment.create as record_repayment\nexpose car.plan.payment.pay as pay_instalment\nexpose car.plan.payment.refund as refund_mistaken_repayment\nexpose car.plan.payoff_quote.create as request_payoff_quote\nexpose car.plan.amendment.create as propose_hardship_extension\nexpose car.plan.amendment.accept as accept_hardship_extension\nexpose car.plan.amendment.decline as decline_hardship_extension\nexpose car.plan.amendment.withdraw as withdraw_hardship_extension\nexpose car.plan.write_off_request.create as request_overdue_write_off\nexpose car.plan.write_off_request.apply as approve_overdue_write_off\nexpose car.plan.write_off_request.cancel as cancel_write_off_request\nexpose car.late.waiver_request.create as request_fine_waiver\nexpose car.late.waiver_request.apply as approve_fine_waiver\nexpose car.late.waiver_request.cancel as cancel_fine_waiver\n"},
|
|
18
|
+
{"id":"wallet","title":"Madinah pottery studio","summary":"Madinah pottery studio lets members prepay for visits at 172.50 SAR each. A reserved visit can be charged, cancelled or released at expiry; unused credit can be withdrawn.","headers":["wallet"],"source":"// Madinah pottery studio lets members prepay for visits at 172.50 SAR each.\n// A reserved visit can be charged, cancelled or released at expiry; unused credit can be withdrawn.\nprogram workshop_credits \"Madinah pottery studio\"\nuse wallet\n\n// Top-up fee: 0%. Loading and withdrawing credit have tax 0% here because\n// they do not sell a visit. Each visit is 150 SAR plus 15% VAT, invoiced by\n// the studio outside wallet.spend, which posts the gross amount to the studio.\nobject membership \"Pottery membership\" {\n fields { memberName: text, membershipNumber: text }\n columns: [memberName, membershipNumber]\n attach balance = wallet.balance {\n holder: owner, spend_limit: 172.50 SAR, topup_fee: 0%\n expose create as create_balance\n expose activate as open_balance\n // For example, top up 690 SAR for four visits.\n expose topup as add_credit\n expose withdraw as withdraw_unused_credit\n expose freeze as freeze_balance\n expose unfreeze as restore_balance\n expose close as close_empty_balance\n expose operator_close as close_empty_membership\n }\n // Supply amount: 172.50 SAR and expiresAt: the booked visit time.\n // Each spend has its own inputs; a second visit cannot inherit the first.\n attach visit = wallet.spend {\n wallet: balance, payee: operator, holder: owner\n economics pay { purpose: earning, sourceParty: owner }\n expose create as book_visit\n expose reserve as reserve_visit_credit\n expose pay as charge_visit\n expose cancel as cancel_reserved_visit\n }\n // Expiry returns a reservation to the wallet. A paid spend has no refund\n // action in this header; resolve cancellations before charging the visit.\n}\n"},
|
|
19
19
|
];
|