Ejemplo n.º 1
0
 private static String getTallyMessageData(TallyMessage tallyMessage, String fileName) {
   Template temp = getTemplate("tally_mesage.template");
   /* Create a data-model */
   Map<String, Object> root = new HashMap<String, Object>();
   Map<String, Object> voucher = new HashMap<String, Object>();
   root.put("voucher", voucher);
   voucher.put("type", tallyMessage.getVoucherType().getValue());
   voucher.put("date", TallyMessageGenerator.DATE_FORMAT.format(tallyMessage.getVoucherDate()));
   voucher.put("fileName", fileName);
   voucher.put("data", getVoucherData(tallyMessage));
   StringWriter bow = new StringWriter();
   process(temp, root, bow);
   return bow.toString() + "\n";
 }
Ejemplo n.º 2
0
  private static String getVoucherData(TallyMessage tallyMessage) {
    StringBuffer allLedgersOutput = new StringBuffer();
    // see payment specs for tally integration
    if (tallyMessage.getVoucherType() == VoucherType.PAYMENT) {
      // Add Debit Accounts
      for (AllLedger allLedger : tallyMessage.getAllLedgers()) {
        if (allLedger.getIsDeemedPositive().equals(Boolean.TRUE)) {
          allLedgersOutput.append(getAllLedgerData(allLedger));
        }
      }
      // Add Credit Accounts
      for (AllLedger allLedger : tallyMessage.getAllLedgers()) {
        if (allLedger.getIsDeemedPositive().equals(Boolean.FALSE)) {
          allLedgersOutput.append(getAllLedgerData(allLedger));
        }
      }

    } else {
      for (AllLedger allLedger : tallyMessage.getAllLedgers()) {
        allLedgersOutput.append(getAllLedgerData(allLedger));
      }
    }
    return allLedgersOutput.substring(0, allLedgersOutput.length() - 1);
  }