Credit note naming series

Continuing the discussion from CREDIT NOTE - Negative Value / Credit Note Issued:

Continuing this old thread…

This has become something long frustrating and resentment task for me to generate proper series for credit note.

As I know there is no separate document called sales return. A return (or credit note) in ERPNext is effectively a Sales Invoice which is reversed. So in this case the base document remains the same ,ie, Sales Invoice.

To differentiate a return from a regular invoice what i did is…

Created a separate print format & naming series for Returns

Below image is Credit note issued which is carrying sales invoice number. A credit note which is carrying invoice number in Credit Note number is redundant as long as we reference number

issued_crn

Also I have return invoice which is carrying unique credit note number which I created is showing in negative value which is perfectly fine

Having said above what I require is I need my unique credit note number (CRN/22-23) should appear in Credit Note Issued format

As per my knowledge the best practice would be to show a return as a return and not a sales invoice.

Have I fundamentally misunderstood something here?
Is there any less volatile proceedure the resolve this

@NCP
@JayRam

Any help on the please

Thanks
Rakshitha

Hi @rakshitha,

What do you want, naming series for credit not or print format for credit note?

In the last discussion, first, create a naming series for credit notes. when you create a single credit note or credit note made from a sales invoice then select a series.

For print format:
If only one print format maintains for an applied condition like if credit note then set credit, not series otherwise invoice number is shown.

Thank You!

1 Like

Dear Nihantra,

This is Credit note issued which carrying invoice number as you see (SINV-22-00061)

creditnote issued

This is return which has negative value carrying our unique number (SRET-22-00017)

Now all I need is to swap these numbers i.e. SRET-22-00017 into Issued credit note ( in first image)

This is for your reference…

(Credit Note Issued)

Return

Thanks
Rakshitha

Hi @rakshitha,

You say that SRET series will convert to the SINV.
am I right?

Hi Nihantra,yes you are right

Hi @rakshitha,

I don’t think it will automatically convert to a regular series.

But in a case when creating a return invoice then you take a regular series and it’s the only option.

Thanks.

Do you have any clue on html customization

Thanks
Rakshitha

Hi @rakshitha,

Can you explain to me what you want and what customization you need in print format?
if applicable, so I can suggest you.

Here is the credit note issued against sales invoice

The credit note number has to be changed in issued credit note which automatically fetching new invoice series.

All i need is eliminate the number showing SINV-22-00061 and replace SRET-22-

Here is the custom html script i have used

<center><h3>CREDIT NOTE</h3><center>
<table width=100% height=100% border=1>
   <tr>
       <td width=30% rowspan=3>
                          <b><left><h8>Aerotek Design </b></h8><left></b> <br>
               <left><h8>Unit:3, Plot NO-27A </h8><left>
           <br>
           <left><h8>Peenya, Bengaluru-56005</h8><left>
               <br
               <left><h8>Phone: +91 (0) 80 41626362 </h8><left> <br>
                <left><h8>accounts@aerotekgroup.com</h8><left> <br>
                               <h8>GSTIN:29AJHPB8312L1Z2</h8><left>
       
       <td width=25%>
           Credit Note No.<br>
           <b>{{ doc.name }}</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
   </tr>
       <td width=25%>
           Delivery Note<br>
	   <b>&nbsp;</b>
       </td>
       <td width=25%>
       	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Reference No.<br>
	   <b>{{ doc.old_invoice_no }}</b>
       </td>
       <td width=25%>
           Dated<br>
	   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
       </td>
     <tr>
       <td width=10% rowspan=3>
           <i>Customer</i><br>
           <strong>{{ doc.customer_name or "" }}</strong><br>
	   {{ doc.address_display or "" }}
   
      	   <b>&nbsp;</b>
       </td>
   </tr>
   <tr>
       <td width=25%>
           Dispatch Document No.<br>
	  
       <td width=25%>
           Dated<br>
	   
    <tr>
       <td width=25%>
        	          
       <td width=25%>
           Shipping Address<br>
           {{ doc.shipping_address_name or " " }}
	   <b>&nbsp;</b>
      
       </td>
   </tr>
</table>
<TABLE cellpadding=0 cellspacing=0 width=100% border=1>
<TR>
<tbody>
	<tr>
		<th>SR</th>
		<th>DISCRIPTION</th>
		<th>HSN/ASN</th>
		<th class="text-right">QTY</th>
		<th class="text-right">UNIT RATE</th>
		<th class="text-right">TAXABLE AMOUNT</th>
	</tr>
	{% set cgst_rate = [] -%}
	 {% set sgst_rate = [] -%}
	 {% set igst_rate = [] -%}
	{% set cgst_account_head = [] -%}
	 {% set sgst_account_head = [] -%}
	 {% set igst_account_head = [] -%}
	{% set tot_cgst_amount = [] %}
	{% set tot_sgst_amount = [] %}
	{% set grand_total = {"qty":0.0, "amount":0.0, "cgst_amt":0.0, "sgst_amt":0.0, "igst_amt":0.0} %}
	{%- for row in doc.taxes -%}
  	   {% if 'CGST' in row.account_head -%}
		{% set _ = cgst_account_head.append(row.account_head) %}
		{% set _ = cgst_rate.append(row.rate) %}
	   {%- endif -%}
	   {% if 'SGST' in row.account_head -%}
		 {% set _ = sgst_account_head.append(row.account_head) %}
		{% set _ = sgst_rate.append(row.rate) %}	
	   {%- endif -%}
	   {% if 'IGST' in row.account_head -%}
		{% set _ = igst_account_head.append(row.account_head) %}
		{% set _ = igst_rate.append(row.rate) %}
	   {%- endif -%}
	{%- endfor -%}
{%- for row in doc.items -%}
	<tr>
	        {% set cgst_amt = [] -%}
	 	 {% set sgst_amt = [] -%}
		 {% set igst_amt = [] -%}
		 {% set it_cgst_rate = [] -%}
	 	 {% set it_sgst_rate = [] -%}
		 {% set it_igst_rate = [] -%}
		 {% set rate_found_item = 0 -%}
	      {%- set item_record = frappe.get_doc("Item", row.item_code) -%}
		{% for item_tax in item_record.taxes %}
		  {% if item_tax.tax_type == igst_account_head[0] %}	
			{% set _ = it_igst_rate.append(item_tax.tax_rate) %}
			{% set _ = igst_amt.append(row.amount * it_igst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
		{% if item_tax.tax_type == sgst_account_head[0] %}
			
			{% set _ = it_sgst_rate.append(item_tax.tax_rate) %}
			{% set _ = sgst_amt.append(row.amount * it_sgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}	
		{% if item_tax.tax_type == cgst_account_head[0] %}
			{% set _ = it_cgst_rate.append(item_tax.tax_rate) %}
			{% set _ = cgst_amt.append(row.amount * it_cgst_rate[0] / 100) -%}
			{% set rate_found_item = 1 -%}
		{% endif %}		
	{% endfor %}	
  	{% if rate_found_item == 0 %}

		{% if cgst_rate[0] -%}
		   {% set _ = cgst_amt.append((row.amount * cgst_rate[0])/100) -%}
		   {% set _= it_cgst_rate.append(cgst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
		{% if sgst_rate[0] -%}
		   {% set _ = sgst_amt.append((row.amount * sgst_rate[0])/100) -%}
		   {% set _= it_sgst_rate.append(sgst_rate[0]) -%}
		   
	       	{%- endif -%}
		{% if igst_rate[0] -%}
		   {% set _ = igst_amt.append((row.amount * igst_rate[0])/100) -%}
		   {% set _= it_igst_rate.append(igst_rate[0]) -%}
		   {% set rate_found_inv = 1 -%}
	       	{%- endif -%}
	{% endif %}
	{% if not it_cgst_rate[0] %}
		{% set _ = it_cgst_rate.append(0) %}
		{% set _ = cgst_amt.append(0) %}
	{% endif %}
	{% if not it_sgst_rate[0] %}
		{% set _ = it_sgst_rate.append(0) %}
		{% set _ = sgst_amt.append(0) %}
	{% endif %}
	{% if not it_igst_rate[0] %}
		{% set _ = it_igst_rate.append(0) %}
		{% set _ = igst_amt.append(0) %}
	{% endif %}
	{% set temp_cgst_amt = grand_total["cgst_amt"] + cgst_amt[0] %}
	{% set temp_sgst_amt = grand_total["sgst_amt"] + sgst_amt[0] %}
	{% set temp_igst_amt = grand_total["igst_amt"] + igst_amt[0] %}
	{% set temp_qty = grand_total["qty"] + row.qty %}
	{% set temp_amount = grand_total["amount"] + row.amount %}
	{% set check = grand_total.update({"qty": temp_qty, "amount": temp_amount, "cgst_amt":temp_cgst_amt, "sgst_amt":temp_sgst_amt, "igst_amt":temp_igst_amt}) %}
	
		<td style="width: 5%;"><font size = "1">{{ row.idx }}</font></td>
		<td style="width: 25%;"><font size = "1">
			{% if row.item_code != row.item_name -%}
			<b>{{ row.item_code}}</b><br>
			{%- endif %}
                            {{ row.item_name }}
		</font></td>
		<td style="width: 10%;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
		<td style="width: 10%; text-align: left;"><font size = "1">{{ row.qty }}<br><small>{{ row.uom or row.stock_uom }}</small> </font></td>
		<td style="width: 10%; text-align: right;"><font size = "1">{{
			row.get_formatted("rate", doc) }}</font></td>
		<td style=display:none;"width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(cgst_amt[0])  }}<br><small>{{
			it_cgst_rate[0] }}%</small></font></td>
		<td style=display:none;"width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(sgst_amt[0])  }}<br><small>{{
			it_sgst_rate[0] }}%</small></font></td>
		<td style=display:none;"width: 11%; text-align: right;"><font size = "1">{{
			"₹ {:,.2f}".format(igst_amt[0])  }}<br><small>{{
			it_igst_rate[0] }}%</small></font></td>
		<td style="width: 11%; text-align: right;"><font size = "1">{{
			row.get_formatted("amount", doc) }}</font></td>
</tr>
{% set trate = "" %}
{% endfor %}

<!-- {% set loop = 10 - doc.items|length  %}
{% for i in range(loop) %}
<TR>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
	<TD>&nbsp;</TD>
</TR>
{% endfor %} -->
</TABLE>

<TABLE cellpadding=0 cellspacing=0 width=100% border=1>
<TR>
        <TD rowspan=3 >
            Amount in Words<br>
            <B>{{ doc.base_in_words }}</B>
        </TD>
	<TD WIDTH=13% align=right><B>SUB TOTAL</B></TD>
	<TD WIDTH=20% align=right>
<TR>
    

    <TD align=right><B>CGST - 9%</B></TD>
    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["cgst_amt"])  }}</B></TD>

