This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 283
Added new functionality to allow LaTeX generation of invoices. #875
Open
neerdoc
wants to merge
18
commits into
kimai:master
Choose a base branch
from
neerdoc:LaTeX_Invoice
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a762e81
Added new functionality to allow LaTeX generation of invoices. Exampl…
neerdoc bb903f6
Added example template for LaTeX invoice.
neerdoc 3e5b42a
Added check if exec is allowed in the system. Changed the way executi…
neerdoc da94312
Change 'canExecute' to 'execAvaiable'. Less misleading.
neerdoc cea423a
Added LaTeXRenderer.php and Checksum.php
neerdoc 8233a19
Fixed style of files to comply with PSR2.
neerdoc 7d322f4
Added download link to help text in admin panel.
neerdoc 7e70e43
Adjust spaces
simonschaufi a3fd2ff
Further code improvements
simonschaufi 924a933
Further code improvements and a little bit less logging
simonschaufi e867de3
Changed Checksum to be a class.
neerdoc e321963
Fixed spaces.
neerdoc b7f87c0
Fixed indentation.
neerdoc 25c575d
Removed explicit load of file and corrected return value.
neerdoc 3221e3e
Added necessary updates to the database.
neerdoc d426792
Fixed typo and increased database version number.
neerdoc 5b05193
Update LaTeXRenderer.php
simonschaufi c96af4e
Update LaTeXRenderer.php
simonschaufi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
extensions/ki_invoice/invoices/my_company_LaTeX/invoice.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
\NeedsTeXFormat{LaTeX2e} | ||
\ProvidesClass{invoice}[2016/12/07 v1.0 Invoice for kimai] | ||
|
||
%% | ||
% This file is part of | ||
% Kimai - Open Source Time Tracking // http://www.kimai.org | ||
% (c) Kimai-Development-Team since 2006 | ||
% | ||
% Kimai is free software; you can redistribute it and/or modify | ||
% it under the terms of the GNU General Public License as published by | ||
% the Free Software Foundation; Version 3, 29 June 2007 | ||
% | ||
% Kimai is distributed in the hope that it will be useful, | ||
% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
% GNU General Public License for more details. | ||
% | ||
% You should have received a copy of the GNU General Public License | ||
% along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
%% | ||
|
||
%% | ||
% An example LaTeX class template for printing invoices. | ||
% | ||
% @author Gustav Johansson <[email protected]> | ||
%% | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Load standard document type % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\LoadClass[10pt,a4paper]{article} | ||
\RequirePackage{fancyhdr} | ||
\RequirePackage{graphicx} | ||
\RequirePackage{longtable} | ||
\RequirePackage{lastpage} | ||
\RequirePackage{hhline} | ||
\RequirePackage{etoolbox} | ||
\RequirePackage{multirow} | ||
\RequirePackage{numprint} | ||
\RequirePackage[table]{xcolor} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Define template controls % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%These can be redefined in the template for different languages, etc. | ||
\def\textTitle{\textbf{\textsf{Invoice}}} | ||
\def\textPage{Page} | ||
\def\textDate{Date:} | ||
\def\textDueDate{Due Date:} | ||
\def\textTotal{Total:} | ||
\def\textID{Invoice ID:} | ||
\def\textPhone{Phone: } | ||
\def\textEmail{Email: } | ||
\def\textTotalExVAT{\textbf{Total (excl. VAT)}} | ||
\def\textVAT{\textbf{VAT \vatRate{}\%}} | ||
\def\textGTotal{\textbf{Total (incl. VAT)}} | ||
\def\rulerWidth{0.4pt} | ||
\def\headerOne{Product} | ||
\def\headerTwo{Price} | ||
\def\headerThree{Quantity} | ||
\def\headerFour{Total} | ||
\def\headerColor{gray!50} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Define commands % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%Define product command | ||
\newcommand*{\@products}{} | ||
\def\rowCol{gray!25} | ||
\newcounter{colCount} | ||
\setcounter{colCount}{0} | ||
\newcommand*{\productColor}[4]{% | ||
\protected@edef\@products{\@products | ||
\cellcolor{\rowCol}#1\unitOne & \cellcolor{\rowCol}#2\unitTwo &% | ||
\cellcolor{\rowCol}% | ||
\ifstrempty{#3}{}{\numprint{#3}\unitThree}% | ||
& \cellcolor{\rowCol}\numprint{#4}\unitFour\\ | ||
}% | ||
} | ||
\newcommand*{\productNoColor}[4]{% | ||
\protected@edef\@products{\@products | ||
#1\unitOne & #2\unitTwo &% | ||
\ifstrempty{#3}{}{\numprint{#3}\unitThree}% | ||
& \numprint{#4}\unitFour\\ | ||
}% | ||
} | ||
\newcommand*{\product}[4]{% | ||
\ifnumequal{\thecolCount}{1}{% | ||
\productColor{#1}{#2}{#3}{#4} | ||
\addtocounter{colCount}{-1}% | ||
}{% | ||
\productNoColor{#1}{#2}{#3}{#4} | ||
\addtocounter{colCount}{1}% | ||
}% | ||
} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Define printing of commands % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%Print company info | ||
\newcommand{\makecompany}{% | ||
\noindent | ||
\companyName\\ | ||
\companyAddress\\ | ||
\textPhone\companyPhone\\ | ||
\textEmail\companyEmail\\ | ||
\par\noindent | ||
\textID\space\invoiceID\\ | ||
\par\noindent | ||
} | ||
|
||
%Print products into a table | ||
\newcommand{\makeproducts}{% | ||
\nprounddigits{2} | ||
\begin{longtable}{@{}p{0.5\textwidth}rrr@{}} | ||
\rowcolor{\headerColor} | ||
\headerOne&\headerTwo&\headerThree&\headerFour\\ | ||
\@products% | ||
\hhline{~~--} | ||
&&\multicolumn{1}{l}{\textTotalExVAT}&\numprint{\total}\space\currency\\ | ||
&&\multicolumn{1}{l}{\textVAT}&\numprint{\vat}\space\currency\\ | ||
&&\multicolumn{1}{l}{\textGTotal}&\numprint{\gtotal}\space\currency | ||
\end{longtable} | ||
} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Setup the headers and footers % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\pagestyle{fancy} | ||
\fancyhf{}%Clear all settings | ||
%Set the rulers | ||
\renewcommand{\headrulewidth}{\rulerWidth} | ||
\renewcommand{\footrulewidth}{\rulerWidth} | ||
%Setup header | ||
\fancyhead[L]{% | ||
\hspace*{0.2cm}\includegraphics[width=4.0cm]{logo.png}% | ||
} | ||
\fancyhead[C]{% | ||
\raisebox{1.7cm}{% | ||
\large{\textTitle}% | ||
} | ||
} | ||
\fancyhead[R]{% | ||
\raisebox{0.5cm}{% | ||
\textsf{% | ||
\begin{tabular}{p{2.0cm}p{3.5cm}}% | ||
\rowcolor{white}% | ||
{\small\textDate} & {\small\today}\tabularnewline% | ||
\rowcolor{white}% | ||
{\small\textID} & {\small\invoiceID}\tabularnewline% | ||
\rowcolor{white}% | ||
\textbf{\small\textDueDate} & \textbf{\duedate}\tabularnewline% | ||
\rowcolor{white}% | ||
{\small\textTotal} & {\numprint{\gtotal}\space\currency}% | ||
\end{tabular}% | ||
}% | ||
}% | ||
} | ||
%Setup footer | ||
\fancyfoot[L]{% | ||
\textsf{% | ||
\leftOne\\% | ||
\leftTwo\\% | ||
\leftThree% | ||
}% | ||
} | ||
\fancyfoot[C]{% | ||
\textsf{% | ||
\centerOne\\% | ||
\centerTwo\\% | ||
\centerThree\\% | ||
}% | ||
} | ||
\fancyfoot[R]{% | ||
\textsf{% | ||
\rightOne\\% | ||
\rightTwo\\% | ||
\rightThree\\% | ||
\textPage\space\thepage(\pageref{LastPage})% | ||
}% | ||
} | ||
\endinput |
60 changes: 60 additions & 0 deletions
60
extensions/ki_invoice/invoices/my_company_LaTeX/invoice.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
;; | ||
; This file is part of | ||
; Kimai - Open Source Time Tracking // http://www.kimai.org | ||
; (c) Kimai-Development-Team since 2006 | ||
; | ||
; Kimai is free software; you can redistribute it and/or modify | ||
; it under the terms of the GNU General Public License as published by | ||
; the Free Software Foundation; Version 3, 29 June 2007 | ||
; | ||
; Kimai is distributed in the hope that it will be useful, | ||
; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
; GNU General Public License for more details. | ||
; | ||
; You should have received a copy of the GNU General Public License | ||
; along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
;; | ||
|
||
;; | ||
; An example LaTeX setting file for printing invoices. | ||
; | ||
; @author Gustav Johansson <[email protected]> | ||
;; | ||
|
||
; This configuration file is used to define some settings | ||
; that defines how the template is rendered. | ||
|
||
; List all files that are needed for rendering except the | ||
; invoice.tex and the automatically generated data.tex and | ||
; info.tex. Typically classes and images. | ||
files[] = "invoice.cls" | ||
files[] = "logo.png" | ||
|
||
; The followin keys can be used in the table generation, i.e., for each row: | ||
; 'type' | ||
; 'desc' | ||
; 'start' | ||
; 'end' | ||
; 'hour' | ||
; 'fDuration' | ||
; 'duration' | ||
; 'timestamp' | ||
; 'amount' | ||
; 'description' | ||
; 'rate' | ||
; 'comment' | ||
; 'username' | ||
; 'useralias' | ||
; 'location' | ||
; 'trackingNr' | ||
; 'projectID' | ||
; 'projectName' | ||
; 'projectComment' | ||
; 'date' | ||
|
||
; List all fields that shall be used as columns in the generated table. | ||
table[] = "desc" | ||
table[] = "rate" | ||
table[] = "hour" | ||
table[] = "amount" |
84 changes: 84 additions & 0 deletions
84
extensions/ki_invoice/invoices/my_company_LaTeX/invoice.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
\documentclass{invoice} | ||
|
||
%% | ||
% This file is part of | ||
% Kimai - Open Source Time Tracking // http://www.kimai.org | ||
% (c) Kimai-Development-Team since 2006 | ||
% | ||
% Kimai is free software; you can redistribute it and/or modify | ||
% it under the terms of the GNU General Public License as published by | ||
% the Free Software Foundation; Version 3, 29 June 2007 | ||
% | ||
% Kimai is distributed in the hope that it will be useful, | ||
% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
% GNU General Public License for more details. | ||
% | ||
% You should have received a copy of the GNU General Public License | ||
% along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
%% | ||
|
||
%% | ||
% An example LaTeX template for printing invoices. | ||
% | ||
% @author Gustav Johansson <[email protected]> | ||
%% | ||
|
||
%%%%%%%%%%%%%%%%%%%%%% | ||
% Setup other stuff % | ||
%%%%%%%%%%%%%%%%%%%%%% | ||
%Language | ||
\usepackage[utf8]{inputenc} %Needed since the data from PHP is in utf8. Don't use any other encoding! | ||
|
||
%%%%%%%%%%%%%%%%%%%%%% | ||
% Setup page % | ||
%%%%%%%%%%%%%%%%%%%%%% | ||
\setlength{\topmargin}{-2cm} | ||
\setlength{\textwidth}{16cm} | ||
\setlength{\textheight}{22cm} | ||
\setlength{\oddsidemargin}{5.5mm} | ||
\setlength{\intextsep}{24pt} | ||
\setlength{\headheight}{3cm} | ||
\setlength{\headwidth}{16cm} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%% | ||
% Setup footer % | ||
%%%%%%%%%%%%%%%%%%%%%% | ||
\def\leftOne{Test company AB} | ||
\def\leftTwo{Fake address 33} | ||
\def\leftThree{SE-123 45 Gotham City} | ||
\def\centerOne{Telephone: +99 99 999 9999} | ||
\def\centerTwo{E-mail: [email protected]} | ||
\def\centerThree{Web: www.batman.robin} | ||
\def\rightOne{Org. nr: 123456-7890} | ||
\def\rightTwo{Bankgiro: 123-1234} | ||
\def\rightThree{Approved for tax.} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%% | ||
% Setup table units % | ||
%%%%%%%%%%%%%%%%%%%%%% | ||
\def\unitOne{} | ||
\def\unitTwo{} | ||
\def\unitThree{\space h} | ||
\def\unitFour{\space\currency} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%% | ||
% Start document % | ||
%%%%%%%%%%%%%%%%%%%%%% | ||
\input{info.tex} | ||
\pagestyle{fancy}% | ||
\thispagestyle{fancy}% | ||
\begin{document} | ||
\sffamily% | ||
%Process company info | ||
\makecompany | ||
%Write any text you like before the table | ||
The following invoice is for services performed from \startDate{} through | ||
\endDate{} under agreement 11111 between \leftOne{} and \companyName. | ||
%Load data | ||
\input{data.tex} | ||
%Alternating colors in table | ||
% \rowcolors{2}{gray!25}{white}% | ||
%Create the table | ||
\makeproducts | ||
\end{document} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name it "execAvailable". What do you think? canExecute sounds more like some internal stuff (object) can execute something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I can change it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.