Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 41 minutes ago History
subscriptions.json · 7.6 KB · 262 lines
1{
2 "name": "subscriptions",
3 "title": "Subscriptions",
4 "version": 3,
5 "description": "One customer's ongoing agreement to a plan, and the record the period biller walks. billing_mode is carried explicitly rather than inferred from whether a plan happens to have a base price -- the predecessor learned this, offering wallet | subscription | hybrid as a stated choice, because 'guess the mode from the numbers' breaks the moment someone sells a zero-base plan with a real contract behind it. The status ladder is time-driven and belongs to the daemon (docs/logic-decisions.md #2): a trial ends, an unpaid invoice ages a subscription to past_due, continued non-payment suspends it. Those moves are declared transitions with guards, so a machine making them is held to the same rules a person is -- and every one lands in the change log with an actor, which is how 'why was I cut off?' has an answer. v2: relation.requires: update on the wallet a subscription is paid from and its entity, read on the customer and plan. A subscription debiting somebody else's wallet was a registered user's own row. v3: the agreement's terms are staff's and the biller's, not the subscriber's. The subscriber owns the row, and v2 let them PUT past_due/suspended -> active, swap plan_id for a cheaper plan, push current_period_end or trial_ends_on years out (the biller closes a period only once its end has passed), or switch billing_mode. customer_id, plan_id, billing_mode, wallet_id, status, the period and trial dates, external_ref and entity_id are field permissions {edit: role:manager, role:admin; default: read}. What a subscriber may change is cancel_at_period_end (the honest cancel), their name and email as billed, and notes. The daemon's ladder and the biller write in process and are untouched.",
6 "fields": [
7 {
8 "name": "id"
9 },
10 {
11 "name": "customer_id",
12 "subject": "relation",
13 "label": "Customer",
14 "relation": {
15 "collection": "contacts",
16 "display_field": "full_name",
17 "requires": "read"
18 },
19 "permissions": {
20 "edit": [
21 "role:manager",
22 "role:admin"
23 ],
24 "default": "read"
25 }
26 },
27 {
28 "name": "customer_name",
29 "type": "text",
30 "label": "Customer Name",
31 "help": "Stamped at signup so an invoice reads correctly even if the contact is later renamed or removed."
32 },
33 {
34 "name": "customer_email",
35 "subject": "email",
36 "type": "text",
37 "label": "Customer Email"
38 },
39 {
40 "name": "plan_id",
41 "required": true,
42 "label": "Plan",
43 "relation": {
44 "collection": "billing_plans",
45 "display_field": "name",
46 "requires": "read"
47 },
48 "permissions": {
49 "edit": [
50 "role:manager",
51 "role:admin"
52 ],
53 "default": "read"
54 }
55 },
56 {
57 "name": "billing_mode",
58 "type": "enum",
59 "default": "subscription",
60 "label": "Billing Mode",
61 "enum": [
62 "wallet",
63 "subscription",
64 "hybrid"
65 ],
66 "help": "wallet: pay-as-you-go from a prepaid balance, no periodic invoice. subscription: a flat fee each period. hybrid: the fee plus metered overage.",
67 "permissions": {
68 "edit": [
69 "role:manager",
70 "role:admin"
71 ],
72 "default": "read"
73 }
74 },
75 {
76 "name": "wallet_id",
77 "label": "Wallet",
78 "relation": {
79 "collection": "wallets",
80 "display_field": "owner_id",
81 "requires": "update"
82 },
83 "help": "Which balance wallet-mode usage draws down.",
84 "permissions": {
85 "edit": [
86 "role:manager",
87 "role:admin"
88 ],
89 "default": "read"
90 }
91 },
92 {
93 "name": "status",
94 "type": "enum",
95 "default": "trialing",
96 "label": "Status",
97 "enum": [
98 "trialing",
99 "active",
100 "past_due",
101 "suspended",
102 "canceled"
103 ],
104 "transitions": {
105 "trialing": [
106 "active",
107 "canceled"
108 ],
109 "active": [
110 "past_due",
111 "canceled"
112 ],
113 "past_due": [
114 "active",
115 "suspended",
116 "canceled"
117 ],
118 "suspended": [
119 "active",
120 "canceled"
121 ],
122 "canceled": []
123 },
124 "help": "past_due -> active is deliberate and common: paying the invoice restores service, and the ladder must be climbable in both directions or a paying customer stays cut off. canceled is terminal -- resubscribing is a new agreement, not a resurrection. Moved by the daemon (trial end, unpaid invoice, suspension) and by staff -- never by the subscriber, who could otherwise climb past_due -> active without paying (v3).",
125 "permissions": {
126 "edit": [
127 "role:manager",
128 "role:admin"
129 ],
130 "default": "read"
131 }
132 },
133 {
134 "name": "current_period_start",
135 "type": "date",
136 "label": "Period Start",
137 "permissions": {
138 "edit": [
139 "role:manager",
140 "role:admin"
141 ],
142 "default": "read"
143 }
144 },
145 {
146 "name": "current_period_end",
147 "type": "date",
148 "label": "Period End",
149 "help": "The biller closes a period once this date has passed, then advances both dates by the plan's period.",
150 "permissions": {
151 "edit": [
152 "role:manager",
153 "role:admin"
154 ],
155 "default": "read"
156 }
157 },
158 {
159 "name": "trial_ends_on",
160 "type": "date",
161 "label": "Trial Ends",
162 "permissions": {
163 "edit": [
164 "role:manager",
165 "role:admin"
166 ],
167 "default": "read"
168 }
169 },
170 {
171 "name": "cancel_at_period_end",
172 "type": "boolean",
173 "default": "false",
174 "label": "Cancel At Period End",
175 "help": "The honest way to cancel: service runs to the end of the paid period, then stops. Cutting service off the instant someone clicks cancel bills them for time they cannot use."
176 },
177 {
178 "name": "external_ref",
179 "type": "text",
180 "label": "Provider Reference",
181 "help": "The provider's subscription id when one exists. This server stays the system of record either way.",
182 "permissions": {
183 "edit": [
184 "role:manager",
185 "role:admin"
186 ],
187 "default": "read"
188 }
189 },
190 {
191 "name": "notes",
192 "type": "textarea",
193 "label": "Notes"
194 },
195 {
196 "name": "owner_id",
197 "type": "text",
198 "label": "Owner"
199 },
200 {
201 "name": "entity_id",
202 "type": "text",
203 "label": "Entity",
204 "relation": {
205 "collection": "entities",
206 "display_field": "name",
207 "requires": "update"
208 },
209 "permissions": {
210 "edit": [
211 "role:manager",
212 "role:admin"
213 ],
214 "default": "read"
215 }
216 },
217 {
218 "name": "created_at",
219 "type": "datetime",
220 "read_only": true,
221 "label": "Created"
222 }
223 ],
224 "search": {
225 "fields": [
226 "customer_name",
227 "customer_email"
228 ]
229 },
230 "forms": {
231 "default": {
232 "fields": [
233 "customer_id",
234 "customer_name",
235 "customer_email",
236 "plan_id",
237 "billing_mode",
238 "wallet_id",
239 "status",
240 "current_period_start",
241 "current_period_end",
242 "trial_ends_on",
243 "cancel_at_period_end",
244 "notes"
245 ]
246 }
247 },
248 "views": {
249 "list_mode": "table",
250 "list_fields": [
251 "customer_name",
252 "plan_id",
253 "billing_mode",
254 "status",
255 "current_period_end"
256 ],
257 "filter_fields": [
258 "status",
259 "billing_mode"
260 ]
261 }
262}