test: check payment order creation against payment entry
This commit is contained in:
		
							parent
							
								
									e1889d0c1b
								
							
						
					
					
						commit
						d9e4883392
					
				| @ -91,28 +91,31 @@ class TestBankTransaction(unittest.TestCase): | ||||
| 		self.assertEqual(frappe.db.get_value("Bank Transaction", bank_transaction.name, "unallocated_amount"), 0) | ||||
| 		self.assertTrue(frappe.db.get_value("Sales Invoice Payment", dict(parent=payment.name), "clearance_date") is not None) | ||||
| 
 | ||||
| def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"): | ||||
| 	try: | ||||
| 		frappe.get_doc({ | ||||
| 			"doctype": "Bank", | ||||
| 			"bank_name":bank_name, | ||||
| 		}).insert() | ||||
| 	except frappe.DuplicateEntryError: | ||||
| 		pass | ||||
| 
 | ||||
| 	try: | ||||
| 		doc = frappe.get_doc({ | ||||
| 			"doctype": "Bank Account", | ||||
| 			"account_name":"Checking Account", | ||||
| 			"bank": bank_name, | ||||
| 			"account": account_name | ||||
| 		}).insert() | ||||
| 	except frappe.DuplicateEntryError: | ||||
| 		pass | ||||
| 
 | ||||
| def add_transactions(): | ||||
| 	if frappe.flags.test_bank_transactions_created: | ||||
| 		return | ||||
| 
 | ||||
| 	frappe.set_user("Administrator") | ||||
| 	try: | ||||
| 		frappe.get_doc({ | ||||
| 			"doctype": "Bank", | ||||
| 			"bank_name":"Citi Bank", | ||||
| 		}).insert() | ||||
| 	except frappe.DuplicateEntryError: | ||||
| 		pass | ||||
| 
 | ||||
| 	try: | ||||
| 		frappe.get_doc({ | ||||
| 			"doctype": "Bank Account", | ||||
| 			"account_name":"Checking Account", | ||||
| 			"bank": "Citi Bank", | ||||
| 			"account": "_Test Bank - _TC" | ||||
| 		}).insert() | ||||
| 	except frappe.DuplicateEntryError: | ||||
| 		pass | ||||
| 	create_bank_account() | ||||
| 
 | ||||
| 	doc = frappe.get_doc({ | ||||
| 		"doctype": "Bank Transaction", | ||||
|  | ||||
| @ -5,6 +5,39 @@ from __future__ import unicode_literals | ||||
| 
 | ||||
| import frappe | ||||
| import unittest | ||||
| from frappe.utils import getdate | ||||
| from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account | ||||
| from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, InvalidPaymentEntry, make_payment_order | ||||
| from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice, make_purchase_invoice_against_cost_center | ||||
| 
 | ||||
| class TestPaymentOrder(unittest.TestCase): | ||||
| 	pass | ||||
| 	def setUp(self): | ||||
| 		create_bank_account() | ||||
| 
 | ||||
| 	def test_payment_order_creation_against_payment_entry(self): | ||||
| 		purchase_invoice = make_purchase_invoice() | ||||
| 		payment_entry = get_payment_entry("Purchase Invoice", purchase_invoice.name, bank_account="_Test Bank - _TC") | ||||
| 		payment_entry.reference_no = "_Test_Payment_Order" | ||||
| 		payment_entry.reference_date = getdate() | ||||
| 		payment_entry.party_bank_account = "Checking Account - Citi Bank" | ||||
| 		payment_entry.insert() | ||||
| 		payment_entry.submit() | ||||
| 
 | ||||
| 		doc = create_payment_order_against_payment_entry(payment_entry, "Payment Entry") | ||||
| 		reference_doc = doc.get("references")[0] | ||||
| 		self.assertEquals(reference_doc.reference_name, payment_entry.name) | ||||
| 		self.assertEquals(reference_doc.reference_doctype, "Payment Entry") | ||||
| 		self.assertEquals(reference_doc.supplier, "_Test Supplier") | ||||
| 		self.assertEquals(reference_doc.amount, 250) | ||||
| 
 | ||||
| def create_payment_order_against_payment_entry(ref_doc, order_type): | ||||
| 	payment_order = frappe.get_doc(dict( | ||||
| 		doctype="Payment Order", | ||||
| 		company="_Test Company", | ||||
| 		payment_order_type=order_type, | ||||
| 		company_bank_account="Checking Account - Citi Bank" | ||||
| 	)) | ||||
| 	doc = make_payment_order(ref_doc.name, payment_order) | ||||
| 	doc.save() | ||||
| 	doc.submit() | ||||
| 	return doc | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user