Commit e56acb2
authored
fix(e-invoices): Handle zero-fee invoices in allowance calculation (#5287)
## Context
Invoices with zero-amount fees (e.g. yearly plans with only fixed
charges terminated mid-period) cause `Invoices::GenerateDocumentsJob` to
fail with `ArgumentError: must be initialized with a finite value` when
the billing entity has e-invoicing enabled.
Scenario to reproduce:
Preconditions:
- Organization billing entity with E-Invoicing enabled
- Plan with Subscription Fee amount = 0
Steps:
1. Add a subscription with the Plan to a customer
2. Terminate subscription
Actual result in Sidekiq: Invoices::GenerateDocumentsJob, ArgumentError:
must be initialized with a finite value
## Description
Root cause: If all fees are zero, `fdiv(0)` produced `Infinity` which
`Money.new` rejects.
Fix: Added a guard before the division when fees are zero.1 parent b747f59 commit e56acb2
3 files changed
Lines changed: 36 additions & 1 deletion
File tree
- app/serializers/e_invoices/invoices
- spec/serializers/e_invoices/invoices
- factur_x
- ubl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
318 | 334 | | |
319 | 335 | | |
320 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
224 | 240 | | |
225 | 241 | | |
226 | 242 | | |
| |||
0 commit comments