Merge pull request #29659 from deepeshgarg007/zero_amount_status

fix: Billing status for zero amount ref doc
This commit is contained in:
Deepesh Garg 2022-02-06 19:22:31 +05:30 committed by GitHub
commit 5d09678954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -400,6 +400,16 @@ class StatusUpdater(Document):
ref_doc = frappe.get_doc(ref_dt, ref_dn)
ref_doc.db_set("per_billed", per_billed)
# set billling status
if hasattr(ref_doc, 'billing_status'):
if ref_doc.per_billed < 0.001:
ref_doc.db_set("billing_status", "Not Billed")
elif ref_doc.per_billed > 99.999999:
ref_doc.db_set("billing_status", "Fully Billed")
else:
ref_doc.db_set("billing_status", "Partly Billed")
ref_doc.set_status(update=True)
def get_allowance_for(item_code, item_allowance=None, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"):

View File

@ -1375,6 +1375,30 @@ class TestSalesOrder(ERPNextTestCase):
automatically_fetch_payment_terms(enable=0)
def test_zero_amount_sales_order_billing_status(self):
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
so = make_sales_order(uom="Nos", do_not_save=1)
so.items[0].rate = 0
so.save()
so.submit()
self.assertEqual(so.net_total, 0)
self.assertEqual(so.billing_status, 'Not Billed')
si = create_sales_invoice(qty=10, do_not_save=1)
si.price_list = '_Test Price List'
si.items[0].rate = 0
si.items[0].price_list_rate = 0
si.items[0].sales_order = so.name
si.items[0].so_detail = so.items[0].name
si.save()
si.submit()
self.assertEqual(si.net_total, 0)
so.load_from_db()
self.assertEqual(so.billing_status, 'Fully Billed')
def automatically_fetch_payment_terms(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")
accounts_settings.automatically_fetch_payment_terms = enable