I am looking forward to a solution for the following problem:
We have invoices in mayan. I’d like to use tags for the accounting like “paid”, “expensed”, “checked” to be sure they were actively marked. Later on employees need for example to get a list of unpaid invoices.
I expected this to be rather simple by an index which shows all invoices which don’t have the tag “paid”. Unfortunately after a day of research I didn’t succeed. Can you get me any hints?
This is what I tried so far. It didn’t find any documents.
{% bez=true %} {% for tag in document.tags.all %} {% if tag.label=="Paid" %}{% bez=false %}{% endif %} {% endfor %} {% if bez %} Bez {% endif %}
{% set 1 as bez %} {% for tag in document.tags.all %} {% if tag.label == 'Paid' %} {% set 0 as bez %} {% endif %} {% endfor %} {% if bez %} Bez {% endif %}
or this:
{% spaceless %}{% for tag in document.tags.all %} {% if tag.label == 'Paid' %}{% set True as paid %}{% endif %} {% endfor %} {% if not paid %}Bez{% endif %}{% endspaceless %}
Thank you very much for your reply. Now I understood what sandbox is for.
So the scope of set is necessary for realizing this? Do you maybe have another idea to solve the problem?
Thank you very much for your reply. The variable is necessary in my opinion because i search for all documents which are not tagged with “paid”. I will try the dirty hack in the evening.
Oh ok I see. I’m not sure if you can use this hack for your use case, it’s a completely different scenario than the one in the linked thread.
Edit: I think it would work
{%spaceless%}{% for tag in document.tags.all %} {% if tag.label == “Paid” %} {% now “Y” as paid %} {% endif %} {% endfor %} {% if not paid %}TRUE{% endif %}{%endspaceless%}
Returns TRUE if the document does not have the tag attached.
{%spaceless%} trims superfluous spaces in the end result. These are spaces added between tags or as carriage returns. Since the output of the template is going to be the value of the index level entry, extra spaces could sometimes cause minor issues.