mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Story#112043941 - show in cron STDOUT log that Directo task has been finished
This commit is contained in:
parent
e963484277
commit
55ffd229f9
1 changed files with 4 additions and 0 deletions
|
@ -3,6 +3,7 @@ class Directo < ActiveRecord::Base
|
||||||
|
|
||||||
def self.send_receipts
|
def self.send_receipts
|
||||||
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where(cancelled_at: nil)
|
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where(cancelled_at: nil)
|
||||||
|
counter = 0
|
||||||
Rails.logger.info("[DIRECTO] Will try to send #{new_trans.count} invoices")
|
Rails.logger.info("[DIRECTO] Will try to send #{new_trans.count} invoices")
|
||||||
|
|
||||||
new_trans.find_in_batches(batch_size: 10).each do |group|
|
new_trans.find_in_batches(batch_size: 10).each do |group|
|
||||||
|
@ -16,6 +17,7 @@ class Directo < ActiveRecord::Base
|
||||||
Rails.logger.info("[DIRECTO] Invoice #{invoice.number} has been skipped")
|
Rails.logger.info("[DIRECTO] Invoice #{invoice.number} has been skipped")
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
counter += 1
|
||||||
|
|
||||||
num = invoice.number
|
num = invoice.number
|
||||||
mappers[num] = invoice
|
mappers[num] = invoice
|
||||||
|
@ -42,6 +44,8 @@ class Directo < ActiveRecord::Base
|
||||||
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
|
||||||
dump_result_to_db(mappers, response)
|
dump_result_to_db(mappers, response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
STDOUT << "Directo receipts sending finished. #{counter} of #{new_trans.count} are sent"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.dump_result_to_db mappers, xml
|
def self.dump_result_to_db mappers, xml
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue