more tests
diff --git a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py
index c1b76a3..bf9b75a 100644
--- a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py
+++ b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py
@@ -9,12 +9,12 @@
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 @@
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,
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 83e1181..cd5b751 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -636,6 +636,15 @@
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")
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 235dec4..5e26f52 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1354,6 +1354,14 @@
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)
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 6e40b5d..b672acb 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -152,6 +152,35 @@
"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 [
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index 7fa91b5..c6a488e 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -8,7 +8,29 @@
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
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index 8f3b14a..723123e 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -532,6 +532,33 @@
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)