TIM SDK
TIM API C
amount.h File Reference

Description

Amount.

Object type amount.

Functions

ta_e_result_code_t ta_amount_create (ta_object_t *amount, int64_t value, ta_e_currency_t currency)
 Create object of type amount. More...
 
ta_e_result_code_t ta_amount_create_decimal (ta_object_t *amount, double value, ta_e_currency_t currency)
 Create object of type amount using double precision floating point value. More...
 
ta_e_result_code_t ta_amount_create_exponent (ta_object_t *amount, int64_t value, ta_e_currency_t currency, int exponent)
 Create object of type amount using custom exponent. More...
 
ta_e_result_code_t ta_amount_create_decimal_exponent (ta_object_t *amount, double value, ta_e_currency_t currency, int exponent)
 Create object of type amount using custom exponent and double precision value. More...
 
ta_e_result_code_t ta_amount_get_value (ta_object_t amount, int64_t *value)
 Amount in minor units. More...
 
ta_e_result_code_t ta_amount_set_value (ta_object_t amount, int64_t value)
 Set amount in minor units. More...
 
ta_e_result_code_t ta_amount_get_decimal_value (ta_object_t amount, double *value)
 Amount in major units as double precision floating point value. More...
 
ta_e_result_code_t ta_amount_set_decimal_value (ta_object_t amount, double value)
 Set amount in major units as double precision floating point value. More...
 
ta_e_result_code_t ta_amount_get_currency (ta_object_t amount, ta_e_currency_t *currency)
 Currency. More...
 
ta_e_result_code_t ta_amount_set_currency (ta_object_t amount, ta_e_currency_t currency)
 Set currency. More...
 
ta_e_result_code_t ta_amount_get_exponent (ta_object_t amount, int *exponent)
 Exponent. More...
 
ta_e_result_code_t ta_amount_set_exponent (ta_object_t amount, int exponent)
 Set exponent. More...
 

Function Documentation

◆ ta_amount_create()

ta_e_result_code_t ta_amount_create ( ta_object_t amount,
int64_t  value,
ta_e_currency_t  currency 
)

Create object of type amount.

Parameters
[out]amountPointer to variable to write created object instance to. Created object instance is retained.
[in]valueValue of amount in minor units. The currency selected by currency defines the used exponent. For example with ta_c_currency_chf the exponent is 2. To create an amount equal to 1 CHF use a value of 100.
[in]currencyCurrency of amount.
Return values
ta_c_rc_okObject instance has been created and written to amount.
ta_c_rc_invalid_argumentamount is null-pointer.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.
ta_c_rc_invalid_argumentvalue is less than 0.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_create_decimal()

ta_e_result_code_t ta_amount_create_decimal ( ta_object_t amount,
double  value,
ta_e_currency_t  currency 
)

Create object of type amount using double precision floating point value.

Note
Double precision floating point values can not provide the same level of numerical accuracy as int64_t. It is recommended to use the integer based methods.
Parameters
[out]amountPointer to variable to write created object instance to. Created object instance is retained.
[in]valueValue of amount in major units. The currency selected by currency defines the used exponent. For example with ta_c_currency_chf the exponent is 2. Values with more than 2 digits after the period will be rounded according to regular mathematical rounding rules.
[in]currencyCurrency of amount.
Return values
ta_c_rc_okObject instance has been created and written to amount.
ta_c_rc_invalid_argumentamount is null-pointer.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.
ta_c_rc_invalid_argumentvalue is less than 0.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_create_decimal_exponent()

ta_e_result_code_t ta_amount_create_decimal_exponent ( ta_object_t amount,
double  value,
ta_e_currency_t  currency,
int  exponent 
)

Create object of type amount using custom exponent and double precision value.

Note
Double precision floating point values can not provide the same level of numerical accuracy as int64_t. It is recommended to use the integer based methods.
Parameters
[out]amountPointer to variable to write created object instance to. Created object instance is retained.
[in]valueValue of amount in minor units. The value of exponent overrides the exponent defined by the currency selected by currency. For example with an exponent of 3 values with more than 3 digits after the period will be rounded according to regular mathematical rounding rules.
[in]currencyCurrency of amount.
[in]exponentExponent to use instead of the exponent defined by the currency.
Return values
ta_c_rc_okObject instance has been created and written to amount.
ta_c_rc_invalid_argumentamount is null-pointer.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.
ta_c_rc_invalid_argumentvalue is less than 0.
ta_c_rc_invalid_argumentexponent is less than 0.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_create_exponent()

