mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 13:39:18 +00:00
fix: add tests for set_status
This commit is contained in:
@@ -1042,7 +1042,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
elif outstanding_amount > 0 and due_date >= nowdate:
|
elif outstanding_amount > 0 and due_date >= nowdate:
|
||||||
self.status = "Unpaid"
|
self.status = "Unpaid"
|
||||||
#Check if outstanding amount is 0 due to debit note issued against invoice
|
#Check if outstanding amount is 0 due to debit note issued against invoice
|
||||||
elif outstanding_amount <= 0 and self.is_return == 0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
|
elif outstanding_amount <= 0 and self.is_return == 0 and frappe.db.get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
|
||||||
self.status = "Debit Note Issued"
|
self.status = "Debit Note Issued"
|
||||||
elif self.is_return == 1:
|
elif self.is_return == 1:
|
||||||
self.status = "Return"
|
self.status = "Return"
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pe.submit()
|
pe.submit()
|
||||||
|
|
||||||
pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
|
pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
|
||||||
|
pi_doc.load_from_db()
|
||||||
|
self.assertTrue(pi_doc.status, "Paid")
|
||||||
|
|
||||||
self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
|
self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
|
||||||
unlink_payment_on_cancel_of_invoice()
|
unlink_payment_on_cancel_of_invoice()
|
||||||
@@ -203,7 +205,9 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
pi.submit()
|
||||||
|
pi.load_from_db()
|
||||||
|
|
||||||
|
self.assertTrue(pi.status, "Unpaid")
|
||||||
self.check_gle_for_pi(pi.name)
|
self.check_gle_for_pi(pi.name)
|
||||||
|
|
||||||
def check_gle_for_pi(self, pi):
|
def check_gle_for_pi(self, pi):
|
||||||
@@ -234,6 +238,9 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
pi = frappe.copy_doc(test_records[0])
|
pi = frappe.copy_doc(test_records[0])
|
||||||
pi.insert()
|
pi.insert()
|
||||||
|
pi.load_from_db()
|
||||||
|
|
||||||
|
self.assertTrue(pi.status, "Draft")
|
||||||
pi.naming_series = 'TEST-'
|
pi.naming_series = 'TEST-'
|
||||||
|
|
||||||
self.assertRaises(frappe.CannotChangeConstantError, pi.save)
|
self.assertRaises(frappe.CannotChangeConstantError, pi.save)
|
||||||
@@ -248,6 +255,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi.get("taxes").pop(1)
|
pi.get("taxes").pop(1)
|
||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
pi.submit()
|
||||||
|
pi.load_from_db()
|
||||||
|
self.assertTrue(pi.status, "Unpaid")
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||||
@@ -599,6 +608,11 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
# return entry
|
# return entry
|
||||||
pi1 = make_purchase_invoice(is_return=1, return_against=pi.name, qty=-2, rate=50, update_stock=1)
|
pi1 = make_purchase_invoice(is_return=1, return_against=pi.name, qty=-2, rate=50, update_stock=1)
|
||||||
|
|
||||||
|
pi.load_from_db()
|
||||||
|
self.assertTrue(pi.status, "Debit Note Issued")
|
||||||
|
pi1.load_from_db()
|
||||||
|
self.assertTrue(pi1.status, "Return")
|
||||||
|
|
||||||
actual_qty_2 = get_qty_after_transaction()
|
actual_qty_2 = get_qty_after_transaction()
|
||||||
self.assertEqual(actual_qty_1 - 2, actual_qty_2)
|
self.assertEqual(actual_qty_1 - 2, actual_qty_2)
|
||||||
|
|
||||||
@@ -771,6 +785,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import get_outstanding_amount
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import get_outstanding_amount
|
||||||
|
|
||||||
pi = make_purchase_invoice(item_code = "_Test Item", qty = (5 * -1), rate=500, is_return = 1)
|
pi = make_purchase_invoice(item_code = "_Test Item", qty = (5 * -1), rate=500, is_return = 1)
|
||||||
|
pi.load_from_db()
|
||||||
|
self.assertTrue(pi.status, "Return")
|
||||||
|
|
||||||
outstanding_amount = get_outstanding_amount(pi.doctype,
|
outstanding_amount = get_outstanding_amount(pi.doctype,
|
||||||
pi.name, "Creditors - _TC", pi.supplier, "Supplier")
|
pi.name, "Creditors - _TC", pi.supplier, "Supplier")
|
||||||
|
|||||||
Reference in New Issue
Block a user