Sha256: b5b660d2dd25344eeff3ef8879c61ce83c69e7ad3de0b23d8309054c1d2e04f6

Contents?: true

Size: 1022 Bytes

Versions: 23

Compression:

Stored size: 1022 Bytes

Contents

class Dorsale::ExpenseGun::ExpenseLine < ::Dorsale::ApplicationRecord
  self.table_name = "dorsale_expense_gun_expense_lines"

  belongs_to :expense,  class_name: "Dorsale::ExpenseGun::Expense"
  belongs_to :category, class_name: "Dorsale::ExpenseGun::Category"

  validates :expense,         presence: true
  validates :name,            presence: true
  validates :date,            presence: true
  validates :category,        presence: true
  validates :total_all_taxes, presence: true, numericality: {greater_than_or_equal_to: 0}
  validates :vat,             presence: true, numericality: {greater_than_or_equal_to: 0}
  validates :company_part,    presence: true
  validates :company_part, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}

  def assign_default_values
    assign_default :company_part, 100
  end

  def employee_payback
    (total_all_taxes * company_part / 100)
  end

  def total_vat_deductible
    category.vat_deductible == true ? (vat * company_part / 100) : 0.0
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
dorsale-4.0.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.20.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.19.1 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.19.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.18.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.17.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.16.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.15.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.11 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.10 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.9 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.8 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.7 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.6 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.5 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.4 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.3 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.2 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.1 app/models/dorsale/expense_gun/expense_line.rb
dorsale-3.14.0 app/models/dorsale/expense_gun/expense_line.rb