diff --git a/bank_statement_reconciliation_summary/report/summary_report.py b/bank_statement_reconciliation_summary/report/summary_report.py index 4efa0490..2fe18834 100644 --- a/bank_statement_reconciliation_summary/report/summary_report.py +++ b/bank_statement_reconciliation_summary/report/summary_report.py @@ -10,46 +10,57 @@ class SummaryReport(models.AbstractModel): _name = 'report.bank_statement_reconciliation_summary.summary_report' @api.model - def _plus_outstanding_payments(self, journals, end_date): + def _plus_outstanding_payments(self, journals, start_date, end_date): rec = {} for journal in journals: account_id = journal.default_debit_account_id.id - account_move_line_records = self.env['account.move.line'].search([ + domain_search = [ ('account_id', '=', account_id), ('reconciled', '=', False), ('account_id.reconcile', '=', False), ('credit', '>', 0.00), ('date', '<=', end_date), - ], order='date') + ] + if start_date: + domain_search += [('date', '>=', start_date)] + account_move_line_records = self.env['account.move.line'].search( + domain_search, order='date') rec[journal.id] = account_move_line_records return rec @api.model - def _less_outstanding_receipts(self, journals, end_date): + def _less_outstanding_receipts(self, journals, start_date, end_date): rec = {} for journal in journals: account_id = journal.default_debit_account_id.id - account_move_line_records = self.env['account.move.line'].search([ + domain_search = [ ('account_id', '=', account_id), ('reconciled', '=', False), ('account_id.reconcile', '=', False), ('debit', '>', 0.00), ('date', '<=', end_date), - ], order='date') + ] + if start_date: + domain_search += [('date', '>=', start_date)] + account_move_line_records = self.env['account.move.line'].search( + domain_search, order='date') rec[journal.id] = account_move_line_records return rec @api.model - def _plus_unreconciled_statement_lines(self, journals, end_date): + def _plus_unreconciled_statement_lines(self, journals, start_date, + end_date): rec = {} for journal in journals: + domain_search = [ + ('date', '<=', end_date), + ('journal_id', '=', journal.id), + ('journal_entry_ids', '=', False)] + if start_date: + domain_search += [('date', '>=', start_date)] statement_lines = self.env['account.bank.statement.line'].search( - [('date', '<=', end_date), - ('journal_id', '=', journal.id)]) - for line in statement_lines: - if not line.journal_entry_ids: - statement_lines += line - rec[journal.id] = statement_lines or False + domain_search) + rec[journal.id] = statement_lines return rec @api.model @@ -84,11 +95,14 @@ class SummaryReport(models.AbstractModel): 'docs': records, 'time': time, 'plus_outstanding_payments': - self._plus_outstanding_payments(records, data['end_date']), + self._plus_outstanding_payments(records, data['start_date'], + data['end_date']), 'less_outstanding_receipts': - self._less_outstanding_receipts(records, data['end_date']), + self._less_outstanding_receipts(records, data['start_date'], + data['end_date']), 'plus_unreconciled_statement_lines': self._plus_unreconciled_statement_lines(records, + data['start_date'], data['end_date']), 'bank_end_balance': self._get_bank_end_balance( records, data['end_date']), diff --git a/bank_statement_reconciliation_summary/report/summary_report.xml b/bank_statement_reconciliation_summary/report/summary_report.xml index 38b1c3e4..10b01797 100644 --- a/bank_statement_reconciliation_summary/report/summary_report.xml +++ b/bank_statement_reconciliation_summary/report/summary_report.xml @@ -22,7 +22,6 @@