-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check payment entries for cancelled or paid invoices before sub…
…mitting (#108)
- Loading branch information
1 parent
b7adf96
commit adbca4d
Showing
2 changed files
with
86 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,50 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import frappe | ||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields | ||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter | ||
import frappe | ||
|
||
|
||
def load_customizations(): | ||
customizations_directory = Path().cwd().parent / 'apps' / 'check_run' / 'check_run' / 'check_run' / 'custom' | ||
files = list(customizations_directory.glob('**/*.json')) | ||
customizations_directory = ( | ||
Path().cwd().parent / "apps" / "check_run" / "check_run" / "check_run" / "custom" | ||
) | ||
files = list(customizations_directory.glob("**/*.json")) | ||
for file in files: | ||
customizations = json.loads(Path(file).read_text()) | ||
for field in customizations.get('custom_fields'): | ||
existing_field = frappe.get_value('Custom Field', field.get('name')) | ||
custom_field = frappe.get_doc("Custom Field", field.get('name')) if existing_field else frappe.new_doc('Custom Field') | ||
field.pop('modified') | ||
for field in customizations.get("custom_fields"): | ||
existing_field = frappe.get_value("Custom Field", field.get("name")) | ||
custom_field = ( | ||
frappe.get_doc("Custom Field", field.get("name")) | ||
if existing_field | ||
else frappe.new_doc("Custom Field") | ||
) | ||
field.pop("modified") | ||
{custom_field.set(key, value) for key, value in field.items()} | ||
custom_field.flags.ignore_permissions = True | ||
custom_field.flags.ignore_version = True | ||
custom_field.save() | ||
for prop in customizations.get('property_setters'): | ||
property_setter = frappe.get_doc({ | ||
"name": prop.get('name'), | ||
"doctype": "Property Setter", | ||
"doctype_or_field": prop.get('doctype_or_field'), | ||
"doc_type": prop.get('doc_type'), | ||
"field_name": prop.get('field_name'), | ||
"property": prop.get('property'), | ||
"value": prop.get('value'), | ||
"property_type": prop.get('property_type') | ||
}) | ||
for prop in customizations.get("property_setters"): | ||
property_setter = frappe.get_doc( | ||
{ | ||
"name": prop.get("name"), | ||
"doctype": "Property Setter", | ||
"doctype_or_field": prop.get("doctype_or_field"), | ||
"doc_type": prop.get("doc_type"), | ||
"field_name": prop.get("field_name"), | ||
"property": prop.get("property"), | ||
"value": prop.get("value"), | ||
"property_type": prop.get("property_type"), | ||
} | ||
) | ||
property_setter.flags.ignore_permissions = True | ||
property_setter.insert() | ||
|
||
|
||
def after_install(): | ||
if not frappe.db.exists('File', 'Home/Check Run'): | ||
try: | ||
if not frappe.db.exists("File", "Home/Check Run"): | ||
try: | ||
cr_folder = frappe.new_doc("File") | ||
cr_folder.update({"file_name":"Check Run", "is_folder": True, "folder":"Home"}) | ||
cr_folder.update({"file_name": "Check Run", "is_folder": True, "folder": "Home"}) | ||
cr_folder.save() | ||
except Exception as e: | ||
pass | ||
pass |