示例#1
0
  public void check(
      GLSession session,
      GLTransaction txn,
      String param,
      Account account,
      int[] entryOffsets,
      short[] layers)
      throws GLException {
    Journal journal = txn.getJournal();
    Date postDate = txn.getPostDate();
    Date end = journal.getEnd();
    Date start = journal.getStart();
    Date lockDate = journal.getLockDate();

    session.checkPermission(GLPermission.POST, journal);

    if (journal.isClosed()) {
      throw new GLException("Journal '" + journal.getName() + "' is closed");
    }
    if (postDate == null) throw new GLException("Invalid transaction. Posting date is null");

    if (start != null && postDate.compareTo(start) < 0) {
      throw new GLException(
          "Journal '"
              + journal.getName()
              + "' cannot accept transactions with a posting date less than "
              + start.toString());
    }
    if (end != null && postDate.compareTo(end) > 0) {
      throw new GLException(
          "Journal '"
              + journal.getName()
              + "' cannot accept transactions with a post date greater than "
              + end.toString());
    }
    if (lockDate != null && postDate.compareTo(lockDate) <= 0) {
      throw new GLException(
          "Journal '" + journal.getName() + "' has a temporary lockDate at " + lockDate.toString());
    }
    checkEntries(txn, postDate);
  }