app.arete_filiation
Description
Section intitulée « Description »Filiation des lots (RG-160) : un lot parent a servi à créer un lot enfant, par un mouvement de transformation non contre-passé. Dérivée des mouvements, rien n’est stocké en double.
Table Definition
CREATE VIEW arete_filiation AS ( SELECT DISTINCT m.organisation_id, p.id AS parent_lot_id, c.id AS enfant_lot_id FROM ((((app.mouvement m JOIN app.mouvement_ligne lp ON (((lp.mouvement_id = m.id) AND (lp.quantite_g < 0)))) JOIN app.lot p ON (((p.organisation_id = lp.organisation_id) AND (p.compte_matiere_id = lp.compte_matiere_id)))) JOIN app.mouvement_ligne lc ON (((lc.mouvement_id = m.id) AND (lc.quantite_g > 0)))) JOIN app.lot c ON (((c.organisation_id = lc.organisation_id) AND (c.compte_matiere_id = lc.compte_matiere_id)))) WHERE ((m.nature = 'transformation'::text) AND (p.id <> c.id) AND (NOT (EXISTS ( SELECT 1 FROM app.mouvement k WHERE ((k.organisation_id = m.organisation_id) AND (k.contrepasse_mouvement_id = m.id)))))))| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| organisation_id | uuid | true | Organisation propriétaire. | |||
| parent_lot_id | uuid | true | Lot dont la matière a été consommée par la transformation. | |||
| enfant_lot_id | uuid | true | Lot créé par la même transformation. |
Referenced Tables
Section intitulée « Referenced Tables »| Name | Columns | Comment | Type |
|---|---|---|---|
| app.mouvement | 10 | Mouvement de matière, en ajout seul. Se compose de lignes signées dont la somme est nulle. Toute correction passe par une contre-passation. | BASE TABLE |
| app.mouvement_ligne | 7 | Ligne d’un mouvement : quantité signée entrée dans un compte (positive) ou sortie (négative), en grammes. | BASE TABLE |
| app.lot | 18 | Lot : objet central de la traçabilité (cahier, entité Lot ; AM-03). Un lot a un compte de matière de nature lot et un mouvement de création obligatoire (I4). Sa quantité n’est pas stockée : elle se lit dans app.lot_solde. | BASE TABLE |
Relations
Section intitulée « Relations »erDiagram
"app.arete_filiation" {
uuid organisation_id "Organisation propriétaire."
uuid parent_lot_id "Lot dont la matière a été consommée par la transformation."
uuid enfant_lot_id "Lot créé par la même transformation."
}
Generated by tbls