Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion propms/auto_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def makeInvoiceSchedule(
doctype="Lease Invoice Schedule",
parent=name,
parentfield="lease_invoice_schedule",
parenttype="lease",
parenttype="Lease",
date_to_invoice=date_to_invoice,
schedule_start_date=date,
lease_item=item,
Expand Down
6 changes: 5 additions & 1 deletion propms/lease_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def makeInvoice(
doc.submit()

return doc
except frappe.ValidationError:
raise
except Exception as e:
app_error_log(frappe.session.user, str(e))

Expand Down Expand Up @@ -147,7 +149,6 @@ def leaseInvoiceAutoCreate():
"invoice_number",
"sales_order_number",
"parent",
"parent",
"invoice_item_group",
"lease_item",
"paid_by",
Expand Down Expand Up @@ -260,6 +261,8 @@ def leaseInvoiceAutoCreate():
prev_currency = invoice_item.currency
row_num += 1 # increment by 1
# Create the last invoice
if not invoice_item:
return
res = makeInvoice(
invoice_item.date_to_invoice,
invoice_item.paid_by,
Expand All @@ -285,6 +288,7 @@ def leaseInvoiceAutoCreate():
frappe.msgprint(_("Lease Invoice generated with number: {0}").format(res.name))

except Exception as e:
frappe.log_error(frappe.get_traceback(), "Lease Invoice Auto Create failed")
app_error_log(frappe.session.user, str(e))


Expand Down
6 changes: 3 additions & 3 deletions propms/lease_invoice_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def make_lease_invoice_schedule():
# Only check start_date, ignore end_date for inclusion
)
)
lease_names = [row[0] for row in frappe.db.sql(query.get_sql())]
lease_names = [row[0] for row in query.run()]

for lease_name in lease_names:
try:
Expand Down Expand Up @@ -145,8 +145,8 @@ def make_lease_invoice_schedule():
# Move to first day of next period
invoice_date = add_days(invoice_period_end, 1)

frappe.msgprint(_(f"Completed invoice schedule for Lease: {lease.name}"))
frappe.msgprint(_("Completed invoice schedule for Lease: {0}").format(lease.name))

except Exception as e:
frappe.msgprint(_(f"Error in {lease_name}. Check app error log."))
frappe.msgprint(_("Error in {0}. Check app error log.").format(lease_name))
app_error_log(frappe.session.user, f"{lease_name}: {str(e)}")
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,16 @@
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"fieldtype": "Data",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "naming_series",
"label": "Naming Series",
"options": "DC-.YYYY.-",
"length": 0,
"no_copy": 0,
"permlevel": 0,
Expand All @@ -239,9 +240,9 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"set_only_once": 1,
"translatable": 0,
"unique": 0
}
Expand All @@ -257,7 +258,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-12-24 19:42:26.306039",
"modified": "2026-08-27 12:00:00.000000",
"modified_by": "Administrator",
"module": "Property Management Solution",
"name": "Daily Checklist",
Expand Down
26 changes: 24 additions & 2 deletions propms/property_management_solution/doctype/lease/lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def on_submit(self):
app_error_log(frappe.session.user, str(e))

def validate(self):
self.set_lease_status()
self.validate_days_to_invoice_in_advance()
try:
properties = self.get_all_properties()
Expand Down Expand Up @@ -119,7 +120,28 @@ def validate(self):
raise
except Exception as e:
app_error_log(frappe.session.user, str(e))
self.set_lease_status()

def validate_days_to_invoice_in_advance(self):
"""Prevent changing 'Days to Invoice in Advance' once invoices have been generated."""
if not self.is_new() and self.has_value_changed("days_to_invoice_in_advance"):
has_generated_invoices = any(
row.invoice_number or row.sales_order_number for row in (self.lease_invoice_schedule or [])
)
if not has_generated_invoices:
has_generated_invoices = frappe.db.exists(
"Lease Invoice Schedule",
{
"parent": self.name,
"invoice_number": ["is", "set"],
},
)
if has_generated_invoices:
frappe.throw(
_(
"Cannot change 'Days to Invoice in Advance' after invoices have been generated for this Lease."
),
title=_("Field Read Only"),
)

def validate_days_to_invoice_in_advance(self):
"""Prevent changing 'Days to Invoice in Advance' once invoices have been generated."""
Expand Down Expand Up @@ -153,7 +175,7 @@ def set_lease_status(self):
All other statuses are considered manual and are not overwritten.
"""

if self.lease_status not in get_system_controlled_statuses():
if self.lease_status and self.lease_status not in get_system_controlled_statuses():
return

status = get_status_for_lease(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,28 @@
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"fieldtype": "Data",
"hidden": 1,
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "naming_series",
"label": "Naming Series",
"options": "OA-.YYYY.-",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"set_only_once": 1,
"translatable": 0,
"unique": 0
},
Expand Down Expand Up @@ -222,7 +223,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-01-16 15:54:32.839686",
"modified": "2026-08-27 12:00:00.000000",
"modified_by": "Administrator",
"module": "Property Management Solution",
"name": "Outsourcing Attendance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ frappe.treeview_settings["Property"] = {
],

fields: [
{ fieldtype: "Data", fieldname: "property_name", label: __("New Property Name"), reqd: true },
{ fieldtype: "Data", fieldname: "name1", label: __("New Property Name"), reqd: true },
{
fieldtype: "Check",
fieldname: "is_group",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@
},
{
"fieldname": "naming_series",
"fieldtype": "Data",
"label": "naming_series",
"fieldtype": "Select",
"hidden": 0,
"label": "Naming Series",
"options": "SA-.YYYY.-",
"print_hide": 1,
"read_only": 1
"reqd": 1,
"set_only_once": 1
}
],
"icon": "octicon octicon-clippy",
"is_submittable": 1,
"modified": "2019-12-05 16:49:29.347921",
"modified": "2026-08-27 12:00:00.000000",
"modified_by": "Administrator",
"module": "Property Management Solution",
"name": "Security Attendance",
Expand Down Expand Up @@ -99,4 +102,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}
Loading
Loading