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 ec370668a0e..c1b76a33ce3 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 @@ -4,6 +4,46 @@ from __future__ import unicode_literals import unittest +import frappe + class TestPaymentTermsTemplate(unittest.TestCase): - pass + def tearDown(self): + frappe.delete_doc('Payment Terms Template', '_Test Payment Terms Template', force=1) + + def test_create_template(self): + template = frappe.get_doc({ + 'doctype': 'Payment Terms Template', + 'template_name': '_Test Payment Terms Template', + 'terms': [{ + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 50.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': 30 + }] + }) + + self.assertRaises(frappe.ValidationError, template.insert) + + template.append('terms', { + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 50.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': 0 + }) + + template.insert() + + def test_credit_days(self): + template = frappe.get_doc({ + 'doctype': 'Payment Terms Template', + 'template_name': '_Test Payment Terms Template', + 'terms': [{ + 'doctype': 'Payment Terms Template Detail', + 'invoice_portion': 100.00, + 'credit_days_based_on': 'Day(s) after invoice date', + 'credit_days': -30 + }] + }) + + self.assertRaises(frappe.ValidationError, template.insert) \ No newline at end of file