TIM SDK
TIM API C
amount_discount.h File Reference

Description

Discount Amount.

Object type amount_discount.

Functions

ta_e_result_code_t ta_amount_discount_create (ta_object_t *amount, int64_t value, ta_e_currency_t currency, ta_object_t discount_id)
 Create object of type amount_discount. More...
 
ta_e_result_code_t ta_amount_discount_create_decimal (ta_object_t *amount, double value, ta_e_currency_t currency, ta_object_t discount_id)
 Create object of type amount_discount using double precision floating point value. More...
 
ta_e_result_code_t ta_amount_discount_create_exponent (ta_object_t *amount, int64_t value, ta_e_currency_t currency, int exponent, ta_object_t discount_id)
 Create object of type amount_discount using custom exponent. More...
 
ta_e_result_code_t ta_amount_discount_create_decimal_exponent (ta_object_t *amount, double value, ta_e_currency_t currency, int exponent, ta_object_t discount_id)
 Create object of type amount_discount using custom exponent and double precision value. More...
 
ta_e_result_code_t ta_amount_discount_get_value (ta_object_t amount, int64_t *value)
 Discount amount in minor units. More...
 
ta_e_result_code_t ta_amount_discount_set_value (ta_object_t amount, int64_t value)
 Set amount in minor units. More...
 
ta_e_result_code_t ta_amount_discount_get_decimal_value (ta_object_t amount, double *value)
 Discount amount in major units as double precision floating point value. More...
 
ta_e_result_code_t ta_amount_discount_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_discount_get_currency (ta_object_t amount, ta_e_currency_t *currency)
 Discount currency. More...
 
ta_e_result_code_t ta_amount_discount_set_currency (ta_object_t amount, ta_e_currency_t currency)
 Set currency. More...
 
ta_e_result_code_t ta_amount_discount_get_exponent (ta_object_t amount, int *exponent)
 Discount exponent. More...
 
ta_e_result_code_t ta_amount_discount_set_exponent (ta_object_t amount, int exponent)
 Set exponent. More...
 
ta_e_result_code_t ta_amount_discount_get_discount_id (ta_object_t amount, ta_object_t *discount_id)
 Discount identifier. More...
 
ta_e_result_code_t ta_amount_discount_set_discount_id (ta_object_t amount, ta_object_t discount_id)
 Set discount identifier. More...
 

Function Documentation

◆ ta_amount_discount_create()

ta_e_result_code_t ta_amount_discount_create ( ta_object_t amount,
int64_t  value,
ta_e_currency_t  currency,
ta_object_t  discount_id 
)

Create object of type amount_discount.

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.
[in]discount_idDiscount identifier as object of type string.
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_argumentdiscount_id is ta_object_invalid.
ta_c_rc_invalid_argumentdiscount_id is not of type string.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_discount_create_decimal()

ta_e_result_code_t ta_amount_discount_create_decimal ( ta_object_t amount,
double  value,
ta_e_currency_t  currency,
ta_object_t  discount_id 
)

Create object of type amount_discount 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.
[in]discount_idDiscount identifier as object of type string.
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_argumentdiscount_id is ta_object_invalid.
ta_c_rc_invalid_argumentdiscount_id is not of type string.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_discount_create_decimal_exponent()

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

Create object of type amount_discount 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.
[in]discount_idDiscount identifier as object of type string.
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_invalid_argumentdiscount_id is ta_object_invalid.
ta_c_rc_invalid_argumentdiscount_id is not of type string.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_discount_create_exponent()

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

Create object of type amount_discount 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.
[in]discount_idDiscount identifier as object of type string.
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_invalid_argumentdiscount_id is ta_object_invalid.
ta_c_rc_invalid_argumentdiscount_id is not of type string.
ta_c_rc_out_of_memoryFailed allocating memory.

◆ ta_amount_discount_get_currency()

ta_e_result_code_t ta_amount_discount_get_currency ( ta_object_t  amount,
ta_e_currency_t currency 
)

Discount currency.

Parameters
[in]amountObject instance of type amount_discount.
[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_discount.
ta_c_rc_invalid_argumentcurrency is null-pointer.

◆ ta_amount_discount_get_decimal_value()

ta_e_result_code_t ta_amount_discount_get_decimal_value ( ta_object_t  amount,
double *  value 
)

Discount 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_discount.
[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_discount.
ta_c_rc_invalid_argumentvalue is null-pointer.

◆ ta_amount_discount_get_discount_id()

ta_e_result_code_t ta_amount_discount_get_discount_id ( ta_object_t  amount,
ta_object_t discount_id 
)

Discount identifier.

Parameters
[in]amountObject instance of type amount_discount.
[out]discount_idPointer to variable to write object instance to. Object instance is of type string and is not retained. Object instance is ta_object_invalid if identifier is not set in amount_discount.
Return values
ta_c_rc_okObject instance written to discount_id.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount_discount.
ta_c_rc_invalid_argumentdiscount_id is null-pointer.

◆ ta_amount_discount_get_exponent()

ta_e_result_code_t ta_amount_discount_get_exponent ( ta_object_t  amount,
int *  exponent 
)

Discount exponent.

Parameters
[in]amountObject instance of type amount_discount.
[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_discount.
ta_c_rc_invalid_argumentexponent is null-pointer.

◆ ta_amount_discount_get_value()

ta_e_result_code_t ta_amount_discount_get_value ( ta_object_t  amount,
int64_t *  value 
)

Discount amount in minor units.

Parameters
[in]amountObject instance of type amount_discount.
[out]valuePointer to variable to write value to. Use ta_amount_discount_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_discount.
ta_c_rc_invalid_argumentvalue is null-pointer.

◆ ta_amount_discount_set_currency()

ta_e_result_code_t ta_amount_discount_set_currency ( ta_object_t  amount,
ta_e_currency_t  currency 
)

Set currency.

Parameters
[in]amountObject instance of type amount_discount.
[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_discount.
ta_c_rc_invalid_argumentcurrency is not a valid value from ta_e_currency_t.

◆ ta_amount_discount_set_decimal_value()

ta_e_result_code_t ta_amount_discount_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_discount.
[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 ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount_discount.
ta_c_rc_out_of_memoryMemory allocation required but failed.

◆ ta_amount_discount_set_discount_id()

ta_e_result_code_t ta_amount_discount_set_discount_id ( ta_object_t  amount,
ta_object_t  discount_id 
)

Set discount identifier.

Parameters
[in]amountObject instance of type amount_discount.
[in]discount_idDiscount identifier as object of type string. Object instance will be retained.
Return values
ta_c_rc_okValue assigned to amount and retained.
ta_c_rc_invalid_argumentamount is ta_object_invalid.
ta_c_rc_invalid_argumentamount is not of type amount_discount.
ta_c_rc_invalid_argumentdiscount_id is ta_object_invalid.
ta_c_rc_invalid_argumentdiscount_id is not of type string.

◆ ta_amount_discount_set_exponent()

ta_e_result_code_t ta_amount_discount_set_exponent ( ta_object_t  amount,
int  exponent 
)

Set exponent.

Parameters
[in]amountObject instance of type amount_discount.
[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_discount.
ta_c_rc_invalid_argumentexponent is less than 0.

◆ ta_amount_discount_set_value()

ta_e_result_code_t ta_amount_discount_set_value ( ta_object_t  amount,
int64_t  value 
)

Set amount in minor units.

Parameters
[in]amountObject instance of type amount_discount.
[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_discount.
ta_c_rc_invalid_argumentvalue is less than 0.