Sha256: 22f12abc636ecf311a7d1b4046ddbb7f79923f4406b59907dad844ebd31c1ab1

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

module Dorsale
  module ExpenseGun
    class ExpenseLine < ActiveRecord::Base
      self.table_name = "dorsale_expense_gun_expense_lines"
      belongs_to :expense, class_name: ::Dorsale::ExpenseGun::Expense
      belongs_to :category, class_name: ::Dorsale::ExpenseGun::Category

      def initialize(h = {})
        super({company_part: 100}.merge(h))
      end

      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: 1.0}
      validates :vat,             presence: true, numericality: {greater_than_or_equal_to: 0}
      validates :company_part,    presence: true, numericality: {greater_than_or_equal_to: 1.0, less_than_or_equal_to: 100.0}

      # simple_form
      validates :category_id, presence: true

      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
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dorsale-3.0.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.7.3 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.7.2 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.7.1 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.7.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.8 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.7 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.6 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.5 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.4 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.3 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.2 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.1 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.6.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.5.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.4.3 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.4.2 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.4.1 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.4.0 app/models/dorsale/expense_gun/expense_line.rb
dorsale-2.3.5 app/models/dorsale/expense_gun/expense_line.rb