more tests

This commit is contained in:
tunde 2017-09-22 17:20:33 +01:00
parent 3aec78b472
commit cf42d1db5c
6 changed files with 98 additions and 3 deletions

View File

@ -9,12 +9,12 @@ import frappe
class TestPaymentTermsTemplate(unittest.TestCase):
def tearDown(self):
frappe.delete_doc('Payment Terms Template', '_Test Payment Terms Template', force=1)
frappe.delete_doc('Payment Terms Template', '_Test Payment Terms Template For Test', force=1)
def test_create_template(self):
template = frappe.get_doc({
'doctype': 'Payment Terms Template',
'template_name': '_Test Payment Terms Template',
'template_name': '_Test Payment Terms Template For Test',
'terms': [{
'doctype': 'Payment Terms Template Detail',
'invoice_portion': 50.00,
@ -37,7 +37,7 @@ class TestPaymentTermsTemplate(unittest.TestCase):
def test_credit_days(self):
template = frappe.get_doc({
'doctype': 'Payment Terms Template',
'template_name': '_Test Payment Terms Template',
'template_name': '_Test Payment Terms Template For Test',
'terms': [{
'doctype': 'Payment Terms Template Detail',
'invoice_portion': 100.00,

View File

@ -636,6 +636,15 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEquals(expected_gl_entries[i][2], gle.credit)
self.assertEquals(getdate(expected_gl_entries[i][3]), getdate(gle.due_date))
def test_make_pi_without_terms(self):
pi = make_purchase_invoice(do_not_save=1)
self.assertFalse(pi.get('payment_schedule'))
pi.insert()
self.assertTrue(pi.get('payment_schedule'))
def unlink_payment_on_cancel_of_invoice(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")

View File

@ -1354,6 +1354,14 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(expected_values[gle.account][1], gle.debit)
self.assertEquals(expected_values[gle.account][2], gle.credit)
def test_create_invoice_without_terms(self):
si = create_sales_invoice(do_not_save=1)
self.assertFalse(si.get('payment_schedule'))
si.insert()
self.assertTrue(si.get('payment_schedule'))
def create_sales_invoice(**args):
si = frappe.new_doc("Sales Invoice")
args = frappe._dict(args)

View File

@ -152,6 +152,35 @@ class TestPurchaseOrder(unittest.TestCase):
"group_same_items": 1
}).insert(ignore_permissions=True)
def test_make_po_without_terms(self):
po = create_purchase_order(do_not_save=1)
self.assertFalse(po.get('payment_schedule'))
po.insert()
self.assertTrue(po.get('payment_schedule'))
def test_terms_does_not_copy(self):
po = create_purchase_order()
self.assertTrue(po.get('payment_schedule'))
pi = make_purchase_invoice(po.name)
self.assertFalse(pi.get('payment_schedule'))
def test_terms_copied(self):
po = create_purchase_order(do_not_save=1)
po.payment_terms_template = '_Test Payment Term Template'
po.insert()
po.submit()
self.assertTrue(po.get('payment_schedule'))
pi = make_purchase_invoice(po.name)
pi.insert()
self.assertTrue(pi.get('payment_schedule'))
def get_same_items():
return [

View File

@ -8,7 +8,29 @@ import unittest
test_dependencies = ["Product Bundle"]
class TestQuotation(unittest.TestCase):
def test_make_quotation_without_terms(self):
quotation = make_quotation(do_not_save=1)
self.assertFalse(quotation.get('payment_schedule'))
quotation.insert()
self.assertTrue(quotation.payment_schedule)
def test_make_sales_order_terms_not_copied(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
quotation = frappe.copy_doc(test_records[0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
quotation.submit()
sales_order = make_sales_order(quotation.name)
self.assertFalse(sales_order.get('payment_schedule'))
def test_make_sales_order(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order

View File

@ -532,6 +532,33 @@ class TestSalesOrder(unittest.TestCase):
self.assertEquals(new_so.get("items")[0].rate, flt((price_list_rate*25)/100 + price_list_rate))
def test_terms_auto_added(self):
so = make_sales_order(do_not_save=1)
self.assertFalse(so.get('payment_schedule'))
so.insert()
self.assertTrue(so.get('payment_schedule'))
def test_terms_not_copied(self):
so = make_sales_order()
self.assertTrue(so.get('payment_schedule'))
si = make_sales_invoice(so.name)
self.assertFalse(si.get('payment_schedule'))
def test_terms_copied(self):
so = make_sales_order(do_not_copy=1)
so.payment_terms_template = '_Test Payment Term Template'
so.insert()
self.assertTrue(so.get('payment_schedule'))
si = make_sales_invoice(so.name)
si.insert()
self.assertTrue(si.get('payment_schedule'))
def make_sales_order(**args):
so = frappe.new_doc("Sales Order")
args = frappe._dict(args)