Sha256: 97aa1a7789579fd43b2f2c97fd69d583a870a5cdd696d46119bdb2f6f4ddfc28

Contents?: true

Size: 700 Bytes

Versions: 10

Compression:

Stored size: 700 Bytes

Contents

class Dorsale::BillingMachine::QuotationLine < ::Dorsale::ApplicationRecord
  self.table_name = "dorsale_billing_machine_quotation_lines"

  belongs_to :quotation, inverse_of: :lines

  validates :quotation, presence: true

  default_scope -> {
    order(:created_at => :asc)
  }

  before_validation :update_total

  def assign_default_values
    assign_default :quantity,   0
    assign_default :unit_price, 0
    assign_default :vat_rate,   ::Dorsale::BillingMachine.default_vat_rate
  end

  def update_total
    assign_default_values
    self.total = (quantity * unit_price).round(2)
  end

  after_save :update_quotation_total

  def update_quotation_total
    quotation.reload.save!
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dorsale-3.14.2 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.14.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.14.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.13.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.12.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.11.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.10.3 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.10.2 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.10.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.10.0 app/models/dorsale/billing_machine/quotation_line.rb