Sha256: dd129d7c3524ed57aa29f13986beed23831c255eb53d13fe1a9222230e154c6f
Contents?: true
Size: 693 Bytes
Versions: 7
Compression:
Stored size: 693 Bytes
Contents
class Dorsale::BillingMachine::InvoiceLine < ::Dorsale::ApplicationRecord self.table_name = "dorsale_billing_machine_invoice_lines" belongs_to :invoice, inverse_of: :lines validates :invoice, presence: true default_scope -> { order(position: :asc, created_at: :asc, id: :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 self.total = (quantity.to_f * unit_price.to_f).round(2) end after_save :update_invoice_total def update_invoice_total invoice.reload.save! end end
Version data entries
7 entries across 7 versions & 1 rubygems