added the test case for the fees

This commit is contained in:
Manas Solanki 2017-08-09 19:53:03 +05:30 committed by Nabin Hait
parent d1d2633658
commit 8c88af23ef
7 changed files with 131 additions and 6 deletions

View File

@ -13,5 +13,15 @@
"doctype": "Academic Term",
"academic_year": "2014-2015",
"term_name": "_Test Academic Term 2"
},
{
"doctype": "Academic Term",
"academic_year": "2017-2018",
"term_name": "_Test AT1"
},
{
"doctype": "Academic Term",
"academic_year": "2017-2018",
"term_name": "_Test AT2"
}
]

View File

@ -1,11 +1,18 @@
[
{
"doctype": "Academic Year",
"academic_year_name": "2014-2015"
},
{
"doctype": "Academic Year",
"academic_year_name": "2015-2016"
},
{
"doctype": "Academic Year",
"academic_year_name": "2016-2017"
},
{
"doctype": "Academic Year",
"academic_year_name": "2017-2018"
}
]

View File

@ -0,0 +1,11 @@
[
{
"category_name": "Admission Fee"
},
{
"category_name": "Tuition Fee"
},
{
"category_name": "Transportation Fee"
}
]

View File

@ -0,0 +1,42 @@
[
{
"doctype": "Fee Structure",
"academic_year": "2017-2018",
"academic_term": "2017-2018 (_Test AT1)",
"components": [
{
"fees_category": "Tuition Fee",
"amount": 40000
},
{
"fees_category": "Transportation Fee",
"amount": 10000
}
],
"total_amount": 50000,
"debit_to": "_Test Receivable - _TC",
"against_income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",
"company": "_Test Company"
},
{
"doctype": "Fee Structure",
"academic_year": "2017-2018",
"academic_term": "2017-2018 (_Test AT2)",
"components": [
{
"fees_category": "Tuition Fee",
"amount": 40000
},
{
"fees_category": "Transportation Fee",
"amount": 10000
}
],
"total_amount": 50000,
"debit_to": "_Test Receivable - _TC",
"against_income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",
"company": "_Test Company"
}
]

View File

@ -12,6 +12,8 @@ from frappe.utils.csvutils import getlink
from erpnext.accounts.utils import get_account_currency
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
from erpnext.accounts.general_ledger import delete_gl_entries
class Fees(AccountsController):
def set_indicator(self):
@ -44,6 +46,10 @@ class Fees(AccountsController):
submit_doc=True, use_dummy_message=True)
frappe.msgprint(_("Payment request {0} created").format(getlink("Payment Request", pr.name)))
def on_cancel(self):
delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
# frappe.db.set(self, 'status', 'Cancelled')
def make_gl_entries(self):
if not self.grand_total:

View File

@ -9,14 +9,22 @@ QUnit.test("test: Fees", function (assert) {
assert.expect(1);
frappe.run_serially('Fees', [
// insert a new Fees
() => frappe.tests.make([
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
return frappe.tests.make('Fees', [
{student: 'STUD00001'},
{due_date: frappe.datetime.get_today()},
{fee_structure: 'FS00001'}
]);
},
() => {
assert.equal(cur_frm.doc.grand_total===cur_frm.doc.outstanding_amount);
},
() => frappe.timeout(0.3),
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => done()
]);

View File

@ -5,8 +5,49 @@ from __future__ import unicode_literals
import frappe
import unittest
from frappe.utils import nowdate
from frappe.utils.make_random import get_random
# test_records = frappe.get_test_records('Fees')
class TestFees(unittest.TestCase):
pass
def test_fees(self):
student = get_random("Student")
fee = frappe.new_doc("Fees")
fee.posting_date = nowdate()
fee.due_date = nowdate()
fee.student = student
fee.debit_to = "_Test Receivable - _TC"
fee.against_income_account = "Sales - _TC"
fee.cost_center = "_Test Cost Center - _TC"
fee.company = "_Test Company"
fee.extend("components", [
{
"fees_category": "Tuition Fee",
"amount": 40000
},
{
"fees_category": "Transportation Fee",
"amount": 10000
}])
fee.save()
fee.submit()
gl_entries = frappe.db.sql("""
select account, posting_date, party_type, party, cost_center, fiscal_year, voucher_type,
voucher_no, against_voucher_type, against_voucher, cost_center, company, credit, debit
from `tabGL Entry` where voucher_type=%s and voucher_no=%s""", ("Fees", fee.name), as_dict=True)
if gl_entries[0].account == "_Test Receivable - _TC":
self.assertEquals(gl_entries[0].debit, 50000)
self.assertEquals(gl_entries[0].credit, 0)
self.assertEquals(gl_entries[1].debit, 0)
self.assertEquals(gl_entries[1].credit, 50000)
else:
self.assertEquals(gl_entries[0].credit, 50000)
self.assertEquals(gl_entries[0].debit, 0)
self.assertEquals(gl_entries[1].credit, 0)
self.assertEquals(gl_entries[1].debit, 50000)