Sha256: cb35c00e1d75eda42ba0c4561abc51d70dde518ee7e2df0b6e51d323ad2b14a6

Contents?: true

Size: 1.17 KB

Versions: 106

Compression:

Stored size: 1.17 KB

Contents

class AddTaxesRateToQuotationAndInvoiceLines < ActiveRecord::Migration
  def change

    rename_column :dorsale_billing_machine_invoices, :total_duty, :total_excluding_taxes
    rename_column :dorsale_billing_machine_invoices, :total_all_taxes, :total_including_taxes
    rename_column :dorsale_billing_machine_quotations, :total_duty, :total_excluding_taxes
    rename_column :dorsale_billing_machine_quotations, :total_all_taxes, :total_including_taxes
    add_column :dorsale_billing_machine_quotation_lines, :vat_rate, :decimal
    add_column :dorsale_billing_machine_invoice_lines, :vat_rate, :decimal

    Dorsale::BillingMachine::Invoice.all.each do |invoice|
      invoice.date     = invoice.created_at if invoice.date.nil?
      invoice.vat_rate = invoice.read_attribute(:vat_rate) || 0.0
      invoice.save!
    end

    Dorsale::BillingMachine::Quotation.all.each do |quotation|
      quotation.date     = quotation.created_at if quotation.date.nil?
      quotation.vat_rate = quotation.read_attribute(:vat_rate) || 0.0
      quotation.save!
    end

    remove_column :dorsale_billing_machine_quotations, :vat_rate
    remove_column :dorsale_billing_machine_invoices, :vat_rate
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
dorsale-4.0.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.20.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.19.1 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.19.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.18.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.17.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.16.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.15.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.11 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.10 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.9 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.8 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.7 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.6 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.5 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.4 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.3 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.2 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.1 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb
dorsale-3.14.0 db/migrate/20151116143024_add_taxes_rate_to_quotation_and_invoice_lines.rb