mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28:27 +02:00
Merge pull request #1524 from internetee/277-check-monthly-invoice-number-in-range
Check if Directo counter is in range
This commit is contained in:
commit
f41289cfa8
2 changed files with 17 additions and 3 deletions
|
@ -67,7 +67,7 @@ class Directo < ApplicationRecord
|
|||
|
||||
|
||||
def self.send_monthly_invoices(debug: false)
|
||||
I18n.locale = :et
|
||||
I18n.locale = :et unless Rails.env.test?
|
||||
month = Time.now - 1.month
|
||||
invoices_until = month.end_of_month
|
||||
date_format = "%Y-%m-%d"
|
||||
|
@ -76,8 +76,9 @@ class Directo < ApplicationRecord
|
|||
min_directo = Setting.directo_monthly_number_min.presence.try(:to_i)
|
||||
max_directo = Setting.directo_monthly_number_max.presence.try(:to_i)
|
||||
last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i), min_directo].compact.max || 0
|
||||
if max_directo && max_directo <= last_directo
|
||||
raise "Directo counter is out of period (max allowed number is smaller than last counter number)"
|
||||
if max_directo && (max_directo <= last_directo + Registrar.count)
|
||||
raise 'Directo counter is out of period (max allowed number is smaller than last counter'\
|
||||
'number plus Registrar\'s count)'
|
||||
end
|
||||
|
||||
directo_next = last_directo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue