My issue is I currently have a value that is £17.40, this is then converted into Euros which becomes €20.01. when selecting the button which which would round up the amount it reads €20.00 but should read €30.00 (with €30 being the next whole amount to pay with).
private fun getNextLogicalCashAmount(currentAmount: Double = getBasket()?.getAmountRemaining() ?: 0.00): Double
{
var amount = ((Math.ceil(currentAmount) / 10.00).toInt() * 10).toDouble()
if (amount <= currentAmount )
{
amount += 10
}
return amount
}
private fun setConvertedAmount(amount: Double)
{
val nativeFormatter = LocalityHelper.getNumberFormatter()
converted_amount?.visibility = if (amount > 0.00) View.VISIBLE else View.INVISIBLE
converted_amount?.text = getString(R.string.same_as_amount, nativeFormatter.format(convertBack(amount)))
}
/**
* Return the custom amount entered into the EditText as a Double.
*/
private fun getCustomAmount(): Double
{
return try
{
custom_amount?.text.toString().toDouble()
}
catch (e: Exception)
{
0.00
}
}
private fun convert(amount: Double): Double = providers.getCurrencyConverter().convert(
amount,
providers.getMarketOptions().getCurrencyCode(),
providers.getStoreOptions().getForeignCurrencyCode()!!
)
private fun convertBack(amount: Double): Double = providers.getCurrencyConverter().convert(
amount,
providers.getStoreOptions().getForeignCurrencyCode()!!,
providers.getMarketOptions().getCurrencyCode()
)
private fun takePayment(amount: Double, foreignAmount: Double)
{
if (amount > 0.00 && foreignAmount > 0.00)
{
CashDrawerDialog().setListener { addPayment(amount, foreignAmount, it) }.show(this)
}
else
{
Toast.makeText(context, R.string.enter_valid_amount, Toast.LENGTH_SHORT).show()
}
}
It seems I am still picking up the value from the £. So when the £ reaches £20, the € will change to €30.00, but when the the foreign currency is at €20.1 it will still show as €20.00.