diff --git a/papermerge/core/schemas/custom_fields.py b/papermerge/core/schemas/custom_fields.py index 1b53a6089..57e068c68 100644 --- a/papermerge/core/schemas/custom_fields.py +++ b/papermerge/core/schemas/custom_fields.py @@ -67,7 +67,7 @@ class CFV(BaseModel): # `custom_fields.type` type: CustomFieldType # `custom_fields.extra_data` - extra_data: str | None + extra_data: str | dict | None # `custom_field_values.id` custom_field_value_id: UUID | None = None # `custom_field_values.value_text` or `custom_field_values.value_int` or ... diff --git a/ui2/src/features/document/components/customFields/Monetary.tsx b/ui2/src/features/document/components/customFields/Monetary.tsx index f829124b9..cf0488799 100644 --- a/ui2/src/features/document/components/customFields/Monetary.tsx +++ b/ui2/src/features/document/components/customFields/Monetary.tsx @@ -6,15 +6,25 @@ type MonetaryExtraDataType = { currency: string } -function getCurrency(extraData?: string): string | undefined { +function getCurrency( + extraData?: string | MonetaryExtraDataType +): string | undefined { if (!extraData) { return } - const extra_data = JSON.parse(extraData) as MonetaryExtraDataType + if (typeof extraData == "string") { + const extra_data = JSON.parse(extraData) as MonetaryExtraDataType - if (extra_data) { - return extra_data.currency + if (extra_data) { + return extra_data.currency + } + + return + } + + if (extraData.currency) { + return extraData.currency } return