Merge pull request #227 from shariquerik/currency-fix
fix: added/render currency for deal & organization amount field
This commit is contained in:
commit
e9010abe20
@ -73,6 +73,7 @@ def get_linked_deals(contact):
|
||||
fields=[
|
||||
"name",
|
||||
"organization",
|
||||
"currency",
|
||||
"annual_revenue",
|
||||
"status",
|
||||
"email",
|
||||
|
||||
@ -257,17 +257,18 @@ def get_list_data(
|
||||
"user": frappe.session.user,
|
||||
}
|
||||
|
||||
_list = get_controller(doctype)
|
||||
|
||||
if not custom_view and frappe.db.exists("CRM View Settings", default_view_filters):
|
||||
list_view_settings = frappe.get_doc("CRM View Settings", default_view_filters)
|
||||
columns = frappe.parse_json(list_view_settings.columns)
|
||||
rows = frappe.parse_json(list_view_settings.rows)
|
||||
is_default = False
|
||||
elif not custom_view or is_default:
|
||||
_list = get_controller(doctype)
|
||||
elif not custom_view or is_default and hasattr(_list, "default_list_data"):
|
||||
columns = _list.default_list_data().get("columns")
|
||||
|
||||
if hasattr(_list, "default_list_data"):
|
||||
columns = _list.default_list_data().get("columns")
|
||||
rows = _list.default_list_data().get("rows")
|
||||
if hasattr(_list, "default_list_data"):
|
||||
rows = _list.default_list_data().get("rows")
|
||||
|
||||
# check if rows has all keys from columns if not add them
|
||||
for column in columns:
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
"job_title",
|
||||
"column_break_xbyf",
|
||||
"territory",
|
||||
"currency",
|
||||
"annual_revenue",
|
||||
"industry",
|
||||
"person_section",
|
||||
@ -72,7 +73,8 @@
|
||||
"fetch_from": ".annual_revenue",
|
||||
"fieldname": "annual_revenue",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Amount"
|
||||
"label": "Amount",
|
||||
"options": "currency"
|
||||
},
|
||||
{
|
||||
"fetch_from": ".website",
|
||||
@ -327,11 +329,17 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Contact",
|
||||
"options": "Contact"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"label": "Currency",
|
||||
"options": "Currency"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-19 18:01:59.213811",
|
||||
"modified": "2024-06-20 12:55:41.602364",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Deal",
|
||||
|
||||
@ -178,6 +178,7 @@ class CRMDeal(Document):
|
||||
"annual_revenue",
|
||||
"status",
|
||||
"email",
|
||||
"currency",
|
||||
"mobile_no",
|
||||
"deal_owner",
|
||||
"sla_status",
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
"field_order": [
|
||||
"organization_name",
|
||||
"no_of_employees",
|
||||
"currency",
|
||||
"annual_revenue",
|
||||
"organization_logo",
|
||||
"column_break_pnpp",
|
||||
@ -47,7 +48,8 @@
|
||||
{
|
||||
"fieldname": "annual_revenue",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Annual Revenue"
|
||||
"label": "Annual Revenue",
|
||||
"options": "currency"
|
||||
},
|
||||
{
|
||||
"fieldname": "industry",
|
||||
@ -60,12 +62,18 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Territory",
|
||||
"options": "CRM Territory"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"label": "Currency",
|
||||
"options": "Currency"
|
||||
}
|
||||
],
|
||||
"image_field": "organization_logo",
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-01-19 21:53:14.945857",
|
||||
"modified": "2024-06-20 12:59:55.297752",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Organization",
|
||||
|
||||
@ -47,6 +47,7 @@ class CRMOrganization(Document):
|
||||
"organization_logo",
|
||||
"website",
|
||||
"industry",
|
||||
"currency",
|
||||
"annual_revenue",
|
||||
"modified",
|
||||
]
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -94,12 +94,12 @@ export function secondsToDuration(seconds) {
|
||||
return `${hours}h ${minutes}m ${_seconds}s`
|
||||
}
|
||||
|
||||
export function formatNumberIntoCurrency(value) {
|
||||
export function formatNumberIntoCurrency(value, currency = 'INR') {
|
||||
if (value) {
|
||||
return value.toLocaleString('en-IN', {
|
||||
maximumFractionDigits: 2,
|
||||
maximumFractionDigits: 0,
|
||||
style: 'currency',
|
||||
currency: 'INR',
|
||||
currency: currency ? currency : 'INR',
|
||||
})
|
||||
}
|
||||
return ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user