package org.openbravo.test.dal;

import java.util.Date;

import org.junit.Test;
import org.openbravo.base.provider.OBProvider;
import org.openbravo.dal.service.OBDal;
import org.openbravo.model.common.enterprise.DocumentType;
import org.openbravo.model.financialmgmt.payment.FIN_BankStatement;
import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
import org.openbravo.test.base.OBBaseTest;

public class DalPersistanceEvent extends OBBaseTest {

  @Test
  public void documentNoHandler() {
    FIN_FinancialAccount fin_FinancialAccount = (FIN_FinancialAccount) OBDal.getInstance().get(
        FIN_FinancialAccount.ENTITY_NAME, "2C059762760F4F3D8A91342ED988DEB8");
    DocumentType doctype = (DocumentType) OBDal.getInstance().get(DocumentType.ENTITY_NAME,
        "4B2FE52726DE492C8C7050483868AD11");
    FIN_BankStatement impBankStat = OBProvider.getInstance().get(FIN_BankStatement.class);
    impBankStat.setAccount(fin_FinancialAccount);
    impBankStat.setOrganization(fin_FinancialAccount.getOrganization());
    impBankStat.setImportdate(new Date());
    impBankStat.setDocumentType(doctype);
    impBankStat.setName("Test stmt");
    impBankStat.setTransactionDate(new Date());
    // impBankStat.setDocumentNo(Utility.getDocumentNo(OBDal.getInstance().getConnection(false),
    // new DalConnectionProvider(false), RequestContext.get().getVariablesSecureApp(), "",
    // FIN_BankStatement.ENTITY_NAME, getDoctype().getId(), getDoctype().getId(), false, true));

    OBDal.getInstance().save(impBankStat);
    OBDal.getInstance().flush();
  }

}
