Merge branch 'release/1.12'
This commit is contained in:
commit
bec855a418
2 changed files with 87 additions and 52 deletions
59
stoptime.rb
59
stoptime.rb
|
@ -54,7 +54,7 @@ end
|
||||||
module StopTime
|
module StopTime
|
||||||
|
|
||||||
# The version of the application
|
# The version of the application
|
||||||
VERSION = '1.10'
|
VERSION = '1.12'
|
||||||
puts "Starting Stop… Camping Time! version #{VERSION}"
|
puts "Starting Stop… Camping Time! version #{VERSION}"
|
||||||
|
|
||||||
# @return [Hash{String=>Object}] The parsed configuration.
|
# @return [Hash{String=>Object}] The parsed configuration.
|
||||||
|
@ -895,18 +895,22 @@ module StopTime::Controllers
|
||||||
# {Views#overview}.
|
# {Views#overview}.
|
||||||
def get
|
def get
|
||||||
@tasks = {}
|
@tasks = {}
|
||||||
@tasks_summary = {}
|
|
||||||
@task_count = 0
|
@task_count = 0
|
||||||
|
@active_tasks = {}
|
||||||
|
@active_tasks_summary = {}
|
||||||
Customer.all.each do |customer|
|
Customer.all.each do |customer|
|
||||||
tasks = customer.active_tasks
|
tasks = customer.unbilled_tasks
|
||||||
@tasks[customer] = tasks
|
@tasks[customer] = tasks
|
||||||
@tasks_summary[customer] = tasks.inject([0.0, 0.0]) do |summ, task|
|
|
||||||
task_summ = task.summary
|
|
||||||
summ[0] += task_summ[0]
|
|
||||||
summ[1] += task_summ[2]
|
|
||||||
summ
|
|
||||||
end
|
|
||||||
@task_count += tasks.count
|
@task_count += tasks.count
|
||||||
|
active_tasks = customer.active_tasks
|
||||||
|
@active_tasks[customer] = active_tasks
|
||||||
|
@active_tasks_summary[customer] =
|
||||||
|
active_tasks.inject([0.0, 0.0]) do |summ, task|
|
||||||
|
task_summ = task.summary
|
||||||
|
summ[0] += task_summ[0]
|
||||||
|
summ[1] += task_summ[2]
|
||||||
|
summ
|
||||||
|
end
|
||||||
end
|
end
|
||||||
render :overview
|
render :overview
|
||||||
end
|
end
|
||||||
|
@ -1382,6 +1386,27 @@ module StopTime::Controllers
|
||||||
#
|
#
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Escapes the given string such that it can be used as in in
|
||||||
|
# LaTeX.
|
||||||
|
#
|
||||||
|
# @param [String] string the given string
|
||||||
|
def _escape_latex(string)
|
||||||
|
escape_chars = { '#' => '\#',
|
||||||
|
'$' => '\$',
|
||||||
|
'%' => '\%',
|
||||||
|
'&' => '\&',
|
||||||
|
'\\' => '\textbackslash{}',
|
||||||
|
'^' => '\textasciicircum{}',
|
||||||
|
'_' => '\_',
|
||||||
|
'{' => '\{',
|
||||||
|
'}' => '\}',
|
||||||
|
'~' => '\textasciitilde{}' }
|
||||||
|
regexp_str = escape_chars.keys.map { |c| Regexp.escape(c) }.join('|')
|
||||||
|
regexp = Regexp.new(regexp_str)
|
||||||
|
string.to_s.gsub(regexp, escape_chars)
|
||||||
|
end
|
||||||
|
alias_method :l, :_escape_latex
|
||||||
|
|
||||||
# Generates a LaTex document for the invoice with the given number.
|
# Generates a LaTex document for the invoice with the given number.
|
||||||
#
|
#
|
||||||
# @param [Fixnum] number number of the invoice
|
# @param [Fixnum] number number of the invoice
|
||||||
|
@ -1784,12 +1809,22 @@ module StopTime::Views
|
||||||
text! "No projects/tasks found! Create one " +
|
text! "No projects/tasks found! Create one " +
|
||||||
"#{a "here", :href => R(CustomersNTasksNew, customer.id)}."
|
"#{a "here", :href => R(CustomersNTasksNew, customer.id)}."
|
||||||
end
|
end
|
||||||
|
elsif @active_tasks[customer].empty?
|
||||||
|
p do
|
||||||
|
text! "No active projects/tasks found! " +
|
||||||
|
"Register time on one of these tasks: "
|
||||||
|
br
|
||||||
|
@tasks[customer].each do |task|
|
||||||
|
a task.name, :href => R(CustomersNTasksN, customer.id, task.id)
|
||||||
|
text! "·" unless task == @tasks[customer].last
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
table.table.table_condensed do
|
table.table.table_condensed do
|
||||||
col.task
|
col.task
|
||||||
col.hours
|
col.hours
|
||||||
col.amount
|
col.amount
|
||||||
@tasks[customer].each do |task|
|
@active_tasks[customer].each do |task|
|
||||||
tr do
|
tr do
|
||||||
summary = task.summary
|
summary = task.summary
|
||||||
td do
|
td do
|
||||||
|
@ -1803,8 +1838,8 @@ module StopTime::Views
|
||||||
end
|
end
|
||||||
tr do
|
tr do
|
||||||
td { b "Total" }
|
td { b "Total" }
|
||||||
td.text_right { "%.2fh" % @tasks_summary[customer][0] }
|
td.text_right { "%.2fh" % @active_tasks_summary[customer][0] }
|
||||||
td.text_right { "€ %.2f" % @tasks_summary[customer][1] }
|
td.text_right { "€ %.2f" % @active_tasks_summary[customer][1] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
\documentclass[a4paper,oneside,dutch]{isodoc}
|
\documentclass[a4paper,oneside,dutch]{isodoc}
|
||||||
|
|
||||||
% rubber: clean <%= @number %>.out
|
% rubber: clean <%=l @number %>.out
|
||||||
|
|
||||||
\usepackage{array}
|
\usepackage{array}
|
||||||
\usepackage[utf8]{inputenc}
|
\usepackage[utf8]{inputenc}
|
||||||
|
@ -10,13 +10,13 @@
|
||||||
dutch,
|
dutch,
|
||||||
fill,
|
fill,
|
||||||
%% Company info.
|
%% Company info.
|
||||||
company=<%= @company.name %>,
|
company=<%=l @company.name %>,
|
||||||
who=<%= @company.contact_name %>,
|
who=<%=l @company.contact_name %>,
|
||||||
street=<%= @company.address_street %>,
|
street=<%=l @company.address_street %>,
|
||||||
zip=<%= @company.address_postal_code %>,
|
zip=<%=l @company.address_postal_code %>,
|
||||||
city=<%= @company.address_city %>,
|
city=<%=l @company.address_city %>,
|
||||||
country=<%= @company.country %>,
|
country=<%=l @company.country %>,
|
||||||
countrycode=<%= @company.country_code %>,
|
countrycode=<%=l @company.country_code %>,
|
||||||
logoaddress={\hspace{-4.4em}
|
logoaddress={\hspace{-4.4em}
|
||||||
\begin{tabular}{l@{\ }l}
|
\begin{tabular}{l@{\ }l}
|
||||||
<% if @company.name.blank? %> \addresstext: & \who\\
|
<% if @company.name.blank? %> \addresstext: & \who\\
|
||||||
|
@ -33,38 +33,38 @@
|
||||||
%% Footer.
|
%% Footer.
|
||||||
<% unless @company.website.blank? %> footer,<%
|
<% unless @company.website.blank? %> footer,<%
|
||||||
end %> areacode=31,
|
end %> areacode=31,
|
||||||
phone=<%= @company.phone %>,
|
phone=<%=l @company.phone %>,
|
||||||
cellphone=<%= @company.cell %>,
|
cellphone=<%=l @company.cell %>,
|
||||||
email=<%= @company.email %>,
|
email=<%=l @company.email %>,
|
||||||
website=<%= @company.website %>,
|
website=<%=l @company.website %>,
|
||||||
%% Addressee info.
|
%% Addressee info.
|
||||||
%foreign,
|
%foreign,
|
||||||
to={<%= @customer.name %>\\<% unless @customer.financial_contact.blank?
|
to={<%=l @customer.name %>\\<% unless @customer.financial_contact.blank?
|
||||||
%><%= @customer.financial_contact
|
%><%=l @customer.financial_contact
|
||||||
%>\\<% end %><%= @customer.address_street%>\\
|
%>\\<% end %><%=l @customer.address_street%>\\
|
||||||
<%= @customer.address_postal_code %> <%= @customer.address_city %>},
|
<%=l @customer.address_postal_code %> <%=l @customer.address_city %>},
|
||||||
% Headlines.
|
% Headlines.
|
||||||
date=<%= @invoice.created_at.to_formatted_s(:day_code) %>,
|
date=<%=l @invoice.created_at.to_formatted_s(:day_code) %>,
|
||||||
ourref=<%= @number %>,
|
ourref=<%=l @number %>,
|
||||||
<% period = @period.map { |p| I18n.l p, :format => :month_and_year }.uniq
|
<% period = @period.map { |p| I18n.l p, :format => :month_and_year }.uniq
|
||||||
case period.length
|
case period.length
|
||||||
when 1 %> subject=Factuur <%= period.first %>,<%
|
when 1 %> subject=Factuur <%=l period.first %>,<%
|
||||||
when 2 %> subject=Factuur <%= period.join(" t/m ") %>,<%
|
when 2 %> subject=Factuur <%=l period.join(" t/m ") %>,<%
|
||||||
end %>
|
end %>
|
||||||
yourref=,
|
yourref=,
|
||||||
%% Payment data.
|
%% Payment data.
|
||||||
term=30,
|
term=30,
|
||||||
accountname=<%= @company.accountname %>,
|
accountname=<%=l @company.accountname %>,
|
||||||
<% unless @company.accountiban.blank? %> iban=<%= @company.accountiban %>,
|
<% unless @company.accountiban.blank? %> iban=<%=l @company.accountiban %>,
|
||||||
<% end %><% unless @company.bank_bic.blank? %> bic=<%= @company.bank_bic %>,
|
<% end %><% unless @company.bank_bic.blank? %> bic=<%=l @company.bank_bic %>,
|
||||||
<% end %><% unless @company.vatno.blank? %> vatno=<%= @company.vatno %>,
|
<% end %><% unless @company.vatno.blank? %> vatno=<%=l @company.vatno %>,
|
||||||
<% end %><% unless @company.chamber.blank? %> chamber=<%= @company.chamber %>
|
<% end %><% unless @company.chamber.blank? %> chamber=<%=l @company.chamber %>
|
||||||
<% end %>}
|
<% end %>}
|
||||||
\setlength{\parindent}{0pt}
|
\setlength{\parindent}{0pt}
|
||||||
\setlength{\parskip}{\medskipamount}
|
\setlength{\parskip}{\medskipamount}
|
||||||
|
|
||||||
<% if @company.bank_name.present? %>
|
<% if @company.bank_name.present? %>
|
||||||
\renewcommand{\accountnotext}{<%= @company.bank_name %> rekeningnr}
|
\renewcommand{\accountnotext}{<%=l @company.bank_name %> rekeningnr}
|
||||||
<% end %>\newcommand{\addresstext}{adres}
|
<% end %>\newcommand{\addresstext}{adres}
|
||||||
\newcommand{\addresswhotext}{t.n.v.}
|
\newcommand{\addresswhotext}{t.n.v.}
|
||||||
\renewcommand{\chambertext}{KvK-nr}
|
\renewcommand{\chambertext}{KvK-nr}
|
||||||
|
@ -105,14 +105,14 @@
|
||||||
<% subtotal = 0.0
|
<% subtotal = 0.0
|
||||||
@tasks.each do |task, line|
|
@tasks.each do |task, line|
|
||||||
if line[1].blank?
|
if line[1].blank?
|
||||||
%> \ifcitem{<%= task.comment_or_name %>}%
|
%> \ifcitem{<%=l task.comment_or_name %>}%
|
||||||
{<%= number_with_precision(line[0]) %>}%
|
{<%=l number_with_precision(line[0]) %>}%
|
||||||
{<%= number_with_precision(line[2]) %>}
|
{<%=l number_with_precision(line[2]) %>}
|
||||||
<% else
|
<% else
|
||||||
%> \ihitem{<%= task.comment_or_name %>}%
|
%> \ihitem{<%=l task.comment_or_name %>}%
|
||||||
{<%= number_with_precision(line[0]) %>}%
|
{<%=l number_with_precision(line[0]) %>}%
|
||||||
{<%= number_with_precision(line[1]) %>}%
|
{<%=l number_with_precision(line[1]) %>}%
|
||||||
{<%= number_with_precision(line[2]) %>}
|
{<%=l number_with_precision(line[2]) %>}
|
||||||
<% end
|
<% end
|
||||||
subtotal += line[2]
|
subtotal += line[2]
|
||||||
end
|
end
|
||||||
|
@ -120,13 +120,13 @@
|
||||||
if @company.vatno.blank?
|
if @company.vatno.blank?
|
||||||
%> \ihnosubtotal{} <%
|
%> \ihnosubtotal{} <%
|
||||||
else
|
else
|
||||||
%> \ihsubtotal{<%= number_with_precision(subtotal) %>}<%
|
%> \ihsubtotal{<%=l number_with_precision(subtotal) %>}<%
|
||||||
@vat.keys.sort.each do |rate|
|
@vat.keys.sort.each do |rate|
|
||||||
vattotal += @vat[rate] %>
|
vattotal += @vat[rate] %>
|
||||||
\ihvat{<%= "%d\\%%" % rate %>}{<%= number_with_precision(@vat[rate]) %>}<%
|
\ihvat{<%= "%d\\%%" % rate %>}{<%=l number_with_precision(@vat[rate]) %>}<%
|
||||||
end
|
end
|
||||||
end %>
|
end %>
|
||||||
\ihtotal{<%= number_with_precision(subtotal + vattotal) %>}
|
\ihtotal{<%=l number_with_precision(subtotal + vattotal) %>}
|
||||||
\end{ihtable}
|
\end{ihtable}
|
||||||
\vspace{2em}
|
\vspace{2em}
|
||||||
|
|
||||||
|
@ -148,11 +148,11 @@
|
||||||
|
|
||||||
\begin{istable}
|
\begin{istable}
|
||||||
<% @invoice.tasks.each do |task|
|
<% @invoice.tasks.each do |task|
|
||||||
%> \istask{<%= task.comment_or_name %>}<%
|
%> \istask{<%=l task.comment_or_name %>}<%
|
||||||
task.time_entries.each do |time_entry| %>
|
task.time_entries.each do |time_entry| %>
|
||||||
\isitem{<%= time_entry.comment || "Geen opmerking" %>}%
|
\isitem{<%=l time_entry.comment || "Geen opmerking" %>}%
|
||||||
{<%= time_entry.date.to_date %>}%
|
{<%=l time_entry.date.to_date %>}%
|
||||||
{<%= number_with_precision(time_entry.hours_total) %>}<%
|
{<%=l number_with_precision(time_entry.hours_total) %>}<%
|
||||||
end %>\\[\medskipamount]<%
|
end %>\\[\medskipamount]<%
|
||||||
end %>
|
end %>
|
||||||
\end{istable}
|
\end{istable}
|
||||||
|
|
Loading…
Reference in a new issue