Currency Field Type
Description:
The currency
field type is used to capture monetary values with currency formatting and validation. It provides a specialized input field for financial data, ensuring consistent currency handling and display. This field type is essential for applications that deal with pricing, budgets, financial calculations, and any monetary transactions.
Elasticsearch Mapping: double
YAML Definition
- name: total_amount
type: number
display: currency
display_name: "Total Amount"
default_value: 0.00
required: true
readonly: false
hidden: false
guidance: "Enter the total amount in the specified currency"
symbol: "£"
precision: 2
display_currency_selector: false
validation: "min:0"
validation_message: "Amount must be greater than or equal to 0"
Attributes
-
name (string): Required.
The unique identifier for the field. -
type (string): Required.
Must be set tonumber
for currency fields. -
display (string): Required.
Must be set tocurrency
for currency display. -
display_name (string): Optional.
The label displayed in the user interface. If not provided, a formatted version ofname
is used. -
guidance (string): Optional.
Help text or instructions for the field, assisting users in understanding what amount to enter. -
required (boolean): Optional.
Iftrue
, the field must be filled before submission. Default:false
. -
readonly (boolean): Optional.
Iftrue
, the field is read-only and cannot be edited by the user. Default:false
. -
hidden (boolean): Optional.
Iftrue
, the field is hidden from the user interface. Default:false
. -
default_value (number): Optional.
The default amount displayed when the form is first loaded. -
symbol (string): Optional.
Currency symbol to display with the amount (e.g., “$”, “£”, “€”). -
precision (number): Optional.
Number of decimal places to display. Default:2
. -
display_currency_selector (boolean): Optional.
Whether to show a currency selector. Default:false
. -
validation (string): Optional.
Validation rules for the currency field. -
validation_message (string): Optional.
Custom validation error message to display when validation fails.
Examples
Basic Currency Field:
- name: total_amount
type: number
display: currency
display_name: "Total Amount"
default_value: 0.00
required: true
symbol: "£"
precision: 2
guidance: "Enter the total amount in pounds"
Currency Field with Validation:
- name: budget
type: number
display: currency
display_name: "Budget"
required: true
symbol: "$"
precision: 2
validation: "min:0,max:1000000"
validation_message: "Budget must be between $0 and $1,000,000"
guidance: "Enter the project budget in dollars"
Readonly Currency Field:
- name: calculated_total
type: number
display: currency
display_name: "Calculated Total"
readonly: true
symbol: "€"
precision: 2
guidance: "This is the automatically calculated total"
Currency Field with Selector:
- name: price
type: number
display: currency
display_name: "Price"
required: true
symbol: "$"
precision: 2
display_currency_selector: true
guidance: "Enter the price and select the currency"
Usage Notes
- Currency Display:
- The field displays monetary values with proper currency formatting.
- Currency symbols are automatically positioned according to locale conventions.
- Decimal places are handled consistently based on the
precision
setting.
- Symbol Configuration:
- Use
symbol
to specify the currency symbol (e.g., “$”, “£”, “€”, “¥”). - Common symbols include:
$
for US Dollar£
for British Pound€
for Euro¥
for Japanese Yen₹
for Indian Rupee
- Use
- Precision Settings:
- 0: Whole numbers only (e.g., $100)
- 2: Standard currency format (e.g., $100.50)
- 3: High precision (e.g., $100.500)
- 4: Very high precision (e.g., $100.5000)
- Currency Selector:
- Set
display_currency_selector: true
to allow users to choose the currency. - Useful for international applications or multi-currency systems.
- The selector typically includes major world currencies.
- Set
- Validation:
- Use
validation
to enforce business rules for currency amounts. - Common validation patterns:
"min:0"
: Non-negative amounts"max:1000000"
: Maximum amount limits"range:0-10000"
: Amount within specific range
- Use
- Default Values:
- Use
default_value
to pre-fill the field with a default amount. - Common defaults include
0.00
for new entries or calculated totals.
- Use
- Readonly Fields:
- Use
readonly
for calculated amounts that shouldn’t be manually edited. - Common for totals, subtotals, or system-calculated values.
- Use
- Use Cases:
- Pricing: Product prices, service costs, and fee structures.
- Budgets: Project budgets, department budgets, and financial planning.
- Invoicing: Invoice amounts, payment totals, and billing information.
- Expenses: Expense tracking, reimbursement amounts, and cost reporting.
- Financial Reports: Revenue, profit, loss, and financial metrics.
- Data Handling:
- Currency values are stored as numbers with appropriate precision.
- Consider locale-specific formatting for display purposes.
- Handle currency conversion if supporting multiple currencies.
- Internationalization:
- Support different currency formats based on user locale.
- Consider currency conversion rates for multi-currency applications.
- Handle different decimal separators (period vs. comma).
- Accessibility:
- Ensure that currency fields are keyboard accessible.
- Provide clear labels that include the currency context.
- Consider screen reader support for currency symbols and formatting.
By incorporating the currency
field type into your schema, you ensure consistent and accurate handling of monetary values, which is essential for financial applications and business processes.