mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
(bug) if a specialized VAT rate was defined when the VAT was disabled, the resulting VAT rate is wrong
This commit is contained in:
parent
4dd5bca55c
commit
d8568f47ad
@ -15,6 +15,7 @@
|
||||
- Fix a bug: do not load Stripe if no keys were defined
|
||||
- Fix a bug: some links redirect to the home page instead of triggering the requested action
|
||||
- Fix a bug: exports to Excel are corrupted (#49)
|
||||
- Fix a bug: if a specialized VAT rate was defined when the VAT was disabled, the resulting VAT rate is wrong
|
||||
- [TODO DEPLOY] `rails db:seed`
|
||||
|
||||
# v5.3.0 2021 December 29
|
||||
|
@ -88,11 +88,11 @@ class VatHistoryService
|
||||
end
|
||||
|
||||
# Now we have all the rates history, we can build the final chronology, depending on whether VAT was enabled or not
|
||||
vat_rate_history_values.each do |rate|
|
||||
vat_rate_history_values.reverse_each do |rate|
|
||||
# when the VAT rate was enabled, set the date it was enabled and the rate
|
||||
range = chronology.select { |p| rate.created_at.to_i.between?(p[:start].to_i, p[:end].to_i) }.first
|
||||
range = chronology.find { |p| rate.created_at.to_i.between?(p[:start].to_i, p[:end].to_i) }
|
||||
date = range[:enabled] ? rate.created_at : range[:end]
|
||||
date_rates.push(date: date, rate: rate.value.to_i)
|
||||
date_rates.push(date: date, rate: rate.value.to_i) unless date_rates.find { |d| d[:date] == date }
|
||||
end
|
||||
chronology.reverse_each do |period|
|
||||
# when the VAT rate was disabled, set the date it was disabled and rate=0
|
||||
|
Loading…
x
Reference in New Issue
Block a user