From 9b8662de14e32d431be95f1399e954fed2c6fec8 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 25 Dec 2024 16:54:10 +0530 Subject: [PATCH] feat: show formatted currency fields in all list views --- frontend/src/pages/Contact.vue | 15 +++++---------- frontend/src/pages/Contacts.vue | 6 ++++++ frontend/src/pages/Deals.vue | 19 +++++++------------ frontend/src/pages/EmailTemplates.vue | 7 +++++++ frontend/src/pages/Leads.vue | 6 ++++++ frontend/src/pages/MobileContact.vue | 15 +++++---------- frontend/src/pages/MobileOrganization.vue | 17 ++++++----------- frontend/src/pages/Organization.vue | 17 ++++++----------- frontend/src/pages/Organizations.vue | 14 ++++++++------ frontend/src/pages/Tasks.vue | 6 ++++++ frontend/src/utils/callLog.js | 6 ++++++ 11 files changed, 68 insertions(+), 60 deletions(-) diff --git a/frontend/src/pages/Contact.vue b/frontend/src/pages/Contact.vue index e3e64c51..5eea6170 100644 --- a/frontend/src/pages/Contact.vue +++ b/frontend/src/pages/Contact.vue @@ -211,13 +211,9 @@ import DealsIcon from '@/components/Icons/DealsIcon.vue' import DealsListView from '@/components/ListViews/DealsListView.vue' import SidePanelModal from '@/components/Modals/SidePanelModal.vue' import AddressModal from '@/components/Modals/AddressModal.vue' -import { - formatDate, - timeAgo, - formatNumberIntoCurrency, - createToast, -} from '@/utils' +import { formatDate, timeAgo, createToast } from '@/utils' import { getView } from '@/utils/view' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global.js' import { usersStore } from '@/stores/users.js' import { organizationsStore } from '@/stores/organizations.js' @@ -601,6 +597,8 @@ async function updateField(fieldname, value) { contact.reload() } +const { getFormattedCurrency } = getMeta('CRM Deal') + const columns = computed(() => dealColumns) function getDealRowObject(deal) { @@ -610,10 +608,7 @@ function getDealRowObject(deal) { label: deal.organization, logo: getOrganization(deal.organization)?.organization_logo, }, - annual_revenue: formatNumberIntoCurrency( - deal.annual_revenue, - deal.currency, - ), + annual_revenue: getFormattedCurrency('annual_revenue', deal), status: { label: deal.status, color: getDealStatus(deal.status)?.iconColorClass, diff --git a/frontend/src/pages/Contacts.vue b/frontend/src/pages/Contacts.vue index dca88f30..172d2565 100644 --- a/frontend/src/pages/Contacts.vue +++ b/frontend/src/pages/Contacts.vue @@ -70,10 +70,12 @@ import LayoutHeader from '@/components/LayoutHeader.vue' import ContactModal from '@/components/Modals/ContactModal.vue' import ContactsListView from '@/components/ListViews/ContactsListView.vue' import ViewControls from '@/components/ViewControls.vue' +import { getMeta } from '@/stores/meta' import { organizationsStore } from '@/stores/organizations.js' import { formatDate, timeAgo } from '@/utils' import { ref, computed } from 'vue' +const { getFormattedCurrency } = getMeta('Contact') const { getOrganization } = organizationsStore() const showContactModal = ref(false) @@ -110,6 +112,10 @@ const rows = computed(() => { _rows[row] = formatDate(contact[row], '', true, fieldType == 'Datetime') } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, contact) + } + if (row == 'full_name') { _rows[row] = { label: contact.full_name, diff --git a/frontend/src/pages/Deals.vue b/frontend/src/pages/Deals.vue index 7a3162b8..3f6f4e68 100644 --- a/frontend/src/pages/Deals.vue +++ b/frontend/src/pages/Deals.vue @@ -281,22 +281,18 @@ import NoteModal from '@/components/Modals/NoteModal.vue' import TaskModal from '@/components/Modals/TaskModal.vue' import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue' import ViewControls from '@/components/ViewControls.vue' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global' import { usersStore } from '@/stores/users' import { organizationsStore } from '@/stores/organizations' import { statusesStore } from '@/stores/statuses' import { callEnabled } from '@/composables/settings' -import { - formatDate, - timeAgo, - website, - formatNumberIntoCurrency, - formatTime, -} from '@/utils' +import { formatDate, timeAgo, website, formatTime } from '@/utils' import { Tooltip, Avatar, Dropdown } from 'frappe-ui' import { useRoute } from 'vue-router' import { ref, reactive, computed, h } from 'vue' +const { getFormattedCurrency } = getMeta('CRM Deal') const { makeCall } = globalStore() const { getUser } = usersStore() const { getOrganization } = organizationsStore() @@ -402,6 +398,10 @@ function parseRows(rows, columns = []) { _rows[row] = formatDate(deal[row], '', true, fieldType == 'Datetime') } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, deal) + } + if (row == 'organization') { _rows[row] = { label: deal.organization, @@ -409,11 +409,6 @@ function parseRows(rows, columns = []) { } } else if (row === 'website') { _rows[row] = website(deal.website) - } else if (row == 'annual_revenue') { - _rows[row] = formatNumberIntoCurrency( - deal.annual_revenue, - deal.currency, - ) } else if (row == 'status') { _rows[row] = { label: deal.status, diff --git a/frontend/src/pages/EmailTemplates.vue b/frontend/src/pages/EmailTemplates.vue index 73e3ec5f..cdbc14ee 100644 --- a/frontend/src/pages/EmailTemplates.vue +++ b/frontend/src/pages/EmailTemplates.vue @@ -75,9 +75,12 @@ import LayoutHeader from '@/components/LayoutHeader.vue' import ViewControls from '@/components/ViewControls.vue' import EmailTemplatesListView from '@/components/ListViews/EmailTemplatesListView.vue' import EmailTemplateModal from '@/components/Modals/EmailTemplateModal.vue' +import { getMeta } from '@/stores/meta' import { formatDate, timeAgo } from '@/utils' import { computed, ref } from 'vue' +const { getFormattedCurrency } = getMeta('Email Template') + const emailTemplatesListView = ref(null) // emailTemplates data is loaded in the ViewControls component @@ -115,6 +118,10 @@ const rows = computed(() => { ) } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, emailTemplate) + } + if (['modified', 'creation'].includes(row)) { _rows[row] = { label: formatDate(emailTemplate[row]), diff --git a/frontend/src/pages/Leads.vue b/frontend/src/pages/Leads.vue index 8be6fa7b..d08d5758 100644 --- a/frontend/src/pages/Leads.vue +++ b/frontend/src/pages/Leads.vue @@ -303,6 +303,7 @@ import NoteModal from '@/components/Modals/NoteModal.vue' import TaskModal from '@/components/Modals/TaskModal.vue' import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue' import ViewControls from '@/components/ViewControls.vue' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global' import { usersStore } from '@/stores/users' import { statusesStore } from '@/stores/statuses' @@ -312,6 +313,7 @@ import { Avatar, Tooltip, Dropdown } from 'frappe-ui' import { useRoute } from 'vue-router' import { ref, computed, reactive, h } from 'vue' +const { getFormattedCurrency } = getMeta('CRM Lead') const { makeCall } = globalStore() const { getUser } = usersStore() const { getLeadStatus } = statusesStore() @@ -416,6 +418,10 @@ function parseRows(rows, columns = []) { _rows[row] = formatDate(lead[row], '', true, fieldType == 'Datetime') } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, lead) + } + if (row == 'lead_name') { _rows[row] = { label: lead.lead_name, diff --git a/frontend/src/pages/MobileContact.vue b/frontend/src/pages/MobileContact.vue index c39d6bc3..9508d3ee 100644 --- a/frontend/src/pages/MobileContact.vue +++ b/frontend/src/pages/MobileContact.vue @@ -186,13 +186,9 @@ import CameraIcon from '@/components/Icons/CameraIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue' import DealsListView from '@/components/ListViews/DealsListView.vue' import AddressModal from '@/components/Modals/AddressModal.vue' -import { - formatDate, - timeAgo, - formatNumberIntoCurrency, - createToast, -} from '@/utils' +import { formatDate, timeAgo, createToast } from '@/utils' import { getView } from '@/utils/view' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global.js' import { usersStore } from '@/stores/users.js' import { organizationsStore } from '@/stores/organizations.js' @@ -581,6 +577,8 @@ async function updateField(fieldname, value) { contact.reload() } +const { getFormattedCurrency } = getMeta('CRM Deal') + const columns = computed(() => dealColumns) function getDealRowObject(deal) { @@ -590,10 +588,7 @@ function getDealRowObject(deal) { label: deal.organization, logo: getOrganization(deal.organization)?.organization_logo, }, - annual_revenue: formatNumberIntoCurrency( - deal.annual_revenue, - deal.currency, - ), + annual_revenue: getFormattedCurrency('annual_revenue', deal), status: { label: deal.status, color: getDealStatus(deal.status)?.iconColorClass, diff --git a/frontend/src/pages/MobileOrganization.vue b/frontend/src/pages/MobileOrganization.vue index 58bd77d0..d73ce09f 100644 --- a/frontend/src/pages/MobileOrganization.vue +++ b/frontend/src/pages/MobileOrganization.vue @@ -176,16 +176,12 @@ import DetailsIcon from '@/components/Icons/DetailsIcon.vue' import CameraIcon from '@/components/Icons/CameraIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global' import { usersStore } from '@/stores/users' import { statusesStore } from '@/stores/statuses' import { getView } from '@/utils/view' -import { - formatDate, - timeAgo, - formatNumberIntoCurrency, - createToast, -} from '@/utils' +import { formatDate, timeAgo, createToast } from '@/utils' import { Breadcrumbs, Avatar, @@ -441,6 +437,8 @@ const rows = computed(() => { }) }) +const { getFormattedCurrency } = getMeta('CRM Deal') + const columns = computed(() => { return tabIndex.value === 0 ? dealColumns : contactColumns }) @@ -450,12 +448,9 @@ function getDealRowObject(deal) { name: deal.name, organization: { label: deal.organization, - logo: props.organization?.organization_logo, + logo: organization.doc?.organization_logo, }, - annual_revenue: formatNumberIntoCurrency( - deal.annual_revenue, - deal.currency, - ), + annual_revenue: getFormattedCurrency('annual_revenue', deal), status: { label: deal.status, color: getDealStatus(deal.status)?.iconColorClass, diff --git a/frontend/src/pages/Organization.vue b/frontend/src/pages/Organization.vue index d84fd232..e4920855 100644 --- a/frontend/src/pages/Organization.vue +++ b/frontend/src/pages/Organization.vue @@ -211,16 +211,12 @@ import EditIcon from '@/components/Icons/EditIcon.vue' import CameraIcon from '@/components/Icons/CameraIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue' +import { getMeta } from '@/stores/meta' import { globalStore } from '@/stores/global' import { usersStore } from '@/stores/users' import { statusesStore } from '@/stores/statuses' import { getView } from '@/utils/view' -import { - formatDate, - timeAgo, - formatNumberIntoCurrency, - createToast, -} from '@/utils' +import { formatDate, timeAgo, createToast } from '@/utils' import { Tooltip, Breadcrumbs, @@ -476,6 +472,8 @@ const rows = computed(() => { }) }) +const { getFormattedCurrency } = getMeta('CRM Deal') + const columns = computed(() => { return tabIndex.value === 0 ? dealColumns : contactColumns }) @@ -485,12 +483,9 @@ function getDealRowObject(deal) { name: deal.name, organization: { label: deal.organization, - logo: props.organization?.organization_logo, + logo: organization.doc?.organization_logo, }, - annual_revenue: formatNumberIntoCurrency( - deal.annual_revenue, - deal.currency, - ), + annual_revenue: getFormattedCurrency('annual_revenue', deal), status: { label: deal.status, color: getDealStatus(deal.status)?.iconColorClass, diff --git a/frontend/src/pages/Organizations.vue b/frontend/src/pages/Organizations.vue index 60a2204b..5db5a8c3 100644 --- a/frontend/src/pages/Organizations.vue +++ b/frontend/src/pages/Organizations.vue @@ -69,9 +69,12 @@ import LayoutHeader from '@/components/LayoutHeader.vue' import OrganizationModal from '@/components/Modals/OrganizationModal.vue' import OrganizationsListView from '@/components/ListViews/OrganizationsListView.vue' import ViewControls from '@/components/ViewControls.vue' -import { formatDate, timeAgo, website, formatNumberIntoCurrency } from '@/utils' +import { getMeta } from '@/stores/meta' +import { formatDate, timeAgo, website } from '@/utils' import { ref, computed } from 'vue' +const { getFormattedCurrency } = getMeta('CRM Organization') + const organizationsListView = ref(null) const showOrganizationModal = ref(false) @@ -110,6 +113,10 @@ const rows = computed(() => { ) } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, organization) + } + if (row === 'organization_name') { _rows[row] = { label: organization.organization_name, @@ -117,11 +124,6 @@ const rows = computed(() => { } } else if (row === 'website') { _rows[row] = website(organization.website) - } else if (row === 'annual_revenue') { - _rows[row] = formatNumberIntoCurrency( - organization.annual_revenue, - organization.currency, - ) } else if (['modified', 'creation'].includes(row)) { _rows[row] = { label: formatDate(organization[row]), diff --git a/frontend/src/pages/Tasks.vue b/frontend/src/pages/Tasks.vue index 0349c876..1d892c7a 100644 --- a/frontend/src/pages/Tasks.vue +++ b/frontend/src/pages/Tasks.vue @@ -204,12 +204,14 @@ import ViewControls from '@/components/ViewControls.vue' import TasksListView from '@/components/ListViews/TasksListView.vue' import KanbanView from '@/components/Kanban/KanbanView.vue' import TaskModal from '@/components/Modals/TaskModal.vue' +import { getMeta } from '@/stores/meta' import { usersStore } from '@/stores/users' import { formatDate, timeAgo } from '@/utils' import { Tooltip, Avatar, TextEditor, Dropdown, call } from 'frappe-ui' import { computed, ref } from 'vue' import { useRouter } from 'vue-router' +const { getFormattedCurrency } = getMeta('CRM Task') const { getUser } = usersStore() const router = useRouter() @@ -271,6 +273,10 @@ function parseRows(rows, columns = []) { _rows[row] = formatDate(task[row], '', true, fieldType == 'Datetime') } + if (fieldType && fieldType == 'Currency') { + _rows[row] = getFormattedCurrency(row, task) + } + if (['modified', 'creation'].includes(row)) { _rows[row] = { label: formatDate(task[row]), diff --git a/frontend/src/utils/callLog.js b/frontend/src/utils/callLog.js index ee006d1a..35388c20 100644 --- a/frontend/src/utils/callLog.js +++ b/frontend/src/utils/callLog.js @@ -1,7 +1,9 @@ import { secondsToDuration, formatDate, timeAgo } from '@/utils' +import { getMeta } from '@/stores/meta' import { usersStore } from '@/stores/users' import { contactsStore } from '@/stores/contacts' +const { getFormattedCurrency } = getMeta('CRM Call Log') const { getUser } = usersStore() const { getContact, getLeadContact } = contactsStore() @@ -58,6 +60,10 @@ export function getCallLogDetail(row, log, columns = []) { return formatDate(log[row], '', true, fieldType == 'Datetime') } + if (fieldType && fieldType == 'Currency') { + return getFormattedCurrency(row, log) + } + return log[row] }