Package org.jallinone.accounting.movements.java

Examples of org.jallinone.accounting.movements.java.JournalRowVO


            "RECORD_NUMBER>? and VAT_DATE<=?";
        pstmt = conn.prepareStatement(sql);
        BigDecimal amount = null;
        BigDecimal newLastRN = null;
        JournalHeaderVO jhVO = null;
        JournalRowVO jrVO = null;
        String accountCode = null;

        sql = "update ACC04_VAT_REGISTERS set LAST_RECORD_NUMBER=?,LAST_VAT_DATE=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where COMPANY_CODE_SYS01=? and REGISTER_CODE=? and (LAST_RECORD_NUMBER=? || LAST_RECORD_NUMBER is null)";
        pstmt2 = conn.prepareStatement(sql);

        while(en.hasMoreElements()) {
          // retrieve total vat amount for the specified vat register...
          amount = new BigDecimal(0);
          regCode = en.nextElement().toString();
          lastRN = (BigDecimal)lastRecordNumbers.get(regCode);
          lastVD = (java.sql.Date)lastVatDates.get(regCode);
          accountCode = (String)accountCodes.get(regCode);
          pstmt.setString(1,companyCode);
          pstmt.setString(2,regCode);
          pstmt.setBigDecimal(3,lastRN);
          pstmt.setDate(4,new java.sql.Date(toDate.getTime()));
          rset = pstmt.executeQuery();
          while(rset.next()) {
            amount = amount.add(rset.getBigDecimal(1));
            newLastRN = rset.getBigDecimal(2);
          }
          rset.close();

          if (amount.doubleValue()!=0) {
            lastVD.setTime(lastVD.getTime()+86400*1000);

            // create the accounting item...
            jhVO = new JournalHeaderVO();
            jhVO.setCompanyCodeSys01ACC05(companyCode);
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_VAT_ENDORSING);
            jhVO.setDescriptionACC05(
              t2+" "+
              regCode+" "+
              t3+" "+sdf.format(lastVD)+" - "+sdf.format(toDate)

            );
            jhVO.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
            jhVO.setItemYearACC05(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));

            jrVO = new JournalRowVO();
            jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
            jrVO.setAccountCodeAcc02ACC06(accountCode);
            jrVO.setAccountCodeACC06(accountCode);
            jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);
            jrVO.setDebitAmountACC06(amount);
            jrVO.setDescriptionACC06("");
            jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
            jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
            jhVO.addJournalRow(jrVO);

            jrVO = new JournalRowVO();
            jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
            jrVO.setAccountCodeAcc02ACC06(vatEndorseAccountCode);
            jrVO.setAccountCodeACC06(vatEndorseAccountCode);
            jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);
            jrVO.setCreditAmountACC06(amount);
            jrVO.setDescriptionACC06("");
            jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
            jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
            jhVO.addJournalRow(jrVO);

            res = bean.insertJournalItem(jhVO,serverLanguageId,username);
            if (res.isError()) {
              throw new Exception(res.getErrorMessage());
View Full Code Here


  /**
   * Update totals in frame.
   */
  private void updateTotals() {
    JournalRowVO vo = null;
    BigDecimal d = new BigDecimal(0);
    BigDecimal c = new BigDecimal(0);
    for(int i=0;i<vos.size();i++) {
      vo = (JournalRowVO)vos.get(i);
      if (vo.getDebitAmountACC06()!=null)
        d = d.add(vo.getDebitAmountACC06());
      if (vo.getCreditAmountACC06()!=null)
        c = c.add(vo.getCreditAmountACC06());
    }
    frame.getControlTotDebit().setValue(d);
    frame.getControlTotCredit().setValue(c);
    frame.getControlSbil().setValue(d.subtract(c));
  }
View Full Code Here

   * Method called by the Form panel to insert new data.
   * @param newValueObject value object to save
   * @return an ErrorResponse value object in case of errors, VOResponse if the operation is successfully completed
   */
  public Response insertRecord(ValueObject newPersistentObject) throws Exception {
    JournalRowVO vo = (JournalRowVO)newPersistentObject;
    if (vo.getAccountCodeACC06()==null)
      return new ErrorResponse("you must specify a code");
    if (vo.getDebitAmountACC06()==null && vo.getCreditAmountACC06()==null)
      return new ErrorResponse("you must specify a debit or credit amount");


    vos.add(newPersistentObject);
    frame.getGrid().reloadData();
View Full Code Here

   * @param oldPersistentObject original value object, previous to the changes
   * @param persistentObject value object to save
   * @return an ErrorResponse value object in case of errors, VOResponse if the operation is successfully completed
   */
  public Response updateRecord(ValueObject oldPersistentObject,ValueObject persistentObject) throws Exception {
    JournalRowVO vo = (JournalRowVO)persistentObject;
    if (vo.getAccountCodeACC06()==null)
      return new ErrorResponse("you must specify a code");
    if (vo.getDebitAmountACC06()==null && vo.getCreditAmountACC06()==null)
      return new ErrorResponse("you must specify a debit or credit amount");

    frame.getGrid().reloadData();
    updateTotals();

View Full Code Here

  /**
   * Update totals in frame.
   */
  private void updateTotals() {
    JournalRowVO vo = null;
    BigDecimal d = new BigDecimal(0);
    BigDecimal c = new BigDecimal(0);
    for(int i=0;i<vos.size();i++) {
      vo = (JournalRowVO)vos.get(i);
      if (vo.getDebitAmountACC06()!=null)
        d = d.add(vo.getDebitAmountACC06());
      if (vo.getCreditAmountACC06()!=null)
        c = c.add(vo.getCreditAmountACC06());
    }
    frame.getControlTotDebit().setValue(d);
    frame.getControlTotCredit().setValue(c);
    frame.getControlSbil().setValue(d.subtract(c));
  }
View Full Code Here

   * Callback method called by the Form panel when the Form is set to INSERT mode.
   * The method can pre-set some v.o. attributes, so that some input controls will have a predefined value associated.
   * @param persistentObject new value object
   */
  public void createPersistentObject(ValueObject persistentObject) throws Exception {
    JournalRowVO vo = (JournalRowVO)persistentObject;
    vo.setItemYearAcc05ACC06(new BigDecimal(new java.util.Date().getYear()+1900));
  }
View Full Code Here

      return new ErrorResponse("you must insert al least one row");
    }

    JournalHeaderWithVatVO jhVO = (JournalHeaderWithVatVO)newPersistentObject;
    jhVO.getJournalRows().clear();
    JournalRowVO jrVO = null;
    JournalRowWithVatVO rowVatVO = null;
    VatRowVO vatVO = null;
    BigDecimal vatValue = null;
    BigDecimal totalValue = new BigDecimal(0);
    for(int i=0;i<gridModel.getRowCount();i++) {
      // create 3 rows for each vat row value object...
      rowVatVO = (JournalRowWithVatVO)gridModel.getObjectForRow(i);

      // 1. add taxable income to the accounting item...
      jrVO = new JournalRowVO();
      jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
      jrVO.setAccountCodeAcc02ACC06(rowVatVO.getAccountCodeAcc02ACC06());
      jrVO.setAccountCodeACC06(rowVatVO.getAccountCodeACC06());
      jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

      if (jhVO.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER))
        jrVO.setCreditAmountACC06(rowVatVO.getTaxableIncome().setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));
      else
        jrVO.setDebitAmountACC06(rowVatVO.getTaxableIncome().setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));
      jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
      jrVO.setDescriptionACC06(rowVatVO.getDescriptionACC06());
      jhVO.addJournalRow(jrVO);

      totalValue = totalValue.add(rowVatVO.getTaxableIncome().setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));

      // 2. prepare vat row for the specified register...
      vatVO = new VatRowVO();
      vatVO.setCompanyCodeSys01ACC07(jhVO.getCompanyCodeSys01ACC05());
      vatVO.setRegisterCodeAcc04ACC07(jhVO.getRegisterCodeACC04());
      vatVO.setTaxableIncomeACC07(rowVatVO.getTaxableIncome().setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));
      vatVO.setVatCodeACC07(rowVatVO.getVatCodeREG01());
      vatVO.setVatDateACC07(new java.sql.Date(System.currentTimeMillis()));
      vatVO.setVatDescriptionACC07(rowVatVO.getVatDescriptionREG01());
      vatValue = rowVatVO.getTaxableIncome().multiply( new BigDecimal(rowVatVO.getValueREG01().doubleValue()/100d*(100d-rowVatVO.getDeductibleREG01().doubleValue())/100d) ).setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP);
      vatVO.setVatValueACC07(vatValue);
      vatVO.setVatYearACC07(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));
      jhVO.addVat(vatVO);

      totalValue = totalValue.add(vatValue);

      // 3. add total vat value to the accounting item...
      jrVO = new JournalRowVO();
      jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
      jrVO.setAccountCodeAcc02ACC06(jhVO.getAccountCodeAcc02ACC04());
      jrVO.setAccountCodeACC06(jhVO.getAccountCodeAcc02ACC04());
      jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);
      if (jhVO.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER))
        jrVO.setCreditAmountACC06(vatValue);
      else
        jrVO.setDebitAmountACC06(vatValue);
      jrVO.setDescriptionACC06("");
      jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
      jhVO.addJournalRow(jrVO);

      // 4. add total credit/debit value to the accounting item...
      jrVO = new JournalRowVO();
      jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
      if (jhVO.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER)) {
        jrVO.setAccountCodeAcc02ACC06(jhVO.getCreditAccountCodeAcc02SAL07());
        jrVO.setAccountCodeACC06(jhVO.getCustomerCodeSAL07());
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER);
        jrVO.setDebitAmountACC06(rowVatVO.getTaxableIncome().add(vatValue).setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));
      }
      else {
        jrVO.setAccountCodeAcc02ACC06(jhVO.getDebitAccountCodeAcc02PUR01());
        jrVO.setAccountCodeACC06(jhVO.getSupplierCodePUR01());
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_SUPPLIER);
        jrVO.setCreditAmountACC06(rowVatVO.getTaxableIncome().add(vatValue).setScale(detailFrame.getCurrencyDecimals(),BigDecimal.ROUND_HALF_UP));
      }
      jrVO.setDescriptionACC06("");
      jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
      jhVO.addJournalRow(jrVO);
    }
    jhVO.setTotalValue(totalValue);

    Response response = ClientUtils.getData("insertJournalItem",jhVO);
