From 17278fac989bdaf68b1b55053a604af223f05e2b Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:31:41 +0200 Subject: [PATCH 1/7] Add specification related attributes to the Customer and Invoice model --- stoptime.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 407cdcb..c10847c 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -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 From 7a58ae93316a14ac8ec23ec8f6b7f40b841d6392 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:32:27 +0200 Subject: [PATCH 2/7] Add the time specification to the customer_form view; update it If time specifications are enabled for a customer this is considered to be a global setting for invoices related to this customer. Note that it will note change any of the existing voices, it will only affect newly created ones! --- stoptime.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index c10847c..6f02fcb 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -851,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 @@ -1819,6 +1820,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 From afd037b95e26bb063a6ac94cfcbcc49f59f239c7 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:32:45 +0200 Subject: [PATCH 3/7] Add the time specification to the invoice_form view; update it Generation of a time specification appendix can be enabled for each invoice indepently on whether it is or is not enabled for the customer. However, whether it is enabled by default when an invoice is created, that does follow the setting for the customer. --- stoptime.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 6f02fcb..ebe0c78 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1056,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. @@ -1143,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) @@ -2040,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" From 6fc2cb87b3aed03465ad41ac9117249273e438d8 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:33:09 +0200 Subject: [PATCH 4/7] Remove 12pt default for the invoice template --- templates/invoice.tex.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/invoice.tex.erb b/templates/invoice.tex.erb index cdc2692..38f6fb4 100644 --- a/templates/invoice.tex.erb +++ b/templates/invoice.tex.erb @@ -1,4 +1,4 @@ -\documentclass[a4paper,12pt,oneside,dutch]{isodoc} +\documentclass[a4paper,oneside,dutch]{isodoc} % rubber: clean <%= @number %>.out From 66c46cd7c33f48ea31cc326f1505fdb7837b0aba Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:34:04 +0200 Subject: [PATCH 5/7] Generate a specification on a new page if enabled for the invoice --- templates/invoice.tex.erb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/templates/invoice.tex.erb b/templates/invoice.tex.erb index 38f6fb4..f6befaf 100644 --- a/templates/invoice.tex.erb +++ b/templates/invoice.tex.erb @@ -88,6 +88,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\\} + \begin{document} \invoice{ @@ -128,4 +135,26 @@ \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} From 52d41145508c5bf8b67a70a5e8031b9a3329d570 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:34:27 +0200 Subject: [PATCH 6/7] Tweak paragraph spacing a bit (needed in the specification part) --- templates/invoice.tex.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/invoice.tex.erb b/templates/invoice.tex.erb index f6befaf..cfa3e37 100644 --- a/templates/invoice.tex.erb +++ b/templates/invoice.tex.erb @@ -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} From 6fca2cdd6ece0a8a02487015b1b1acef0ec87c08 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 13 Jul 2013 22:34:56 +0200 Subject: [PATCH 7/7] Add a reference to the accompanying specification if enabled on the 1st page --- templates/invoice.tex.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/invoice.tex.erb b/templates/invoice.tex.erb index cfa3e37..aacabee 100644 --- a/templates/invoice.tex.erb +++ b/templates/invoice.tex.erb @@ -131,6 +131,8 @@ \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. \\