Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.27k stars 2.73k forks source link

Total VAT rate is not displayed if there is no item with this specific VAT rate in ODT invoice #14250

Closed berndbaringhorst closed 3 years ago

berndbaringhorst commented 4 years ago

Instructions

This is a template to help you report good issues. You may use Github Markdown syntax to format your issue report. Please:

Bug

[Total VAT rate is not displayed if there is no item with this specific VAT rate in ODT invoice]

Environment

Expected and actual behavior

[In germany we have new temporary VAT rates, so I added these VAT rates in my company details. In the ODT template I used these tags to call the total VAT amounts:

{object_total_vat_locale_5} € {object_total_vat_locale_16} €

As long as there is at least one item, the corresponding total VAT is displayed. But if there is for example not one item with 5%, the total is showed as "{object_total_vat_locale_5} €".]

Steps to reproduce the behavior

[Verbose description]

Attached files (Screenshots, screencasts, dolibarr.log, debugging informations…)

[Files]

ksar-ksar commented 4 years ago

Hi,

Have you tried to use [!-- IF {my_var} --] Print this text if {my_var} is true (can be any value but null/0/empty string) [!-- ELSE {my_var} --] Or print this if it's false (null/0/empty string) [!-- ENDIF {my_var} --]

berndbaringhorst commented 4 years ago

Hi,

Have you tried to use [!-- IF {my_var} --] Print this text if {my_var} is true (can be any value but null/0/empty string) [!-- ELSE {my_var} --] Or print this if it's false (null/0/empty string) [!-- ENDIF {my_var} --]

Hi ksar-ksar, thank you very much for your reply!

Unfortunately I am very far away from being able to adapt everything beyond copying the basic tags for my ODT. Do I use this in the same field in my ODT? Would I do it like this (example for the 5% VAT)?

[!-- IF {object_total_vat_locale_5} --] 0,00 € [!-- ELSE {object_total_vat_locale_5} --] {object_total_vat_locale_5} € [!-- ENDIF {my_var} --]

dpriskorn commented 4 years ago

Try it. It looks like it could work.

berndbaringhorst commented 4 years ago

Try it. It looks like it could work.

Unfortunaltely this does not work.

When there is 5% vat, the result in the generated invoice is:
0,00 € [!-- ELSE 101,25 --] 101,25 € [!-- ENDIF {my_var} --]

When there is no position with 5% vat, the result is: [!-- IF --] 0,00 € [!-- ELSE --] € [!-- ENDIF {my_var} --]

I honestly hav no too much of a clue about this. Any help is appreciated.

Thanks in advance!!

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).

eldy commented 3 years ago

For the tag {objecttotal..._x}, if there is no amount for the vat rate x, the key is not replaced. So you can use the condition syntax to show 0 instead of the key when value is not defined:

[!-- IF {objecttotal..._x} --] {objecttotal..._x} [!-- ELSE {objecttotal..._x} --] 0 [!-- ENDIF {objecttotal..._x} --]

Warning: To be sure this part of code does not contains hidden text (added silently by LibreOffice for versioning/tracking change purpose), you must select all the code section, make a right click an select the feature "Remove direct formatting" (not doing this may make the code section not working).