Class: Einvoicing::PPF::InvoiceAdapter
- Inherits:
-
Object
- Object
- Einvoicing::PPF::InvoiceAdapter
- Defined in:
- lib/einvoicing/ppf/invoice_adapter.rb
Class Method Summary collapse
-
.to_chorus_payload(invoice, id_structure_cpp:, code_service: nil, engagement_number: nil) ⇒ Object
Converts an Einvoicing::Invoice to a Chorus Pro SoumettreFacture payload.
Class Method Details
.to_chorus_payload(invoice, id_structure_cpp:, code_service: nil, engagement_number: nil) ⇒ Object
Converts an Einvoicing::Invoice to a Chorus Pro SoumettreFacture payload.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/einvoicing/ppf/invoice_adapter.rb', line 12 def self.to_chorus_payload(invoice, id_structure_cpp:, code_service: nil, engagement_number: nil) { idStructureCPP: id_structure_cpp, codeService: code_service, numeroEngagement: engagement_number, cadreFacturation: { codeCadreFacturation: "FACTURE_FOURNISSEUR", codeServiceValideur: nil }, identifiantFactureFournisseur: invoice.invoice_number, dateFacture: invoice.issue_date.strftime("%Y-%m-%dT00:00:00.000+01:00"), dateEcheancePaiement: invoice.due_date&.strftime("%Y-%m-%dT00:00:00.000+01:00"), montantHT: invoice.net_total.to_f, montantTVA: invoice.tax_total.to_f, montantTTC: invoice.gross_total.to_f, devise: invoice.currency || "EUR", siretFournisseur: invoice.seller.siret, siretDestinataire: invoice.buyer.siret, typeFacture: "FACTURE", lignesPoste: invoice.lines.map.with_index(1) { |line, i| line_to_chorus(line, i) }, modePaiement: chorus_payment_mode(invoice) }.compact end |