From 8b9aa51bdeb40095f6a8a03b3757c5189351e33f Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 28 Sep 2012 11:58:38 +0200 Subject: [PATCH] Modify Invoice#total_amount to take different VAT rates into account --- stoptime.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 557ef26..c1e77f2 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -384,12 +384,16 @@ module StopTime::Models # Returns the total amount (including VAT). def total_amount - subtotal = summary.inject(0.0) { |tot, (task, summ)| tot + summ[2] } + subtotal, vattotal = summary.inject([0.0, 0.0]) do |tot, (task, summ)| + tot[0] += summ[2] + tot[1] += summ[3] + tot + end + if company_info.vatno.blank? subtotal else - config = Config.instance - subtotal * (1 + config["vat_rate"]/100.0) + subtotal + vattotal end end end