app/models/booking.rb~ in has_accounts-0.5.0 vs app/models/booking.rb~ in has_accounts-0.6.0

- old
+ new

@@ -62,11 +62,11 @@ begin date = Date.parse(value) rescue ArgumentError end - where("title LIKE :text OR remarks = :text OR amount = :amount OR value_date = :value_date", :text => text, :amount => amount, :value_date => date) + where("title LIKE :text OR comments = :text OR amount = :amount OR value_date = :value_date", :text => text, :amount => amount, :value_date => date) } # Returns array of all years we have bookings for def self.fiscal_years with_exclusive_scope do @@ -151,9 +151,26 @@ def booking_template_id nil end def booking_template_id=(value) + end + + # Helpers + def split(amount, params = {}) + # Clone + new_booking = self.clone + + # Set amount + new_booking[:amount] = amount + self.amount -= amount + + # Update attributes + params.each{|key, value| + new_booking[key] = value + } + + new_booking end # Reference belongs_to :reference, :polymorphic => true after_save :notify_references