Added support for not adding VAT in views and template.

This commit is contained in:
Paul van Tilburg 2011-11-09 14:07:03 +01:00
parent 69d6424462
commit ee58b00d2c
2 changed files with 37 additions and 22 deletions

View File

@ -35,7 +35,7 @@ unless defined? PUBLIC_DIR
# FIXME: this should be configurable.
HourlyRate = 20.0
VATRate = 19.0
VATRate = 0.0
end
module StopTime
@ -872,18 +872,22 @@ module StopTime::Views
end
subtotal += line[2]
end
tr do
td { i "Sub-total" }
td ""
td ""
td { "€ %.2f" % subtotal }
end
vat = subtotal * VATRate/100
tr do
td { i "VAT #{VATRate}%" }
td ""
td ""
td { "€ %.2f" % vat }
if VATRate.zero?
vat = 0
else
tr do
td { i "Sub-total" }
td ""
td ""
td { "€ %.2f" % subtotal }
end
vat = subtotal * VATRate/100
tr do
td { i "VAT #{VATRate}%" }
td ""
td ""
td { "€ %.2f" % vat }
end
end
tr do
td { b "Total amount" }

View File

@ -82,17 +82,28 @@
\invoice{
\hypersetup{pdftitle=\invoicetext\ naar\ \toname\ gedateerd \date\ (\ourref)}
% FIXME: localise the dot/comma stuff in numbers.
\begin{ihtable}
<% subtotal = 0.0 %>
<% tasks.each do |task, line| %>
\ihitem{<%= task.name %>}{<%= "%.2f" % line[0] %>}%
{<%= "%.2f" % line[1] %>}{<%= "%.2f" % line[2] %>}
<% subtotal += line[2] %>
<% end %>
<% subtotal = 0.0
@tasks.each do |task, line|
if line[0].nil? and line[1].nil?
%> \ifcitem{<%= task %>}%
{<%= "%.2f" % line[2] %>}<%
else
%> \ihitem{<%= task %>}%
{<%= "%.2f" % line[0] %>}{<%= "%.2f" % line[1] %>}%
{<%= "%.2f" % line[2] %>}<%
end
subtotal += line[2]
end
if VATRate.zero?
vat = 0 %>
\ihnosubtotal{} <%
else
vat = subtotal * VATRate/100 %>
\ihsubtotal{<%= "%.2f" % subtotal %>}
%\inosubtotal
<% vat = subtotal * VATRate/100 %>
\ihvat{<%= "%.2f" % vat %>}
\ihvat{<%= "%.2f" % vat %>} <%
end %>
\ihtotal{<%= "%.2f" % (subtotal + vat) %>}
\end{ihtable}
\vspace{2em}