kimai / invoice-templates

A place for sharing Kimai invoice templates
MIT License
16 stars 9 forks source link

Unable to find template after creation/preview #5

Closed chrisonline closed 1 year ago

chrisonline commented 1 year ago

I have tried the template din5008-invoice.pdf.twig and copied it to the "invoices" directory.
It is now shown in the invoice templates and I can select it.

Now if I try to show the invoice I get the following error:
image

Running it via Docker compose on a Synology NAS.
Version 1.30.1 stable (prod)

Here is the template saved:
image

I have not changed the template yet.

Can you help what I did wrong?

kevinpapst commented 1 year ago

The part @SynoESStream sounds weird. That is not normal. Seems Synology (your setup) is somehow messing with the file loading streams of PHP. Never seen before... that needs debugging in the system. I have no Synology available to test, maybe their community forum can help?

chrisonline commented 1 year ago

So you think it is a problem because of the Synology? What exactly should I ask in the community forum? Can you send me the command what is used or any other related infos? Because if I ask the same question in the Synology forum I think I get immediately back "ask the developer" ;-) It is better if I can ask a more "general" question about php stream or something.

Alternative, I can of course test some commands inside the docker container via ssh if this would help.

chrisonline commented 1 year ago

Have now tried to copy the invoice file and rename it to din5008-invoice.pdf.twig@SynoEAStream and now it is working. Will ask now in the Synology forum what exactly this SynoEAStream is and let you know if I get more infos.

kevinpapst commented 1 year ago

Wow, that is even weirder. Please check the var/invoices/ directory displaying all files (including hidden). Maybe this is some kind of Synology meta-data directory (thats what a quick search suggests). Also check the invoice document dropdown, if there are multiple files you can select with the name din5008-invoice.

chrisonline commented 1 year ago

There is indeed a hidden directory called @eaDir. Seems this is something like the .thumb hidden folder on Windows to store some metadata of the files.

If I delete this directory, it works.

So I think you parse the directory invoices and all subfolders. And you find the file inside the invoices AND inside the @eaDir. Both are having the same name, so it shows in the invoice template selection only ones (I don't see it twice).

A good solution I think would be to ignore hidden folders if you search for the invoice templates. Is this possible?

kevinpapst commented 1 year ago

Aha, yeah right, Two files with the same name are not allowed. Kimai does not guarantee any order, so behavior is undefined. That is even documented in the invoices docs: https://www.kimai.org/documentation/invoices.html#invoice-document

Documents are addressed by their filename without extension (e.g. kimai.html.twig results in kimai) You can use every document name only once: so having kimai.html.twig and kimai.docx will lead to unpredictable results (the first file to be found takes precedence)

Regarding your question:

A good solution I think would be to ignore hidden folders if you search for the invoice templates. Is this possible?

I am not entirely happy that I should fix the problems caused by another product^^ But yes, at some point I might add a filter.

Even though you should probably just remove the directory and not use the Synology webfrontend (if that is the one creating those dirs & files).

kevinpapst commented 1 year ago

Fixed. Closing.

chrisonline commented 1 year ago

Oh awesome, thanks for the really quick fix :-)