mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
parent
d85e57d800
commit
7723a30d1b
17 changed files with 240 additions and 200 deletions
16
lib/tasks/data_migrations/populate_invoice_vat_rate.rake
Normal file
16
lib/tasks/data_migrations/populate_invoice_vat_rate.rake
Normal file
|
@ -0,0 +1,16 @@
|
|||
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_columns(vat_rate: vat_rate)
|
||||
|
||||
processed_invoice_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "Invoices processed: #{processed_invoice_count}"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue