diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue
index e48efa3c..5a003508 100644
--- a/frontend/src/pages/Deal.vue
+++ b/frontend/src/pages/Deal.vue
@@ -7,12 +7,12 @@
updateAssignedAgent(option.email)"
placeholder="Deal owner"
>
-
+
@@ -20,17 +20,16 @@
-
@@ -254,7 +253,8 @@
:debounce="500"
class="form-control"
/>
-
@@ -272,7 +272,11 @@
/>
@@ -335,7 +339,7 @@ const props = defineProps({
})
const deal = createResource({
- url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
+ url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
params: { name: props.dealId },
cache: ['deal', props.dealId],
auto: true,
@@ -347,7 +351,7 @@ function updateDeal(fieldname, value) {
createResource({
url: 'frappe.client.set_value',
params: {
- doctype: 'CRM Lead',
+ doctype: 'CRM Deal',
name: props.dealId,
fieldname,
value,
@@ -377,7 +381,7 @@ function updateDeal(fieldname, value) {
const breadcrumbs = computed(() => {
let items = [{ label: 'Deals', route: { name: 'Deals' } }]
items.push({
- label: organization.value.name,
+ label: organization.value?.name,
route: { name: 'Deal', params: { dealId: deal.data.name } },
})
return items
@@ -435,12 +439,16 @@ const detailSections = computed(() => {
type: 'read_only',
name: 'website',
value: organization.value?.website,
- tooltip: 'It is a read only field, value is fetched from organization',
+ tooltip:
+ 'It is a read only field, value is fetched from organization',
},
{
label: 'Amount',
- type: 'number',
+ type: 'read_only',
name: 'annual_revenue',
+ value: organization.value?.annual_revenue,
+ tooltip:
+ 'It is a read only field, value is fetched from organization',
},
{
label: 'Close date',
@@ -514,8 +522,8 @@ const organization = computed(() => {
})
function updateAssignedAgent(email) {
- deal.data.lead_owner = email
- updateDeal('lead_owner', email)
+ deal.data.deal_owner = email
+ updateDeal('deal_owner', email)
}
diff --git a/frontend/src/pages/Lead.vue b/frontend/src/pages/Lead.vue
index 144e4d31..082db241 100644
--- a/frontend/src/pages/Lead.vue
+++ b/frontend/src/pages/Lead.vue
@@ -336,6 +336,7 @@ import {
Avatar,
Tabs,
Breadcrumbs,
+ call,
} from 'frappe-ui'
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
@@ -372,9 +373,6 @@ function updateLead(fieldname, value) {
},
auto: true,
onSuccess: () => {
- if (fieldname == 'is_deal') {
- router.push({ name: 'Deal', params: { dealId: lead.data.name } })
- }
lead.reload()
contacts.reload()
reload.value = true
@@ -565,8 +563,23 @@ const organization = computed(() => {
function convertToDeal() {
lead.data.status = 'Qualified'
- lead.data.is_deal = 1
- updateLead('is_deal', 1)
+ lead.data.converted = 1
+ createDeal(lead.data)
+}
+
+async function createDeal(lead) {
+ let d = await call('frappe.client.insert', {
+ doc: {
+ doctype: 'CRM Deal',
+ organization: lead.organization,
+ email: lead.email,
+ mobile_no: lead.mobile_no,
+ lead: lead.name,
+ },
+ })
+ if (d.name) {
+ router.push({ name: 'Deal', params: { dealId: d.name } })
+ }
}
function updateAssignedAgent(email) {