Пример #1
0
 // Operational Cost
 public JournalStandardAccount[] getJournalStandardAccount(PmtOperationalCost entity) {
   String attr = "";
   if (entity.getCashAccount() != null) {
     attr = IConstants.ATTR_PMT_CASH;
   } else if (entity.getBankAccount() != null) {
     attr = IConstants.ATTR_PMT_BANK;
   } else if (entity.getPaymentSource().equalsIgnoreCase("BANK")) {
     attr = IConstants.ATTR_PMT_BANK;
   } else if (entity.getPaymentSource().equalsIgnoreCase("CASH")) {
     attr = IConstants.ATTR_PMT_CASH;
   }
   JournalStandardSettingPickerHelper helper =
       new JournalStandardSettingPickerHelper(
           m_conn, m_sessionid, IDBConstants.MODUL_ACCOUNTING);
   List journalStdList =
       helper.getJournalStandardSettingWithAccount(IConstants.PAYMENT_OPERASIONAL_COST, attr);
   JournalStandardSetting setting = (JournalStandardSetting) journalStdList.get(0);
   JournalStandard journal = setting.getJournalStandard();
   JournalStandardAccount[] jsAcc = journal.getJournalStandardAccount();
   return jsAcc;
 }
Пример #2
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);
    }