Remove leading whitespace from charge/allowance reason

This commit is contained in:
Sebastian Sieber
2024-12-03 10:18:16 +01:00
parent 500a25c3bd
commit 1b66929add

View File

@@ -4,7 +4,10 @@ import static java.math.BigDecimal.ZERO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/*** /***
@@ -91,17 +94,14 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
} }
private String getAllowanceChargeReasonForPercent(BigDecimal percent, IZUGFeRDAllowanceCharge[] charges) { private String getAllowanceChargeReasonForPercent(BigDecimal percent, IZUGFeRDAllowanceCharge[] charges) {
String res = " "; if (charges == null) {
if ((charges != null) && (charges.length > 0)) { return "";
for (IZUGFeRDAllowanceCharge currentCharge : charges) {
if ((percent == null) || (currentCharge.getTaxPercent().compareTo(percent) == 0)
&& currentCharge.getReason() != null) {
res += currentCharge.getReason() + " ";
}
}
} }
res = res.substring(0, res.length() - 1); return Arrays.stream(charges)
return res; .filter(currentCharge -> (percent == null || currentCharge.getTaxPercent().compareTo(percent) == 0))
.map(IZUGFeRDAllowanceCharge::getReason)
.filter(Objects::nonNull)
.collect(Collectors.joining(" "));
} }
/*** /***