Sha256: fa4487ec9a99f34f97986232e370629af7755ee50b211350fbeebba9aa76bfb2

Contents?: true

Size: 706 Bytes

Versions: 18

Compression:

Stored size: 706 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 = self.quantity * self.unit_price
  end

  after_save :update_quotation_total

  def update_quotation_total
    self.quotation.reload.save!
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dorsale-3.8.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.8.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.8 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.7 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.6 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.5 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.4 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.2 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.7.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.6.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.6.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.5.2 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.5.1 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.5.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.4.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.3.0 app/models/dorsale/billing_machine/quotation_line.rb
dorsale-3.2.0 app/models/dorsale/billing_machine/quotation_line.rb