lumnik. / scénarios Tous les scénarios · English

Apprentissage: une échéance OPCO facturée après la rupture du contrat

Objectif Joindre chaque ligne de facture OPCO au registre des contrats du CFA, et être prévenu quand la période facturée dépasse la rupture du contrat, même quand la rupture est saisie après la facture.

Le CFA d'une école de commerce, deux exports CSV: 36 contrats d'apprentissage, 40 lignes de facture OPCO.

contrats.csv
contract_id,apprentice_id,program,opco,start_on,end_on,rupture_on
CTR-26-0001,APP-26-0001,Bachelor 3 alternance,AKTO,2026-09-01,2027-08-31,
CTR-26-0002,APP-26-0002,MSc Supply Chain alternance,OPCO EP,2026-09-01,2027-08-31,
CTR-26-0003,APP-26-0003,PGE M2 alternance,OPCO Commerce,2026-09-01,2027-08-31,
CTR-26-0004,APP-26-0004,Bachelor 3 alternance,Atlas,2026-09-01,2027-08-31,
CTR-26-0005,APP-26-0005,MSc Supply Chain alternance,AKTO,2026-09-01,2027-08-31,
CTR-26-0006,APP-26-0006,PGE M2 alternance,OPCO EP,2026-09-01,2027-08-31,
CTR-26-0007,APP-26-0007,Bachelor 3 alternance,OPCO Commerce,2026-09-01,2027-08-31,
CTR-26-0008,APP-26-0008,MSc Supply Chain alternance,Atlas,2026-09-01,2027-08-31,
CTR-26-0009,APP-26-0009,PGE M2 alternance,AKTO,2026-09-01,2027-08-31,
CTR-26-0010,APP-26-0010,Bachelor 3 alternance,OPCO EP,2026-09-01,2027-08-31,
CTR-26-0011,APP-26-0011,MSc Supply Chain alternance,OPCO Commerce,2026-09-01,2027-08-31,
CTR-26-0012,APP-26-0012,PGE M2 alternance,Atlas,2026-09-01,2027-08-31,
CTR-26-0013,APP-26-0013,Bachelor 3 alternance,AKTO,2026-09-01,2027-08-31,
CTR-26-0014,APP-26-0014,MSc Supply Chain alternance,OPCO EP,2026-09-01,2027-08-31,
CTR-26-0015,APP-26-0015,PGE M2 alternance,OPCO Commerce,2026-09-01,2027-08-31,
CTR-26-0016,APP-26-0016,Bachelor 3 alternance,Atlas,2026-09-01,2027-08-31,
CTR-26-0017,APP-26-0017,MSc Supply Chain alternance,AKTO,2026-09-01,2027-08-31,
CTR-26-0018,APP-26-0018,PGE M2 alternance,OPCO EP,2026-09-01,2027-08-31,
CTR-26-0019,APP-26-0019,Bachelor 3 alternance,OPCO Commerce,2026-09-01,2027-08-31,

… 17 lignes de plus

factures-2026-09.csv
invoice_line,contract_id,opco,installment,period_start,period_end,amount_eur,invoiced_on
F26-09-001,CTR-26-0001,AKTO,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-002,CTR-26-0002,OPCO EP,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-003,CTR-26-0003,OPCO Commerce,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-004,CTR-26-0004,Atlas,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-005,CTR-26-0005,AKTO,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-006,CTR-26-0006,OPCO EP,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-007,CTR-26-0007,OPCO Commerce,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-008,CTR-26-0008,Atlas,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-009,CTR-26-0009,AKTO,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-010,CTR-26-0010,OPCO EP,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-011,CTR-26-0011,OPCO Commerce,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-012,CTR-26-0012,Atlas,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-013,CTR-26-0013,AKTO,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-014,CTR-26-0014,OPCO EP,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-015,CTR-26-0015,OPCO Commerce,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-016,CTR-26-0016,Atlas,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-017,CTR-26-0017,AKTO,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-018,CTR-26-0018,OPCO EP,1,2026-09-01,2027-03-31,3520.00,2026-09-15
F26-09-019,CTR-26-0019,OPCO Commerce,1,2026-09-01,2027-03-31,3520.00,2026-09-15

… 17 lignes de plus

