Support for new Voucher Vault export

This commit is contained in:
Sylvia van Os
2021-07-08 19:59:27 +02:00
parent f53c61bbec
commit 18c5aa4707
3 changed files with 10 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ Changes:
- Support importing password-protected zip files
- Support importing from Stocard (Beta)
- Fix useless whitespace in notes from Fidme import
- Support new Voucher Vault export format
## v1.14.1 (2021-06-14)

View File

@@ -61,11 +61,13 @@ public class VoucherVaultImporter implements Importer
expiry = dateFormat.parse(jsonCard.getString("expires"));
}
BigDecimal balance;
if (!jsonCard.isNull("balance")) {
BigDecimal balance = new BigDecimal("0");
if (jsonCard.has("balanceMilliunits")) {
if (!jsonCard.isNull("balanceMilliunits")) {
balance = new BigDecimal(String.valueOf(jsonCard.getInt("balanceMilliunits") / 1000.0));
}
} else if (!jsonCard.isNull("balance")) {
balance = new BigDecimal(String.valueOf(jsonCard.getDouble("balance")));
} else {
balance = new BigDecimal("0");
}
Currency balanceType = Currency.getInstance("USD");

View File

@@ -1194,6 +1194,7 @@ public class ImportExportTest
" \"expires\": null,\n" +
" \"removeOnceExpired\": true,\n" +
" \"balance\": null,\n" +
" \"balanceMilliunits\": null,\n" +
" \"color\": \"GREY\"\n" +
" },\n" +
" {\n" +
@@ -1203,7 +1204,8 @@ public class ImportExportTest
" \"codeType\": \"CODE39\",\n" +
" \"expires\": \"2021-03-26T00:00:00.000\",\n" +
" \"removeOnceExpired\": true,\n" +
" \"balance\": 3.5,\n" +
" \"balance\": null,\n" +
" \"balanceMilliunits\": 3500,\n" +
" \"color\": \"PURPLE\"\n" +
" }\n" +
"]";