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
|
||||
|
||||
# The version of the application
|
||||
VERSION = '1.10'
|
||||
VERSION = '1.12'
|
||||
puts "Starting Stop… Camping Time! version #{VERSION}"
|
||||
|
||||
# @return [Hash{String=>Object}] The parsed configuration.
|
||||
|
@ -895,18 +895,22 @@ module StopTime::Controllers
|
|||
# {Views#overview}.
|
||||
def get
|
||||
@tasks = {}
|
||||
@tasks_summary = {}
|
||||
@task_count = 0
|
||||
@active_tasks = {}
|
||||
@active_tasks_summary = {}
|
||||
Customer.all.each do |customer|
|
||||
tasks = customer.active_tasks
|
||||
tasks = customer.unbilled_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
|
||||
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
|
||||
render :overview
|
||||
end
|
||||
|
@ -1382,6 +1386,27 @@ module StopTime::Controllers
|
|||
#
|
||||
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.
|
||||
#
|
||||
# @param [Fixnum] number number of the invoice
|
||||
|
@ -1784,12 +1809,22 @@ module StopTime::Views
|
|||
text! "No projects/tasks found! Create one " +
|
||||
"#{a "here", :href => R(CustomersNTasksNew, customer.id)}."
|
||||
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
|
||||
table.table.table_condensed do
|
||||
col.task
|
||||
col.hours
|
||||
col.amount
|
||||
@tasks[customer].each do |task|
|
||||
@active_tasks[customer].each do |task|
|
||||
tr do
|
||||
summary = task.summary
|
||||
td do
|
||||
|
@ -1803,8 +1838,8 @@ module StopTime::Views
|
|||
end
|
||||
tr do
|
||||
td { b "Total" }
|
||||
td.text_right { "%.2fh" % @tasks_summary[customer][0] }
|
||||
td.text_right { "€ %.2f" % @tasks_summary[customer][1] }
|
||||
td.text_right { "%.2fh" % @active_tasks_summary[customer][0] }
|
||||
td.text_right { "€ %.2f" % @active_tasks_summary[customer][1] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
\documentclass[a4paper,oneside,dutch]{isodoc}
|
||||
|
||||
% rubber: clean <%= @number %>.out
|
||||
% rubber: clean <%=l @number %>.out
|
||||
|
||||
\usepackage{array}
|
||||
\usepackage[utf8]{inputenc}
|
||||
|
@ -10,13 +10,13 @@
|
|||
dutch,
|
||||
fill,
|
||||
%% Company info.
|
||||
company=<%= @company.name %>,
|
||||
who=<%= @company.contact_name %>,
|
||||
street=<%= @company.address_street %>,
|
||||
zip=<%= @company.address_postal_code %>,
|
||||
city=<%= @company.address_city %>,
|
||||
country=<%= @company.country %>,
|
||||
countrycode=<%= @company.country_code %>,
|
||||
company=<%=l @company.name %>,
|
||||
who=<%=l @company.contact_name %>,
|
||||
street=<%=l @company.address_street %>,
|
||||
zip=<%=l @company.address_postal_code %>,
|
||||
city=<%=l @company.address_city %>,
|
||||
country=<%=l @company.country %>,
|
||||
countrycode=<%=l @company.country_code %>,
|
||||
logoaddress={\hspace{-4.4em}
|
||||
\begin{tabular}{l@{\ }l}
|
||||
<% if @company.name.blank? %> \addresstext: & \who\\
|
||||
|
@ -33,38 +33,38 @@
|
|||
%% Footer.
|
||||
<% unless @company.website.blank? %> footer,<%
|
||||
end %> areacode=31,
|
||||
phone=<%= @company.phone %>,
|
||||
cellphone=<%= @company.cell %>,
|
||||
email=<%= @company.email %>,
|
||||
website=<%= @company.website %>,
|
||||
phone=<%=l @company.phone %>,
|
||||
cellphone=<%=l @company.cell %>,
|
||||
email=<%=l @company.email %>,
|
||||
website=<%=l @company.website %>,
|
||||
%% Addressee info.
|
||||
%foreign,
|
||||
to={<%= @customer.name %>\\<% unless @customer.financial_contact.blank?
|
||||
%><%= @customer.financial_contact
|
||||
%>\\<% end %><%= @customer.address_street%>\\
|
||||
<%= @customer.address_postal_code %> <%= @customer.address_city %>},
|
||||
to={<%=l @customer.name %>\\<% unless @customer.financial_contact.blank?
|
||||
%><%=l @customer.financial_contact
|
||||
%>\\<% end %><%=l @customer.address_street%>\\
|
||||
<%=l @customer.address_postal_code %> <%=l @customer.address_city %>},
|
||||
% Headlines.
|
||||
date=<%= @invoice.created_at.to_formatted_s(:day_code) %>,
|
||||
ourref=<%= @number %>,
|
||||
date=<%=l @invoice.created_at.to_formatted_s(:day_code) %>,
|
||||
ourref=<%=l @number %>,
|
||||
<% period = @period.map { |p| I18n.l p, :format => :month_and_year }.uniq
|
||||
case period.length
|
||||
when 1 %> subject=Factuur <%= period.first %>,<%
|
||||
when 2 %> subject=Factuur <%= period.join(" t/m ") %>,<%
|
||||
when 1 %> subject=Factuur <%=l period.first %>,<%
|
||||
when 2 %> subject=Factuur <%=l period.join(" t/m ") %>,<%
|
||||
end %>
|
||||
yourref=,
|
||||
%% Payment data.
|
||||
term=30,
|
||||
accountname=<%= @company.accountname %>,
|
||||
<% unless @company.accountiban.blank? %> iban=<%= @company.accountiban %>,
|
||||
<% end %><% unless @company.bank_bic.blank? %> bic=<%= @company.bank_bic %>,
|
||||
<% end %><% unless @company.vatno.blank? %> vatno=<%= @company.vatno %>,
|
||||
<% end %><% unless @company.chamber.blank? %> chamber=<%= @company.chamber %>
|
||||
accountname=<%=l @company.accountname %>,
|
||||
<% unless @company.accountiban.blank? %> iban=<%=l @company.accountiban %>,
|
||||
<% end %><% unless @company.bank_bic.blank? %> bic=<%=l @company.bank_bic %>,
|
||||
<% end %><% unless @company.vatno.blank? %> vatno=<%=l @company.vatno %>,
|
||||
<% end %><% unless @company.chamber.blank? %> chamber=<%=l @company.chamber %>
|
||||
<% end %>}
|
||||
\setlength{\parindent}{0pt}
|
||||
\setlength{\parskip}{\medskipamount}
|
||||
|
||||
<% if @company.bank_name.present? %>
|
||||
\renewcommand{\accountnotext}{<%= @company.bank_name %> rekeningnr}
|
||||
\renewcommand{\accountnotext}{<%=l @company.bank_name %> rekeningnr}
|
||||
<% end %>\newcommand{\addresstext}{adres}
|
||||
\newcommand{\addresswhotext}{t.n.v.}
|
||||
\renewcommand{\chambertext}{KvK-nr}
|
||||
|
@ -105,14 +105,14 @@
|
|||
<% subtotal = 0.0
|
||||
@tasks.each do |task, line|
|
||||
if line[1].blank?
|
||||
%> \ifcitem{<%= task.comment_or_name %>}%
|
||||
{<%= number_with_precision(line[0]) %>}%
|
||||
{<%= number_with_precision(line[2]) %>}
|
||||
%> \ifcitem{<%=l task.comment_or_name %>}%
|
||||
{<%=l number_with_precision(line[0]) %>}%
|
||||
{<%=l number_with_precision(line[2]) %>}
|
||||
<% else
|
||||
%> \ihitem{<%= task.comment_or_name %>}%
|
||||
{<%= number_with_precision(line[0]) %>}%
|
||||
{<%= number_with_precision(line[1]) %>}%
|
||||
{<%= number_with_precision(line[2]) %>}
|
||||
%> \ihitem{<%=l task.comment_or_name %>}%
|
||||
{<%=l number_with_precision(line[0]) %>}%
|
||||
{<%=l number_with_precision(line[1]) %>}%
|
||||
{<%=l number_with_precision(line[2]) %>}
|
||||
<% end
|
||||
subtotal += line[2]
|
||||
end
|
||||
|
@ -120,13 +120,13 @@
|
|||
if @company.vatno.blank?
|
||||
%> \ihnosubtotal{} <%
|
||||
else
|
||||
%> \ihsubtotal{<%= number_with_precision(subtotal) %>}<%
|
||||
%> \ihsubtotal{<%=l number_with_precision(subtotal) %>}<%
|
||||
@vat.keys.sort.each do |rate|
|
||||
vattotal += @vat[rate] %>
|
||||
\ihvat{<%= "%d\\%%" % rate %>}{<%= number_with_precision(@vat[rate]) %>}<%
|
||||
\ihvat{<%= "%d\\%%" % rate %>}{<%=l number_with_precision(@vat[rate]) %>}<%
|
||||
end
|
||||
end %>
|
||||
\ihtotal{<%= number_with_precision(subtotal + vattotal) %>}
|
||||
\ihtotal{<%=l number_with_precision(subtotal + vattotal) %>}
|
||||
\end{ihtable}
|
||||
\vspace{2em}
|
||||
|
||||
|
@ -148,11 +148,11 @@
|
|||
|
||||
\begin{istable}
|
||||
<% @invoice.tasks.each do |task|
|
||||
%> \istask{<%= task.comment_or_name %>}<%
|
||||
%> \istask{<%=l 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) %>}<%
|
||||
\isitem{<%=l time_entry.comment || "Geen opmerking" %>}%
|
||||
{<%=l time_entry.date.to_date %>}%
|
||||
{<%=l number_with_precision(time_entry.hours_total) %>}<%
|
||||
end %>\\[\medskipamount]<%
|
||||
end %>
|
||||
\end{istable}
|
||||
|
|
Loading…
Reference in a new issue