mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
rewrite Supplier test cases
This commit is contained in:
34
erpnext/accounts/doctype/payment_term/test_records.json
Normal file
34
erpnext/accounts/doctype/payment_term/test_records.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"doctype":"Payment Term",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"payment_term_name":"_Test N30",
|
||||||
|
"description":"_Test Net 30 Days",
|
||||||
|
"invoice_portion":50,
|
||||||
|
"credit_days":30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Term",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"payment_term_name":"_Test COD",
|
||||||
|
"description":"_Test Cash on Delivery",
|
||||||
|
"invoice_portion":50,
|
||||||
|
"credit_days":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Term",
|
||||||
|
"due_date_based_on":"Month(s) after the end of the invoice month",
|
||||||
|
"payment_term_name":"_Test EONM",
|
||||||
|
"description":"_Test End of Next Month",
|
||||||
|
"invoice_portion":100,
|
||||||
|
"credit_months":1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Term",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"payment_term_name":"_Test N30 1",
|
||||||
|
"description":"_Test Net 30 Days",
|
||||||
|
"invoice_portion":100,
|
||||||
|
"credit_days":30
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template",
|
||||||
|
"terms":[
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template Detail",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"idx":1,
|
||||||
|
"description":"Cash on Delivery",
|
||||||
|
"invoice_portion":50,
|
||||||
|
"credit_days":0,
|
||||||
|
"credit_months":0,
|
||||||
|
"payment_term":"_Test COD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template Detail",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"idx":2,
|
||||||
|
"description":"Net 30 Days ",
|
||||||
|
"invoice_portion":50,
|
||||||
|
"credit_days":30,
|
||||||
|
"credit_months":0,
|
||||||
|
"payment_term":"_Test N30"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template_name":"_Test Payment Term Template"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template",
|
||||||
|
"terms":[
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template Detail",
|
||||||
|
"due_date_based_on":"Month(s) after the end of the invoice month",
|
||||||
|
"idx":1,
|
||||||
|
"description":"_Test End of Next Months",
|
||||||
|
"invoice_portion":100,
|
||||||
|
"credit_days":0,
|
||||||
|
"credit_months":1,
|
||||||
|
"payment_term":"_Test EONM"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template_name":"_Test Payment Term Template 1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template",
|
||||||
|
"terms":[
|
||||||
|
{
|
||||||
|
"doctype":"Payment Terms Template Detail",
|
||||||
|
"due_date_based_on":"Day(s) after invoice date",
|
||||||
|
"idx":1,
|
||||||
|
"description":"_Test Net Within 30 days",
|
||||||
|
"invoice_portion":100,
|
||||||
|
"credit_days":30,
|
||||||
|
"credit_months":0,
|
||||||
|
"payment_term":"_Test N30 1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template_name":"_Test Payment Term Template 3"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"doctype": "Supplier",
|
||||||
|
"supplier_name": "_Test Supplier With Template 1",
|
||||||
|
"supplier_type": "_Test Supplier Type",
|
||||||
|
"payment_terms": "_Test Payment Term Template 3"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Supplier",
|
"doctype": "Supplier",
|
||||||
"supplier_name": "_Test Supplier P",
|
"supplier_name": "_Test Supplier P",
|
||||||
|
|||||||
@@ -5,13 +5,59 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe, unittest
|
import frappe, unittest
|
||||||
from erpnext.accounts.party import get_due_date
|
from erpnext.accounts.party import get_due_date
|
||||||
from erpnext.exceptions import PartyFrozen, PartyDisabled
|
from erpnext.exceptions import PartyDisabled
|
||||||
from frappe.test_runner import make_test_records
|
from frappe.test_runner import make_test_records
|
||||||
|
from frappe.utils import add_days, add_months, get_last_day
|
||||||
|
|
||||||
|
test_dependencies = ['Payment Term', 'Payment Terms Template']
|
||||||
test_records = frappe.get_test_records('Supplier')
|
test_records = frappe.get_test_records('Supplier')
|
||||||
|
|
||||||
|
|
||||||
class TestSupplier(unittest.TestCase):
|
class TestSupplier(unittest.TestCase):
|
||||||
|
def test_supplier_default_payment_terms(self):
|
||||||
|
# Payment Term based on Days after invoice date
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 3")
|
||||||
|
|
||||||
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
|
self.assertEqual(due_date, "2016-02-21")
|
||||||
|
|
||||||
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
|
self.assertEqual(due_date, "2017-02-21")
|
||||||
|
|
||||||
|
# Payment Term based on last day of month
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 1")
|
||||||
|
|
||||||
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
|
self.assertEqual(due_date, "2016-02-29")
|
||||||
|
|
||||||
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
|
self.assertEqual(due_date, "2017-02-28")
|
||||||
|
|
||||||
|
frappe.db.set_value("Supplier", "_Test Supplier With Template 1", "payment_terms", "")
|
||||||
|
|
||||||
|
# Set credit limit for the supplier type instead of supplier and evaluate the due date
|
||||||
|
# frappe.db.set_value("Supplier Type", "_Test Supplier Type", "credit_days_based_on",
|
||||||
|
# "Fixed Days")
|
||||||
|
# frappe.db.set_value("Supplier Type", "_Test Supplier Type", "credit_days", 10)
|
||||||
|
#
|
||||||
|
# due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier", "_Test Company")
|
||||||
|
# self.assertEqual(due_date, "2016-02-01")
|
||||||
|
#
|
||||||
|
# # Set credit limit for the supplier type instead of supplier and evaluate the due date
|
||||||
|
# # based on Last day of next month
|
||||||
|
# frappe.db.set_value("Supplier", "_Test Supplier Type", "credit_days", 0)
|
||||||
|
# frappe.db.set_value("Supplier Type", "_Test Supplier Type", "credit_days_based_on",
|
||||||
|
# "Last Day of the Next Month")
|
||||||
|
#
|
||||||
|
# # Leap year
|
||||||
|
# due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier", "_Test Company")
|
||||||
|
# self.assertEqual(due_date, "2016-02-29")
|
||||||
|
# # Non Leap year
|
||||||
|
# due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier", "_Test Company")
|
||||||
|
# self.assertEqual(due_date, "2017-02-28")
|
||||||
|
|
||||||
def test_supplier_disabled(self):
|
def test_supplier_disabled(self):
|
||||||
make_test_records("Item")
|
make_test_records("Item")
|
||||||
|
|
||||||
|
|||||||
23
erpnext/setup/doctype/supplier_type/test_supplier_type.js
Normal file
23
erpnext/setup/doctype/supplier_type/test_supplier_type.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
// rename this file from _test_[name] to test_[name] to activate
|
||||||
|
// and remove above this line
|
||||||
|
|
||||||
|
QUnit.test("test: Supplier Type", function (assert) {
|
||||||
|
let done = assert.async();
|
||||||
|
|
||||||
|
// number of asserts
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
// insert a new Supplier Type
|
||||||
|
() => frappe.tests.make('Supplier Type', [
|
||||||
|
// values to be set
|
||||||
|
{key: 'value'}
|
||||||
|
]),
|
||||||
|
() => {
|
||||||
|
assert.equal(cur_frm.doc.key, 'value');
|
||||||
|
},
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user