unova_factur_x 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d09c11c8d2bfdc9f2d14de6eb7bbd7aee94f46675b929681cb683487fb0a2bb
4
- data.tar.gz: de833a261679131412fce8ec11d9925e099107fbd4462c1d2908b3917a467f13
3
+ metadata.gz: afe65450ac95318d3801d4b6c32354ed59cf54f3cf29ada07341338757298196
4
+ data.tar.gz: fa80807526a468b386c79d58a1a2e56b591ab12b1bd6d9cc65afccf5c23d9b92
5
5
  SHA512:
6
- metadata.gz: 44189769adcebd89694313a24d2e6a9bd3a109e99a2c4ac53891a4a2a5c2e55b03427e61434d9c94a182f69f3ac03a1317e0c22d504f2dd302925aa53865524e
7
- data.tar.gz: 2b0b0163eee7106f2b1fc00b85eb4328ccc50b87ea4476a7e451b51cdcc2dfe9f952eaca7d8df773ca4d837e064c1406ada894148b9f2369ca0ec0a5185318e2
6
+ metadata.gz: 3640dca1a01ecd8125e706eae96610791150ff4cfdd98051d3c03eb5d5cfb65ccc42002e2009d1bb843a194b75b34a7982cea004ce3d63c814004153df6598fb
7
+ data.tar.gz: 7be6c186c292247e77240a17bac801059eaf292cc62bfb4fb4c2c4686521cd0d8cb79f4689b1e3bd23acc0ec69671a8bb9f24ec5462de36c6376b07da42e0a31
data/README.md CHANGED
@@ -60,7 +60,15 @@ For the expected document hash:
60
60
  document_hash = {
61
61
  id: "Unique invoice number (BT-1) [REQUIRED]",
62
62
  issue_date: "Issue date in YYYYMMDD format (BT-2) [REQUIRED]",
63
-
63
+ context: "BT-23 [REQUIRED] Value in (B1: Unpaid products, S1: Unpaid services, M1: Unpaid products and services, B2: Paid products, S2: Paid services, M2: Paid products and services)",
64
+
65
+ # [REQUIRED BLOCK IF BR_FR PROFILE AND IF THE DOCUMENT IS A CREDIT]
66
+ referenced_invoice: {
67
+ reference: "Referenced invoice identifier (BT-25) [REQUIRED if block is present]",
68
+ date: "Referenced invoice issue date in YYYYMMDD format (BT-26) [REQUIRED if block is present]",
69
+ },
70
+
71
+ # [REQUIRED BLOCK]
64
72
  seller: {
65
73
  name: "Seller legal name (BT-27) [REQUIRED]",
66
74
  legal_id: { # [REQUIRED IF BR_FR PROFILE, OTHERWISE OPTIONAL]
@@ -68,10 +76,10 @@ document_hash = {
68
76
  scheme: "Legal registration identifier scheme (ICD), e.g. 0002 for SIREN, 0009 for SIRET (BT-30-1) [REQUIRED IF IDENTIFIER IS PROVIDED]"
69
77
  },
70
78
  electronic_address: { # [REQUIRED IF BR_FR PROFILE, OTHERWISE OPTIONAL]
71
- identifier: "Seller electronic address (e.g. email address or Peppol endpoint) (BT-34) [REQUIRED IF BR_FR PROFILE, OTHERWISE OPTIONAL]",
72
- scheme: "Electronic address scheme identifier (EAS code, e.g. EM for email, 0088 for GLN) [REQUIRED IF IDENTIFIER IS PROVIDED]"
79
+ identifier: "Seller electronic address (e.g. email address or Peppol endpoint) (BT-34) [REQUIRED AS PEPPOL ENDPOINT IF BR_FR PROFILE, OTHERWISE OPTIONAL]",
80
+ scheme: "Electronic address scheme identifier (EAS code, e.g. EM for email, 0225 for Peppol ID) [REQUIRED IF IDENTIFIER IS PROVIDED]"
73
81
  },
74
- vat_number: "VAT number including buyer country prefix (e.g. FR123...) (BT-31) [OPTIONAL]",
82
+ vat_number: "VAT number including seller country prefix (e.g. FR123...) (BT-31) [OPTIONAL]",
75
83
  address: {
76
84
  line1: "Street address (BT-35) [REQUIRED]",
77
85
  line2: "Address complement [OPTIONAL]",
@@ -94,8 +102,8 @@ document_hash = {
94
102
  name: "Customer contact name (BT-56) [OPTIONAL]",
95
103
  },
96
104
  electronic_address: { # [REQUIRED IF BR_FR PROFILE, OTHERWISE OPTIONAL]
97
- identifier: "Buyer electronic address (e.g. email address or Peppol endpoint) (BT-49) [REQUIRED IF BR_FR PROFILE, OTHERWISE OPTIONAL]",
98
- scheme: "Electronic address scheme identifier (EAS code, e.g. EM for email, 0088 for GLN) (BT-49-1) [REQUIRED IF IDENTIFIER IS PROVIDED]"
105
+ identifier: "Buyer electronic address (e.g. email address or Peppol endpoint) (BT-49) [REQUIRED AS PEPPOL ENDPOINT IF BR_FR PROFILE, OTHERWISE OPTIONAL]",
106
+ scheme: "Electronic address scheme identifier (EAS code, e.g. EM for email, 0225 for Peppol ID) (BT-49-1) [REQUIRED IF IDENTIFIER IS PROVIDED]"
99
107
  },
100
108
  address: {
101
109
  line1: "Street address (BT-50) [REQUIRED]",
@@ -181,9 +189,10 @@ document_hash = {
181
189
  tax_basis_total_ht: "Total taxable amount (BT-109) [REQUIRED]",
182
190
  tax_total: "Total VAT amount (BT-110) [REQUIRED]",
183
191
  grand_total_ttc: "Grand total including VAT (BT-112) [REQUIRED]",
184
- amount_due: "Amount due for payment (BT-115) [OPTIONAL]",
192
+ prepaid_amount: "Amount already paid (BT-113) [REQUIRED IF BR_FR PROFILE AND context is B2, S2 or M2]",
193
+ amount_due: "Amount due for payment (BT-115) [OPTIONAL, REQUIRED AND MUST BE 0 IF BR_FR PROFILE AND context is B2, S2 or M2]",
185
194
  # due_date OR description [REQUIRED] if amount_due is defined and positive
186
- due_date: "Payment due date in YYYYMMDD format (BT-9)",
195
+ due_date: "Payment due date in YYYYMMDD format (BT-9) [REQUIRED IF BR_FR PROFILE AND context is B2, S2 or M2]",
187
196
  description: "Payment terms (BT-20)"
188
197
  },
189
198
 
@@ -192,7 +201,7 @@ document_hash = {
192
201
  notes: [
193
202
  {
194
203
  content: "Free-text note content (BT-22) [REQUIRED if block is present]",
195
- subject_code: "Note subject code (BT-21), e.g. AAB (early payment discount), PMD (late payment penalties), PMT (fixed recovery compensation) [OPTIONAL, REQUIRED IF BR_FR PROFILE FOR SOME NOTES SUCH AS AAB, PMD AND PMT]"
204
+ subject_code: "Note subject code (BT-21), e.g. AAB (early payment discount), PMD (late payment penalties), PMT (fixed recovery compensation) [OPTIONAL, REQUIRED IF BR_FR PROFILE WITH THE NOTES AAB, PMD AND PMT]"
196
205
  },
197
206
  ]
198
207
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UnovaFacturX
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
@@ -45,7 +45,7 @@ module UnovaFacturX
45
45
  def build_exchanged_document_context(xml)
46
46
  xml['rsm'].ExchangedDocumentContext do
47
47
  xml['ram'].BusinessProcessSpecifiedDocumentContextParameter do
48
- xml['ram'].ID(@type == :credit ? "B2" : "B1") # Business process type identifier, value in (B1, S1, M1, B2, S2, M2, B4, S4, M4, S5, S6, B7, S7) (BT-23)
48
+ xml['ram'].ID(@document[:context]) # Business process type identifier, value in (B1, S1, M1, B2, S2, M2, B4, S4, M4, S5, S6, B7, S7) (BT-23)
49
49
  end
50
50
  xml['ram'].GuidelineSpecifiedDocumentContextParameter do
51
51
  xml['ram'].ID("urn:cen.eu:en16931:2017") # Identifier of the invoice specification (European EN16931 standard)
@@ -240,6 +240,18 @@ module UnovaFacturX
240
240
  end
241
241
  end
242
242
 
243
+ def build_referenced_invoice(xml)
244
+ referenced_invoice = @document[:referenced_invoice]
245
+ return if referenced_invoice.blank?
246
+
247
+ xml['ram'].InvoiceReferencedDocument do
248
+ xml['ram'].IssuerAssignedID(referenced_invoice[:reference]) # Referenced invoice identifier (BT-25)
249
+ xml['ram'].FormattedIssueDateTime do
250
+ xml['qdt'].DateTimeString(referenced_invoice[:date], format: "102") # Referenced invoice issue date (BT-26)
251
+ end
252
+ end
253
+ end
254
+
243
255
  def build_applicable_header_trade_settlement(xml)
244
256
  xml['ram'].ApplicableHeaderTradeSettlement do
245
257
  payment = @document[:payment_means]
@@ -303,8 +315,11 @@ module UnovaFacturX
303
315
  xml['ram'].TaxBasisTotalAmount(totals[:tax_basis_total_ht]) # Total taxable base amount (BT-109)
304
316
  xml['ram'].TaxTotalAmount(totals[:tax_total], currencyID: @currency) # Total VAT amount (BT-110)
305
317
  xml['ram'].GrandTotalAmount(totals[:grand_total_ttc]) # Total amount including VAT (BT-112)
318
+ xml['ram'].TotalPrepaidAmount(totals[:prepaid_amount]) if totals[:prepaid_amount].present? # Amount already paid (BT-113)
306
319
  xml['ram'].DuePayableAmount(totals[:amount_due]) if totals[:amount_due].present? # Amount remaining to be paid (BT-115)
307
320
  end
321
+
322
+ build_referenced_invoice(xml)
308
323
  end
309
324
  end
310
325
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unova_factur_x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodolphe Limousin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-07-08 00:00:00.000000000 Z
11
+ date: 2026-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hexapdf