Theresa | Expense Report PDF Model

Theresa - An Alternative Expense Report PDF Document Model

WARNING:
This information and code is presented to you in good faith. Using parts of this code or file is at your own risk. This feature has been tested on Dolibarr [tt] 7.0.4 [/tt] and [tt] 8.0.2 [/tt].

What this does
Upto Dolibarr [tt] 8.0 [/tt] the ‘standard’ expense report PDF model followed the typical invoice-style layout. With Dolibarr [tt] 9.0 [/tt] a new improved layout was created for the ‘standard’ model which tackled reducing the columns and blank pages.

The ‘theresa’ model is focussed on a business expense usage, as opposed to a user expense usage. Model ‘theresa’ is based on the improved ‘standard’ model but with the following changes:

  • Added payment table to PDF
  • Amount paid/claimed/unpaid is only shown when unpaid
  • Add PDF Description and Author *
  • Only show payments on PDF if there is a payment.
  • Hidden config [tt] MAIN_GENERATE_NON_SALES_DOCUMENTS_WITHOUT_VAT [/tt] to make sales doc vat different from internal docs
  • Page table titles in bold and aligned
  • Changed the overall text color to black for paper printing
  • Highlighted date (in bold) for easier reference
  • Changed the status color to a paper-friendly green
  • Changed the ‘Amount in’ to italics
  • Aligned columns

* Requires new translation string

What the PDF looks like

Here’s the general look…

Here’s with the payment table…

Here’s the unpaid section…

Upload the document model
EXTRACT and upload to:

/core/modules/expensereport/doc/

This file:
[hide]

pdf_theresa.modules.zip (10.5 KB)[/hide]

Add the translation text
In file:

/langs/en_US/trips.lang

Add: (around line 39)

PDFTheresaExpenseReports=Advanced template to generate a PDF document for Expense Reports more suitable for business expenses. <br>Shows the payment table if payments have been made. Amount paid/claimed/unpaid is only shown when unpaid.<br>Set <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">MAIN_GENERATE_NON_SALES_DOCUMENTS_WITHOUT_VAT</b> to <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">1</b> in <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">Setup > Other</b> to hide VAT details on the generated PDF.

Activate the document model
Finally in Dolibarr, go to: Home ► Setup ► Modules ► Expense Reports

3 Likes

Hello, Thanks for your model. Unfortunately this isn’t working on my system. I have Dolibarr 8.0.1 but the report has the same problem.
Maybe there is another problem?

Pièces jointes :

Hello

There is no easy way to fix the line spacing from what I know as the pdf is created through “guessing” because of all the different bits that link to it to create a single document.

When I tested, I did notice that re-creating an expense report did improve one ‘silly empty page’ pdf but from 5 white pages i got 1 so I was happy. It may be too time consuming for you to re-create (not just generate the pdf) your expense reports.

At least you have two choices in expense report models now. Hopefully one is better system-generated than the other.

Hello, I have just experienced (even in this new model) the problem similar to yours. I think it is to do with how many lines in the expense report.

Anyway, my new problem was 36 lines of expenses created 8 pages but only 3 or 4 of the pages had REAL lines on them. In the blank pages it was one value per page - not even a full row.

So I have just been playing around to try to get this ‘improved’ and I think I MAY have found the solution.

Try this code and see if it works. It has worked for me and reduced my 8 silly pages to a correct 3 pages.

Replace: (line 307)

$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);

With:

$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?50:10);
[hr]
I still have around 5 or 6 expense reports to do so I will keep testing it on my side in this report. Please check on your side and let me know if it improves or solves the problem.

1 Like

Hello,

Thank you for your response, i tried your lines of code but unfortunately the same thing happens.
The model looks a bit nicer because there is less space between the header and the table but the problem still exists.

I tried to play with the numbers but it will only get worse :happy:

By the way, i just updated to 8.0.3.

but you should have less pages now with ‘less space between the header and table’ ? What line number is your blank page problem starting from? mine was 31 or 32

Your image earlier shows your pdf breaks at line 12… hmmm

I just noticed, in your blurred part, you’re using two lines in your description

Your pdf:
date / type
line 1
line 2

try

date / type
line 1 | line 2

Maybe it’s that extra second line in the description which is the culprit. Worth a try.

So today I had one report which was enough for one page but spread across two. I solved it. Still a few more reports to do but this could be useful for the blank page problem.

I will finalise the original theresa template model once I have finished all my reports (about 4 left).

Replace: line 264

$heightforinfotot = 40; // Height reserved to output the info and total part

With:

[code]
$heightforinfotot = 35; // Height reserved to output the info and total part // old value 40[/code