diff --git a/custom_ui/events/jobs.py b/custom_ui/events/jobs.py index de0d9ff..c8cb80e 100644 --- a/custom_ui/events/jobs.py +++ b/custom_ui/events/jobs.py @@ -81,6 +81,13 @@ def before_save(doc, method): def after_save(doc, method): print("DEBUG: After Save Triggered for Project:", doc.name) + if doc.ready_to_schedule: + service_apt_ready_to_schedule = frappe.get_value("Service Address 2", doc.service_appointment, "ready_to_schedule") + if not service_apt_ready_to_schedule: + print("DEBUG: Project is ready to schedule, setting Service Appointment to ready to schedule.") + service_apt_doc = frappe.get_doc("Service Address 2", doc.service_appointment) + service_apt_doc.ready_to_schedule = 1 + service_apt_doc.save(ignore_permissions=True) if doc.project_template == "SNW Install": print("DEBUG: Project template is SNW Install, updating Address Job Status based on Project status") status_mapping = { diff --git a/custom_ui/events/payments.py b/custom_ui/events/payments.py index f603fca..f4eb2a5 100644 --- a/custom_ui/events/payments.py +++ b/custom_ui/events/payments.py @@ -9,7 +9,7 @@ def on_submit(doc, method): if so_ref: so_doc = frappe.get_doc("Sales Order", so_ref.reference_name) if so_doc.requires_half_payment: - is_paid = doc.custom_halfdown_amount <= doc.advance_paid or doc.advance_paid >= so_doc.grand_total / 2 + is_paid = so_doc.custom_halfdown_amount <= so_doc.advance_paid or so_doc.advance_paid >= so_doc.grand_total / 2 if is_paid and not so_doc.custom_halfdown_is_paid: print("DEBUG: Sales Order requires half payment and it has not been marked as paid, marking it as paid now.") so_doc.custom_halfdown_is_paid = 1 diff --git a/custom_ui/events/sales_order.py b/custom_ui/events/sales_order.py index ed51bba..c2ef402 100644 --- a/custom_ui/events/sales_order.py +++ b/custom_ui/events/sales_order.py @@ -151,7 +151,9 @@ def on_update_after_submit(doc, method): project_is_scheduable = frappe.get_value("Project", doc.project, "ready_to_schedule") if not project_is_scheduable: print("DEBUG: Half-down payment made, setting Project to ready to schedule.") - frappe.set_value("Project", doc.project, "ready_to_schedule", 1) + project_doc = frappe.get_doc("Project", doc.project) + project_doc.ready_to_schedule = 1 + project_doc.save() diff --git a/custom_ui/hooks.py b/custom_ui/hooks.py index 6cfcf77..ec8f716 100644 --- a/custom_ui/hooks.py +++ b/custom_ui/hooks.py @@ -204,6 +204,9 @@ doc_events = { "before_save": "custom_ui.events.service_appointment.before_save", "after_insert": "custom_ui.events.service_appointment.after_insert", "on_update": "custom_ui.events.service_appointment.on_update" + }, + "Payment Entry": { + "on_submit": "custom_ui.events.payments.on_submit" } } diff --git a/custom_ui/services/stripe_service.py b/custom_ui/services/stripe_service.py index ed3d2c7..6120af3 100644 --- a/custom_ui/services/stripe_service.py +++ b/custom_ui/services/stripe_service.py @@ -54,8 +54,8 @@ class StripeService: "company": company, "payment_type": "advance" if for_advance_payment else "full" }, - success_url=f"{get_url()}/payment-success?session_id={{CHECKOUT_SESSION_ID}}", - cancel_url=f"{get_url()}/payment-cancelled", + success_url=f"{get_url()}/payment_success?session_id={{CHECKOUT_SESSION_ID}}", + cancel_url=f"{get_url()}/payment_cancelled", ) return session diff --git a/custom_ui/www/cancelled_payment.html b/custom_ui/www/cancelled_payment.html deleted file mode 100644 index 8ada12e..0000000 --- a/custom_ui/www/cancelled_payment.html +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "templates/web.html" %} -{% block page_content %} -
Payment cancelled.
-{% endblock %} diff --git a/custom_ui/www/payment_cancelled.html b/custom_ui/www/payment_cancelled.html new file mode 100644 index 0000000..4fbec21 --- /dev/null +++ b/custom_ui/www/payment_cancelled.html @@ -0,0 +1,141 @@ + + + + + +No charges have been made to your account. If you cancelled by mistake or need assistance, please try again or contact support.
+The remaining balance will be invoiced once the project is complete.
+We're here to help! Contact us if you need assistance.
+Thank you for your payment!
-{% endblock %} diff --git a/frontend/src/components/calendar/jobs/SNWProjectCalendar.vue b/frontend/src/components/calendar/jobs/SNWProjectCalendar.vue index 978ca0c..f339930 100644 --- a/frontend/src/components/calendar/jobs/SNWProjectCalendar.vue +++ b/frontend/src/components/calendar/jobs/SNWProjectCalendar.vue @@ -17,6 +17,12 @@ {{ weekDisplayText }}