---
title: "Subscriptions"
description: "Toistuva laskutus. Jokainen sovellus on moduuli samalla tietomallilla."
canonical: "https://obop.dev/fi/apps/subscriptions/"
lang: "fi"
---

# Subscriptions

## Mihin se on tarkoitettu

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.

## Mitä paketti tekee ja mitä ei

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.

## Mallit

### `subscriptions_plan`

A recurring offer customers can subscribe to

Lukuryhmä: `subscriptions.user`. Kirjoitusryhmä: `subscriptions.manager`.

| Kenttä | Tyyppi | Tietoluokka | Henkilötieto | Ryhmä | Agentit näkevät | Kuvaus |
|---|---|---|---|---|---|---|
| `name` | text | `none` | ei | `subscriptions.user` | selkoisena | Plan name, for example Team yearly |
| `code` | text | `none` | ei | `subscriptions.user` | selkoisena | Short code of the plan |
| `interval` | select (monthly, quarterly, yearly) | `none` | ei | `subscriptions.user` | selkoisena | How often the customer is billed: monthly, quarterly, yearly |
| `price` | money | `none` | ei | `subscriptions.user` | selkoisena | Standard price per billing interval (minor currency units, e.g. cents) |
| `trial_days` | number | `none` | ei | `subscriptions.user` | selkoisena | Length of the free trial in days |
| `active` | bool | `none` | ei | `subscriptions.user` | selkoisena | Whether new customers can pick the plan |

### `subscriptions_subscription`

A customer's recurring subscription to a plan

Lukuryhmä: `subscriptions.user`. Kirjoitusryhmä: `subscriptions.manager`.

| Kenttä | Tyyppi | Tietoluokka | Henkilötieto | Ryhmä | Agentit näkevät | Kuvaus |
|---|---|---|---|---|---|---|
| `customer_id` | ref → party | `none` | ei | `subscriptions.user` | selkoisena | The customer who subscribed |
| `plan_id` | ref → subscriptions_plan | `none` | ei | `subscriptions.user` | selkoisena | The plan subscribed to |
| `started_on` | date | `none` | ei | `subscriptions.user` | selkoisena | Date the subscription began (YYYY-MM-DD) |
| `trial_ends_on` | date | `none` | ei | `subscriptions.user` | selkoisena | Date the free trial ends (YYYY-MM-DD) |
| `next_invoice_on` | date | `none` | ei | `subscriptions.user` | selkoisena | Date the next invoice is due (YYYY-MM-DD) |
| `recurring_amount` | money | `none` | ei | `subscriptions.user` | selkoisena | Amount billed each interval after discounts (minor currency units, e.g. cents) |
| `currency` | text | `none` | ei | `subscriptions.user` | selkoisena | ISO 4217 currency code, for example EUR |
| `seats` | number | `none` | ei | `subscriptions.user` | selkoisena | Number of licences or users covered |
| `cancel_reason` | longtext | `none` | ei | `subscriptions.user` | selkoisena | Why the customer cancelled |
| `state` | select (trial, active, past_due, cancelled) | `none` | ei | `subscriptions.user` | selkoisena | Subscription status: trial, active, past_due, cancelled |

## Työnkulut

### `subscriptions_subscription`

| Toiminto | Siirtää | Kuka voi suorittaa | Hyväksyntä |
|---|---|---|---|
| `subscriptions_subscription.activate` | state: trial → active | `subscriptions.manager` | ei |
| `subscriptions_subscription.mark_past_due` | state: active → past_due | `subscriptions.manager` | ei |
| `subscriptions_subscription.recover` | state: past_due → active | `subscriptions.manager` | ei |
| `subscriptions_subscription.cancel_trial` | state: trial → cancelled | `subscriptions.manager` | kyllä |
| `subscriptions_subscription.cancel` | state: active → cancelled | `subscriptions.manager` | kyllä |
| `subscriptions_subscription.cancel_overdue` | state: past_due → cancelled | `subscriptions.manager` | kyllä |

## Käyttöoikeusryhmät

Tämän sovelluksen käyttämät ryhmät:

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

## Hyväksyntävaiheet

Vaiheet, joita agentti voi vain ehdottaa:

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

## Mitä agentit voivat ja eivät voi tehdä

Agentti voi lukea, hakea, luoda ja päivittää tämän sovelluksen tietueita sekä suorittaa toiminnot, jotka eivät vaadi hyväksyntää, tunnisteensa käyttöoikeusryhmien rajoissa.

Se voi vain ehdottaa näitä vaiheita, ja ihmisen on hyväksyttävä ne: `subscriptions_subscription.cancel_trial`, `subscriptions_subscription.cancel`, `subscriptions_subscription.cancel_overdue`, `subscriptions_plan.delete`, `subscriptions_subscription.delete`.

## Riippuvuudet

- `base`

## Asennus

Asenna se Customize-sovelluksesta (Marketplace) tai komentoriviltä:

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

Vaatii tietokannan ja ylläpitäjän oikeudet.

## Tee oma

[Moduulioppaassa näytetään, miten tällaiset sovellukset kirjoitetaan](/fi/docs/reference/module-manifest/)
