Add VAT rate specific summaries to the template and invoice_form view

This commit is contained in:
Paul van Tilburg 2012-09-28 12:00:42 +02:00
parent 537b0d47ea
commit b45bb356ef
2 changed files with 20 additions and 16 deletions

View File

@ -1058,6 +1058,7 @@ module StopTime::Controllers
@company = @invoice.company_info @company = @invoice.company_info
@tasks = @invoice.summary @tasks = @invoice.summary
@vat = @invoice.vat_summary
@period = @invoice.period @period = @invoice.period
if @format == "html" if @format == "html"
@ -1833,28 +1834,29 @@ module StopTime::Views
end end
end unless task.fixed_cost? end unless task.fixed_cost?
end end
if @company.vatno.blank? vattotal = 0.0
vat = 0 if @company.vatno.present?
else
tr.total do tr.total do
td { i "Sub-total" } td { i "Sub-total" }
td "" td ""
td "" td ""
td.right { "€ %.2f" % subtotal } td.right { "€ %.2f" % subtotal }
end end
vat = subtotal * @config["vat_rate"]/100.0 @vat.keys.sort.each do |rate|
tr do vattotal += @vat[rate]
td { i "VAT %d%%" % @config["vat_rate"] } tr do
td "" td { i "VAT %d%%" % rate }
td "" td ""
td.right { "€ %.2f" % vat } td ""
td.right { "€ %.2f" % @vat[rate] }
end
end end
end end
tr.total do tr.total do
td { b "Total" } td { b "Total" }
td "" td ""
td "" td ""
td.right { "€ %.2f" % (subtotal + vat) } td.right { "€ %.2f" % (subtotal + vattotal) }
end end
end end

View File

@ -84,7 +84,7 @@
\newcommand{\ihsubtotal}[1]{\cmidrule[.0em]{4-4}% \newcommand{\ihsubtotal}[1]{\cmidrule[.0em]{4-4}%
\textit{Subtotaal}&&&\currency~#1\\} \textit{Subtotaal}&&&\currency~#1\\}
\newcommand{\ihnosubtotal}[1]{\cmidrule[.0em]{4-4}&&&\\} \newcommand{\ihnosubtotal}[1]{\cmidrule[.0em]{4-4}&&&\\}
\newcommand{\ihvat}[1]{\textit{Btw-heffing <%= "%d\\%%" % @config["vat_rate"] %>}&&&\currency~#1\\} \newcommand{\ihvat}[2]{\textit{Btw-heffing #1}&&&\currency~#2\\}
\newcommand{\ihtotal}[1]{\cmidrule[.05em]{4-4}% \newcommand{\ihtotal}[1]{\cmidrule[.05em]{4-4}%
\textbf{\totaltext}&&&\textbf{\currency~#1}} \textbf{\totaltext}&&&\textbf{\currency~#1}}
@ -108,15 +108,17 @@
<% end <% end
subtotal += line[2] subtotal += line[2]
end end
vattotal = 0.0
if @company.vatno.blank? if @company.vatno.blank?
vat = 0
%> \ihnosubtotal{} <% %> \ihnosubtotal{} <%
else else
vat = subtotal * @config["vat_rate"]/100.0 %> %> \ihsubtotal{<%= number_with_precision(subtotal) %>}<%
\ihsubtotal{<%= number_with_precision(subtotal) %>} @vat.keys.sort.each do |rate|
\ihvat{<%= number_with_precision(vat) %>}<% vattotal += @vat[rate] %>
\ihvat{<%= "%d\\%%" % rate %>}{<%= number_with_precision(@vat[rate]) %>}<%
end
end %> end %>
\ihtotal{<%= number_with_precision(subtotal + vat) %>} \ihtotal{<%= number_with_precision(subtotal + vattotal) %>}
\end{ihtable} \end{ihtable}
\vspace{2em} \vspace{2em}