Added the Confirm Estimate reponse in the UI.

This commit is contained in:
rocketdebris 2025-12-22 16:35:03 -05:00
parent 20a3517d7b
commit d30fc77527
3 changed files with 70 additions and 21 deletions

View file

@ -161,6 +161,30 @@ def send_estimate_email(estimate_name):
print(f"DEBUG: Error in send_estimate_email: {str(e)}")
return build_error_response(str(e), 500)
@frappe.whitelist()
def manual_response(name, response):
"""Update the response for an estimate in the UI."""
print("DEBUG: RESPONSE_RECEIVED:", name, response)
try:
if not frappe.db.exists("Quotation", name):
raise Exception("Estimate not found.")
estimate = frappe.get_doc("Quotation", name)
if estimate.docstatus != 1:
raise Exception("Estimate must be submitted to update response.")
accepted = True if response == "Accepted" else False
new_status = "Estimate Accepted" if accepted else "Lost"
estimate.custom_response = response
estimate.custom_current_status = new_status
estimate.status = "Ordered" if accepted else "Closed"
estimate.flags.ignore_permissions = True
print("DEBUG: Updating estimate with response:", response, "and status:", new_status)
estimate.save()
except Exception as e:
return e
@frappe.whitelist(allow_guest=True)
def update_response(name, response):
"""Update the response for a given estimate."""

View file

@ -11,6 +11,7 @@ const FRAPPE_GET_ESTIMATES_METHOD = "custom_ui.api.db.estimates.get_estimate_tab
const FRAPPE_GET_ESTIMATE_BY_ADDRESS_METHOD = "custom_ui.api.db.estimates.get_estimate_from_address";
const FRAPPE_SEND_ESTIMATE_EMAIL_METHOD = "custom_ui.api.db.estimates.send_estimate_email";
const FRAPPE_LOCK_ESTIMATE_METHOD = "custom_ui.api.db.estimates.lock_estimate";
const FRAPPE_ESTIMATE_UPDATE_RESPONSE_METHOD = "custom_ui.api.db.estimates.manual_response";
// Job methods
const FRAPPE_GET_JOBS_METHOD = "custom_ui.api.db.get_jobs";
const FRAPPE_UPSERT_JOB_METHOD = "custom_ui.api.db.jobs.upsert_job";
@ -203,6 +204,10 @@ class Api {
return await this.request(FRAPPE_LOCK_ESTIMATE_METHOD, { estimateName });
}
static async updateEstimateResponse(estimateName, response) {
return await this.request(FRAPPE_ESTIMATE_UPDATE_RESPONSE_METHOD, {name: estimateName, response});
}
// ============================================================================
// JOB / PROJECT METHODS
// ============================================================================

View file

@ -2,6 +2,7 @@
<div class="estimate-page">
<h2>{{ isNew ? 'Create Estimate' : 'View Estimate' }}</h2>
<div v-if="!isNew && estimate" class="page-actions">
<Button label="Estimate Response" @click="showResponseModal = true" />
<Button label="Duplicate" icon="pi pi-copy" @click="duplicateEstimate" />
</div>
@ -113,6 +114,18 @@
</div>
</div>
<!-- Manual Response Modal -->
<Modal
:visible="showResponseModal"
@update:visible="showResponseModal = $event"
@close="showResponseModal = false"
:options="{ showActions: false }"
>
<template #title>Set Response</template>
<Select v-model="estimateResponse" :options="responses" placeholder="Select Response"/>
<Button label="Submit" @click="submitResponse"/>
</Modal>
<!-- Address Search Modal -->
<Modal
:visible="showAddressModal"
@ -260,14 +273,17 @@ const formData = reactive({
const selectedAddress = ref(null);
const selectedContact = ref(null);
const estimateResponse = ref(null);
const contacts = ref([]);
const contactOptions = ref([]);
const quotationItems = ref([]);
const selectedItems = ref([]);
const responses = ref(["Accepted", "Rejected"]);
const showAddressModal = ref(false);
const showAddItemModal = ref(false);
const showConfirmationModal = ref(false);
const showResponseModal = ref(false);
const addressSearchResults = ref([]);
const itemSearchTerm = ref("");
@ -395,6 +411,10 @@ const saveDraft = async () => {
}
};
const submitResponse = () => {
Api.updateEstimateResponse(estimate.value.name, estimateResponse.value, false);
}
const duplicateEstimate = () => {
if (!estimate.value) return;