Skip to content

Commit

Permalink
cfv can be of type dict (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur authored Oct 27, 2024
1 parent 7c6b582 commit fc524a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion papermerge/core/schemas/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down
18 changes: 14 additions & 4 deletions ui2/src/features/document/components/customFields/Monetary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc524a9

Please sign in to comment.