test: use insert instead of save (#25045)
* test: use insert instead of save * test: use do_not_save
This commit is contained in:
parent
11e9ae3841
commit
4e07695a08
@ -15,12 +15,14 @@ from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profi
|
|||||||
test_dependencies = ["Item", "Cost Center"]
|
test_dependencies = ["Item", "Cost Center"]
|
||||||
|
|
||||||
class TestBankTransaction(unittest.TestCase):
|
class TestBankTransaction(unittest.TestCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
make_pos_profile()
|
make_pos_profile()
|
||||||
add_transactions()
|
add_transactions()
|
||||||
add_vouchers()
|
add_vouchers()
|
||||||
|
|
||||||
def tearDown(self):
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
for bt in frappe.get_all("Bank Transaction"):
|
for bt in frappe.get_all("Bank Transaction"):
|
||||||
doc = frappe.get_doc("Bank Transaction", bt.name)
|
doc = frappe.get_doc("Bank Transaction", bt.name)
|
||||||
doc.cancel()
|
doc.cancel()
|
||||||
@ -33,9 +35,6 @@ class TestBankTransaction(unittest.TestCase):
|
|||||||
# Delete POS Profile
|
# Delete POS Profile
|
||||||
frappe.db.sql("delete from `tabPOS Profile`")
|
frappe.db.sql("delete from `tabPOS Profile`")
|
||||||
|
|
||||||
frappe.flags.test_bank_transactions_created = False
|
|
||||||
frappe.flags.test_payments_created = False
|
|
||||||
|
|
||||||
# This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction.
|
# This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction.
|
||||||
def test_linked_payments(self):
|
def test_linked_payments(self):
|
||||||
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="Re 95282925234 FE/000002917 AT171513000281183046 Conrad Electronic"))
|
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="Re 95282925234 FE/000002917 AT171513000281183046 Conrad Electronic"))
|
||||||
@ -44,8 +43,8 @@ class TestBankTransaction(unittest.TestCase):
|
|||||||
|
|
||||||
# This test validates a simple reconciliation leading to the clearance of the bank transaction and the payment
|
# This test validates a simple reconciliation leading to the clearance of the bank transaction and the payment
|
||||||
def test_reconcile(self):
|
def test_reconcile(self):
|
||||||
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="1512567 BG/000002918 OPSKATTUZWXXX AT776000000098709837 Herr G"))
|
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="1512567 BG/000003025 OPSKATTUZWXXX AT776000000098709849 Herr G"))
|
||||||
payment = frappe.get_doc("Payment Entry", dict(party="Mr G", paid_amount=1200))
|
payment = frappe.get_doc("Payment Entry", dict(party="Mr G", paid_amount=1700))
|
||||||
vouchers = json.dumps([{
|
vouchers = json.dumps([{
|
||||||
"payment_doctype":"Payment Entry",
|
"payment_doctype":"Payment Entry",
|
||||||
"payment_name":payment.name,
|
"payment_name":payment.name,
|
||||||
@ -116,10 +115,6 @@ def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def add_transactions():
|
def add_transactions():
|
||||||
if frappe.flags.test_bank_transactions_created:
|
|
||||||
return
|
|
||||||
|
|
||||||
frappe.set_user("Administrator")
|
|
||||||
create_bank_account()
|
create_bank_account()
|
||||||
|
|
||||||
doc = frappe.get_doc({
|
doc = frappe.get_doc({
|
||||||
@ -172,14 +167,8 @@ def add_transactions():
|
|||||||
}).insert()
|
}).insert()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
|
|
||||||
frappe.flags.test_bank_transactions_created = True
|
|
||||||
|
|
||||||
def add_vouchers():
|
def add_vouchers():
|
||||||
if frappe.flags.test_payments_created:
|
|
||||||
return
|
|
||||||
|
|
||||||
frappe.set_user("Administrator")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "Supplier",
|
"doctype": "Supplier",
|
||||||
@ -272,13 +261,6 @@ def add_vouchers():
|
|||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080)
|
|
||||||
pe = get_payment_entry("Sales Invoice", si.name, bank_account="_Test Bank - _TC")
|
|
||||||
pe.reference_no = "Fayva Oct 18"
|
|
||||||
pe.reference_date = "2018-10-29"
|
|
||||||
pe.insert()
|
|
||||||
pe.submit()
|
|
||||||
|
|
||||||
mode_of_payment = frappe.get_doc({
|
mode_of_payment = frappe.get_doc({
|
||||||
"doctype": "Mode of Payment",
|
"doctype": "Mode of Payment",
|
||||||
"name": "Cash"
|
"name": "Cash"
|
||||||
@ -291,14 +273,12 @@ def add_vouchers():
|
|||||||
})
|
})
|
||||||
mode_of_payment.save()
|
mode_of_payment.save()
|
||||||
|
|
||||||
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_submit=1)
|
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_save=1)
|
||||||
si.is_pos = 1
|
si.is_pos = 1
|
||||||
si.append("payments", {
|
si.append("payments", {
|
||||||
"mode_of_payment": "Cash",
|
"mode_of_payment": "Cash",
|
||||||
"account": "_Test Bank - _TC",
|
"account": "_Test Bank - _TC",
|
||||||
"amount": 109080
|
"amount": 109080
|
||||||
})
|
})
|
||||||
si.save()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
frappe.flags.test_payments_created = True
|
|
||||||
|
Loading…
Reference in New Issue
Block a user