Class: Cpro::Cdv::Statut
- Inherits:
-
Object
- Object
- Cpro::Cdv::Statut
- Defined in:
- lib/cpro/cdv/statut.rb
Overview
Catalogue des statuts qu'un émetteur peut poser sur sa propre facture en G2B, d'après l'annexe « Correspondance codes interfaces / CDV / statuts » de Chorus Pro (feuillet G2B). Tous relèvent de la phase Traitement, d'où MDT-77 = 23.
Constant Summary collapse
- PHASE_TRAITEMENT =
"23"- CATALOGUE =
untdid : code UNTDID 1373 attendu en MDT-88 (BR-FR-CDV-CL-05). motif : MDT-113 obligatoire (BR-FR-CDV-15). montant : bloc MDG-43 requis avec MDT-207 = MEN (BR-FR-CDV-14).
{ approuvee: { code: "205", untdid: "1", obligatoire: false }, completee: { code: "209", untdid: "37", obligatoire: false }, refusee: { code: "210", untdid: "50", obligatoire: true, motif: true }, encaissee: { code: "212", untdid: "47", obligatoire: true, montant: true }, visee: { code: "214", untdid: "5", obligatoire: false }, annulee: { code: "220", untdid: "5", obligatoire: false }, changement_de_compte_a_payer: { code: "227", untdid: "5", obligatoire: false } }.freeze
- MOTIFS =
Listes fermées des motifs admis par statut, relevées du Schematron BR-FR-CDV (BR-FR-CDV-CL-09). Le PPF rejette tout autre code.
{ "210" => %w[TX_TVA_ERR MONTANTTOTAL_ERR CALCUL_ERR NON_CONFORME DOUBLON DEST_ERR TRANSAC_INC EMMET_INC CONTRAT_TERM DOUBLE_FACT CMD_ERR ADR_ERR REF_CT_ABSENT].freeze }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#nom ⇒ Object
readonly
Returns the value of attribute nom.
-
#untdid ⇒ Object
readonly
Returns the value of attribute untdid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(nom, definition) ⇒ Statut
constructor
A new instance of Statut.
- #montant_requis? ⇒ Boolean
- #motif_admis?(motif) ⇒ Boolean
- #motif_requis? ⇒ Boolean
-
#motifs_admis ⇒ Object
Nil lorsque la norme ne restreint pas les motifs pour ce statut.
-
#obligatoire? ⇒ Boolean
Statut dont l'émission est obligatoire au titre de la réforme.
- #phase ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nom, definition) ⇒ Statut
Returns a new instance of Statut.
41 42 43 44 45 46 |
# File 'lib/cpro/cdv/statut.rb', line 41 def initialize(nom, definition) @nom = nom @code = definition.fetch(:code) @untdid = definition.fetch(:untdid) @definition = definition end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
31 32 33 |
# File 'lib/cpro/cdv/statut.rb', line 31 def code @code end |
#nom ⇒ Object (readonly)
Returns the value of attribute nom.
31 32 33 |
# File 'lib/cpro/cdv/statut.rb', line 31 def nom @nom end |
#untdid ⇒ Object (readonly)
Returns the value of attribute untdid.
31 32 33 |
# File 'lib/cpro/cdv/statut.rb', line 31 def untdid @untdid end |
Class Method Details
.[](nom) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/cpro/cdv/statut.rb', line 33 def self.[](nom) definition = CATALOGUE[nom.to_s.downcase.to_sym] return new(nom.to_s.downcase.to_sym, definition) if definition raise ArgumentError, "statut inconnu : #{nom.inspect} (attendus : #{CATALOGUE.keys.join(", ")})" end |
Instance Method Details
#montant_requis? ⇒ Boolean
62 63 64 |
# File 'lib/cpro/cdv/statut.rb', line 62 def montant_requis? @definition.fetch(:montant, false) end |
#motif_admis?(motif) ⇒ Boolean
53 54 55 56 |
# File 'lib/cpro/cdv/statut.rb', line 53 def motif_admis?(motif) admis = motifs_admis admis.nil? || admis.include?(motif.to_s) end |
#motif_requis? ⇒ Boolean
58 59 60 |
# File 'lib/cpro/cdv/statut.rb', line 58 def motif_requis? @definition.fetch(:motif, false) end |
#motifs_admis ⇒ Object
Nil lorsque la norme ne restreint pas les motifs pour ce statut.
49 50 51 |
# File 'lib/cpro/cdv/statut.rb', line 49 def motifs_admis MOTIFS[code] end |
#obligatoire? ⇒ Boolean
Statut dont l'émission est obligatoire au titre de la réforme.
67 68 69 |
# File 'lib/cpro/cdv/statut.rb', line 67 def obligatoire? @definition.fetch(:obligatoire) end |
#phase ⇒ Object
71 72 73 |
# File 'lib/cpro/cdv/statut.rb', line 71 def phase PHASE_TRAITEMENT end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/cpro/cdv/statut.rb', line 75 def to_s nom.to_s end |