Sha256: 11f8c7b0179b65ba2a1e657afa9520ea42124e97dbc1c0116bb318b018842e85

Contents?: true

Size: 534 Bytes

Versions: 17

Compression:

Stored size: 534 Bytes

Contents

module Dorsale
  module BillingMachine
    class InvoiceLine < ActiveRecord::Base
      self.table_name = "dorsale_billing_machine_invoice_lines"

      belongs_to :invoice, inverse_of: :lines

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

      before_save :update_total

      def update_total
        self.quantity   ||= 0
        self.unit_price ||= 0
        self.total = self.quantity * self.unit_price
      end

      # ???
      after_save do
        self.invoice.reload.save
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dorsale-2.1.15 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.14 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.13 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.12 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.11 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.10 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.9 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.8 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.7 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.6 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.5 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.4 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.3 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.2 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.1 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.1.0 app/models/dorsale/billing_machine/invoice_line.rb
dorsale-2.0.1 app/models/dorsale/billing_machine/invoice_line.rb