View Full Code Here

      attribute2dbField.put("creditAmountACC06","CREDIT_AMOUNT");
      attribute2dbField.put("accountCodeTypeACC06","ACCOUNT_CODE_TYPE");
      attribute2dbField.put("accountCodeACC06","ACCOUNT_CODE");
      attribute2dbField.put("accountCodeAcc02ACC06","ACCOUNT_CODE_ACC02");
      attribute2dbField.put("descriptionACC06","DESCRIPTION");
      JournalRowVO rowVO = null;
      for(int i=0;i<vo.getJournalRows().size();i++) {
        rowVO = (JournalRowVO)vo.getJournalRows().get(i);
        rowVO.setProgressiveAcc05ACC06(vo.getProgressiveACC05());
        rowVO.setProgressiveACC06(CompanyProgressiveUtils.getConsecutiveProgressive(
            vo.getCompanyCodeSys01ACC05(),
            "ACC06_JOURNAL_ROWS",
            "PROGRESSIVE",
            conn
        ));
View Full Code Here

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          AccountVO accountVO = (AccountVO)accountController.getLookupVO();
          JournalRowVO vo = (JournalRowVO)detailPanel.getVOModel().getValueObject();
          vo.setAccountCodeAcc02ACC06(accountVO.getAccountCodeACC02());
          vo.setAccountCodeACC06(accountVO.getAccountCodeACC02());
//          controlAcode.setValue(accountVO.getAccountCodeACC02());
        }

        public void beforeLookupAction(ValueObject parentVO) {
          accountDataLocator.getLookupFrameParams().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
          accountDataLocator.getLookupValidationParameters().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
        }

        public void forceValidate() {}

      });


      // customer lookup...
      customerDataLocator.setGridMethodName("loadCustomers");
      customerDataLocator.setValidationMethodName("validateCustomerCode");
      controlCcode.setLookupController(customerController);
      controlCcode.setControllerMethodName("getCustomersList");
      customerController.setForm(headerPanel);
      customerController.setLookupDataLocator(customerDataLocator);
      customerController.setFrameTitle("customers");
      customerController.setLookupValueObjectClassName("org.jallinone.sales.customers.java.GridCustomerVO");
      customerController.addLookup2ParentLink("customerCodeSAL07","customerCodeSAL07");
      customerController.addLookup2ParentLink("name_1REG04", "name_1REG04");
      customerController.addLookup2ParentLink("progressiveREG04", "progressiveREG04");
      customerController.setAllColumnVisible(false);
      customerController.setVisibleColumn("companyCodeSys01REG04", true);
      customerController.setVisibleColumn("customerCodeSAL07", true);
      customerController.setVisibleColumn("name_1REG04", true);
      customerController.setVisibleColumn("name_2REG04", true);
      customerController.setVisibleColumn("cityREG04", true);
      customerController.setVisibleColumn("provinceREG04", true);
      customerController.setVisibleColumn("countryREG04", true);
      customerController.setVisibleColumn("taxCodeREG04", true);
      customerController.setHeaderColumnName("cityREG04", "city");
      customerController.setHeaderColumnName("provinceREG04", "prov");
      customerController.setHeaderColumnName("countryREG04", "country");
      customerController.setHeaderColumnName("taxCodeREG04", "taxCode");
      customerController.setPreferredWidthColumn("name_1REG04", 200);
      customerController.setPreferredWidthColumn("name_2REG04", 150);
      customerController.setFramePreferedSize(new Dimension(750,500));
      customerDataLocator.getLookupFrameParams().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_VAT");
      customerDataLocator.getLookupValidationParameters().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_VAT");
      customerController.addLookupListener(new LookupListener() {

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          GridCustomerVO custVO = (GridCustomerVO)customerController.getLookupVO();
          JournalHeaderWithVatVO vo = (JournalHeaderWithVatVO)headerPanel.getVOModel().getValueObject();
          vo.setCreditAccountCodeAcc02SAL07(custVO.getCreditAccountCodeAcc02SAL07());
        }

        public void beforeLookupAction(ValueObject parentVO) {
          customerDataLocator.getLookupFrameParams().put(ApplicationConsts.SUBJECT_TYPE,ApplicationConsts.SUBJECT_ORGANIZATION_CUSTOMER);
          customerDataLocator.getLookupFrameParams().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
          customerDataLocator.getLookupValidationParameters().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
          customerController.setHeaderColumnName("name_1REG04", "corporateName1");
          customerController.setHeaderColumnName("name_2REG04", "corporateName2");
        }

        public void forceValidate() {}

      });



      // supplier lookup...
      supplierDataLocator.setGridMethodName("loadSuppliers");
      supplierDataLocator.setValidationMethodName("validateSupplierCode");
      controlScode.setLookupController(supplierController);
      controlScode.setControllerMethodName("getSuppliersList");
      supplierController.setForm(headerPanel);
      supplierController.setLookupDataLocator(supplierDataLocator);
      supplierController.setFrameTitle("suppliers");
      supplierController.setLookupValueObjectClassName("org.jallinone.purchases.suppliers.java.GridSupplierVO");
      supplierController.addLookup2ParentLink("supplierCodePUR01","supplierCodePUR01");
      supplierController.addLookup2ParentLink("name_1REG04", "name_1REG04");
      supplierController.addLookup2ParentLink("progressiveREG04", "progressiveREG04");
      supplierController.setAllColumnVisible(false);
      supplierController.setVisibleColumn("companyCodeSys01REG04", true);
      supplierController.setVisibleColumn("supplierCodePUR01", true);
      supplierController.setVisibleColumn("name_1REG04", true);
      supplierController.setVisibleColumn("name_2REG04", true);
      supplierController.setVisibleColumn("cityREG04", true);
      supplierController.setVisibleColumn("provinceREG04", true);
      supplierController.setVisibleColumn("countryREG04", true);
      supplierController.setVisibleColumn("taxCodeREG04", true);
      supplierController.setHeaderColumnName("name_1REG04", "corporateName1");
      supplierController.setHeaderColumnName("cityREG04", "city");
      supplierController.setHeaderColumnName("provinceREG04", "prov");
      supplierController.setHeaderColumnName("countryREG04", "country");
      supplierController.setHeaderColumnName("taxCodeREG04", "taxCode");
      supplierController.setPreferredWidthColumn("name_1REG04", 200);
      supplierController.setPreferredWidthColumn("name_2REG04", 150);
      supplierController.setFramePreferedSize(new Dimension(750,500));
      supplierDataLocator.getLookupFrameParams().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_VAT");
      supplierDataLocator.getLookupValidationParameters().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_VAT");
      supplierController.addLookupListener(new LookupListener() {

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          GridSupplierVO supplierVO = (GridSupplierVO)supplierController.getLookupVO();
          JournalHeaderWithVatVO vo = (JournalHeaderWithVatVO)headerPanel.getVOModel().getValueObject();
          vo.setDebitAccountCodeAcc02PUR01(supplierVO.getDebitAccountCodeAcc02PUR01());
        }

        public void beforeLookupAction(ValueObject parentVO) {
          supplierDataLocator.getLookupFrameParams().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
          supplierDataLocator.getLookupValidationParameters().put(ApplicationConsts.COMPANY_CODE_SYS01,controlCompaniesCombo.getValue());
View Full Code Here

   * Callback method called by the Form panel when the Form is set to INSERT mode.
   * The method can pre-set some v.o. attributes, so that some input controls will have a predefined value associated.
   * @param persistentObject new value object
   */
  public void createPersistentObject(ValueObject persistentObject) throws Exception {
    JournalRowVO vo = (JournalRowVO)persistentObject;
    vo.setItemYearAcc05ACC06(new BigDecimal(new java.util.Date().getYear()+1900));
  }
View Full Code Here

TOP

Related Classes of org.jallinone.accounting.movements.java.JournalRowVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.