/**
   * post the qualified origin entries into Labor Ledger tables
   *
   * @param validGroup the origin entry group that holds the valid transactions
   * @param invalidGroup the origin entry group that holds the invalid transactions
   * @param runDate the data when the process is running
   */
  protected void postLaborLedgerEntries(Date runDate) {
    LOG.debug("postLaborLedgerEntries() started..........................");
    numberOfErrorOriginEntry = 0;
    // change file name to FIS

    String postInputFileName =
        batchFileDirectoryName
            + File.separator
            + LaborConstants.BatchFileSystem.POSTER_INPUT_FILE
            + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
    String postErrFileName =
        batchFileDirectoryName
            + File.separator
            + LaborConstants.BatchFileSystem.POSTER_ERROR_OUTPUT_FILE
            + GeneralLedgerConstants.BatchFileSystem.EXTENSION;

    FileReader INPUT_GLE_FILE = null;
    try {
      INPUT_GLE_FILE = new FileReader(postInputFileName);
    } catch (FileNotFoundException e) {
      throw new RuntimeException(e);
    }

    try {
      POSTER_OUTPUT_ERR_FILE_ps = new PrintStream(postErrFileName);
    } catch (IOException e) {
      LOG.error("postLaborLedgerEntries cannot open file: " + e.getMessage(), e);
      throw new RuntimeException(e);
    }

    int lineNumber = 0;
    int loadedCount = 0;

    int numberOfSelectedOriginEntry = 0;
    LaborLedgerUnitOfWork laborLedgerUnitOfWork = new LaborLedgerUnitOfWork();

    LedgerSummaryReport ledgerSummaryReport = new LedgerSummaryReport();

    Map<String, Integer> reportSummary = this.constructPosterReportSummary();
    Map<String, Integer> glEntryReportSummary = this.constructGlEntryReportSummary();

    try {
      BufferedReader INPUT_GLE_FILE_br = new BufferedReader(INPUT_GLE_FILE);
      String currentLine = INPUT_GLE_FILE_br.readLine();

      while (currentLine != null) {
        LaborOriginEntry laborOriginEntry = null;

        try {
          lineNumber++;
          if (!StringUtils.isEmpty(currentLine) && !StringUtils.isBlank(currentLine.trim())) {
            laborOriginEntry = new LaborOriginEntry();

            // checking parsing process and stop poster when it has errors.
            List<Message> parsingError = new ArrayList<Message>();
            parsingError = laborOriginEntry.setFromTextFileForBatch(currentLine, lineNumber);
            if (parsingError.size() > 0) {
              throw new RuntimeException("Exception happened from parsing process");
            }

            loadedCount++;
            if (loadedCount % 1000 == 0) {
              LOG.info(loadedCount + " " + laborOriginEntry.toString());
            }

            boolean isPostable =
                this.postSingleEntryIntoLaborLedger(
                    laborOriginEntry, reportSummary, runDate, currentLine);
            if (isPostable) {
              this.updateReportSummary(
                  glEntryReportSummary, ORIGN_ENTRY, KFSConstants.OperationType.READ);
              this.writeLaborGLEntry(
                  laborOriginEntry,
                  laborLedgerUnitOfWork,
                  runDate,
                  lineNumber,
                  glEntryReportSummary);

              ledgerSummaryReport.summarizeEntry(laborOriginEntry);

              numberOfSelectedOriginEntry++;
              laborOriginEntry = null;
            }
          }

          currentLine = INPUT_GLE_FILE_br.readLine();
        } catch (RuntimeException re) {
          // catch here again, it should be from postSingleEntryIntoLaborLedger
          LOG.error(
              "postLaborLedgerEntries stopped due to: "
                  + re.getMessage()
                  + " on line number : "
                  + loadedCount,
              re);
          LOG.error(
              "laborOriginEntry failure occured on: " + laborOriginEntry == null
                  ? null
                  : laborOriginEntry.toString());
          throw new RuntimeException(
              "Unable to execute: " + re.getMessage() + " on line number : " + loadedCount, re);
        }
      }

      this.writeLaborGLEntry(
          null, laborLedgerUnitOfWork, runDate, lineNumber, glEntryReportSummary);

      INPUT_GLE_FILE_br.close();
      INPUT_GLE_FILE.close();
      POSTER_OUTPUT_ERR_FILE_ps.close();

      this.fillPosterReportWriter(lineNumber, reportSummary, glEntryReportSummary);
      this.fillGlEntryReportWriter(glEntryReportSummary);

      // Generate Error Listing Report
      ledgerSummaryReport.writeReport(ledgerSummaryReportWriterService);
      new TransactionListingReport()
          .generateReport(
              errorListingReportWriterService,
              new LaborOriginEntryFileIterator(new File(postErrFileName)));
    } catch (IOException ioe) {
      LOG.error("postLaborLedgerEntries stopped due to: " + ioe.getMessage(), ioe);
      throw new RuntimeException(
          "Unable to execute: " + ioe.getMessage() + " on line number : " + loadedCount, ioe);
    }
  }