From 2c53932522214637b7d5a38d90c63a51f546d0f6 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 6 Nov 2023 18:25:02 +0530 Subject: [PATCH 01/17] fix: created deal doctype --- crm/fcrm/doctype/crm_deal/__init__.py | 0 crm/fcrm/doctype/crm_deal/crm_deal.js | 8 ++ crm/fcrm/doctype/crm_deal/crm_deal.json | 123 +++++++++++++++++++++ crm/fcrm/doctype/crm_deal/crm_deal.py | 9 ++ crm/fcrm/doctype/crm_deal/test_crm_deal.py | 9 ++ 5 files changed, 149 insertions(+) create mode 100644 crm/fcrm/doctype/crm_deal/__init__.py create mode 100644 crm/fcrm/doctype/crm_deal/crm_deal.js create mode 100644 crm/fcrm/doctype/crm_deal/crm_deal.json create mode 100644 crm/fcrm/doctype/crm_deal/crm_deal.py create mode 100644 crm/fcrm/doctype/crm_deal/test_crm_deal.py diff --git a/crm/fcrm/doctype/crm_deal/__init__.py b/crm/fcrm/doctype/crm_deal/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.js b/crm/fcrm/doctype/crm_deal/crm_deal.js new file mode 100644 index 000000000..1b305ae09 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal/crm_deal.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("CRM Deal", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json new file mode 100644 index 000000000..30f9e7c44 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -0,0 +1,123 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2023-11-06 17:56:25.210449", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "naming_series", + "organization", + "website", + "annual_revenue", + "column_break_afce", + "deal_owner", + "close_date", + "deal_status", + "probability", + "next_step", + "section_break_eepu", + "lead", + "column_break_bqvs" + ], + "fields": [ + { + "fieldname": "organization", + "fieldtype": "Link", + "label": "Organization", + "options": "CRM Organization" + }, + { + "fieldname": "probability", + "fieldtype": "Percent", + "label": "Probability" + }, + { + "fetch_from": "organization.annual_revenue", + "fieldname": "annual_revenue", + "fieldtype": "Int", + "label": "Annual Revenue" + }, + { + "fieldname": "column_break_afce", + "fieldtype": "Column Break" + }, + { + "fetch_from": "organization.website", + "fieldname": "website", + "fieldtype": "Data", + "label": "Website", + "options": "URL" + }, + { + "fieldname": "close_date", + "fieldtype": "Date", + "label": "Close Date" + }, + { + "fieldname": "next_step", + "fieldtype": "Data", + "label": "Next Step" + }, + { + "fieldname": "lead", + "fieldtype": "Link", + "label": "Lead", + "options": "CRM Lead" + }, + { + "fieldname": "section_break_eepu", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_bqvs", + "fieldtype": "Column Break" + }, + { + "fieldname": "deal_owner", + "fieldtype": "Link", + "label": "Deal Owner", + "options": "User" + }, + { + "default": "Qualification", + "fieldname": "deal_status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Deal Status", + "options": "Qualification\nDemo/Making\nProposal/Quotation\nNegotiation\nReady to Close\nWon\nLost", + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Naming Series", + "options": "CRM-DEAL-.YYYY.-" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-11-06 18:07:22.815164", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py new file mode 100644 index 000000000..f36b1cf9c --- /dev/null +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class CRMDeal(Document): + pass diff --git a/crm/fcrm/doctype/crm_deal/test_crm_deal.py b/crm/fcrm/doctype/crm_deal/test_crm_deal.py new file mode 100644 index 000000000..b9ecc378a --- /dev/null +++ b/crm/fcrm/doctype/crm_deal/test_crm_deal.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestCRMDeal(FrappeTestCase): + pass From 5b4cb4cd7f52ef3d423e1f99a94d460249897d3e Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 6 Nov 2023 22:01:20 +0530 Subject: [PATCH 02/17] chore: moved contactModal in modals folder --- frontend/src/components/{ => Modals}/ContactModal.vue | 0 frontend/src/pages/Contact.vue | 8 -------- frontend/src/pages/Contacts.vue | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) rename frontend/src/components/{ => Modals}/ContactModal.vue (100%) diff --git a/frontend/src/components/ContactModal.vue b/frontend/src/components/Modals/ContactModal.vue similarity index 100% rename from frontend/src/components/ContactModal.vue rename to frontend/src/components/Modals/ContactModal.vue diff --git a/frontend/src/pages/Contact.vue b/frontend/src/pages/Contact.vue index 1c19f6543..245458a40 100644 --- a/frontend/src/pages/Contact.vue +++ b/frontend/src/pages/Contact.vue @@ -174,11 +174,6 @@ - diff --git a/frontend/src/pages/Lead.vue b/frontend/src/pages/Lead.vue index 144e4d310..082db2415 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) { From 71a0b6780810ca33457cd491905d92094055d7d2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 6 Nov 2023 22:14:35 +0530 Subject: [PATCH 09/17] fix: updated leads/deals list view code --- frontend/src/pages/Deals.vue | 79 ++++++++++++++++-------------------- frontend/src/pages/Leads.vue | 2 +- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/frontend/src/pages/Deals.vue b/frontend/src/pages/Deals.vue index 9783fddc2..3edbc493c 100644 --- a/frontend/src/pages/Deals.vue +++ b/frontend/src/pages/Deals.vue @@ -28,8 +28,8 @@
- - + +
@@ -96,23 +96,20 @@ const currentView = ref({ }) function getFilter() { - return { - ...(getArgs() || {}), - is_deal: 1, - } + return getArgs() || {} } -const leads = createListResource({ +const deals = createListResource({ type: 'list', - doctype: 'CRM Lead', + doctype: 'CRM Deal', fields: [ 'name', 'organization', 'annual_revenue', - 'deal_status', + 'status', 'email', 'mobile_no', - 'lead_owner', + 'deal_owner', 'modified', ], filters: getFilter(), @@ -125,8 +122,8 @@ watch( () => getOrderBy(), (value, old_value) => { if (!value && !old_value) return - leads.orderBy = getOrderBy() || 'modified desc' - leads.reload() + deals.orderBy = getOrderBy() || 'modified desc' + deals.reload() }, { immediate: true } ) @@ -135,8 +132,8 @@ watch( storage, useDebounceFn((value, old_value) => { if (JSON.stringify([...value]) === JSON.stringify([...old_value])) return - leads.filters = getFilter() - leads.reload() + deals.filters = getFilter() + deals.reload() }, 300), { deep: true } ) @@ -154,7 +151,7 @@ const columns = [ }, { label: 'Status', - key: 'deal_status', + key: 'status', width: '10rem', }, { @@ -168,8 +165,8 @@ const columns = [ width: '11rem', }, { - label: 'Lead owner', - key: 'lead_owner', + label: 'Deal owner', + key: 'deal_owner', width: '10rem', }, { @@ -180,28 +177,28 @@ const columns = [ ] const rows = computed(() => { - if (!leads.data) return [] - return leads.data.map((lead) => { + if (!deals.data) return [] + return deals.data.map((deal) => { return { - name: lead.name, + name: deal.name, organization: { - label: lead.organization, - logo: getOrganization(lead.organization)?.organization_logo, + label: deal.organization, + logo: getOrganization(deal.organization)?.organization_logo, }, - annual_revenue: formatNumberIntoCurrency(lead.annual_revenue), - deal_status: { - label: lead.deal_status, - color: dealStatuses[lead.deal_status]?.color, + annual_revenue: formatNumberIntoCurrency(deal.annual_revenue), + status: { + label: deal.status, + color: dealStatuses[deal.status]?.color, }, - email: lead.email, - mobile_no: lead.mobile_no, - lead_owner: { - label: lead.lead_owner && getUser(lead.lead_owner).full_name, - ...(lead.lead_owner && getUser(lead.lead_owner)), + email: deal.email, + mobile_no: deal.mobile_no, + deal_owner: { + label: deal.deal_owner && getUser(deal.deal_owner).full_name, + ...(deal.deal_owner && getUser(deal.deal_owner)), }, modified: { - label: dateFormat(lead.modified, dateTooltipFormat), - timeAgo: timeAgo(lead.modified), + label: dateFormat(deal.modified, dateTooltipFormat), + timeAgo: timeAgo(deal.modified), }, } }) @@ -253,25 +250,19 @@ const viewsDropdownOptions = [ const showNewDialog = ref(false) let newDeal = reactive({ - salutation: '', - first_name: '', - last_name: '', - lead_name: '', organization: '', - deal_status: 'Qualification', + status: 'Qualification', email: '', mobile_no: '', - lead_owner: getUser().email, - is_deal: 1, - created_as_deal: 1, + deal_owner: getUser().email, }) -const createLead = createResource({ +const createDeal = createResource({ url: 'frappe.client.insert', makeParams(values) { return { doc: { - doctype: 'CRM Lead', + doctype: 'CRM Deal', ...values, }, } @@ -281,7 +272,7 @@ const createLead = createResource({ const router = useRouter() function createNewDeal(close) { - createLead + createDeal .submit(newDeal, { validate() { if (!newDeal.first_name) { diff --git a/frontend/src/pages/Leads.vue b/frontend/src/pages/Leads.vue index b0e26a1df..de1f1c28e 100644 --- a/frontend/src/pages/Leads.vue +++ b/frontend/src/pages/Leads.vue @@ -91,7 +91,7 @@ const currentView = ref({ function getFilter() { return { ...(getArgs() || {}), - is_deal: 0, + converted: 0, } } From 256a4bba254fceec269e6844f6dcb5a26f1fc5c9 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 6 Nov 2023 22:15:32 +0530 Subject: [PATCH 10/17] fix: remove unused fields in lead doctype --- crm/fcrm/doctype/crm_lead/crm_lead.json | 74 +++++++------------------ 1 file changed, 19 insertions(+), 55 deletions(-) diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.json b/crm/fcrm/doctype/crm_lead/crm_lead.json index bfe7dbbd4..8257a2e5f 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.json +++ b/crm/fcrm/doctype/crm_lead/crm_lead.json @@ -13,20 +13,15 @@ "first_name", "middle_name", "last_name", - "is_deal", - "created_as_deal", "column_break_izjs", "lead_name", "gender", - "lead_owner", - "status", "image", "column_break_lcuv", + "lead_owner", + "status", "source", - "deal_status", - "close_date", - "probability", - "next_step", + "converted", "organization_tab", "section_break_uixv", "organization", @@ -93,7 +88,7 @@ "fieldname": "status", "fieldtype": "Select", "in_list_view": 1, - "label": "Lead Status", + "label": "Status", "options": "Open\nContacted\nNurture\nQualified\nUnqualified\nJunk", "reqd": 1, "search_index": 1 @@ -123,8 +118,9 @@ }, { "fieldname": "mobile_no", - "fieldtype": "Phone", - "label": "Mobile No" + "fieldtype": "Data", + "label": "Mobile No", + "options": "Phone" }, { "fieldname": "column_break_sjtw", @@ -132,8 +128,9 @@ }, { "fieldname": "phone", - "fieldtype": "Phone", - "label": "Phone" + "fieldtype": "Data", + "label": "Phone", + "options": "Phone" }, { "fieldname": "section_break_uixv", @@ -189,25 +186,6 @@ "label": "Full Name", "search_index": 1 }, - { - "default": "Qualification", - "fieldname": "deal_status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Deal Status", - "options": "Qualification\nDemo/Making\nProposal/Quotation\nNegotiation\nReady to Close\nWon\nLost", - "reqd": 1, - "search_index": 1 - }, - { - "default": "0", - "fieldname": "is_deal", - "fieldtype": "Check", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Is Deal", - "search_index": 1 - }, { "fetch_from": "organization.job_title", "fieldname": "job_title", @@ -225,21 +203,6 @@ "fieldtype": "Tab Break", "label": "Contact" }, - { - "fieldname": "close_date", - "fieldtype": "Date", - "label": "Close Date" - }, - { - "fieldname": "probability", - "fieldtype": "Data", - "label": "Probability" - }, - { - "fieldname": "next_step", - "fieldtype": "Data", - "label": "Next Step" - }, { "fieldname": "contacts", "fieldtype": "Table", @@ -250,24 +213,25 @@ "fieldname": "section_break_jyxr", "fieldtype": "Section Break" }, - { - "default": "0", - "fieldname": "created_as_deal", - "fieldtype": "Check", - "hidden": 1, - "label": "Created as Deal" - }, { "fieldname": "organization", "fieldtype": "Link", "label": "Organization", "options": "CRM Organization" + }, + { + "default": "0", + "fieldname": "converted", + "fieldtype": "Check", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Converted" } ], "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-06 15:29:56.868755", + "modified": "2023-11-06 21:53:32.542503", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead", From 98f76e14178e74265ce2cb5a877b94408bd75c20 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 6 Nov 2023 22:15:51 +0530 Subject: [PATCH 11/17] fix: new deal dialog --- frontend/src/components/NewDeal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/NewDeal.vue b/frontend/src/components/NewDeal.vue index a4b3dbdb3..869ad0eab 100644 --- a/frontend/src/components/NewDeal.vue +++ b/frontend/src/components/NewDeal.vue @@ -10,7 +10,7 @@ :options="field.options" v-model="newDeal[field.name]" > -