app/models/appointment.rb
# After save, updates any related field inside the associated receipt row.
# (for instance, if all appointments are 'is_payed' => the associated receipt is assumed to be 'is_payed')
#
After save, updates any related field inside the associated receipt row.
(for instance, if all appointments are 'is_payed' => the associated receipt is assumed to be 'is_payed')
After save updates any related field inside the associated receipt row . ( for instance if all appointments are ' is_payed ' = > the associated receipt is assumed to be ' is_payed ' )
def update_associated_receipts()
    if self.is_payed? && self.is_receipt_issued?
      apps_found = Appointment.find( :all, :conditions => ['(receipt_id = ?) and (is_payed <> 1)', self.receipt_id] )
      if apps_found.size == 0                       
        Receipt.update( self.receipt_id, :is_payed => 1 )
      end
    end
  end
def update_associated_receipts ( ) if self . is_payed? && self . is_receipt_issued? apps_found = Appointment . find ( :all , :conditions => [ '(receipt_id = ?) and (is_payed <> 1)' , self . receipt_id ] ) if apps_found . size == 0 Receipt . update ( self . receipt_id , :is_payed => 1 ) end end end
After save, updates any related field inside the associated receipt row.
After save updates any related field inside the associated receipt row .
# If there aren't any other unpayed appointments, make sure the receipt is flagged as 'payed' too: