Sales Invoice status changes overnight

I have some sales invoices created through subscriptions, the sales invoices which are Overdue and Partly Paid, I want to show Partly Paid status with them. At the time we create payment it shows Partly Paid but overnight it changes to Overdue. I have changed the status directly in the tabSales Invoice table in the database and changed the following code in the following files but the status is still changing overnight from Partly Paid to Overdue.

The following changes I have made in the following files

sales_invoice.py in set_status method

if self.is_internal_transfer():
self.status = “Internal Transfer”
elif 0 < outstanding_amount < total:
self.status = “Partly Paid” # brought Partly Paid before Overdue
elif is_overdue(self, total):
self.status = “Overdue”

fix_invoice_statuses.py in method get_correct_status

if 0 < outstanding_amount < total:
status = “Partly Paid” # brought Partly Paid before Overdue
elif is_overdue(doc, total):
status = “Overdue”
elif outstanding_amount > 0 and getdate(doc.due_date) >= TODAY:
status = “Unpaid”

How I can get Partly Paid status with the invoices which are Partly Paid and Overdue? instead of Overdue?

the overdue status is set by a daily background job in hooks.py

login to your erpnext system, in awesome bar input scheduled Job Type, go to the list view and filter by method name update_invoice_status, goto the form view, check the Stopped, then save

2 Likes

Thank you for your answer. I have changed the following line in the file accounts_controller.py to solve my issue.

from
is_overdue = total_amount - invoice.outstanding_amount < payable_amount

to
is_overdue = (invoice.outstanding_amount == total_amount) & (invoice.due_date < today)

1 Like