Example #1
0
    public String getTotal(GeneralVoucherToGetTotal voucher, String type, Connection conn) {
      double total = 0;
      DecimalFormat dm = new DecimalFormat("#,##0.00");

      if (type.equalsIgnoreCase("Project Cost")) {
        /*GenericMapper mapper=MasterMap.obtainMapperFor(PmtProjectCostDetail.class);
        mapper.setActiveConn(vConn);
        String strWhere = IDBConstants.ATTR_PMT_PROJECT_COST+"="+voucher.vgetIndex();
        List rs=mapper.doSelectWhere(strWhere);
        */
        PmtProjectCostDetail detail = null;

        Long key = new Long(voucher.vgetIndex());
        List rs = (List) childrenMap.get(key);

        String attr = "";
        if (voucher.vgetCashAccount() != null) attr = IConstants.ATTR_PMT_CASH;
        else if (voucher.vgetBankAccount() != null) attr = IConstants.ATTR_PMT_BANK;
        else {
          if (voucher.igetPaymentSource().equalsIgnoreCase("CASH")) attr = IConstants.ATTR_PMT_CASH;
          else attr = IConstants.ATTR_PMT_BANK;
        }
        /*JournalStandardAccount[] jsAccounts = getJournalStandardAccount(attr);*/

        JournalStandardAccount[] jsAccounts =
            (JournalStandardAccount[]) journalStandardAccountsMap.get(attr);

        if (rs != null)
          for (int i = 0; i < rs.size(); i++) {
            detail = (PmtProjectCostDetail) rs.get(i);
            for (int j = 0; j < jsAccounts.length; j++)
              if (detail.getAccount().getIndex() == jsAccounts[j].getAccount().getIndex())
                if (!jsAccounts[j].isCalculate() && !jsAccounts[j].isHidden()) {
                  JournalStandardAccount jsAccount = jsAccounts[j];
                  double amount = detail.getaccValue();
                  if (jsAccount.getBalance() == 1) amount = -detail.getaccValue();
                  total += amount;
                }
          }
      } else if (type.equalsIgnoreCase("Operational Cost")) {
        if (voucher != null) {
          /*GenericMapper mapper=MasterMap.obtainMapperFor(PmtOperationalCostDetail.class);
          mapper.setActiveConn(conn);
          List detailList=mapper.doSelectWhere(IDBConstants.ATTR_PMT_OPERASIONAL_COST+"="+voucher.vgetIndex());*/

          Long key = new Long(voucher.vgetIndex());
          List detailList = (List) childrenMap.get(key);

          PmtOperationalCostDetail detail;
          int length = detailList.size();
          if (length > 0) {
            /*JournalStandardAccount[] jsAccounts = getJournalStandardAccount((PmtOperationalCost) voucher);*/

            PmtOperationalCost pmt = (PmtOperationalCost) voucher;

            String attr = "";
            if (pmt.getCashAccount() != null) {
              attr = IConstants.ATTR_PMT_CASH;
            } else if (pmt.getBankAccount() != null) {
              attr = IConstants.ATTR_PMT_BANK;
            } else if (pmt.getPaymentSource().equalsIgnoreCase("BANK")) {
              attr = IConstants.ATTR_PMT_BANK;
            } else if (pmt.getPaymentSource().equalsIgnoreCase("CASH")) {
              attr = IConstants.ATTR_PMT_CASH;
            }

            JournalStandardAccount[] jsAccounts =
                (JournalStandardAccount[]) journalStandardAccountsMap.get(attr);

            if (detailList != null)
              for (int i = 0; i < detailList.size(); i++) {
                detail = (PmtOperationalCostDetail) detailList.get(i);
                for (int j = 0; j < jsAccounts.length; j++)
                  if (detail.getAccount().getIndex() == jsAccounts[j].getAccount().getIndex())
                    if (!jsAccounts[j].isCalculate() && !jsAccounts[j].isHidden()) {
                      JournalStandardAccount jsAccount = jsAccounts[j];
                      double amount = detail.getAccValue();
                      if (jsAccount.getBalance() == 1) amount = -detail.getAccValue();
                      total += amount;
                    }
              }
          } else {
            total = 0;
          }
        }
      }
      return dm.format(total);
    }
Example #2
0
 void setReceiptList(Object[] object, String type) {
   model.clearRows();
   objRows = object;
   for (int i = 0; i < object.length; i++) {
     GeneralVoucherToGetTotal voucher = (GeneralVoucherToGetTotal) object[i];
     if (voucher != null)
       model.addRow(
           new Object[] {
             new Integer(i + 1),
             voucher.igetPaymentSource(),
             voucher.vgetVoucherType(),
             voucher.vgetVoucherNo(),
             voucher.vgetVoucherDate(),
             voucher.vgetPayTo(),
             voucher.vgetOriginator(),
             voucher.vgetApprovedBy(),
             voucher.vgetReceivedBy(),
             voucher.vgetUnitCode(),
             voucher.vgetStatus(),
             voucher.vgetSubmitDate(),
             voucher.vgetSymbolCurrency() + " " + getTotal(voucher, type, vConn).toString()
           });
   }
 }