Skip to content

Commit

Permalink
Merge pull request #133 from maniamartial/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
NagariaHussain authored Oct 17, 2023
2 parents 24f0726 + 88c1b13 commit d3da251
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 7 deletions.
1 change: 1 addition & 0 deletions changemakers/fixtures/custom_html_block.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"html": "<a class=\"btn btn-primary\" href=\"/c\" target=\"_blank\">Open PWA</a>",
"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}"
Expand Down
23 changes: 23 additions & 0 deletions changemakers/fixtures/payment_type.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
28 changes: 21 additions & 7 deletions changemakers/frappe_changemakers/doctype/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Empty file.
Original file line number Diff line number Diff line change
@@ -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": []
}
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) {

// }
});
Original file line number Diff line number Diff line change
@@ -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": []
}
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
2 changes: 2 additions & 0 deletions changemakers/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Custom HTML Block",
"Case Type",
"State",
"Payment Type",
{"dt": "Client Script", "filters": {"name": "Action: Create User Profile"}},
{
"dt": "Role",
Expand All @@ -32,6 +33,7 @@
)
},
},

]

# Includes in <head>
Expand Down

0 comments on commit d3da251

Please sign in to comment.