</TR>

<TR>

    <TD align=right><B>SGST - 9%</B></TD>
    <TD WIDTH=20% align=right><B>{{ "₹ {:,.2f}".format(grand_total["sgst_amt"])  }}</B></TD>

</TR>

<TR>

	<TD WIDTH=60% align=right><B><TD align=right><B>TOTAL</B></TD>
	<TD WIDTH=60% align=right><B>{{ doc.get_formatted("grand_total", doc) }}</B></TD>
</TR>
<TR>
	<TD colspan=2 height=120>We declare that this invoice shows the actual price of the goods described and that all particulars
are true and correct.

<Br>
<br>


</TD>

	<TD align=right colspan=3>
            <B>for {{ doc.company }}</B>
            <div style="position: relative; height: 100px; border: solid; border-style: none;">
               <div style="position: absolute; height: 10px; border: solid; bottom: 0; right: 0;  left: 0; border-style: none;">
                  Authorised Signatory
               </div>
            </div>
        </TD>
</TR>
</TABLE>

Hi @rakshitha,

For only print format purposes only.

Please set your condition according to.
If a credit note is Issued then set series like:

{{doc.name | replace("SINV-22-","SRET-22-")}}

OR

{{doc.name | replace("SINV","SRET")}}

It will show only in a print format not show in doctype view.

There is not an option to automatically change the series.
If know it’s going to the credit note issued stage. If you can select manually then your all problem will be solved.

Thanks.