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

View file

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