@hyperscale0/hsx 5.4.1 → 5.5.0
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 +10 -0
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +80 -0
- package/dist/src/compile.js.map +1 -1
- package/dist/src/parse.js +2 -0
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.js +10 -10
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/docs/README.md +40 -0
- package/package.json +4 -4
- package/src/compile.ts +128 -0
- package/src/parse.ts +1 -0
- package/src/std-bundle.ts +10 -10
- package/src/version.ts +1 -1
- package/std/collections.hsx +4 -1
- package/std/escrow.hsx +7 -4
- package/std/financing.hsx +49 -44
- package/std/insurance.hsx +7 -3
- package/std/lending.hsx +11 -7
- package/std/marketplace.hsx +10 -7
- package/std/money.hsx +10 -6
- package/std/savings.hsx +4 -2
- package/std/travel.hsx +21 -17
- package/std/wallet.hsx +5 -2
package/std/travel.hsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
header travel
|
|
2
2
|
|
|
3
|
+
// Economics: Booking funds and refunds are principal. Supplier payments are payouts,
|
|
4
|
+
// tax is pass-through, and the company margin is earning. An outside operator
|
|
5
|
+
// receives a participant payout instead of company earnings.
|
|
6
|
+
|
|
3
7
|
// Publish a package before booking.create. Expose deposit, balance and confirm
|
|
4
8
|
// separately. Deposit needs pending premium slices whose cover is active, and
|
|
5
9
|
// collects those premiums in addition to booking cash. Balance is due by balanceAt.
|
|
@@ -59,27 +63,27 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
|
|
|
59
63
|
action deposit { allowZero: true, requires self.price > "0";
|
|
60
64
|
from: created, to: deposit_paid, actor: { party: buyer }, deadline: { at: self.balanceAt }
|
|
61
65
|
requires count of { instrument: child(cover, slice), reference: "covers", anchor: self.id, states: [pending], limit: 366 } >= 1
|
|
62
|
-
moves self.deposit from buyer to self.held
|
|
66
|
+
moves self.deposit from buyer to self.held economics { purpose: principal, sourceParty: buyer }
|
|
63
67
|
invoke: [{ selection: { instrument: child(cover, slice), reference: "covers", anchor: self.id, states: [pending], limit: 366 }, action: collect, input: {} }]
|
|
64
68
|
}
|
|
65
69
|
action balance { allowZero: true, requires self.price > "0";
|
|
66
70
|
from: deposit_paid, to: paid, actor: { party: buyer }, deadline: { at: self.balanceAt }
|
|
67
|
-
moves self.balance from buyer to self.held
|
|
71
|
+
moves self.balance from buyer to self.held economics { purpose: principal, sourceParty: buyer }
|
|
68
72
|
}
|
|
69
73
|
action confirm { allowZero: true, requires self.price > "0";
|
|
70
74
|
from: paid, to: completed, actor: { party: operator }
|
|
71
75
|
due: { at: self.package.departure }, deadline: { at: self.confirmBy }
|
|
72
|
-
moves self.supplierCost from self.held to supplier
|
|
73
|
-
moves self.tax from self.held to programTax
|
|
74
|
-
moves self.operatorNet from self.held to operator
|
|
76
|
+
moves self.supplierCost from self.held to supplier economics { purpose: participant_payout, sourceParty: programOperator }
|
|
77
|
+
moves self.tax from self.held to programTax economics { purpose: pass_through, sourceParty: programOperator }
|
|
78
|
+
moves self.operatorNet from self.held to operator economics { recipient: operator, company: { purpose: earning, sourceParty: buyer }, participant: { purpose: participant_payout, sourceParty: programOperator } }
|
|
75
79
|
}
|
|
76
80
|
action timeout {
|
|
77
81
|
from: paid, to: refunded, actor: clock, due: { at: self.confirmBy }
|
|
78
|
-
moves self.price from self.held to buyer
|
|
82
|
+
moves self.price from self.held to buyer economics { purpose: principal, sourceParty: programOperator }
|
|
79
83
|
}
|
|
80
84
|
action cancel_early { allowZero: true, requires self.price > "0";
|
|
81
85
|
from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, deadline: { at: self.earlyAt }
|
|
82
|
-
moves self.held.balance from self.held to buyer
|
|
86
|
+
moves self.held.balance from self.held to buyer economics { purpose: principal, sourceParty: programOperator }
|
|
83
87
|
}
|
|
84
88
|
action cancel_middle { allowZero: true, requires self.price > "0";
|
|
85
89
|
from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, due: { at: self.earlyAt }, deadline: { at: self.lateAt }
|
|
@@ -89,10 +93,10 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
|
|
|
89
93
|
{ target: retainedTax, op: "rate", base: { field: self.retainedMargin }, bps: { literal: tax }, rounding: "floor" }
|
|
90
94
|
{ target: retainedNet, op: "subtract", base: { field: self.retainedMargin }, subtract: [{ field: self.retainedTax }] }
|
|
91
95
|
]
|
|
92
|
-
moves self.refund from self.held to buyer
|
|
93
|
-
moves self.middlePenalty from self.held to supplier
|
|
94
|
-
moves self.retainedTax from self.held to programTax
|
|
95
|
-
moves self.retainedNet from self.held to operator
|
|
96
|
+
moves self.refund from self.held to buyer economics { purpose: principal, sourceParty: programOperator }
|
|
97
|
+
moves self.middlePenalty from self.held to supplier economics { purpose: participant_payout, sourceParty: programOperator }
|
|
98
|
+
moves self.retainedTax from self.held to programTax economics { purpose: pass_through, sourceParty: programOperator }
|
|
99
|
+
moves self.retainedNet from self.held to operator economics { recipient: operator, company: { purpose: earning, sourceParty: buyer }, participant: { purpose: participant_payout, sourceParty: programOperator } }
|
|
96
100
|
}
|
|
97
101
|
action cancel_late { allowZero: true, requires self.price > "0";
|
|
98
102
|
from: [deposit_paid, paid], to: cancelled, actor: { party: buyer }, due: { at: self.lateAt }
|
|
@@ -101,9 +105,9 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
|
|
|
101
105
|
{ target: retainedTax, op: "rate", base: { field: self.retainedMargin }, bps: { literal: tax }, rounding: "floor" }
|
|
102
106
|
{ target: retainedNet, op: "subtract", base: { field: self.retainedMargin }, subtract: [{ field: self.retainedTax }] }
|
|
103
107
|
]
|
|
104
|
-
moves self.latePenalty from self.held to supplier
|
|
105
|
-
moves self.retainedTax from self.held to programTax
|
|
106
|
-
moves self.retainedNet from self.held to operator
|
|
108
|
+
moves self.latePenalty from self.held to supplier economics { purpose: participant_payout, sourceParty: programOperator }
|
|
109
|
+
moves self.retainedTax from self.held to programTax economics { purpose: pass_through, sourceParty: programOperator }
|
|
110
|
+
moves self.retainedNet from self.held to operator economics { recipient: operator, company: { purpose: earning, sourceParty: buyer }, participant: { purpose: participant_payout, sourceParty: programOperator } }
|
|
107
111
|
}
|
|
108
112
|
action default_balance { allowZero: true, requires self.price > "0";
|
|
109
113
|
from: deposit_paid, to: cancelled, actor: clock, due: { at: self.balanceAt }
|
|
@@ -112,8 +116,8 @@ instrument booking(package: ref<travel.package>, buyer: party, supplier: party,
|
|
|
112
116
|
{ target: retainedTax, op: "rate", base: { field: self.retainedMargin }, bps: { literal: tax }, rounding: "floor" }
|
|
113
117
|
{ target: retainedNet, op: "subtract", base: { field: self.retainedMargin }, subtract: [{ field: self.retainedTax }] }
|
|
114
118
|
]
|
|
115
|
-
moves self.latePenalty from self.held to supplier
|
|
116
|
-
moves self.retainedTax from self.held to programTax
|
|
117
|
-
moves self.retainedNet from self.held to operator
|
|
119
|
+
moves self.latePenalty from self.held to supplier economics { purpose: participant_payout, sourceParty: programOperator }
|
|
120
|
+
moves self.retainedTax from self.held to programTax economics { purpose: pass_through, sourceParty: programOperator }
|
|
121
|
+
moves self.retainedNet from self.held to operator economics { recipient: operator, company: { purpose: earning, sourceParty: buyer }, participant: { purpose: participant_payout, sourceParty: programOperator } }
|
|
118
122
|
}
|
|
119
123
|
}
|
package/std/wallet.hsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
header wallet
|
|
2
2
|
|
|
3
|
+
// Economics: Topups and withdrawals are excluded prepaid credit. Spending remains
|
|
4
|
+
// unclassified because the bound payee alone does not state the purchase purpose.
|
|
5
|
+
|
|
3
6
|
// Expose balance.create, activate, topup and withdraw as needed. Holder moves
|
|
4
7
|
// cash only while active. Freeze blocks new topups, withdrawals and spend reserves;
|
|
5
8
|
// close requires no held cash. Freeze/unfreeze use caller operation authority.
|
|
@@ -22,12 +25,12 @@ instrument balance(holder: party, spend_limit: money = 100000 SAR) {
|
|
|
22
25
|
action topup {
|
|
23
26
|
from: active, to: active, actor: { party: holder }
|
|
24
27
|
input { amount: money }
|
|
25
|
-
moves input.amount from holder to self.held
|
|
28
|
+
moves input.amount from holder to self.held economics { purpose: prepaid_credit, sourceParty: holder }
|
|
26
29
|
}
|
|
27
30
|
action withdraw {
|
|
28
31
|
from: active, to: active, actor: { party: holder }
|
|
29
32
|
input { amount: money }
|
|
30
|
-
moves input.amount from self.held to holder
|
|
33
|
+
moves input.amount from self.held to holder economics { purpose: prepaid_credit, sourceParty: programOperator }
|
|
31
34
|
}
|
|
32
35
|
action freeze { from: active, to: frozen, }
|
|
33
36
|
action unfreeze { from: frozen, to: active, }
|