Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding child table payment Details #130 #133

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions changemakers/frappe_changemakers/doctype/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@
class Case(Document):
def before_save(self):
self.set_created_by()
self.calculate_total_amount()
self.validate_total_amount()
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved

def set_created_by(self):
if not self.created_by:
owner = frappe.db.get_value("User", self.owner, "full_name")
self.created_by = owner

def calculate_total_amount(doc):
total_amount = 0
for row in doc.get("payment_details"):
total_amount += row.amount
doc.total_amount = total_amount
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved


def validate_total_amount(doc):
if doc.total_amount < 0:
frappe.throw("Total amount must not be less than zero.")


Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-10-14 12:40:57.317152",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"sno",
"payment_type",
"payment_details",
"amount"
],
"fields": [
{
"fieldname": "sno",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Sno",
"reqd": 1
},
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
{
"fieldname": "payment_type",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Payment Type",
"reqd": 1
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
},
{
"fieldname": "payment_details",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Payment Details",
"reqd": 1
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
},
{
"fieldname": "amount",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Amount",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-14 13:30:04.469922",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Payment Details",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023, hussain@frappe.io and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document

class PaymentDetails(Document):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2023, hussain@frappe.io and contributors
// For license information, please see license.txt

frappe.ui.form.on('Payment Type', {
// refresh: function(frm) {

// }
});
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-10-14 12:52:50.195141",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"consultation",
"testing",
"medicine"
],
"fields": [
{
"fieldname": "consultation",
"fieldtype": "Data",
"label": "Consultation"
},
{
"fieldname": "testing",
"fieldtype": "Data",
"label": "Testing"
},
{
"fieldname": "medicine",
"fieldtype": "Data",
"label": "Medicine"
}
],
NagariaHussain marked this conversation as resolved.
Show resolved Hide resolved
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-10-14 12:52:50.195141",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Payment Type",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023, hussain@frappe.io and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document

class PaymentType(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, hussain@frappe.io and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestPaymentType(FrappeTestCase):
pass