Merge branch 'story/105855968-directo' into staging

This commit is contained in:
Vladimir Krylov 2016-03-15 17:13:18 +02:00
commit c30adb7bce

View file

@ -71,9 +71,10 @@ class Directo < ActiveRecord::Base
max_directo = Setting.directo_monthly_number_max.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 last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i), min_directo].compact.max || 0
if max_directo && max_directo <= last_directo if max_directo && max_directo <= last_directo
raise "Directo counter is out of period" raise "Directo counter is out of period (max allowed number is smaller than last counter number)"
end end
directo_next = last_directo
Registrar.where.not(exclude_in_monthly_directo: true).find_each do |registrar| Registrar.where.not(exclude_in_monthly_directo: true).find_each do |registrar|
unless registrar.cash_account unless registrar.cash_account
Rails.logger.info("[DIRECTO] Monthly invoice for registrar #{registrar.id} has been skipped as it doesn't has cash_account") Rails.logger.info("[DIRECTO] Monthly invoice for registrar #{registrar.id} has been skipped as it doesn't has cash_account")
@ -118,7 +119,7 @@ class Directo < ActiveRecord::Base
# generating XML # generating XML
if items.any? if items.any?
directo_next = last_directo + 1 directo_next += 1
invoice_counter.next invoice_counter.next
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|