fix: pass currency also get currency every where

This commit is contained in:
Shariq Ansari 2024-06-20 15:05:15 +05:30
parent 431f45fea2
commit 5955c06855
8 changed files with 40 additions and 14 deletions

View File

@ -73,6 +73,7 @@ def get_linked_deals(contact):
fields=[ fields=[
"name", "name",
"organization", "organization",
"currency",
"annual_revenue", "annual_revenue",
"status", "status",
"email", "email",

View File

@ -178,6 +178,7 @@ class CRMDeal(Document):
"annual_revenue", "annual_revenue",
"status", "status",
"email", "email",
"currency",
"mobile_no", "mobile_no",
"deal_owner", "deal_owner",
"sla_status", "sla_status",

View File

@ -47,6 +47,7 @@ class CRMOrganization(Document):
"organization_logo", "organization_logo",
"website", "website",
"industry", "industry",
"currency",
"annual_revenue", "annual_revenue",
"modified", "modified",
] ]

View File

@ -61,9 +61,11 @@
<script setup> <script setup>
import Fields from '@/components/Fields.vue' import Fields from '@/components/Fields.vue'
import EditIcon from '@/components/Icons/EditIcon.vue' import EditIcon from '@/components/Icons/EditIcon.vue'
import MoneyIcon from '@/components/Icons/MoneyIcon.vue'
import WebsiteIcon from '@/components/Icons/WebsiteIcon.vue' import WebsiteIcon from '@/components/Icons/WebsiteIcon.vue'
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue' import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
import TerritoryIcon from '@/components/Icons/TerritoryIcon.vue' import TerritoryIcon from '@/components/Icons/TerritoryIcon.vue'
import { formatNumberIntoCurrency } from '@/utils'
import { call, FeatherIcon, createResource } from 'frappe-ui' import { call, FeatherIcon, createResource } from 'frappe-ui'
import { ref, nextTick, watch, computed, h } from 'vue' import { ref, nextTick, watch, computed, h } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@ -205,9 +207,12 @@ const fields = computed(() => {
value: _organization.value.territory, value: _organization.value.territory,
}, },
{ {
icon: h(FeatherIcon, { name: 'dollar-sign', class: 'h-4 w-4' }), icon: MoneyIcon,
name: 'annual_revenue', name: 'annual_revenue',
value: _organization.value.annual_revenue, value: formatNumberIntoCurrency(
_organization.value.annual_revenue,
_organization.value.currency,
),
}, },
{ {
icon: h(FeatherIcon, { name: 'hash', class: 'h-4 w-4' }), icon: h(FeatherIcon, { name: 'hash', class: 'h-4 w-4' }),
@ -246,6 +251,6 @@ watch(
editMode.value = true editMode.value = true
} }
}) })
} },
) )
</script> </script>

View File

@ -357,7 +357,10 @@ function getDealRowObject(deal) {
label: deal.organization, label: deal.organization,
logo: getOrganization(deal.organization)?.organization_logo, logo: getOrganization(deal.organization)?.organization_logo,
}, },
annual_revenue: formatNumberIntoCurrency(deal.annual_revenue), annual_revenue: formatNumberIntoCurrency(
deal.annual_revenue,
deal.currency,
),
status: { status: {
label: deal.status, label: deal.status,
color: getDealStatus(deal.status)?.iconColorClass, color: getDealStatus(deal.status)?.iconColorClass,

View File

@ -109,7 +109,7 @@ const rows = computed(() => {
if (!deals.value?.data.group_by_field?.name) return [] if (!deals.value?.data.group_by_field?.name) return []
return getGroupedByRows( return getGroupedByRows(
deals.value?.data.data, deals.value?.data.data,
deals.value?.data.group_by_field deals.value?.data.group_by_field,
) )
} else { } else {
return parseRows(deals.value?.data.data) return parseRows(deals.value?.data.data)
@ -158,7 +158,10 @@ function parseRows(rows) {
logo: getOrganization(deal.organization)?.organization_logo, logo: getOrganization(deal.organization)?.organization_logo,
} }
} else if (row == 'annual_revenue') { } else if (row == 'annual_revenue') {
_rows[row] = formatNumberIntoCurrency(deal.annual_revenue) _rows[row] = formatNumberIntoCurrency(
deal.annual_revenue,
deal.currency,
)
} else if (row == 'status') { } else if (row == 'status') {
_rows[row] = { _rows[row] = {
label: deal.status, label: deal.status,
@ -207,7 +210,7 @@ function parseRows(rows) {
} }
} else if ( } else if (
['first_response_time', 'first_responded_on', 'response_by'].includes( ['first_response_time', 'first_responded_on', 'response_by'].includes(
row row,
) )
) { ) {
let field = row == 'response_by' ? 'response_by' : 'first_responded_on' let field = row == 'response_by' ? 'response_by' : 'first_responded_on'

View File

@ -104,7 +104,12 @@
class="flex items-center gap-1.5" class="flex items-center gap-1.5"
> >
<MoneyIcon class="size-4" /> <MoneyIcon class="size-4" />
<span class="">{{ formatNumberIntoCurrency(organization.doc.annual_revenue) }}</span> <span class="">{{
formatNumberIntoCurrency(
organization.doc.annual_revenue,
organization.doc.currency,
)
}}</span>
</div> </div>
<span <span
v-if="organization.doc.annual_revenue" v-if="organization.doc.annual_revenue"
@ -348,6 +353,7 @@ const deals = createListResource({
fields: [ fields: [
'name', 'name',
'organization', 'organization',
'currency',
'annual_revenue', 'annual_revenue',
'status', 'status',
'email', 'email',
@ -406,7 +412,10 @@ function getDealRowObject(deal) {
label: deal.organization, label: deal.organization,
logo: props.organization?.organization_logo, logo: props.organization?.organization_logo,
}, },
annual_revenue: formatNumberIntoCurrency(deal.annual_revenue), annual_revenue: formatNumberIntoCurrency(
deal.annual_revenue,
deal.currency,
),
status: { status: {
label: deal.status, label: deal.status,
color: getDealStatus(deal.status)?.iconColorClass, color: getDealStatus(deal.status)?.iconColorClass,

View File

@ -85,7 +85,7 @@ const showOrganizationModal = ref(false)
const currentOrganization = computed(() => { const currentOrganization = computed(() => {
return organizations.value?.data?.data?.find( return organizations.value?.data?.data?.find(
(organization) => organization.name === route.params.organizationId (organization) => organization.name === route.params.organizationId,
) )
}) })
@ -124,7 +124,10 @@ const rows = computed(() => {
} else if (row === 'website') { } else if (row === 'website') {
_rows[row] = website(organization.website) _rows[row] = website(organization.website)
} else if (row === 'annual_revenue') { } else if (row === 'annual_revenue') {
_rows[row] = formatNumberIntoCurrency(organization.annual_revenue) _rows[row] = formatNumberIntoCurrency(
organization.annual_revenue,
organization.currency,
)
} else if (['modified', 'creation'].includes(row)) { } else if (['modified', 'creation'].includes(row)) {
_rows[row] = { _rows[row] = {
label: dateFormat(organization[row], dateTooltipFormat), label: dateFormat(organization[row], dateTooltipFormat),