ta_e_result_code_t ta_amount_create_exponent ( ta_object_t amount,
int64_t  value,
ta_e_currency_t  currency,
int  exponent 
)

Create object of type amount using custom exponent.

Parameters
[out]amountPointer to variable to write created object instance to. Created object instance is retained.
[in]valueValue of amount in minor units. The value of exponent overrides the exponent defined by the currency selected by currency. For example with an exponent of 3 to create an amount equal to 1 CHF use a value of 1000.
[in]currencyCurrency of amount.
[in]exponentExponent to use instead of the exponent defined by the currency.
Return values
ta_c_rc_okObject instance has been created and written to amount.
ta_c_rc_invalid_argumentamount is null-pointer.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.
ta_c_rc_invalid_argumentvalue is less than 0.
ta_c_rc_invalid_argumentexponent is less than 0.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_get_currency()

ta_e_result_code_t ta_amount_get_currency ( ta_object_t  amount,
ta_e_currency_t currency 
)

Currency.

Parameters
[in]amountObject instance of type amount.
[out]currencyPointer to variable to write currency to.
Return values
ta_c_rc_okValue written to currency.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentcurrency is null-pointer.

◆ ta_amount_get_decimal_value()

ta_e_result_code_t ta_amount_get_decimal_value ( ta_object_t  amount,
double *  value 
)

Amount in major units as double precision floating point value.

Note
Double precision floating point values can not provide the same level of numerical accuracy as int64_t. It is recommended to use the integer based methods.
Parameters
[in]amountObject instance of type amount.
[out]valuePointer to variable to write value to.
Return values
ta_c_rc_okValue written to value.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentvalue is null-pointer.

◆ ta_amount_get_exponent()

ta_e_result_code_t ta_amount_get_exponent ( ta_object_t  amount,
int *  exponent 
)

Exponent.

Parameters
[in]amountObject instance of type amount.
[out]exponentPointer to variable to write exponent to.
Return values
ta_c_rc_okValue written to exponent.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentexponent is null-pointer.

◆ ta_amount_get_value()

ta_e_result_code_t ta_amount_get_value ( ta_object_t  amount,
int64_t *  value 
)

Amount in minor units.

Parameters
[in]amountObject instance of type amount.
[out]valuePointer to variable to write value to. Use ta_amount_get_exponent to get the used exponent. This can be a different exponent than the one defined by the used currency.
Return values
ta_c_rc_okValue written to value.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentvalue is null-pointer.

◆ ta_amount_set_currency()

ta_e_result_code_t ta_amount_set_currency ( ta_object_t  amount,
ta_e_currency_t  currency 
)

Set currency.

Parameters
[in]amountObject instance of type amount.
[in]currencyCurrency to set.
Return values
ta_c_rc_okValue assigned to amount.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.

◆ ta_amount_set_decimal_value()

ta_e_result_code_t ta_amount_set_decimal_value ( ta_object_t  amount,
double  value 
)

Set amount in major units as double precision floating point value.

Note
Double precision floating point values can not provide the same level of numerical accuracy as int64_t. It is recommended to use the integer based methods.
Parameters
[in]amountObject instance of type amount.
[in]valueValue to set. Use ta_amount_get_exponent to get the used exponent. For example with an exponent of 2 values with more than 2 digits after the period will be rounded according to regular mathematical rounding rules.
Return values
ta_c_rc_okValue written to value.
ta_c_rc_invalid_argumentamount is 0 pointer.
ta_c_rc_out_of_memoryMemory allocation required but failed.

◆ ta_amount_set_exponent()

ta_e_result_code_t ta_amount_set_exponent ( ta_object_t  amount,
int  exponent 
)

Set exponent.

Parameters
[in]amountObject instance of type amount.
[in]exponentExponent to set.
Return values
ta_c_rc_okValue assigned to amount.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentexponent is less than 0.

◆ ta_amount_set_value()

ta_e_result_code_t ta_amount_set_value ( ta_object_t  amount,
int64_t  value 
)

Set amount in minor units.

Parameters
[in]amountObject instance of type amount.
[in]valueValue to set. Use ta_amount_get_exponent to get the used exponent. This can be a different exponent than the one defined by the used currency. For example with an exponent of 2 to set an amount equal to 1 CHF you have to use a value of 100.
Return values
ta_c_rc_okValue assigned to amount.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount.
ta_c_rc_invalid_argumentvalue is less than 0.