Hello guys. So am trying to print a sales invoice and I get this error; "TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘int’ " What could really be the issue?
I believe your print format has custom calculation which causing the issue, the error meant NoneType
cannot be divided by int
. Could verify your custom calculation both has value or not.
The custom calculation is based on taxes or where specifically?
Could u copy paste ur print format code here for better understanding
Can u copy paster Bakeking 2021
print format code over here
And also please think twice before pasting ur data here, it may contain P&C matters. Just paste code
Alright
SALES INVOICE
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%} {% if letter_head and not no_letterhead %}{{ _("PROFORMA") }}
{{ _("CANCELLED") }}
{{ _("Page #{0} of {1}").format(page_num, max_pages) }}
{% endif %} {%- endmacro -%}{{ add_header(0,1,doc,letter_head, no_letterhead) }}
Customer Details | INVOICE NUMBER : {{doc.name}} |
---|---|
{{ doc.customer_name }} {{ doc.address_display or '' }} |
|
Invoice Date | {{ doc.get_formatted("posting_date") or '' }} |
Order Date | {{ doc.get_formatted("po_date") or '' }} |
P.O Number | {{ doc.get_formatted("po_no") or '' }} |
Due Date | {{ doc.get_formatted("due_date") or '' }} |
Sales Person | {%- for row in doc.sales_team -%}
{{ row.sales_person }} {%- endfor -%} |
<td style="width: 15%; text-align: right;">
<!--{{ "%.2f"|format(row.rate * (1+(this_docs_vat_rate/100)) )}}-->
{% if row.item_tax_template %}
{% set item_tax = frappe.get_doc('Item Tax Template', row.item_tax_template) %}
{% set ttotal = {'val': 0} %}
{% for i in item_tax.taxes %}
{% if ttotal.update({'val': ttotal['val']+i.tax_rate}) %} {% endif %}
{% endfor %}
{% if ttotal['val']>0 %}
{% if taxable.update({'amount_origin': taxable['amount_origin']+row.amount}) %} {% endif %}
{% for i in item_tax.taxes %}
{% if taxable.update({'tax': taxable['tax']+row.amount*(i.tax_rate/100)}) %} {% endif %}
{% endfor %}
{% else %}
{% if non_taxable.update({'amount_origin': non_taxable['amount_origin']+row.amount}) %} {% endif %}
{% endif %}
{% for i in item_tax.taxes %}
{{i.tax_rate}}%
{% endfor %}
{% else %}
0.0%
{% if non_taxable.update({'amount_origin': non_taxable['amount_origin']+row.amount}) %} {% endif %}
{% endif %}
</td>
<td style="width: 24%; text-align: right;">{{
row.get_formatted("amount", doc) }}</td>
{% if discount.update({'total': discount['total']+row.discount_amount}) %} {% endif %}
</tr>
{%- endfor -%}
<TR>
<TD colspan=5 rowspan=5>
Amount in Words<br>
<B>{{ doc.base_in_words }}</B>
</TD>
<Th WIDTH=15% align=right><B>Taxable Amount</B></Th>
<Td WIDTH=15% align=right><B>{{frappe.format_value(taxable['amount_origin'], {'fieldtype': 'Currency', 'options': 'KSH'})}}</B></Td>
</tbody>
No | Item Name | Qty | Rate | Disc. | VAT | Amount |
---|---|---|---|---|---|---|
{{ row.idx }} | {{ row.description }} Batch: {{ row.batch_no }} | {{ row.qty }} | {{ "%.2f"|format(row.rate +(row.discount_amount) ) }} | {{ "%.2f"|format(row.discount_amount * row.qty)}} | ||
VAT | {{ doc.get_formatted("base_total_taxes_and_charges", doc) }} | |||||
Exempted Amount | {{frappe.format_value(non_taxable['amount_origin'], {'fieldtype': 'Currency', 'options': 'KSH'})}} | |||||
Discount | {% set disc = doc.grand_total - ((doc.additional_discount_percentage/100) * doc.grand_total) %} {{frappe.format_value(doc.discount_amount, {'fieldtype': 'Currency', 'options': 'KSH'})}} | |||||
Amount Payable | {{ doc.get_formatted("rounded_total", doc) }} |
</tbody>
</table>
Terms and Conditions |
---|
{{ doc.terms or '' }} |
From your code, I can see that ur using /
as per the followings (3 places), could u try to remove all the 3 below and test it out? Remove it, don’t just comment it out. If no error it mean any of this has no value.
Lemme do that
Not working buddy
Did u remove all the 3 lines also after u saved the print format make sure u validate the 3 lines are removed because sometimes it will revert back to the 1st save? If ur 100% sure the code is not there, make sure to do Reload
to clear the cache and try printing it out.
Alright