app/models/recurring_invoice.rb
def next_occurrences
    result = []

    occurrences = Invoice.belonging_to(id).count
    next_date = next_invoice_date
    max_date = [Date.current, finishing_date.blank? ? Date.current + 1 : finishing_date].min

    while next_date <= max_date and (max_occurrences.nil? or occurrences < max_occurrences) do
      result.append(next_date)
      occurrences += 1
      next_date += period.send period_type
    end

    result
  end
# Returns the list of issue dates for all pending invoices
Returns the list of issue dates for all pending invoices
Returns the list of issue dates for all pending invoices
def next_occurrences
    result = []
    occurrences = Invoice.belonging_to(id).count
    next_date = next_invoice_date
    max_date = [Date.current, finishing_date.blank? ? Date.current + 1 : finishing_date].min
    while next_date <= max_date and (max_occurrences.nil? or occurrences < max_occurrences) do
      result.append(next_date)
      occurrences += 1
      next_date += period.send period_type
    end
    result
  end
def next_occurrences result = [ ] occurrences = Invoice . belonging_to ( id ) . count next_date = next_invoice_date max_date = [ Date . current , finishing_date . blank? ? Date . current + 1 : finishing_date ] . min while next_date <= max_date and ( max_occurrences . nil? or occurrences < max_occurrences ) do result . append ( next_date ) occurrences += 1 next_date += period . send period_type end result end
Returns the list of issue dates for all pending invoices
Returns the list of issue dates for all pending invoices