Skip to content

Commit

Permalink
Merge pull request #287 from RitvikSardana/invoice-outstanding
Browse files Browse the repository at this point in the history
fix: Invoice outstanding
  • Loading branch information
RitvikSardana authored Oct 11, 2024
2 parents a876675 + e2f889a commit 1634577
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 278 deletions.
9 changes: 5 additions & 4 deletions education/education/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def get_student_invoices(student):
"Sales Invoice",
filters={
"student": student,
"status": ["in", ["Paid", "Unpaid", "Overdue"]],
"status": ["in", ["Paid", "Unpaid", "Overdue","Partly Paid"]],
"docstatus": 1,
},
fields=[
Expand All @@ -673,8 +673,9 @@ def get_student_invoices(student):
"student",
"due_date",
"fee_schedule",
"grand_total",
"outstanding_amount",
"currency",
"grand_total"
],
order_by="status desc",
)
Expand All @@ -686,10 +687,10 @@ def get_student_invoices(student):
si.fee_schedule
)
symbol = get_currency_symbol(si.get("currency", "INR"))
student_program_invoice_status["amount"] = symbol + " " + str(si.grand_total)
# TODO: get currency
student_program_invoice_status["amount"] = symbol + " " + str(si.outstanding_amount)
student_program_invoice_status["invoice"] = si.name
if si.status == "Paid":
student_program_invoice_status["amount"] = symbol + " " + str(si.grand_total)
student_program_invoice_status[
"payment_date"
] = get_posting_date_from_payment_entry_against_sales_invoice(si.name)
Expand Down
8 changes: 4 additions & 4 deletions education/education/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def get_details(docname):
details = frappe.db.get_value(
"Sales Invoice", docname, ["name", "currency", "grand_total"], as_dict=1
"Sales Invoice", docname, ["name", "currency", "outstanding_amount"], as_dict=1
)
return details

Expand Down Expand Up @@ -51,11 +51,11 @@ def get_payment_options(doctype, docname, phone, currency=None):
validate_phone_number(phone_number=phone, throw=True)
details = get_details(docname)
client = get_client()
order = create_order(client, details.grand_total, details.currency)
order = create_order(client, details.outstanding_amount, details.currency)
options = {
"key_id": frappe.db.get_single_value("Education Settings", "razorpay_key"),
"name": frappe.db.get_single_value("Website Settings", "app_name"),
"description": _("Payment for {0} course").format(details["grand_total"]),
"description": _("Payment for {0} course").format(details["outstanding_amount"]),
"order_id": order["id"],
"amount": cint(order["amount"]) * 100,
"currency": order["currency"],
Expand All @@ -75,7 +75,7 @@ def create_razorpay_payment_record(args, status):
payment_record.signature = args.get("razorpay_signature", "")
payment_record.against_invoice = args.get("name", "")
payment_record.status = status
payment_record.amount = args.get("grand_total", "")
payment_record.amount = args.get("outstanding_amount", "")
if status == "Captured":
payment_record.student = args.get("id", "")
payment_record.mobile = args.get("mobile_number", "")
Expand Down
Loading

0 comments on commit 1634577

Please sign in to comment.