mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
fix: test cases
This commit is contained in:
@@ -344,6 +344,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
pi = frappe.copy_doc(test_records[0])
|
pi = frappe.copy_doc(test_records[0])
|
||||||
pi.disable_rounded_total = 1
|
pi.disable_rounded_total = 1
|
||||||
|
pi.allocate_advances_automatically = 0
|
||||||
pi.append("advances", {
|
pi.append("advances", {
|
||||||
"reference_type": "Journal Entry",
|
"reference_type": "Journal Entry",
|
||||||
"reference_name": jv.name,
|
"reference_name": jv.name,
|
||||||
@@ -383,6 +384,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
pi = frappe.copy_doc(test_records[0])
|
pi = frappe.copy_doc(test_records[0])
|
||||||
pi.disable_rounded_total = 1
|
pi.disable_rounded_total = 1
|
||||||
|
pi.allocate_advances_automatically = 0
|
||||||
pi.append("advances", {
|
pi.append("advances", {
|
||||||
"reference_type": "Journal Entry",
|
"reference_type": "Journal Entry",
|
||||||
"reference_name": jv.name,
|
"reference_name": jv.name,
|
||||||
@@ -551,7 +553,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
sum(credit) as credit, debit_in_account_currency, credit_in_account_currency
|
sum(credit) as credit, debit_in_account_currency, credit_in_account_currency
|
||||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||||
group by account, voucher_no order by account asc;""", pi.name, as_dict=1)
|
group by account, voucher_no order by account asc;""", pi.name, as_dict=1)
|
||||||
|
|
||||||
stock_in_hand_account = get_inventory_account(pi.company, pi.get("items")[0].warehouse)
|
stock_in_hand_account = get_inventory_account(pi.company, pi.get("items")[0].warehouse)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
|
|
||||||
@@ -634,7 +636,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Serial No", pi.get("items")[0].rejected_serial_no,
|
self.assertEqual(frappe.db.get_value("Serial No", pi.get("items")[0].rejected_serial_no,
|
||||||
"warehouse"), pi.get("items")[0].rejected_warehouse)
|
"warehouse"), pi.get("items")[0].rejected_warehouse)
|
||||||
|
|
||||||
def test_outstanding_amount_after_advance_jv_cancelation(self):
|
def test_outstanding_amount_after_advance_jv_cancelation(self):
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry \
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry \
|
||||||
import test_records as jv_test_records
|
import test_records as jv_test_records
|
||||||
@@ -656,14 +658,14 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
pi.submit()
|
||||||
pi.load_from_db()
|
pi.load_from_db()
|
||||||
|
|
||||||
#check outstanding after advance allocation
|
#check outstanding after advance allocation
|
||||||
self.assertEqual(flt(pi.outstanding_amount), flt(pi.rounded_total - pi.total_advance))
|
self.assertEqual(flt(pi.outstanding_amount), flt(pi.rounded_total - pi.total_advance))
|
||||||
|
|
||||||
#added to avoid Document has been modified exception
|
#added to avoid Document has been modified exception
|
||||||
jv = frappe.get_doc("Journal Entry", jv.name)
|
jv = frappe.get_doc("Journal Entry", jv.name)
|
||||||
jv.cancel()
|
jv.cancel()
|
||||||
|
|
||||||
pi.load_from_db()
|
pi.load_from_db()
|
||||||
#check outstanding after advance cancellation
|
#check outstanding after advance cancellation
|
||||||
self.assertEqual(flt(pi.outstanding_amount), flt(pi.rounded_total + pi.total_advance))
|
self.assertEqual(flt(pi.outstanding_amount), flt(pi.rounded_total + pi.total_advance))
|
||||||
@@ -722,7 +724,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
shipping_rule = create_shipping_rule(shipping_rule_type = "Buying", shipping_rule_name = "Shipping Rule - Purchase Invoice Test")
|
shipping_rule = create_shipping_rule(shipping_rule_type = "Buying", shipping_rule_name = "Shipping Rule - Purchase Invoice Test")
|
||||||
|
|
||||||
pi = frappe.copy_doc(test_records[0])
|
pi = frappe.copy_doc(test_records[0])
|
||||||
|
|
||||||
pi.shipping_rule = shipping_rule.name
|
pi.shipping_rule = shipping_rule.name
|
||||||
pi.insert()
|
pi.insert()
|
||||||
|
|
||||||
@@ -740,14 +742,14 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
"tax_amount": shipping_amount,
|
"tax_amount": shipping_amount,
|
||||||
"description": shipping_rule.name,
|
"description": shipping_rule.name,
|
||||||
"add_deduct_tax": "Add"
|
"add_deduct_tax": "Add"
|
||||||
}
|
}
|
||||||
pi.append("taxes", shipping_charge)
|
pi.append("taxes", shipping_charge)
|
||||||
pi.save()
|
pi.save()
|
||||||
|
|
||||||
self.assertEqual(pi.net_total, 1250)
|
self.assertEqual(pi.net_total, 1250)
|
||||||
|
|
||||||
self.assertEqual(pi.total_taxes_and_charges, 462.3)
|
self.assertEqual(pi.total_taxes_and_charges, 462.3)
|
||||||
self.assertEqual(pi.grand_total, 1712.3)
|
self.assertEqual(pi.grand_total, 1712.3)
|
||||||
|
|
||||||
def test_make_pi_without_terms(self):
|
def test_make_pi_without_terms(self):
|
||||||
pi = make_purchase_invoice(do_not_save=1)
|
pi = make_purchase_invoice(do_not_save=1)
|
||||||
|
|||||||
@@ -855,6 +855,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
si = frappe.copy_doc(test_records[0])
|
si = frappe.copy_doc(test_records[0])
|
||||||
|
si.allocate_advances_automatically = 0
|
||||||
si.append("advances", {
|
si.append("advances", {
|
||||||
"doctype": "Sales Invoice Advance",
|
"doctype": "Sales Invoice Advance",
|
||||||
"reference_type": "Journal Entry",
|
"reference_type": "Journal Entry",
|
||||||
|
|||||||
Reference in New Issue
Block a user