From b6fd215d2958120f308019c3c97fa780684d3eb0 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Mon, 27 Apr 2015 12:08:35 +0300 Subject: [PATCH] Fix test --- app/models/invoice.rb | 7 +++++++ spec/models/bank_statement_spec.rb | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 298fae6e6..ee7a55a64 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -109,4 +109,11 @@ class Invoice < ActiveRecord::Base def sum sum_without_vat + vat end + + class << self + def cancel_overdue_invoices + cr_at = Time.zone.now - Setting.days_to_keep_overdue_invoices_active.days + self.class.where('due_date < ? AND created_at < ?', Time.zone.now, cr_at) + end + end end diff --git a/spec/models/bank_statement_spec.rb b/spec/models/bank_statement_spec.rb index 2a901adb4..84f81aebf 100644 --- a/spec/models/bank_statement_spec.rb +++ b/spec/models/bank_statement_spec.rb @@ -41,18 +41,18 @@ describe BankStatement do it 'should bind transactions with invoices' do r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') - r.issue_prepayment_invoice(200, 'add some money') + invoice = r.issue_prepayment_invoice(200, 'add some money') bs = Fabricate(:bank_statement, bank_transactions: [ Fabricate(:bank_transaction, { sum: 240.0, # with vat reference_no: 'RF7086666663', - description: 'Invoice no. 1' + description: "Invoice no. #{invoice.number}" }), Fabricate(:bank_transaction, { sum: 240.0, reference_no: 'RF7086666663', - description: 'Invoice no. 1' + description: "Invoice no. #{invoice.number}" }) ])