|
5 | 5 | import android.os.Bundle; |
6 | 6 |
|
7 | 7 | import java.io.File; |
| 8 | +import java.math.RoundingMode; |
8 | 9 | import java.util.Arrays; |
9 | 10 | import java.util.Currency; |
10 | 11 | import java.util.List; |
|
22 | 23 |
|
23 | 24 | public class SnabbleSdk { |
24 | 25 |
|
25 | | - |
26 | 26 | public static class Config { |
27 | 27 | /** |
28 | 28 | * The endpoint url of the snabble backend. For example "snabble.io" for the Production environment. |
@@ -135,6 +135,8 @@ public static class Config { |
135 | 135 | public String[] weighPrefixes = new String[0]; |
136 | 136 |
|
137 | 137 | public String[] amountPrefixes = new String[0]; |
| 138 | + |
| 139 | + public RoundingMode roundingMode = RoundingMode.UP; |
138 | 140 | } |
139 | 141 |
|
140 | 142 | private String endpointBaseUrl; |
@@ -166,6 +168,8 @@ public static class Config { |
166 | 168 | private String[] weighPrefixes = new String[0]; |
167 | 169 | private String[] amountPrefixes = new String[0]; |
168 | 170 |
|
| 171 | + private RoundingMode roundingMode; |
| 172 | + |
169 | 173 | private SnabbleSdk() { |
170 | 174 |
|
171 | 175 | } |
@@ -264,6 +268,8 @@ private void init(final Application app, |
264 | 268 | pricePrefixes = Arrays.copyOf(config.pricePrefixes, config.pricePrefixes.length); |
265 | 269 | amountPrefixes = Arrays.copyOf(config.amountPrefixes, config.amountPrefixes.length); |
266 | 270 |
|
| 271 | + roundingMode = config.roundingMode != null ? config.roundingMode : RoundingMode.UP; |
| 272 | + |
267 | 273 | updateShops(); |
268 | 274 |
|
269 | 275 | if (config.bundledMetadataAssetPath != null) { |
@@ -535,6 +541,10 @@ public Locale getCurrencyLocale() { |
535 | 541 | return currencyLocale; |
536 | 542 | } |
537 | 543 |
|
| 544 | + public RoundingMode getRoundingMode() { |
| 545 | + return roundingMode; |
| 546 | + } |
| 547 | + |
538 | 548 | public Checkout getCheckout() { |
539 | 549 | return checkout; |
540 | 550 | } |
|
0 commit comments