einvoicing 0.9.3 → 0.10.0

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: 96c1b67f435b7ca99b2716f4aba9c8dcf631302d37db1a6fa3743d993de55334
4
- data.tar.gz: 0c5713cbce3d1e842b64c3361957eb2764dadd89eefd5fb361816bfbd786aa3b
3
+ metadata.gz: d183c6b6825abf878fbc50cd7ccb3f719f534836a851a690b06d16aa37ba4d7f
4
+ data.tar.gz: '0693f5fecd3cccb08d9044aeb981b1df6c766c027dad562ff77978a705ce3e48'
5
5
  SHA512:
6
- metadata.gz: 9c4b6d6c1907118f2743887788ac55a6b3bade8268e7ddb8ed6a78afcb735bc7581f249166501428216af1ae0ce883a6fef338c1d6eb45f473089b7f02a07924
7
- data.tar.gz: 9c4e9728880210475896ce42280595b5eecf26514dffcbc58198d97f2f0e9dee749ab3dae3b38db7780f3ec79ae8604d93c738959f6cccfd4f7961cbfb300770
6
+ metadata.gz: 051e1202cb65ad9fca73b36d222d0475a2741c801dd94f9b73eedf8d663236baf804653409dfcf8aaf83b119fa1aad86c6daad5d6700630c05b0140da406859a
7
+ data.tar.gz: 2e6a4bcf48b4d48cfcb6454db8052fd3bf5b495fc066803e612e1ff6d30ca21908b11712f140dd910a242c3a43f8fee2bbac503ea4379826bddbf3090e7b4bd7
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.10.0] - 2026-11-22
11
+
12
+ ### Changed
13
+ - Ruby 3.3 or later is now required. Ruby 3.2 reached its end of life in March 2026, and the development toolchain (prism 2.1, pulled by RuboCop) no longer installs on it. Applications still on Ruby 3.2 keep working with 0.9.x
14
+
15
+ ## [0.9.4] - 2026-10-14
16
+
17
+ ### Fixed
18
+ - Unit prices kept only two decimals. The item net price (BT-146) went out through the same `%.2f` as every amount, so a line of 1 512 000 eggs at 0.0095 € said `0.01` in `ram:ChargeAmount` (CII) and `cbc:PriceAmount` (UBL) while its line total said 14 364.00 €: 756 € off, and the Peppol rule PEPPOL-EN16931-R120 rejects the UBL. EN 16931 holds amounts to two decimals but sets no such limit on prices: a price now keeps every decimal it carries and never shows fewer than two (`0.0095`, `14.00`, `14.50`). Every amount stays at two decimals
19
+ - Quantities (BT-129) went through `Float` and four decimals, so `8.915839` came out as `8.9158` while the line total used the real quantity. They are now written from the `BigDecimal` with every decimal (`5`, `2.5`, `8.915839`)
20
+
8
21
  ## [0.9.3] - 2026-08-31
9
22
 
10
23
  ### Fixed
data/README.md CHANGED
@@ -386,7 +386,7 @@ Common `payment_means_code` values (UNCL4461):
386
386
 
387
387
  ## Requirements
388
388
 
389
- - **Ruby >= 3.2** (uses `Data.define`)
389
+ - **Ruby >= 3.3** (uses `Data.define`)
390
390
  - **hexapdf ~> 1.0** (runtime, for Factur-X PDF/A-3 embedding)
391
391
  - **Java** (optional) — for local validation with the Mustang CLI validator
392
392
 
@@ -93,7 +93,7 @@ module Einvoicing
93
93
  end
94
94
  b.tag("ram:SpecifiedLineTradeAgreement") do
95
95
  b.tag("ram:NetPriceProductTradePrice") do
96
- b.text("ram:ChargeAmount", format_amount(line.unit_price))
96
+ b.text("ram:ChargeAmount", format_price(line.unit_price))
97
97
  end
98
98
  end
99
99
  b.tag("ram:SpecifiedLineTradeDelivery") do
@@ -299,9 +299,20 @@ module Einvoicing
299
299
  end
300
300
  private_class_method :format_amount
301
301
 
302
+ # Unit prices (BT-146) are not amounts: EN 16931 holds amounts to two
303
+ # decimals but sets no such limit on prices, and a sub-cent price written
304
+ # as 0.01 contradicts its own line total. Keep every decimal the price
305
+ # carries, never write fewer than two.
306
+ def self.format_price(value)
307
+ whole, fraction = BigDecimal(value.to_s).to_s("F").split(".")
308
+ "#{whole}.#{fraction.ljust(2, "0")}"
309
+ end
310
+ private_class_method :format_price
311
+
312
+ # Every decimal of the quantity (BT-129), like the price: the line total
313
+ # is computed from both, and must stay their product once serialized.
302
314
  def self.format_quantity(value)
303
- v = value.to_f
304
- v % 1 == 0 ? v.to_i.to_s : format("%.4f", v)
315
+ BigDecimal(value.to_s).to_s("F").delete_suffix(".0")
305
316
  end
306
317
  private_class_method :format_quantity
307
318
  end
@@ -229,7 +229,7 @@ module Einvoicing
229
229
  end
230
230
  end
231
231
  b.tag("cac:Price") do
232
- b.text("cbc:PriceAmount", format_amount(line.unit_price),
232
+ b.text("cbc:PriceAmount", format_price(line.unit_price),
233
233
  "currencyID" => currency)
234
234
  end
235
235
  end
@@ -276,9 +276,20 @@ module Einvoicing
276
276
  end
277
277
  private_class_method :format_amount
278
278
 
279
+ # Unit prices (BT-146) are not amounts: EN 16931 holds amounts to two
280
+ # decimals but sets no such limit on prices, and a sub-cent price written
281
+ # as 0.01 contradicts its own line total. Keep every decimal the price
282
+ # carries, never write fewer than two.
283
+ def self.format_price(value)
284
+ whole, fraction = BigDecimal(value.to_s).to_s("F").split(".")
285
+ "#{whole}.#{fraction.ljust(2, "0")}"
286
+ end
287
+ private_class_method :format_price
288
+
289
+ # Every decimal of the quantity (BT-129), like the price: the line total
290
+ # is computed from both, and must stay their product once serialized.
279
291
  def self.format_quantity(value)
280
- v = value.to_f
281
- v % 1 == 0 ? v.to_i.to_s : format("%.4f", v)
292
+ BigDecimal(value.to_s).to_s("F").delete_suffix(".0")
282
293
  end
283
294
  private_class_method :format_quantity
284
295
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Einvoicing
4
- VERSION = "0.9.3"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: einvoicing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Le Ray
@@ -250,14 +250,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - ">="
252
252
  - !ruby/object:Gem::Version
253
- version: '3.2'
253
+ version: '3.3'
254
254
  required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - ">="
257
257
  - !ruby/object:Gem::Version
258
258
  version: '0'
259
259
  requirements: []
260
- rubygems_version: 4.0.19
260
+ rubygems_version: 4.0.20
261
261
  specification_version: 4
262
262
  summary: EU electronic invoicing for Ruby — EN 16931, Factur-X, UBL 2.1
263
263
  test_files: []