Skip to content

Commit

Permalink
Scoped down accounts in carrying_forward to only include those that h…
Browse files Browse the repository at this point in the history
…ad items to work on, greatly improving performance, especially on quasi-empty FinancialYears.
  • Loading branch information
Aquaj committed Jun 7, 2017
1 parent d4462c8 commit 5cc218a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/financial_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ def generate_carrying_forward_entry!(opening_journal, closure_journal, to_close_
unlettered_items = []

accounts = Account.where('accounts.number ~ ?', "^(#{account_radices.join('|')})")
.joins(:journal_entry_items)
.where('journal_entry_items.printed_on BETWEEN ? AND ?', started_on, to_close_on)
.where('journal_entry_items.financial_year_id = ?', id)

letterable_accounts = accounts.joins(:journal_entry_items)
.where('journal_entry_items.letter IS NOT NULL OR reconcilable')
Expand Down

0 comments on commit 5cc218a

Please sign in to comment.