diff --git a/changemakers/fixtures/custom_html_block.json b/changemakers/fixtures/custom_html_block.json index 61a6cc0..fa5a2fe 100644 --- a/changemakers/fixtures/custom_html_block.json +++ b/changemakers/fixtures/custom_html_block.json @@ -5,6 +5,7 @@ "html": "Open PWA", "modified": "2023-06-09 15:38:21.813843", "name": "Open PWA Button", + "private": 0, "roles": [], "script": null, "style": ".btn {\n background-color: aquamarine;\n padding: 10px 20px;\n text-decoration: none;\n color: darkslategrey;\n font-weight: 600;\n border-radius: 6px;\n}" diff --git a/changemakers/fixtures/payment_type.json b/changemakers/fixtures/payment_type.json new file mode 100644 index 0000000..b89a010 --- /dev/null +++ b/changemakers/fixtures/payment_type.json @@ -0,0 +1,23 @@ +[ + { + "description": "Medicine", + "docstatus": 0, + "doctype": "Payment Type", + "modified": "2023-10-17 09:21:16.075071", + "name": "Medicine" + }, + { + "description": "Testing", + "docstatus": 0, + "doctype": "Payment Type", + "modified": "2023-10-17 09:21:47.261596", + "name": "Testing" + }, + { + "description": "Consultation", + "docstatus": 0, + "doctype": "Payment Type", + "modified": "2023-10-17 09:22:17.794554", + "name": "Consultation" + } +] \ No newline at end of file diff --git a/changemakers/frappe_changemakers/doctype/case/case.py b/changemakers/frappe_changemakers/doctype/case/case.py index f3b3ad1..e0a083f 100644 --- a/changemakers/frappe_changemakers/doctype/case/case.py +++ b/changemakers/frappe_changemakers/doctype/case/case.py @@ -4,12 +4,26 @@ import frappe from frappe.model.document import Document - class Case(Document): - def before_save(self): - self.set_created_by() + def before_save(self): + self.set_created_by() + self.calculate_total_amount() + + def validate(self): + self.validate_total_amount() + + 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(self): + total_amount = 0 + for row in self.get("payment_details"): + total_amount += row.amount + self.total_amount = total_amount - 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 validate_total_amount(self): + if self.total_amount: + if self.total_amount < 0: + frappe.throw("Total amount must not be less than zero.") diff --git a/changemakers/frappe_changemakers/doctype/payment_details/__init__.py b/changemakers/frappe_changemakers/doctype/payment_details/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/changemakers/frappe_changemakers/doctype/payment_details/payment_details.json b/changemakers/frappe_changemakers/doctype/payment_details/payment_details.json new file mode 100644 index 0000000..0e80291 --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_details/payment_details.json @@ -0,0 +1,50 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-10-14 12:40:57.317152", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "payment_type", + "payment_details", + "amount" + ], + "fields": [ + { + "fieldname": "payment_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Payment Type", + "options": "Payment Type", + "reqd": 1 + }, + { + "fieldname": "payment_details", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Payment Details" + }, + { + "fieldname": "amount", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Amount", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-10-15 10:12:31.178405", + "modified_by": "Administrator", + "module": "Frappe Changemakers", + "name": "Payment Details", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/changemakers/frappe_changemakers/doctype/payment_details/payment_details.py b/changemakers/frappe_changemakers/doctype/payment_details/payment_details.py new file mode 100644 index 0000000..90ab4fe --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_details/payment_details.py @@ -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 diff --git a/changemakers/frappe_changemakers/doctype/payment_type/__init__.py b/changemakers/frappe_changemakers/doctype/payment_type/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/changemakers/frappe_changemakers/doctype/payment_type/payment_type.js b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.js new file mode 100644 index 0000000..cc0a719 --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.js @@ -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) { + + // } +}); diff --git a/changemakers/frappe_changemakers/doctype/payment_type/payment_type.json b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.json new file mode 100644 index 0000000..11055f5 --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.json @@ -0,0 +1,46 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "prompt", + "creation": "2023-10-14 12:52:50.195141", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "description" + ], + "fields": [ + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-10-17 09:20:27.707412", + "modified_by": "Administrator", + "module": "Frappe Changemakers", + "name": "Payment Type", + "name_case": "Title Case", + "naming_rule": "Set by user", + "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": [] +} \ No newline at end of file diff --git a/changemakers/frappe_changemakers/doctype/payment_type/payment_type.py b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.py new file mode 100644 index 0000000..2d94620 --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_type/payment_type.py @@ -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 diff --git a/changemakers/frappe_changemakers/doctype/payment_type/test_payment_type.py b/changemakers/frappe_changemakers/doctype/payment_type/test_payment_type.py new file mode 100644 index 0000000..404eced --- /dev/null +++ b/changemakers/frappe_changemakers/doctype/payment_type/test_payment_type.py @@ -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 diff --git a/changemakers/hooks.py b/changemakers/hooks.py index cef0da7..03abb78 100644 --- a/changemakers/hooks.py +++ b/changemakers/hooks.py @@ -12,6 +12,7 @@ "Custom HTML Block", "Case Type", "State", + "Payment Type", {"dt": "Client Script", "filters": {"name": "Action: Create User Profile"}}, { "dt": "Role", @@ -32,6 +33,7 @@ ) }, }, + ] # Includes in