mirror of
https://github.com/google/nomulus
synced 2026-01-07 14:05:44 +00:00
Prefer Money.zero over Money.of(currency, 0)
In the case where currency has a zero scale (i.e. JPY), Money.of(currency, 0) throws ArithmeticException because the second argument is handled as a double, and JPY (for example) does not allow decimal precision, even if the decimal is zero. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129023540
This commit is contained in:
committed by
Justine Tunney
parent
3f471a32e2
commit
b2d5108c0c
@@ -56,7 +56,7 @@ public final class TldSpecificLogicProxy {
|
|||||||
* Returns the total cost of all fees for the event.
|
* Returns the total cost of all fees for the event.
|
||||||
*/
|
*/
|
||||||
public Money getTotalCost() {
|
public Money getTotalCost() {
|
||||||
Money result = Money.of(currency, 0);
|
Money result = Money.zero(currency);
|
||||||
for (Fee fee : fees) {
|
for (Fee fee : fees) {
|
||||||
result = result.plus(fee.getCost());
|
result = result.plus(fee.getCost());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user