Skip to content

Commit

Permalink
Add failure reason for UOB invalid import
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Oct 19, 2024
1 parent 1f0db69 commit 6ba2707
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/tech/sledger/service/importer/UobImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public List<Transaction> process(
) {
try {
Sheet sheet = Workbook.getWorkbook(inputStream).getSheet(0);
long accountNumberLength = sheet.getCell(1, 4).getContents().length();
String accountNumber = sheet.getCell(1, 4).getContents();
long accountNumberLength = accountNumber.length();
if (
(account.getType() == Cash && accountNumberLength != 10) ||
(account.getType() == Credit && accountNumberLength != 16)
) {
throw new ResponseStatusException(BAD_REQUEST, "Invalid import file");
throw new ResponseStatusException(BAD_REQUEST, "Invalid import file for " + account.getType() + ": " + accountNumber);
}
return account.getType() == AccountType.Cash ?
processCash(sheet, account, templates) : processCredit(sheet, account, templates);
Expand Down

0 comments on commit 6ba2707

Please sign in to comment.