Change invoices.vat_rate to NOT NULL

#1031
This commit is contained in:
Artur Beljajev 2019-05-16 19:15:57 +03:00
parent 942ac47b00
commit a0aac379b6
4 changed files with 8 additions and 57 deletions

View file

@ -1,16 +0,0 @@
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