private List<Double> captureSelectedBlock() {
    int startIndex = FileUtils.findIndexBySingleValue(lines, "Transaction\\s+History");
    int endIndex = FileUtils.findIndexBySingleValue(lines, "^\\s*Totals");

    List<Double> mainList = new ArrayList<>();
    List<String> selected = new ArrayList<>();

    List<String> list = FileUtils.getSelectedBlockByIndex(lines, startIndex, endIndex);
    for (String s : list) {
      String result = FileUtils.getResultFromPattern("^\\s*\\d{1,2}/\\d{1,2}\\s+", s);
      if (!result.startsWith("NoMatch")) {
        if (selected.size() > 0) {
          if (selected.get(selected.size() - 1).startsWith(result)) {
            selected.set(selected.size() - 1, s);
          } else {
            selected.add(s);
          }
        } else {
          selected.add(s);
        }
      }
    }
    for (int a = 0; a < selected.size(); a++) {
      String[] line = selected.get(a).split(" ");
      if (line.length > 1) {
        mainList.add(
            FileUtils.convertStringToDouble(
                FileUtils.getDollarSignRemovedValue(
                    FileUtils.getBracketRemovedValue(line[line.length - 1]))));
      }
    }

    return mainList;
  }
  private double extractAmountFromKeywordListAndReturnSum() {
    List<Double> list = new ArrayList<>();
    List<String> datelist = new ArrayList<>();
    int count = 0;
    double sum = 0;
    for (int a = 0; a < this.selectedBlock.size(); a++) {

      String value = FileUtils.getLastElementFromArray(this.selectedBlock.get(a));
      value = FileUtils.getDollarSignRemovedValue(value);
      double d = FileUtils.convertStringToDouble(value);
      String[] temp = this.selectedBlock.get(a).trim().split(" ");
      datelist.add(temp[0]);
      list.add(d);
    }
    for (int a = 0; a < list.size(); a++) {
      double d = list.get(a);
      if (d < 3000) {

        ++count;
      } else {
        keywordAmount.add(d);
        keywordDate.add(datelist.get(a));
        keywordDescription.add(keyDescription.get(a));
        sum += d;
      }
    }
    setNoOfValuesLessThan3000(count);
    return sum;
  }
 private double findOnlineTransferFromSum() {
   List<String> list = captureOnlineTransferFromRecords();
   double sum = 0;
   for (String s : list) {
     String value = FileUtils.getSecondLastElementFromArray(s);
     value = FileUtils.getDollarSignRemovedValue(value);
     double d = FileUtils.convertStringToDouble(value);
     sum += d;
   }
   return sum;
 }
 private List<Double> captureAmountFromSelectedRecords() {
   List<Double> main = new ArrayList<>();
   for (String s : this.filteredBlock) {
     String result = FileUtils.getResultFromPattern("Refund|REFUND|Return", s);
     if (!result.startsWith("NoMatch")) {
       String[] temp = s.split("\\s+");
       main.add(
           FileUtils.convertStringToDouble(
               FileUtils.getDollarSignRemovedValue(temp[temp.length - 1])));
     }
   }
   return main;
 }
 private double captureAverageLedgerBalance() {
   double d = 0;
   for (String s : lines) {
     String result = FileUtils.getResultFromPattern("Average\\s+Ledger\\s+Balance*", s);
     if (!result.startsWith("NoMatch")) {
       String[] temp = s.split("\\s+");
       d =
           FileUtils.convertStringToDouble(
               FileUtils.getDollarSignRemovedValue(
                   FileUtils.getNegativeSignDetectedValue(temp[3])));
       break;
     }
   }
   return d;
 }
  private double captureTotalDeposits() {
    String result = "";
    double d = 0;
    for (String s : lines) {
      if (s.contains("Credits (+)")) {
        result = s;
        break;
      }
    }
    if (result.length() > 1) {
      String[] temp = result.split("\\s+");
      String dd = FileUtils.getDollarSignRemovedValue(temp[temp.length - 1]);
      d = FileUtils.convertStringToDouble(dd);
    }

    return d;
  }
  private void captureSelectedBlockForDebit() {
    List<String> List = new ArrayList<>();
    List<Double> list = new ArrayList<>();
    List<String> datelist = new ArrayList<>();
    List<Double> CheckDailyPaymentAmount = new ArrayList<>();

    for (int x = 0; x < debitBlock.size(); x++) {
      for (int a = 0; a < words.size(); a++) {
        String wordLine = words.get(a).toLowerCase();
        String result = FileUtils.getResultFromPattern(wordLine, debitBlock.get(x).toLowerCase());
        if (!result.startsWith("NoMatch")) {
          for (int R = x; R > 0; R--) {
            if (debitBlock.get(R).matches("^\\s*\\d{1,2}/\\d{1,2}/\\d{1,2}.+")) {
              List.add(debitBlock.get(R));
              dailykeyDescription.add(words.get(a).toLowerCase());
              break;
            }
          }
          break;
        }
      }
    }
    for (int a = 0; a < List.size(); a++) {
      String value = FileUtils.getLastElementFromArray(List.get(a));
      value = FileUtils.getDollarSignRemovedValue(value);
      double d = FileUtils.convertStringToDouble(value);
      String[] temp = List.get(a).trim().split("\\s+");
      datelist.add(temp[0]);
      list.add(d);
    }
    for (int a = 0; a < list.size(); a++) {
      double d = list.get(a);
      if (CheckDailyPaymentAmount.contains(d)) {
        //  if (!DailypaymentkeywordDescription.contains(dailykeyDescription.get(a)))
        //  {
        DailypaymentkeywordAmount.add(d);
        DailypaymentkeywordDate.add(datelist.get(a));
        DailypaymentkeywordDescription.add(dailykeyDescription.get(a));
        //  }
      } else {
        CheckDailyPaymentAmount.add(d);
      }
    }
  }
 private void captureDateDescriptionAmount() {
   List<String> list = this.selectedBlock;
   for (String s : list) {
     String[] temp = s.split("\\s+");
     date.add(temp[0]);
     amount.add(FileUtils.convertStringToDouble(FileUtils.getDollarSignRemovedValue(temp[1])));
     String desc = "";
     for (int a = 2; a < temp.length; a++) {
       desc += temp[a] + " ";
     }
     description.add(desc);
     String res = FileUtils.getResultFromPattern("\\d{7,}", desc);
     if (!res.startsWith("NoMatch")) {
       checkNo.add(FileUtils.getFourDigitAccountNumber(res));
     } else {
       checkNo.add("N/A");
     }
   }
   this.checkNoDuplicateRemoved = FileUtils.removeDuplicateValues(checkNo);
 }
