fix: render correct currency format

(cherry picked from commit 5420fcfe291a4059729aa1736aca21c6c2f1e00e)
This commit is contained in:
Shariq Ansari 2025-05-12 17:45:05 +05:30 committed by Mergify
parent d70a0e1979
commit 5d4e971398
2 changed files with 41 additions and 49 deletions

View File

@ -95,7 +95,13 @@
<FormControl <FormControl
v-if=" v-if="
field.read_only && field.read_only &&
!['Float', 'Currency', 'Check'].includes(field.fieldtype) ![
'Int',
'Float',
'Currency',
'Percent',
'Check',
].includes(field.fieldtype)
" "
type="text" type="text"
:placeholder="field.placeholder" :placeholder="field.placeholder"
@ -186,13 +192,22 @@
@change="fieldChange($event.target.value, field, row)" @change="fieldChange($event.target.value, field, row)"
/> />
<FormControl <FormControl
v-else-if="field.fieldtype === 'Float'" v-else-if="field.fieldtype === 'Select'"
class="[&_input]:text-right" class="text-sm text-ink-gray-8"
type="text" type="select"
variant="outline" variant="outline"
:value="getFormattedFloat(field.fieldname, row)" v-model="row[field.fieldname]"
:options="field.options"
@change="(e) => fieldChange(e.target.value, field, row)"
/>
<FormControl
v-else-if="['Int'].includes(field.fieldtype)"
class="[&_input]:text-right"
type="number"
variant="outline"
:value="row[field.fieldname]"
:disabled="Boolean(field.read_only)" :disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)" @change="fieldChange($event.target.value, field, row)"
/> />
<FormControl <FormControl
v-else-if="field.fieldtype === 'Percent'" v-else-if="field.fieldtype === 'Percent'"
@ -203,6 +218,15 @@
:disabled="Boolean(field.read_only)" :disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)" @change="fieldChange(flt($event.target.value), field, row)"
/> />
<FormControl
v-else-if="field.fieldtype === 'Float'"
class="[&_input]:text-right"
type="text"
variant="outline"
:value="getFormattedFloat(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl <FormControl
v-else-if="field.fieldtype === 'Currency'" v-else-if="field.fieldtype === 'Currency'"
class="[&_input]:text-right" class="[&_input]:text-right"
@ -214,46 +238,6 @@
:disabled="Boolean(field.read_only)" :disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)" @change="fieldChange(flt($event.target.value), field, row)"
/> />
<FormControl
v-else-if="field.fieldtype === 'Select'"
class="text-sm text-ink-gray-8"
type="select"
variant="outline"
v-model="row[field.fieldname]"
:options="field.options"
@change="(e) => fieldChange(e.target.value, field, row)"
/>
<FormControl
v-else-if="['Int'].includes(field.fieldtype)"
type="number"
variant="outline"
:value="row[field.fieldname]"
@change="fieldChange($event.target.value, field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Percent'"
type="text"
variant="outline"
:value="getFormattedPercent(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Float'"
type="text"
variant="outline"
:value="getFormattedFloat(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl
v-else-if="field.fieldtype === 'Currency'"
type="text"
variant="outline"
:value="getFormattedCurrency(field.fieldname, row)"
:disabled="Boolean(field.read_only)"
@change="fieldChange(flt($event.target.value), field, row)"
/>
<FormControl <FormControl
v-else v-else
class="text-sm text-ink-gray-8" class="text-sm text-ink-gray-8"
@ -342,7 +326,7 @@ import {
dayjs, dayjs,
} from 'frappe-ui' } from 'frappe-ui'
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import { ref, reactive, computed, inject } from 'vue' import { ref, reactive, computed, inject, provide } from 'vue'
const props = defineProps({ const props = defineProps({
label: { label: {
@ -380,6 +364,9 @@ const { getUser } = usersStore()
const rows = defineModel() const rows = defineModel()
const parentDoc = defineModel('parent') const parentDoc = defineModel('parent')
provide('parentDoc', parentDoc)
const showRowList = ref(new Array(rows.value?.length || []).fill(false)) const showRowList = ref(new Array(rows.value?.length || []).fill(false))
const selectedRows = reactive(new Set()) const selectedRows = reactive(new Set())

View File

@ -14,7 +14,9 @@
<FormControl <FormControl
v-if=" v-if="
field.read_only && field.read_only &&
!['Float', 'Currency', 'Check', 'Percent'].includes(field.fieldtype) !['Int', 'Float', 'Currency', 'Percent', 'Check'].includes(
field.fieldtype,
)
" "
type="text" type="text"
:placeholder="getPlaceholder(field)" :placeholder="getPlaceholder(field)"
@ -164,6 +166,7 @@
type="number" type="number"
:placeholder="getPlaceholder(field)" :placeholder="getPlaceholder(field)"
:value="data[field.fieldname]" :value="data[field.fieldname]"
:disabled="Boolean(field.read_only)"
:description="field.description" :description="field.description"
@change="fieldChange($event.target.value, field)" @change="fieldChange($event.target.value, field)"
/> />
@ -188,7 +191,7 @@
<FormControl <FormControl
v-else-if="field.fieldtype === 'Currency'" v-else-if="field.fieldtype === 'Currency'"
type="text" type="text"
:value="getFormattedCurrency(field.fieldname, data)" :value="getFormattedCurrency(field.fieldname, data, parentDoc)"
:placeholder="getPlaceholder(field)" :placeholder="getPlaceholder(field)"
:disabled="Boolean(field.read_only)" :disabled="Boolean(field.read_only)"
:description="field.description" :description="field.description"
@ -235,6 +238,7 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
const { getUser } = usersStore() const { getUser } = usersStore()
let triggerOnChange let triggerOnChange
let parentDoc
if (!isGridRow) { if (!isGridRow) {
const { const {
@ -249,6 +253,7 @@ if (!isGridRow) {
provide('triggerOnRowRemove', triggerOnRowRemove) provide('triggerOnRowRemove', triggerOnRowRemove)
} else { } else {
triggerOnChange = inject('triggerOnChange') triggerOnChange = inject('triggerOnChange')
parentDoc = inject('parentDoc')
} }
const field = computed(() => { const field = computed(() => {