Skip to content

Commit

Permalink
Merge pull request #181 from RitvikSardana/develop-ritvik-fees-sales-…
Browse files Browse the repository at this point in the history
…invoice

feat: Replace Fees Doctype with Sales Invoice
  • Loading branch information
RitvikSardana authored Jan 25, 2024
2 parents 6306ed3 + 615b5c9 commit e7af91a
Show file tree
Hide file tree
Showing 38 changed files with 1,089 additions and 555 deletions.
2 changes: 1 addition & 1 deletion education/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "15.0.0"
__version__ = "15.1.0"
54 changes: 54 additions & 0 deletions education/education/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,57 @@ def get_instructors(student_group):
return frappe.get_all(
"Student Group Instructor", {"parent": student_group}, pluck="instructor"
)


@frappe.whitelist()
def get_student_invoices(student):
student_sales_invoices = []

sales_invoice_list = frappe.db.get_list(
"Sales Invoice",
filters={"student": student, "status": ["in", ["Paid", "Unpaid"]]},
fields=["name", "status", "student", "due_date", "fee_schedule", "grand_total"],
)

for si in sales_invoice_list:
student_program_invoice_status = {}
student_program_invoice_status["status"] = si.status
student_program_invoice_status["program"] = get_program_from_fee_schedule(
si.fee_schedule
)
student_program_invoice_status["amount"] = si.grand_total

if si.status == "Paid":
student_program_invoice_status[
"payment_date"
] = get_posting_date_from_payment_entry_against_sales_invoice(si.name)
student_program_invoice_status["due_date"] = ""
else:
student_program_invoice_status["due_date"] = si.due_date
student_program_invoice_status["payment_date"] = ""

student_sales_invoices.append(student_program_invoice_status)

return student_sales_invoices


def get_posting_date_from_payment_entry_against_sales_invoice(sales_invoice):
payment_entry = frappe.qb.DocType("Payment Entry")
payment_entry_reference = frappe.qb.DocType("Payment Entry Reference")
q = (
frappe.qb.from_(payment_entry)
.inner_join(payment_entry_reference)
.on(payment_entry.name == payment_entry_reference.parent)
.select(payment_entry.posting_date)
.where(payment_entry_reference.reference_name == sales_invoice)
).run(as_dict=1)
payment_date = q[0].get("posting_date")
return payment_date


def get_program_from_fee_schedule(fee_schedule):
# fee_schedule = "EDU-FSH-2024-00023"
program = frappe.db.get_value(
"Fee Schedule", filters={"name": fee_schedule}, fieldname=["program"]
)
return program
45 changes: 43 additions & 2 deletions education/education/doctype/academic_term/academic_term.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,49 @@
"show_dashboard": 1
}
],
"links": [],
"modified": "2023-02-14 13:13:40.419268",
"links": [
{
"group": "Student",
"link_doctype": "Student Applicant",
"link_fieldname": "academic_term"
},
{
"group": "Student",
"link_doctype": "Student Group",
"link_fieldname": "academic_term"
},
{
"group": "Student",
"link_doctype": "Student Log",
"link_fieldname": "academic_term"
},
{
"group": "Fee",
"link_doctype": "Fee Structure",
"link_fieldname": "academic_term"
},
{
"group": "Fee",
"link_doctype": "Fee Schedule",
"link_fieldname": "academic_term"
},
{
"group": "Program",
"link_doctype": "Program Enrollment",
"link_fieldname": "academic_term"
},
{
"group": "Assessment",
"link_doctype": "Assessment Plan",
"link_fieldname": "academic_term"
},
{
"group": "Assessment",
"link_doctype": "Assessment Result",
"link_fieldname": "academic_term"
}
],
"modified": "2024-01-25 11:11:16.432849",
"modified_by": "Administrator",
"module": "Education",
"name": "Academic Term",
Expand Down

This file was deleted.

55 changes: 53 additions & 2 deletions education/education/doctype/academic_year/academic_year.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,59 @@
"show_dashboard": 1
}
],
"links": [],
"modified": "2023-10-30 16:34:17.354467",
"links": [
{
"group": "Student",
"link_doctype": "Student Admission",
"link_fieldname": "academic_year"
},
{
"group": "Student",
"link_doctype": "Student Applicant",
"link_fieldname": "academic_year"
},
{
"group": "Student",
"link_doctype": "Student Group",
"link_fieldname": "academic_year"
},
{
"group": "Student",
"link_doctype": "Student Log",
"link_fieldname": "academic_year"
},
{
"group": "Academic Term and Program",
"link_doctype": "Academic Term",
"link_fieldname": "academic_year"
},
{
"group": "Academic Term and Program",
"link_doctype": "Program Enrollment",
"link_fieldname": "academic_year"
},
{
"group": "Assessment",
"link_doctype": "Assessment Plan",
"link_fieldname": "academic_year"
},
{
"group": "Assessment",
"link_doctype": "Assessment Result",
"link_fieldname": "academic_year"
},
{
"group": "Fee",
"link_doctype": "Fee Schedule",
"link_fieldname": "academic_year"
},
{
"group": "Fee",
"link_doctype": "Fee Structure",
"link_fieldname": "academic_year"
}
],
"modified": "2024-01-25 11:14:11.648233",
"modified_by": "Administrator",
"module": "Education",
"name": "Academic Year",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"validate_course",
"academic_term_reqd",
"user_creation_skip",
"auto_submit_sales_invoice",
"section_break_7",
"instructor_created_by"
],
Expand Down Expand Up @@ -76,11 +77,18 @@
"fieldname": "user_creation_skip",
"fieldtype": "Check",
"label": "Skip User creation for new Student"
},
{
"default": "0",
"description": "By default, the Sales Invoice Created will be in Draft Mode. If enabled, the Sales Invoice will be submitted once created.",
"fieldname": "auto_submit_sales_invoice",
"fieldtype": "Check",
"label": "Submit Sales Invoice from Program Enrollment / Fee Schedule"
}
],
"issingle": 1,
"links": [],
"modified": "2022-12-12 15:20:54.983137",
"modified": "2024-01-24 14:43:09.520597",
"modified_by": "Administrator",
"module": "Education",
"name": "Education Settings",
Expand Down Expand Up @@ -115,7 +123,6 @@
}
],
"quick_entry": 1,
"restrict_to_domain": "",
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
Expand Down
Loading

0 comments on commit e7af91a

Please sign in to comment.