app/models/invoice.rb
# Public: Check the payments and update the paid and
# paid_amount fields
#
Check the payments and update the paid and
paid_amount fields
Check the payments and update the paid and paid_amount fields
def check_paid
    self.paid_amount = 0
    self.paid = false
    payments.each do |payment|
      self.paid_amount += payment.amount if payment.complete?
    end
    if self.paid_amount - self.gross_amount >= 0
      self.paid = true
    end
  end
def check_paid self . paid_amount = 0 self . paid = false payments . each do | payment | self . paid_amount += payment . amount if payment . complete? end if self . paid_amount - self . gross_amount >= 0 self . paid = true end end
Public: Check the payments and update the paid and
paid_amount fields
Public : Check the payments and update the paid and paid_amount fields