Beispiel #1
0
  public void test1() throws Exception {
    Class.forName("com.sap.dbtech.jdbc.DriverSapDB");
    String url = "jdbc:sapdb://" + host + "/" + dbname;

    Connection connection = DriverManager.getConnection(url, username, password);

    JournalStandardSettingPickerHelper helper =
        new JournalStandardSettingPickerHelper(connection, 0, IDBConstants.MODUL_MASTER_DATA);
    List list = helper.getJournalStandardSetting(IConstants.PAYROLL_VERIFICATION_PAYCHEQUES);
    System.out.println(list.size());
    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
      JournalStandardSetting setting = (JournalStandardSetting) iterator.next();
      System.out.println(setting.getJournalStandard().toString());
    }
  }
Beispiel #2
0
  public void submit(long sessionId, java.sql.Connection conn) throws Exception {
    // CREATE THE TRANSACTION
    // siapkan khusus untuk work in progress
    VariableAccountSetting vas =
        VariableAccountSetting.createVariableAccountSetting(
            conn, sessionId, IConstants.ATTR_VARS_WORK_IN_PROGRESS);
    Account wipAcct = null;
    if (vas != null) wipAcct = vas.getAccount();

    // bikin si pemberi
    // amount-nya diminus soalnya ga pada tempatnya
    ArrayList detailList = new ArrayList();

    // nyang nerima/buat apa (syusah....)
    PmtProjectCostDetail[] dets = getPmtProjectCostDetail();
    double tempamount = 0;
    CashBankAccount sourceAccount = getSourceAccount();
    for (int i = 0; i < dets.length; i++) {
      TransactionDetail detail = null;
      if (dets[i].getAccount().equals(sourceAccount.getAccount()))
        detail =
            createNewTransDet(
                dets[i].getAccount(),
                dets[i].getaccValue(),
                dets[i].getCurrency(),
                dets[i].getExchangeRate(),
                sourceAccount.getIndex());
      else if (dets[i].getAccount().equals(wipAcct))
        detail =
            createNewTransDet(
                dets[i].getAccount(),
                dets[i].getaccValue(),
                dets[i].getCurrency(),
                dets[i].getExchangeRate(),
                getProject().getIndex());
      else
        detail =
            createNewTransDet(
                dets[i].getAccount(),
                dets[i].getaccValue(),
                dets[i].getCurrency(),
                dets[i].getExchangeRate());
      tempamount = tempamount + dets[i].getaccValue();
      detailList.add(detail);
    }
    // setAmount(tempamount);

    /*	TransactionDetail sourceDetail =
    createNewTransDet(sourceAccount.getAccount(), -getAmount(), sourceAccount.getIndex());
    detailList.add(sourceDetail);*/

    // GET THE STANDARD JOURNAL
    JournalStandardSettingPickerHelper helper =
        new JournalStandardSettingPickerHelper(conn, sessionId, IDBConstants.MODUL_ACCOUNTING);

    String type = "";
    String code = "";
    String attr = "";
    if (sourceAccount instanceof BankAccount) {
      // artinya dikeluarken dari bank
      type = ReferenceNoGeneratorHelper.BANK_OUT;
      code = ((BankAccount) sourceAccount).getCode();
      attr = IConstants.ATTR_PMT_BANK;
    } else {
      // buat yang cash
      type = ReferenceNoGeneratorHelper.CASH_OUT;
      code = ((CashAccount) sourceAccount).getUnit().getCode();
      attr = IConstants.ATTR_PMT_CASH;
    }

    List journalStdList =
        helper.getJournalStandardSettingWithAccount(IConstants.PAYMENT_PROJECT_COST, attr);

    // harusnya dapat satu, yang lain abaikan aja... berarti user salah milih hehehehehe
    JournalStandardSetting setting = (JournalStandardSetting) journalStdList.get(0);
    JournalStandard journal = setting.getJournalStandard();

    // get the reference no first
    ReferenceNoGeneratorHelper noGenerator =
        new ReferenceNoGeneratorHelper(
            conn, sessionId, IDBConstants.MODUL_ACCOUNTING, getReferenceNo());
    setReferenceNo(noGenerator.createCashOrBankReferenceNo(type, code, getTransactionDate()));

    //	this is waktunya...
    Transaction trans = createNewTrans(journal);
    TransactionDetail[] details =
        (TransactionDetail[]) detailList.toArray(new TransactionDetail[detailList.size()]);

    TransactionDetailPreparingHelper transHelper = new TransactionDetailPreparingHelper();
    details =
        transHelper.prepareJournalStandardTransactionDetail(
            journal.getJournalStandardAccount(), details, getUnit(), igetBaseCurrency(), 1, false);

    trans.setTransactionDetail(details);
    // save lah
    AccountingBusinessLogic logic = new AccountingBusinessLogic(conn);
    trans =
        logic.createTransactionData(
            sessionId, IDBConstants.MODUL_ACCOUNTING, trans, trans.getTransactionDetail());

    // get everything related
    setStatus((short) StateTemplateEntity.State.VERIFIED);
    setSubmitDate(trans.getVerifyDate());
    setTrans(trans);

    System.out.println("DONE");

    // UNTESTED !!!!
    // UNTESTED !!!!
    // UNTESTED !!!!
  }