manifests/20-invoice-line.yaml
kind: Entityname: cfa_invoice_amatch: [invoice_line]scopes: [cfa-billing-a]sources:  - table: t_scenario_cfa_invoices_a    map: { invoice_line: invoice_line, contract_id: contract_id, opco: opco, installment: installment,           period_start: period_start, period_end: period_end, amount_eur: amount_eur, invoiced_on: invoiced_on }joins:  - table: t_scenario_cfa_contracts_a    # per contract, not per invoice line    from: contract_id    to: contract_id    map: { apprentice_id: apprentice_id, program: program, start_on: start_on, end_on: end_on, rupture_on: rupture_on }
manifests/30-billed-after-rupture.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata:  name: scenario-cfa-billed-after-rupture-aspec:  scope: cfa-billing-a  on: { event: data.row.changed, table: connector.v_cfa_invoice_a }  when:    - "period_end>{rupture_on}"        # the invoiced period runs past the contract's rupture  emit:    type: decision.billed-after-rupture-a    message: "{invoice_line}: {amount_eur} EUR invoiced to {opco} for {period_start} to {period_end}; contract {contract_id} ({apprentice_id}) broken on {rupture_on}"    key: invoice_line
factures-2026-11.csv
invoice_line,contract_id,opco,installment,period_start,period_end,amount_eur,invoiced_on
F26-11-001,CTR-26-0027,OPCO Commerce,2,2026-11-13,2027-02-12,2640.00,2026-11-16
F26-11-002,CTR-26-0028,Atlas,2,2026-11-04,2027-02-03,2640.00,2026-11-16
F26-11-003,CTR-26-0029,AKTO,2,2026-11-15,2027-02-14,2640.00,2026-11-16
F26-11-004,CTR-26-0030,OPCO EP,1,2026-10-05,2027-05-04,3520.00,2026-11-16
$ lm connector run scenario-cfa-contracts-a
run scheduled: 458b4d3c-e774-477f-bb3f-297f6e39fbe9

$ lm run get 458b4d3c-e774-477f-bb3f-297f6e39fbe9
ID        CONNECTOR                 ENDPOINT  STATUS     IN  OUT  SKIPPED  DEAD-LETTERS  STARTED           ENDED             EVALUATED
458b4d3c  scenario-cfa-contracts-a  default   Completed  36  36   0        0             2026-11-11 12:09  2026-11-11 12:09  yes

$ lm inbox --process scenario-cfa-billed-after-rupture-a
ID     WHEN      PROCESS                              MESSAGE                                                                                                                                  ENTITY_KEY
27397  just now  scenario-cfa-billed-after-rupture-a  F26-09-032: 3520.00 EUR invoiced to OPCO Commerce for 2026-09-01 to 2027-03-31; contract CTR-25-0003 (APP-25-0003) broken on 2026-10-30  F26-09-032
27396  just now  scenario-cfa-billed-after-rupture-a  F26-09-007: 3520.00 EUR invoiced to OPCO Commerce for 2026-09-01 to 2027-03-31; contract CTR-26-0007 (APP-26-0007) broken on 2026-10-28  F26-09-007
27391  just now  scenario-cfa-billed-after-rupture-a  F26-11-001: 2640.00 EUR invoiced to OPCO Commerce for 2026-11-13 to 2027-02-12; contract CTR-26-0027 (APP-26-0027) broken on 2026-10-09  F26-11-001

Limites

  • lumnik signale la ligne; il ne calcule pas le prorata au jour ni le montant à rembourser.
  • Le nombre de jours réellement suivis, que demande le certificat de réalisation, n'est pas compté.
  • Une formation poursuivie après la rupture n'est pas distinguée: la facture relève alors d'un accord rectificatif.
  • Les lignes déjà là quand le Process est appliqué ne sont jugées que si elles changent, ou si leur contrat change.
  • Contrats, périodes et montants synthétiques: l'échéancier réel est celui de l'accord de prise en charge de chaque OPCO.

École · apprentissage

Une échéance OPCO ne vaut que pour les jours du contrat.

Les contrats et les factures vivent dans deux outils.

36 contrats, 40 lignes de facture, deux exports CSV

Le problème

CTR-26-0027 est rompu le 9 octobre.

  • En novembre, son échéance part quand même.
  • La rupture saisie en retard ne rattrape pas les factures déjà envoyées.

Ce qui n'est pas modifié

Le registre et la facturation restent tels quels.

  • Leurs exports CSV habituels.
  • Aucun développement dans l'un ou l'autre.

Ce qu'il a fallu écrire

joins: [{ table: contrats, from: contract_id }]
when: ["period_end>{rupture_on}"]

Une jointure, une condition entre deux colonnes.

  • Une Entity: la rupture sur chaque ligne.
  • Un Process: une décision par ligne.

La rupture arrive en retard

Deux ruptures saisies fin octobre.

  • Les factures de septembre remontent.
  • Le solde de l'année 1, clos avant, reste muet.

Essayer

Le scénario se rejoue en local.

Chaque étape est publiée avec sa sortie.

Ce scénario tourne sur lumnik Open, gratuit et open source.

Essayer lumnik Open →