mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
try to fix edge cases of VatHistoryService, related to issue #156
This commit is contained in:
parent
1ed3eba129
commit
12b9155b43
@ -32,9 +32,10 @@ class VatHistoryService
|
||||
chronology.push(start: v.created_at, end: end_date, enabled: v.value == 'true')
|
||||
end_date = v.created_at
|
||||
end
|
||||
chronology.push(start: DateTime.new(0), end: end_date, enabled: false)
|
||||
date_rates = []
|
||||
Setting.find_by(name: 'invoice_VAT-rate').history_values.order(created_at: 'ASC').each do |rate|
|
||||
range = chronology.select { |p| rate.created_at.between?(p[:start], p[:end]) }.first
|
||||
range = chronology.select { |p| rate.created_at.to_i.between?(p[:start].to_i, p[:end].to_i) }.first
|
||||
date = range[:enabled] ? rate.created_at : range[:end]
|
||||
date_rates.push(date: date, rate: rate.value.to_i)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user