Merge branch 'feature/time-spec' into development (closes: #fb896d)

This implements the generation of time specifications which are seen
as an appendix in the invoice (template).  Whether this is generated
can be set globally on a customer or toggled per invoice.
This commit is contained in:
Paul van Tilburg 2013-07-13 22:39:28 +02:00
commit 6798d99d0b
2 changed files with 64 additions and 1 deletions

View File

@ -193,6 +193,7 @@ module StopTime::Models
# [email] email address (String)
# [phone] phone number (String)
# [hourly_rate] default hourly rate (Float)
# [time_specification] whether the customer requires time specifications (TrueClass/FalseClass)
# [created_at] time of creation (Time)
# [updated_at] time of last update (Time)
#
@ -358,6 +359,8 @@ module StopTime::Models
# [id] unique identification number (Fixnum)
# [number] invoice number (Fixnum)
# [paid] flag whether the invoice has been paid (TrueClass/FalseClass)
# [include_specification] flag whether the invoice should include a time
# specification (TrueClass/FalseClass)
# [created_at] time of creation (Time)
# [updated_at] time of last update (Time)
#
@ -694,6 +697,18 @@ module StopTime::Models
end
end
class TimeSpecificationSupport < V 1.95 # :nodoc:
def self.up
add_column(Customer.table_name, :time_specification, :boolean)
add_column(Invoice.table_name, :include_specification, :boolean)
end
def self.down
remove_column(Customer.table_name, :time_specification)
remove_column(Invoice.table_name, :include_specification)
end
end
end # StopTime::Models
# = The Stop… Camping Time! controllers
@ -836,6 +851,7 @@ module StopTime::Controllers
attrs.each do |attr|
@customer[attr] = @input[attr]
end
@customer.time_specification = @input.has_key? "time_specification"
@customer.save
if @customer.invalid?
@errors = @customer.errors
@ -1040,6 +1056,7 @@ module StopTime::Controllers
invoice = Invoice.create(:number => number)
invoice.customer = Customer.find(customer_id)
invoice.company_info = CompanyInfo.last
invoice.include_specification = invoice.customer.time_specification
# Handle the hourly rated tasks first by looking at the selected time
# entries.
@ -1127,6 +1144,7 @@ module StopTime::Controllers
def post(customer_id, invoice_number)
invoice = Invoice.find_by_number(invoice_number)
invoice.paid = @input.has_key? "paid"
invoice.include_specification = @input.has_key? "include_specification"
invoice.save
redirect R(CustomersNInvoicesX, customer_id, invoice_number)
@ -1804,6 +1822,12 @@ module StopTime::Views
_form_input_with_label("Phone number", "phone", :tel)
_form_input_with_label("Financial contact", "financial_contact", :text)
_form_input_with_label("Default hourly rate", "hourly_rate", :text)
div.control_group do
label.control_label "Time specifications?"
div.controls do
_form_input_checkbox("time_specification")
end
end
div.form_actions do
button.btn.btn_primary @button.capitalize, :type => "submit",
:name => @button, :value => @button.capitalize
@ -2018,6 +2042,12 @@ module StopTime::Views
_form_input_checkbox("paid")
end
end
div.control_group do
label.control_label "Include specification?"
div.controls do
_form_input_checkbox("include_specification")
end
end
div.form_actions do
button.btn.btn_primary "Update", :type => :submit,
:name => "update", :value => "Update"

View File

@ -1,4 +1,4 @@
\documentclass[a4paper,12pt,oneside,dutch]{isodoc}
\documentclass[a4paper,oneside,dutch]{isodoc}
% rubber: clean <%= @number %>.out
@ -61,6 +61,8 @@
<% end %><% unless @company.vatno.blank? %> vatno=<%= @company.vatno %>,
<% end %><% unless @company.chamber.blank? %> chamber=<%= @company.chamber %>
<% end %>}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\medskipamount}
<% if @company.bank_name.present? %>
\renewcommand{\accountnotext}{<%= @company.bank_name %> rekeningnr}
@ -88,6 +90,13 @@
\newcommand{\ihtotal}[1]{\cmidrule[.05em]{4-4}%
\textbf{\totaltext}&&&\textbf{\currency~#1}}
\newenvironment{istable}%
{\vskip1em\tabularx{\linewidth}{@{}X@{\quad}l@{\qquad}r@{}}
\descriptiontext&Datum&Aantal uur\ML}%
{\endtabularx}
\newcommand{\istask}[1]{\textbf{#1}\\}
\newcommand{\isitem}[3]{\quad #1&#2&#3\\}
\begin{document}
\invoice{
@ -122,10 +131,34 @@
\end{ihtable}
\vspace{2em}
<% if @invoice.include_specification?
%> Zie bijlage op de volgende pagina voor een nadere specificatie.\\[1em]<%end %>
Ik verzoek u vriendelijk het verschuldigde bedrag binnen 30 dagen na
factuurdatum over te maken onder vermelding van het factuurnummer. \\
\accountdata
}
<% if @invoice.include_specification? %>{
\newpage
{\bfseries\scshape\Large Specificatie}
Hieronder volgt een specificatie van gemaakte uren per taak per
uitgevoerde activiteit.
\begin{istable}
<% @invoice.tasks.each do |task|
%> \istask{<%= task.comment_or_name %>}<%
task.time_entries.each do |time_entry| %>
\isitem{<%= time_entry.comment || "Geen opmerking" %>}%
{<%= time_entry.date.to_date %>}%
{<%= number_with_precision(time_entry.hours_total) %>}<%
end %>\\[\medskipamount]<%
end %>
\end{istable}
\label{LastPageOf\thelettercount}
<% end %>}
\letter{}
\end{document}