Merge pull request #29659 from deepeshgarg007/zero_amount_status
fix: Billing status for zero amount ref doc
This commit is contained in:
commit
5d09678954
@ -400,6 +400,16 @@ class StatusUpdater(Document):
|
|||||||
ref_doc = frappe.get_doc(ref_dt, ref_dn)
|
ref_doc = frappe.get_doc(ref_dt, ref_dn)
|
||||||
|
|
||||||
ref_doc.db_set("per_billed", per_billed)
|
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)
|
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"):
|
def get_allowance_for(item_code, item_allowance=None, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"):
|
||||||
|
@ -1375,6 +1375,30 @@ class TestSalesOrder(ERPNextTestCase):
|
|||||||
|
|
||||||
automatically_fetch_payment_terms(enable=0)
|
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):
|
def automatically_fetch_payment_terms(enable=1):
|
||||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
accounts_settings.automatically_fetch_payment_terms = enable
|
accounts_settings.automatically_fetch_payment_terms = enable
|
||||||
|
Loading…
Reference in New Issue
Block a user