askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
subscriptions.json · 4.3 KB · 55 lines
| 1 | { |
| 2 | "name": "subscriptions", |
| 3 | "title": "Subscriptions", |
| 4 | "version": 1, |
| 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.", |
| 6 | "fields": [ |
| 7 | {"name": "id"}, |
| 8 | {"name": "customer_id", "label": "Customer", |
| 9 | "relation": {"collection": "contacts", "display_field": "full_name"}}, |
| 10 | {"name": "customer_name", "type": "text", "label": "Customer Name", |
| 11 | "help": "Stamped at signup so an invoice reads correctly even if the contact is later renamed or removed."}, |
| 12 | {"name": "customer_email", "type": "text", "label": "Customer Email"}, |
| 13 | {"name": "plan_id", "required": true, "label": "Plan", |
| 14 | "relation": {"collection": "billing_plans", "display_field": "name"}}, |
| 15 | {"name": "billing_mode", "type": "enum", "default": "subscription", "label": "Billing Mode", |
| 16 | "enum": ["wallet", "subscription", "hybrid"], |
| 17 | "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."}, |
| 18 | {"name": "wallet_id", "label": "Wallet", |
| 19 | "relation": {"collection": "wallets", "display_field": "owner_id"}, |
| 20 | "help": "Which balance wallet-mode usage draws down."}, |
| 21 | {"name": "status", "type": "enum", "default": "trialing", "label": "Status", |
| 22 | "enum": ["trialing", "active", "past_due", "suspended", "canceled"], |
| 23 | "transitions": { |
| 24 | "trialing": ["active", "canceled"], |
| 25 | "active": ["past_due", "canceled"], |
| 26 | "past_due": ["active", "suspended", "canceled"], |
| 27 | "suspended": ["active", "canceled"], |
| 28 | "canceled": [] |
| 29 | }, |
| 30 | "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."}, |
| 31 | {"name": "current_period_start", "type": "date", "label": "Period Start"}, |
| 32 | {"name": "current_period_end", "type": "date", "label": "Period End", |
| 33 | "help": "The biller closes a period once this date has passed, then advances both dates by the plan's period."}, |
| 34 | {"name": "trial_ends_on", "type": "date", "label": "Trial Ends"}, |
| 35 | {"name": "cancel_at_period_end", "type": "boolean", "default": "false", |
| 36 | "label": "Cancel At Period End", |
| 37 | "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."}, |
| 38 | {"name": "external_ref", "type": "text", "label": "Provider Reference", |
| 39 | "help": "The provider's subscription id when one exists. This server stays the system of record either way."}, |
| 40 | {"name": "notes", "type": "textarea", "label": "Notes"}, |
| 41 | {"name": "owner_id", "type": "text", "label": "Owner"}, |
| 42 | {"name": "entity_id", "type": "text", "label": "Entity", |
| 43 | "relation": {"collection": "entities", "display_field": "name"}}, |
| 44 | {"name": "created_at", "type": "datetime", "read_only": true, "label": "Created"} |
| 45 | ], |
| 46 | "search": {"fields": ["customer_name", "customer_email"]}, |
| 47 | "forms": {"default": {"fields": ["customer_id", "customer_name", "customer_email", |
| 48 | "plan_id", "billing_mode", "wallet_id", "status", |
| 49 | "current_period_start", "current_period_end", |
| 50 | "trial_ends_on", "cancel_at_period_end", "notes"]}}, |
| 51 | "views": {"list_mode": "table", |
| 52 | "list_fields": ["customer_name", "plan_id", "billing_mode", "status", |
| 53 | "current_period_end"], |
| 54 | "filter_fields": ["status", "billing_mode"]} |
| 55 | } |