Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Fix: Date in English format in Major accountant despite being in Span…
Browse files Browse the repository at this point in the history
…ish language (#2989)

* PanJiaChen#2915

* Minimal changes

* Minimal changes

* Minimal changes

* Update DataCells.vue

* Update DataCells.vue

* remove redundant code.

* remove warning

* improve current.value

---------

Co-authored-by: Edwin Betancourt <[email protected]>
  • Loading branch information
elsiosanchez and EdwinBetanc0urt authored Nov 19, 2024
1 parent 70962e5 commit 46ed546
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ import FieldDefinition from '@/components/ADempiere/FieldDefinition/index.vue'
import ProgressPercentage from '@/components/ADempiere/ContainerOptions/ProgressPercentage.vue'

// Utils and helpers Methods
import { isEmptyValue, getTypeOfValue } from '@/utils/ADempiere/valueUtils.js'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { copyToClipboard } from '@/utils/ADempiere/coreUtils.js'
import { formatField } from '@/utils/ADempiere/valueFormat.js'
import { getImagePath } from '@/utils/ADempiere/resource'
Expand Down Expand Up @@ -194,13 +194,10 @@ export default defineComponent({
})

const displayedValue = computed(() => {
let currentValue = props.dataRow[columnName.value]
if (getTypeOfValue(currentValue) === 'OBJECT') {
currentValue = currentValue.value
}
if (props.fieldAttributes.is_encrypted) {
return '••••••••••••••••••'
}
const currentValue = props.dataRow[columnName.value]
return formatField({
value: currentValue,
currency: props.dataRow[DISPLAY_COLUMN_PREFIX + CURRENCY],
Expand Down
17 changes: 7 additions & 10 deletions src/components/ADempiere/Report/Data/DataCells.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ import InfoReport from '@/views/ADempiere/ReportViewerEngine/infoReport.vue'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { isLookup } from '@/utils/ADempiere/references'
import { zoomIn } from '@/utils/ADempiere/coreUtils.js'
import { isSalesTransaction } from '@/utils/ADempiere/contextUtils'
import { formatField } from '@/utils/ADempiere/valueFormat.js'

// API Request Methods
import { listZoomWindowsRequest } from '@/api/ADempiere/fields/zoom.js'
Expand Down Expand Up @@ -221,15 +221,12 @@ export default defineComponent({
const rowData = row.cells[field.code]
if (!isEmptyValue(rowData)) {
const { display_value, value: currentValue } = rowData
if (!isEmptyValue(display_value) || isLookup(field.display_type)) {
return display_value
}
if (!isEmptyValue(currentValue)) {
if (!isEmptyValue(currentValue.value)) {
return currentValue.value
}
return currentValue
}
return formatField({
value: currentValue,
displayedValue: display_value,
displayType: field.display_type,
columnName: field.column_name
})
}
}

Expand Down
54 changes: 19 additions & 35 deletions src/utils/ADempiere/valueFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ export function formatField({
if (isEmptyValue(value)) {
return undefined
}
let currentValue = value
// date and number is object { value, type }
if (getTypeOfValue(currentValue) === 'OBJECT' && Object.prototype.hasOwnProperty.call(currentValue, 'value')) {
currentValue = value.value
}
if (isEmptyValue(currentValue)) {
return undefined
}
if (isEmptyValue(displayType)) {
return value
return currentValue
}
// Format
let formattedValue
Expand All @@ -93,17 +101,13 @@ export function formatField({
formattedValue = displayedValue
if (isEmptyValue(formattedValue)) {
// set value
formattedValue = value
formattedValue = currentValue
}
break

case DATE.id:
// date is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatDateTemp({
value,
value: currentValue,
isTime: false,
format: getDateFormat({
format: optionalFormat,
Expand All @@ -114,23 +118,15 @@ export function formatField({
break

case DATE_PLUS_TIME.id:
// date is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatDateTemp({
value,
value: currentValue,
isTime: true,
format: optionalFormat || 'yyyy-MM-dd hh:mm:ss A'
})
break
case TIME.id:
// date is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatDateTemp({
value,
value: currentValue,
isTime: true,
format: getDateFormat({
format: optionalFormat,
Expand All @@ -142,45 +138,33 @@ export function formatField({

case AMOUNT.id:
case COSTS_PLUS_PRICES.id:
// number is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatPriceTemp({
value,
value: currentValue,
currency
})
break

case NUMBER.id:
// number is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatQuantity({
value,
value: currentValue,
precision
})
break
case QUANTITY.id:
// number is object { value, type }
if (getTypeOfValue(value) === 'OBJECT' && Object.prototype.hasOwnProperty.call(value, 'value')) {
value = value.value
}
formattedValue = formatQuantity({
value
value: currentValue
})
break

case YES_NO.id:
formattedValue = convertBooleanToTranslationLang(value)
formattedValue = convertBooleanToTranslationLang(currentValue)
break

case CHAR.id:
case MEMO.id:
case TEXT.id:
case TEXT_LONG.id:
formattedValue = decodeHtmlEntities(value)
formattedValue = decodeHtmlEntities(currentValue)
break

case IMAGE.id:
Expand All @@ -192,7 +176,7 @@ export function formatField({
break

default:
formattedValue = value
formattedValue = currentValue
}
return formattedValue
}
Expand Down

0 comments on commit 46ed546

Please sign in to comment.