1
0
forked from test/crm

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=[
"name",
"organization",
"currency",
"annual_revenue",
"status",
"email",

View File

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

View File

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

View File

@ -61,9 +61,11 @@
<script setup>
import Fields from '@/components/Fields.vue'
import EditIcon from '@/components/Icons/EditIcon.vue'
import MoneyIcon from '@/components/Icons/MoneyIcon.vue'
import WebsiteIcon from '@/components/Icons/WebsiteIcon.vue'
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
import TerritoryIcon from '@/components/Icons/TerritoryIcon.vue'
import { formatNumberIntoCurrency } from '@/utils'
import { call, FeatherIcon, createResource } from 'frappe-ui'
import { ref, nextTick, watch, computed, h } from 'vue'
import { useRouter } from 'vue-router'
@ -205,9 +207,12 @@ const fields = computed(() => {
value: _organization.value.territory,
},
{
icon: h(FeatherIcon, { name: 'dollar-sign', class: 'h-4 w-4' }),
icon: MoneyIcon,
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' }),
@ -227,7 +232,7 @@ const fields = computed(() => {
const sections = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
cache: ['quickEntryFields', 'CRM Organization'],
params: { doctype: 'CRM Organization', type: 'Quick Entry'},
params: { doctype: 'CRM Organization', type: 'Quick Entry' },
auto: true,
})
@ -246,6 +251,6 @@ watch(
editMode.value = true
}
})
}
},
)
</script>

View File

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

View File

@ -109,7 +109,7 @@ const rows = computed(() => {
if (!deals.value?.data.group_by_field?.name) return []
return getGroupedByRows(
deals.value?.data.data,
deals.value?.data.group_by_field
deals.value?.data.group_by_field,
)
} else {
return parseRows(deals.value?.data.data)
@ -158,7 +158,10 @@ function parseRows(rows) {
logo: getOrganization(deal.organization)?.organization_logo,
}
} else if (row == 'annual_revenue') {
_rows[row] = formatNumberIntoCurrency(deal.annual_revenue)
_rows[row] = formatNumberIntoCurrency(
deal.annual_revenue,
deal.currency,
)
} else if (row == 'status') {
_rows[row] = {
label: deal.status,
@ -171,8 +174,8 @@ function parseRows(rows) {
deal.sla_status == 'Failed'
? 'red'
: deal.sla_status == 'Fulfilled'
? 'green'
: 'orange'
? 'green'
: 'orange'
if (value == 'First Response Due') {
value = __(timeAgo(deal.response_by))
tooltipText = dateFormat(deal.response_by, dateTooltipFormat)
@ -207,7 +210,7 @@ function parseRows(rows) {
}
} else if (
['first_response_time', 'first_responded_on', 'response_by'].includes(
row
row,
)
) {
let field = row == 'response_by' ? 'response_by' : 'first_responded_on'

View File

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

View File

@ -85,7 +85,7 @@ const showOrganizationModal = ref(false)
const currentOrganization = computed(() => {
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') {
_rows[row] = website(organization.website)
} 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)) {
_rows[row] = {
label: dateFormat(organization[row], dateTooltipFormat),