I need help for custom pos invoice

i need help for custom pos invoice

i ceate 3 items which is item A, item B and item c

item A and item B have GST charge so in item (item tax section i add GST-RD tax rate 6) and item C no GST charge (i dont do anything)

i create a custom pos invoice i use {{ item.item_tax_rate }} please refer my code and attactment

{“GST - RD”: 6.0}
{}

what i want is if {“GST - RD”: 6.0} display “S” if {} display “Z”

any script can do it?

------ below is my custom pos invoice code and attactment–

.print-format table, .print-format tr, .print-format td, .print-format div, .print-format p { font-family: Monospace; line-height: 200%; vertical-align: middle; } @media screen { .print-format { width: 4in; padding: 0.25in; min-height: 8in; } } {%- for item in doc.items -%}
		<td width="23%" class="text-right">{{ '{:20,.2f}'.format(item.amount) }}   {{ item.item_tax_rate }} </td>
	 
	</tr>
	{%- endfor -%}
</tbody>
{{ item.qty }} @{{ '{:20,.2f}'.format(item.rate) }} {%- if item.item_name != item.item_code -%}
{{ item.item_name }}{%- endif -%}


Try this:

{% if item.item_tax_rate == '{"GST - RD": 6.0}' %}
    S
{% elif item.item_tax_rate == '{}' %}
    Z
{% endif %}

wow!

thank you very much it work very good such simple code solve my problem.

thanks again

can you help me again

{% if item.item_tax_rate == ‘{“GST - RD”: 6.0}’ %}
S
{% elif item.item_tax_rate == ‘{}’ %}
Z
{% endif %}

this is py code run on server side.

because my custom point of sale invoice Print Format Type is Js how do i convert to js script?

Glad to help you.

I didn’t use Js type before, but I think the code will be similar to this (like report print format):

{% if (item.item_tax_rate === '{"GST - RD": 6.0}') { %}
    S
{% } else if (item.item_tax_rate === '{}') { %}
    Z
{% } %}

Or:

<% if (item.item_tax_rate === '{"GST - RD": 6.0}') { %>
    S
<% } else if (item.item_tax_rate === '{}') { %>
    Z
<% } %>

thank you for help

unfortunately both code does not work on custom point of sale invoice Print Format Js Type.

Please try:

<script>
    if (item.item_tax_rate === '{"GST - RD": 6.0}') {
        document.write('S');
    } else if (item.item_tax_rate === '{}') {
        document.write('Z');
    }
</script>

Make sure you are inside the loop.
If the previous code does not work, please share your Js code so that I can help you better.

thank you,

this code also not working i share my code

py code and js code

hi, @mibrahim

finally i use this code the output is (refer attachment)

<% if ( {{item.item_tax_rate}} === “{“GST - RD”:6}”) { S } else { Z } %>

i still cant figure out why the output not S or Z

Oh, I see.

The syntax in Js type is similar to Server type, but for some reason elif does not work.

Now it is clear. You should rewrite the code for Js type like this to work:

{% if item.item_tax_rate == '{"GST - RD": 6.0}' %}
    S
{% endif %}
{% if item.item_tax_rate == '{}' %}
    Z
{% endif %}

I tried a similar code on my test server. I hope this will work for you.

thank you,

finally i know the problem to this code why not print because of this ‘{“GST - RD”:6}’

for example if i simply change it let say change it to ‘88’ it working

{% if item.item_tax_rate == ‘88’ %} S {% else %} Z {% endif %}

how do i replace this ‘{“GST - RD”:6}’ ??

Js type is supposed to work exactly as Server type, both of them use Jinja templating language.

I don’t know what is the difference. Maybe there is a bug or limitations in Js type.

thanks you help me a lot

i try find another way