Sha256: d8d3b098cc4703ad507ea133b317e0d2f73d51ae1aec0e263fa0fe0764284761

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

class DebitInvoice < Invoice
  # Accounts
  # ========
  def self.direct_account
    Account.find_by_code("1100")
  end

  def balance_account
    bookings.first.try(:credit_account)
  end

  def profit_account
    bookings.first.try(:debit_account)
  end

  # Callback hook
  def booking_saved(booking)
    if (self.state != 'canceled') and (self.state != 'reactivated') and (self.amount <= 0.0)
      update_attribute(:state, 'paid')
    elsif !self.overdue? and (self.amount > 0.0)
      update_attribute(:state, 'booked')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookyt-0.0.1 app/models/debit_invoice.rb