---
title: "Subscriptions"
description: "Återkommande fakturering. Varje app är en modul i en gemensam datamodell."
canonical: "https://obop.dev/sv/apps/subscriptions/"
lang: "sv"
---

# Subscriptions

## Vad den är till för

Define recurring plans and track customer subscriptions with trial, active, past due and cancelled states, including the next invoice date. It does not create invoices by itself.

## Vad paketet gör och inte gör

Recurring plans and customer subscriptions with a trial, active, past due and cancelled flow. It records the next invoice date; it does not create invoices on its own.

## Modeller

### `subscriptions_plan`

A recurring offer customers can subscribe to

Läsgrupp: `subscriptions.user`. Skrivgrupp: `subscriptions.manager`.

| Fält | Typ | Dataklass | Personuppgift | Grupp | Agenter ser | Beskrivning |
|---|---|---|---|---|---|---|
| `name` | text | `none` | nej | `subscriptions.user` | i klartext | Plan name, for example Team yearly |
| `code` | text | `none` | nej | `subscriptions.user` | i klartext | Short code of the plan |
| `interval` | select (monthly, quarterly, yearly) | `none` | nej | `subscriptions.user` | i klartext | How often the customer is billed: monthly, quarterly, yearly |
| `price` | money | `none` | nej | `subscriptions.user` | i klartext | Standard price per billing interval (minor currency units, e.g. cents) |
| `trial_days` | number | `none` | nej | `subscriptions.user` | i klartext | Length of the free trial in days |
| `active` | bool | `none` | nej | `subscriptions.user` | i klartext | Whether new customers can pick the plan |

### `subscriptions_subscription`

A customer's recurring subscription to a plan

Läsgrupp: `subscriptions.user`. Skrivgrupp: `subscriptions.manager`.

| Fält | Typ | Dataklass | Personuppgift | Grupp | Agenter ser | Beskrivning |
|---|---|---|---|---|---|---|
| `customer_id` | ref → party | `none` | nej | `subscriptions.user` | i klartext | The customer who subscribed |
| `plan_id` | ref → subscriptions_plan | `none` | nej | `subscriptions.user` | i klartext | The plan subscribed to |
| `started_on` | date | `none` | nej | `subscriptions.user` | i klartext | Date the subscription began (YYYY-MM-DD) |
| `trial_ends_on` | date | `none` | nej | `subscriptions.user` | i klartext | Date the free trial ends (YYYY-MM-DD) |
| `next_invoice_on` | date | `none` | nej | `subscriptions.user` | i klartext | Date the next invoice is due (YYYY-MM-DD) |
| `recurring_amount` | money | `none` | nej | `subscriptions.user` | i klartext | Amount billed each interval after discounts (minor currency units, e.g. cents) |
| `currency` | text | `none` | nej | `subscriptions.user` | i klartext | ISO 4217 currency code, for example EUR |
| `seats` | number | `none` | nej | `subscriptions.user` | i klartext | Number of licences or users covered |
| `cancel_reason` | longtext | `none` | nej | `subscriptions.user` | i klartext | Why the customer cancelled |
| `state` | select (trial, active, past_due, cancelled) | `none` | nej | `subscriptions.user` | i klartext | Subscription status: trial, active, past_due, cancelled |

## Arbetsflöden

### `subscriptions_subscription`

| Åtgärd | Flyttar | Vem får köra den | Godkännande |
|---|---|---|---|
| `subscriptions_subscription.activate` | state: trial → active | `subscriptions.manager` | nej |
| `subscriptions_subscription.mark_past_due` | state: active → past_due | `subscriptions.manager` | nej |
| `subscriptions_subscription.recover` | state: past_due → active | `subscriptions.manager` | nej |
| `subscriptions_subscription.cancel_trial` | state: trial → cancelled | `subscriptions.manager` | ja |
| `subscriptions_subscription.cancel` | state: active → cancelled | `subscriptions.manager` | ja |
| `subscriptions_subscription.cancel_overdue` | state: past_due → cancelled | `subscriptions.manager` | ja |

## Behörighetsgrupper

Grupper som den här appen använder:

- `subscriptions.manager`
- `subscriptions.user`

## Steg som kräver godkännande

Steg som en agent bara kan föreslå:

- `subscriptions_subscription.cancel_trial`
- `subscriptions_subscription.cancel`
- `subscriptions_subscription.cancel_overdue`

## Vad agenter kan och inte kan göra

En agent kan läsa, söka, skapa och uppdatera poster i den här appen, och köra de åtgärder som inte kräver godkännande, inom behörighetsgrupperna för sin token.

Den kan bara föreslå de här stegen, och en person måste godkänna dem: `subscriptions_subscription.cancel_trial`, `subscriptions_subscription.cancel`, `subscriptions_subscription.cancel_overdue`, `subscriptions_plan.delete`, `subscriptions_subscription.delete`.

## Beroenden

- `base`

## Installera

Installera den från appen Customize (Marknadsplats), eller från kommandoraden:

```bash
obop modules install-from subscriptions
```

Kräver en databas och administratörsbehörighet.

## Bygg din egen

[Modulguiden visar hur appar som den här skrivs](/sv/docs/reference/module-manifest/)