Ejemplo n.º 9
0
  private void captureOnlineTransferToRecords() {
    List<String> firstLine = new ArrayList<>();
    List<String> secondLine = new ArrayList<>();
    List<Integer> indexFinder = new ArrayList<>();
    List<String> mergedLine = new ArrayList<>();

    for (int a = 0; a < this.selectedBlock.size(); a++) {
      String result =
          FileUtils.getResultFromPattern(
              "ONLINE\\s+BANKING\\s+TRANSFER\\s+TO", this.selectedBlock.get(a));

      if (!result.startsWith("NoMatch")) {
        indexFinder.add(a + 1);
        firstLine.add(this.selectedBlock.get(a));
        String[] temp = this.selectedBlock.get(a).split("\\s+");
        date.add(temp[0]);
        String value =
            FileUtils.getDollarSignRemovedValue(
                FileUtils.getLastElementFromArray(this.selectedBlock.get(a)));
        double d = FileUtils.convertStringToDouble(value);
        amount.add(d);
        String desc = "";
        for (int x = 1; x < temp.length - 1; x++) {
          desc += temp[x] + " ";
        }
        description.add(desc);
      }
    }
    for (int a = 0; a < indexFinder.size(); a++) {
      String val = selectedBlock.get(indexFinder.get(a));

      String result = this.description.get(a) + " " + val;
      String ch = FileUtils.getResultFromPattern("TO\\s+XX+\\d+", result);
      if (!ch.startsWith("NoMatch")) {
        ch = FileUtils.getFourDigitAccountNumber(ch);
        checkNo.add(ch);
      } else {
        checkNo.add("N/A");
      }
    }
  }