Une facture passée son échéance: 30 jours, 50 pour un hôpital, 30 jours fin de mois
Objectif Être alerté de chaque facture impayée passée son échéance, calculée à l'entrée selon le client: 30 jours pour un acheteur public, 50 pour un hôpital, 30 jours fin de mois pour un client privé.
L'échéance n'est pas une date de la facture: elle se calcule depuis la réception, et la règle dépend du client. Un acheteur public paie sous 30 jours, un établissement public de santé sous 50. Un client privé, ici, à 30 jours fin de mois.
- le script de l'opérateur calcule due_on à l'entrée
- un Workflow déclare l'échéance
- une décision par facture impayée en retard
invoice_no;buyer;buyer_type;received_on;amount;status F-101;Mairie de Saint-Aubin;collectivite;2026-10-12;4 860,00;A_PAYER F-102;Centre hospitalier de Valmont;hopital;2026-10-12;12 340,50;A_PAYER F-103;Préfecture de région;etat;2026-10-07;2 150,00;PAYEE F-104;Communauté de communes du Val;collectivite;2026-11-11;780,00;A_PAYER F-105;Centre hospitalier de Valmont;hopital;2026-09-22;3 920,00;A_PAYER P-201;Garage Morel;prive;2026-09-12;1 380,00;A_PAYER P-202;Boulangerie Roux;prive;2026-11-16;245,90;A_PAYER
manifests/payment-due.kts
// Operator-provided: the payment deadline of an invoice, from the day the customer received it.// A public buyer: 30 days (Code de la commande publique R2192-10), 50 for a public health establishment (R2192-11).// A private customer, on this supplier's terms: 30 days end of month — the end of the month of reception, then 30 days.// An unknown customer type gets no deadline, and due_issue says why.@Suppress("UNCHECKED_CAST")val cells = bindings["cells"] as MutableMap<String, Any?>val type = (cells["buyer_type"] as String?)?.trim()val received = (cells["received_on"] as String?)?.trim()val due = if (received.isNullOrEmpty()) null else { val day = java.time.LocalDate.parse(received) when (type) { "etat", "collectivite" -> day.plusDays(30) "hopital" -> day.plusDays(50) "prive" -> day.with(java.time.temporal.TemporalAdjusters.lastDayOfMonth()).plusDays(30) else -> null }}cells["due_on"] = due?.toString()cells["due_issue"] = when { received.isNullOrEmpty() -> "no received_on" due == null -> "unknown buyer_type" else -> null}manifests/10-invoices.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata: name: scenario-invoices-a connector_type: csv-file scopes: [recouvrement-a]spec: transport: kind: sftp host: host.docker.internal port: 2228 user: compta path: /exports/factures.csv password_env: SCENARIO_INVOICES_A_SFTP # The fingerprint the export server presents, read out of band (ssh-keyscan | ssh-keygen -lf -). host_key_fingerprint: "SHA256:FINGERPRINT_READ_AT_REPLAY" parser: has_header: true delimiter: ";" encoding: UTF-8 after_process: none mapping: cell: - kotlin: script: hooks:payment-due-a.kts # the operator's script: 30 or 50 days public, 30 days end of month private - parse-date: { column: received_on, formats: ["yyyy-MM-dd"] } - parse-date: { column: due_on, formats: ["yyyy-MM-dd"] } - parse-number: { column: amount, decimal-separator: "," }manifests/20-payment-deadline.yaml
apiVersion: apps.lumnik.io/v1kind: Workflowmetadata: name: scenario-payment-deadline-aspec: scope: recouvrement-a provenance: declared on: table: connector.t_scenario_invoices_a column: status key: invoice_no due: column: due_on # computed at the door from received_on and the customer type states: [A_PAYER] zone: Europe/Paris message: "{doc_key} — {buyer}, {amount} €: unpaid, its payment deadline passed on {due}" fields: [buyer_type, received_on] states: - { code: A_PAYER, label: "Unpaid", initial: true } - { code: PAYEE, label: "Paid", terminal: true }$ lm hook scripts
NAME SIZE SHA256
cfonb-amount-b.kts 784 3f94b73a8a923324f6750648e230e3d91026299ed636627a4562b14552d493ba
cfonb-amount-c.kts 784 3f94b73a8a923324f6750648e230e3d91026299ed636627a4562b14552d493ba
coordinates-c.kts 5076 cc87f4a8e8ccbb38f3306d4dce5a013dab984c36a8cd72afd72e8bd142504542
ean-check-b.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-check-c.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-check-d.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-draft-b.kts 476 c8692d84859f810de8903ded14a03a1ec4db93e1282aa88b4fb9f5e42b6586ea
ean-draft-c.kts 476 c8692d84859f810de8903ded14a03a1ec4db93e1282aa88b4fb9f5e42b6586ea
ean-draft-d.kts 526 90a58aae66c5feec5e52017e90d86b9ee93e46ce7d97dc0c1eb4b5faefb636a7
payment-due-a.kts 1106 885d56162b45d32575f5097682e6fc73b0d4e66c03ebacfa52111f372db1b894
promised-date-b.kts 1407 44ceece5d17c40d337374d02f942aef41b092b6708ff7dbc48efc8b43aef1ac9
shipping-fee-c.kts 333 c1c59e5c7b81302d5a284c9c722ca8cacaca0fe859c8ae1c393cd1d54a1ad9ad
shipping-fee-p.kts 333 c1c59e5c7b81302d5a284c9c722ca8cacaca0fe859c8ae1c393cd1d54a1ad9ad
$ lm apply -f 10-invoices.yaml
Applied connector "scenario-invoices-a" — 1 endpoint
$ lm connector run scenario-invoices-a
run scheduled: 586ddb59-7705-408d-be63-2698a726d32b
$ lm run get 586ddb59-7705-408d-be63-2698a726d32b --wait-evaluated
ID CONNECTOR ENDPOINT STATUS IN OUT SKIPPED DEAD-LETTERS STARTED ENDED EVALUATED
586ddb59 scenario-invoices-a default Completed 7 7 0 0 2026-11-21 22:29 2026-11-21 22:29 yes
• script hooks:payment-due-a.kts sha256 885d56162b45d32575f5097682e6fc73b0d4e66c03ebacfa52111f372db1b894
$ lm workflow apply -f 20-payment-deadline.yaml -o json
{
"name": "scenario-payment-deadline-a",
"scope": "recouvrement-a",
"table": "connector.t_scenario_invoices_a",
"column": "status",
"dataTruth": {
"undeclared": [],
"unobserved": [],
"nullOrBlank": 0,
"tableMissing": false,
"keyColumnMissing": false,
"keyNullOrBlank": 0,
"checkUnavailable": false,
"unavailableReason": null,
"dueProblem": null,
"invalidOrderValues": null,
"keysWithSeveralRows": null,
"columnsUnverified": []
}
}- run
- IN 7 · OUT 7 · cell errors 0
- F-101
- due 2026-11-11
- F-102
- due 2026-12-01
- F-103
- due 2026-11-06
- F-104
- due 2026-12-11
- F-105
- due 2026-11-11
- P-201
- due 2026-10-30
- P-202
- due 2026-12-30
preuves: replay.log, 00-check-deadlines.txt, 01-hook-scripts.txt, 02-run.json, 03-workflow-apply.json, 04-decisions.json · transform v1
$ lm inbox --process workflow:scenario-payment-deadline-a
ID WHEN PROCESS MESSAGE ENTITY_KEY
31723 just now workflow:scenario-payment-deadline-a P-201 — Garage Morel, 1380 €: unpaid, its payment deadline passed on 2026-10-30 P-201
31722 just now workflow:scenario-payment-deadline-a F-105 — Centre hospitalier de Valmont, 3920 €: unpaid, its payment deadline passed on 2026-11-11 F-105
31721 just now workflow:scenario-payment-deadline-a F-101 — Mairie de Saint-Aubin, 4860 €: unpaid, its payment deadline passed on 2026-11-11 F-101- decision
- F-101 — Mairie de Saint-Aubin, 4860 €: unpaid, its payment deadline passed on 2026-11-11
- decision
- F-105 — Centre hospitalier de Valmont, 3920 €: unpaid, its payment deadline passed on 2026-11-11
- decision
- P-201 — Garage Morel, 1380 €: unpaid, its payment deadline passed on 2026-10-30
- check_deadlines.py
- F-101 F-105 P-201
preuves: replay.log, 00-check-deadlines.txt, 01-hook-scripts.txt, 02-run.json, 03-workflow-apply.json, 04-decisions.json · transform v1
Limites
- Aucun transformer n'ajoute de jours: l'échéance demande le script de l'opérateur, installé dans le dossier de hooks du hub.
- «30 jours fin de mois» se lit de deux façons: ici, fin de mois puis 30 jours. Le contrat dit laquelle.
- Les intérêts moratoires ne sont pas calculés, et rien n'est envoyé au client.
- Le contrôle tourne toutes les 15 minutes.
- Une suspension du délai par l'acheteur public n'est pas lue.
- Sept factures synthétiques, datées depuis le jour du rejeu.
Ce scénario demande lumnik Pro.
Voir l'offre →