mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
16 lines
No EOL
452 B
Ruby
16 lines
No EOL
452 B
Ruby
namespace :data_migrations do
|
|
task populate_invoice_vat_rate: :environment do
|
|
processed_invoice_count = 0
|
|
|
|
Invoice.transaction do
|
|
Invoice.where(vat_rate: nil).find_each do |invoice|
|
|
vat_rate = Invoice::VatRateCalculator.new(registrar: invoice.buyer).calculate
|
|
invoice.update!(vat_rate: vat_rate)
|
|
|
|
processed_invoice_count += 1
|
|
end
|
|
end
|
|
|
|
puts "Invoices processed: #{processed_invoice_count}"
|
|
end
|
|
end |