mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
story#116954455 - set parameter debug for Directo monthly invoices
This commit is contained in:
parent
53fae3d535
commit
375e649009
1 changed files with 10 additions and 5 deletions
|
@ -60,7 +60,8 @@ class Directo < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.send_monthly_invoices
|
def self.send_monthly_invoices(debug: false)
|
||||||
|
@debug = debug
|
||||||
I18n.locale = :et
|
I18n.locale = :et
|
||||||
month = Time.now - 1.month
|
month = Time.now - 1.month
|
||||||
invoices_until = month.end_of_month
|
invoices_until = month.end_of_month
|
||||||
|
@ -141,10 +142,14 @@ class Directo < ActiveRecord::Base
|
||||||
|
|
||||||
data = builder.to_xml.gsub("\n",'')
|
data = builder.to_xml.gsub("\n",'')
|
||||||
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s
|
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s
|
||||||
Setting.directo_monthly_number_last = directo_next
|
if @debug
|
||||||
Nokogiri::XML(response).css("Result").each do |res|
|
STDOUT << "#{Time.zone.now.utc} - Directo xml had to be sent #{data}\n"
|
||||||
Directo.create!(response: res.as_json.to_h, invoice_number: directo_next)
|
else
|
||||||
Rails.logger.info("[DIRECTO] Invoice #{res.attributes["docid"].value} was pushed and return is #{res.as_json.to_h.inspect}")
|
Setting.directo_monthly_number_last = directo_next
|
||||||
|
Nokogiri::XML(response).css("Result").each do |res|
|
||||||
|
Directo.create!(response: res.as_json.to_h, invoice_number: directo_next)
|
||||||
|
Rails.logger.info("[DIRECTO] Invoice #{res.attributes["docid"].value} was pushed and return is #{res.as_json.to_h.inspect}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Rails.logger.info("[DIRECTO] Registrar #{registrar.id} has nothing to be sent to Directo")
|
Rails.logger.info("[DIRECTO] Registrar #{registrar.id} has nothing to be sent to Directo")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue