From cd29a51680f386cc4247d0d6ecb0a6d1502fc808 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 28 Sep 2012 11:57:14 +0200 Subject: [PATCH] Add Invoice#vat_summary to return a VAT summary grouped by VAT rate --- stoptime.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 90a8aa0..628857a 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -367,6 +367,16 @@ module StopTime::Models return summ end + # Returns a total per VAT rate of the contained tasks (Hash of Float to + # Fixnum). + def vat_summary + vatsumm = Hash.new(0.0) + summary.each do |task, summ| + vatsumm[task.vat_rate] += summ[3] + end + return vatsumm + end + # Returns the invoice period based on the contained tasks (Array of Time). # See also Task#bill_period. def period