Package org.jallinone.accounting.movements.java

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


        }

        // add taxable income rows to the accounting item...
        java.util.List taxableIncomes = ((VOListResponse)res).getRows();
        TaxableIncomeVO tVO = null;
        JournalRowVO jrVO = null;
        BigDecimal totalVat = new BigDecimal(0);
        Hashtable vats = new Hashtable(); // collections of: vat code,VatRowVO
        VatRowVO vatVO = null;
        for(int i=0;i<taxableIncomes.size();i++) {
          tVO = (TaxableIncomeVO)taxableIncomes.get(i);
          totalVat = totalVat.add(tVO.getVatValue());
          jrVO = new JournalRowVO();
          jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
          if (tVO.getRowType()==tVO.ITEM_ROW_TYPE) {
            jrVO.setAccountCodeAcc02ACC06(itemsAccountCodeAcc02);
            jrVO.setAccountCodeACC06(itemsAccountCodeAcc02);
          }
          else if (tVO.getRowType()==tVO.ACTIVITY_ROW_TYPE) {
            jrVO.setAccountCodeAcc02ACC06(actAccountCodeAcc02);
            jrVO.setAccountCodeACC06(actAccountCodeAcc02);
          }
          else if (tVO.getRowType()==tVO.CHARGE_ROW_TYPE) {
            jrVO.setAccountCodeAcc02ACC06(chargesAccountCodeAcc02);
            jrVO.setAccountCodeACC06(chargesAccountCodeAcc02);
          }
          jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

          if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
            jrVO.setCreditAmountACC06(tVO.getTaxableIncome().negate());
          else
            jrVO.setCreditAmountACC06(tVO.getTaxableIncome());
          jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);

          // prepare vat row for sale vat register...
          vatVO = (VatRowVO)vats.get(tVO.getVatCode());
          if (vatVO==null) {
            vatVO = new VatRowVO();
            vatVO.setCompanyCodeSys01ACC07(docVO.getCompanyCodeSys01DOC01());
            if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE))
              vatVO.setRegisterCodeAcc04ACC07(ApplicationConsts.VAT_REGISTER_RETAIL);
            else
              vatVO.setRegisterCodeAcc04ACC07(ApplicationConsts.VAT_REGISTER_SELLING);
            vatVO.setTaxableIncomeACC07(tVO.getTaxableIncome());
            vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
            vatVO.setVatCodeACC07(tVO.getVatCode());
            vatVO.setVatDateACC07(new java.sql.Date(System.currentTimeMillis()));
            vatVO.setVatDescriptionACC07(tVO.getVatDescription());

            if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
              vatVO.setVatValueACC07(tVO.getVatValue().negate());
            else
              vatVO.setVatValueACC07(tVO.getVatValue());
            vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));

            vatVO.setVatYearACC07(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));
          }
          else {
            vatVO.setTaxableIncomeACC07(vatVO.getTaxableIncomeACC07().add(tVO.getTaxableIncome()));
            vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
            if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
              vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()).negate());
            else
              vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()));
            vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));
          }
          vats.put(tVO.getVatCode(),vatVO);
        }

        // add total vat value to the accounting item...
        jrVO = new JournalRowVO();
        jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
        jrVO.setAccountCodeAcc02ACC06(vatAccountCodeAcc02);
        jrVO.setAccountCodeACC06(vatAccountCodeAcc02);
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
          jrVO.setCreditAmountACC06(totalVat.negate());
        else
          jrVO.setCreditAmountACC06(totalVat);
        jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));

        jrVO.setDescriptionACC06("");
        jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
        jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
        jhVO.addJournalRow(jrVO);

        // add total credit value to the accounting item...
        jrVO = new JournalRowVO();
        jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
        jrVO.setAccountCodeAcc02ACC06(creditAccountCodeAcc02);
        jrVO.setAccountCodeACC06(docVO.getCustomerCodeSAL07());
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER);

        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
          jrVO.setDebitAmountACC06(docVO.getTotalDOC01().negate());
        else
          jrVO.setDebitAmountACC06(docVO.getTotalDOC01());
        jrVO.setDebitAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getDebitAmountACC06(),conv));

        jrVO.setDescriptionACC06("");
        jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
        jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
        jhVO.addJournalRow(jrVO);

        res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }

        // insert vat rows in sale vat register...
        ArrayList vatRows = new ArrayList();
        Enumeration en = vats.keys();
        while(en.hasMoreElements())
          vatRows.add(vats.get(en.nextElement()));
        res = vatRegisterAction.insertVatRows(vatRows,serverLanguageId,username);
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }

/*
        // create an item registration for proceeds, according to expiration settings (e.g. retail selling):
        // there must be only one instalment and this instalment has 0 instalment days
        if (paymentInstallments.size()==1 && ((PaymentInstalmentVO)paymentInstallments.get(0)).getInstalmentDaysREG17().intValue()==0) {
*/

         if (pk.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE)) {

          map = new HashMap();
          map.put(ApplicationConsts.COMPANY_CODE_SYS01,docVO.getCompanyCodeSys01DOC01());
          map.put(ApplicationConsts.PARAM_CODE,ApplicationConsts.CASE_ACCOUNT);
          res = parsBean.loadUserParam(map,serverLanguageId,username);
          if (res.isError()) {
            throw new Exception(res.getErrorMessage());
          }
          String caseAccountCode = ((VOResponse)res).getVo().toString();


          jhVO = new JournalHeaderVO();
          jhVO.setCompanyCodeSys01ACC05(docVO.getCompanyCodeSys01DOC01());
          if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE)) {
            jhVO.setDescriptionACC05(
                t3+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()
            );
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_SALE_RETAIL_PROCEEDS);
          }
          else if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE)) {
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_INVOICE_PROCEEDS);
            jhVO.setDescriptionACC05(
                t4+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()+" - "+
                t5+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
            );
          }
          else {
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_INVOICE_PROCEEDS);
            jhVO.setDescriptionACC05(
                t6+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()+" - "+
                t5+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
            );
          }

          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(creditAccountCodeAcc02);
          jrVO.setAccountCodeACC06(docVO.getCustomerCodeSAL07());
          jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER);

          if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
            jrVO.setCreditAmountACC06(docVO.getTotalDOC01().negate());
          else
            jrVO.setCreditAmountACC06(docVO.getTotalDOC01());
          jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);

          jrVO = new JournalRowVO();
          jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
          jrVO.setAccountCodeAcc02ACC06(caseAccountCode);
          jrVO.setAccountCodeACC06(caseAccountCode);
          jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

          if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
            jrVO.setDebitAmountACC06(docVO.getTotalDOC01().negate());
          else
            jrVO.setDebitAmountACC06(docVO.getTotalDOC01());
          jrVO.setDebitAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getDebitAmountACC06(),conv));

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);

          res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
          if (res.isError()) {
            throw new Exception(res.getErrorMessage());
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());
          if (accountVO.getAccountTypeACC02()!=null) {
            if (accountVO.getAccountTypeACC02().equals(ApplicationConsts.DEBIT_ACCOUNT))
              controlDebit.requestFocus();
            else
              controlCredit.requestFocus();
          }
        }

        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(detailPanel);
      customerController.setLookupDataLocator(customerDataLocator);
      customerController.setFrameTitle("customers");
      customerController.setLookupValueObjectClassName("org.jallinone.sales.customers.java.GridCustomerVO");
      customerController.addLookup2ParentLink("customerCodeSAL07","accountCodeACC06");
      customerController.addLookup2ParentLink("name_1REG04", "accountDescriptionACC06");
      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_NOVAT");
      customerDataLocator.getLookupValidationParameters().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_NOVAT");
      customerController.addLookupListener(new LookupListener() {

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          GridCustomerVO custVO = (GridCustomerVO)customerController.getLookupVO();
          JournalRowVO vo = (JournalRowVO)detailPanel.getVOModel().getValueObject();
          vo.setAccountCodeAcc02ACC06(custVO.getCreditAccountCodeAcc02SAL07());
          vo.setAccountCodeACC06(custVO.getCustomerCodeSAL07());
          controlCcode.setValue(custVO.getCustomerCodeSAL07());
          controlDebit.requestFocus();
        }

        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(detailPanel);
      supplierController.setLookupDataLocator(supplierDataLocator);
      supplierController.setFrameTitle("suppliers");
      supplierController.setLookupValueObjectClassName("org.jallinone.purchases.suppliers.java.GridSupplierVO");
      supplierController.addLookup2ParentLink("supplierCodePUR01","accountCodeACC06");
      supplierController.addLookup2ParentLink("name_1REG04", "accountDescriptionACC06");
      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_NOVAT");
      supplierDataLocator.getLookupValidationParameters().put(ApplicationConsts.FILTER_COMPANY_FOR_INSERT,"ACC05_NEW_ITEM_NOVAT");
      supplierController.addLookupListener(new LookupListener() {

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          GridSupplierVO supplierVO = (GridSupplierVO)supplierController.getLookupVO();
          JournalRowVO vo = (JournalRowVO)detailPanel.getVOModel().getValueObject();
          vo.setAccountCodeAcc02ACC06(supplierVO.getDebitAccountCodeAcc02PUR01());
          vo.setAccountCodeACC06(supplierVO.getSupplierCodePUR01());
          controlScode.setValue(supplierVO.getSupplierCodePUR01());
          controlCredit.requestFocus();
        }

        public void beforeLookupAction(ValueObject parentVO) {
View Full Code Here

    }
  }


  public void updateCodes() {
    JournalRowVO vo = (JournalRowVO)detailPanel.getVOModel().getValueObject();
    vo.setCompanyCodeSys01ACC06((String)controlCompaniesCombo.getValue());
    vo.setAccountCodeTypeACC06((String)controlCSA.getValue());

    if (vo.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT)) {
      controlCcode.setEnabled(false);
      controlScode.setEnabled(false);
      controlAcode.setEnabled(true && detailPanel.getMode()!=Consts.READONLY);
      controlCcode.setValue("");
      controlScode.setValue("");
      if (detailPanel.getMode()==Consts.READONLY)
        controlAcode.setValue(vo.getAccountCodeACC06());
    }
    else if (vo.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_CUSTOMER)) {
      controlCcode.setEnabled(true && detailPanel.getMode()!=Consts.READONLY);
      controlScode.setEnabled(false);
      controlAcode.setEnabled(false);
      controlAcode.setValue("");
      controlScode.setValue("");
      if (detailPanel.getMode()==Consts.READONLY)
        controlCcode.setValue(vo.getAccountCodeACC06());
    }
    else if (vo.getAccountCodeTypeACC06().equals(ApplicationConsts.ACCOUNT_TYPE_SUPPLIER)) {
      controlCcode.setEnabled(false);
      controlScode.setEnabled(true && detailPanel.getMode()!=Consts.READONLY);
      controlAcode.setEnabled(false);
      controlCcode.setValue("");
      controlAcode.setValue("");
      if (detailPanel.getMode()==Consts.READONLY)
        controlScode.setValue(vo.getAccountCodeACC06());
    }
  }
View Full Code Here

          jhVO.setItemDateACC05(newVO.getPayedDateDOC19());
          Calendar cal = Calendar.getInstance();
          cal.setTime(newVO.getPayedDateDOC19());
          jhVO.setItemYearACC05(new BigDecimal(cal.get(Calendar.YEAR)));

          JournalRowVO jrVO = new JournalRowVO();
          jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
          jrVO.setAccountCodeAcc02ACC06(creditDebitAccountCode);
          jrVO.setAccountCodeACC06(newVO.getCustomerSupplierCodeDOC19());
          jrVO.setAccountCodeTypeACC06(accountCodeTypeACC06);

          if (newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE))
            jrVO.setCreditAmountACC06(newVO.getValueDOC19());
          else
            jrVO.setDebitAmountACC06(newVO.getValueDOC19());

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);

          jrVO = new JournalRowVO();
          jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
          jrVO.setAccountCodeAcc02ACC06( newVO.getRealAccountCodeAcc02DOC19()==null?bankAccountCode:newVO.getRealAccountCodeAcc02DOC19() );
          jrVO.setAccountCodeACC06( newVO.getRealAccountCodeAcc02DOC19()==null?bankAccountCode:newVO.getRealAccountCodeAcc02DOC19() );
          jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

          if (newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
              newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE))
            jrVO.setDebitAmountACC06(newVO.getPayedValueDOC19());
          else
            jrVO.setCreditAmountACC06(newVO.getPayedValueDOC19());

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);


          // check if there is a rounding on payment...
          if (newVO.getPayedValueDOC19()!=null && !newVO.getPayedValueDOC19().equals(newVO.getValueDOC19())) {

            // another accounting movement must be performed, related to rounding...
            jrVO = new JournalRowVO();
            jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
            jrVO.setAccountCodeAcc02ACC06( newVO.getRoundingAccountCodeAcc02DOC19() );
            jrVO.setAccountCodeACC06( newVO.getRoundingAccountCodeAcc02DOC19() );
            jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

            if (newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
                newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
                newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
                newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
                newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
                newVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE))
              jrVO.setDebitAmountACC06(newVO.getValueDOC19().subtract(newVO.getPayedValueDOC19()));
            else
              jrVO.setCreditAmountACC06(newVO.getValueDOC19().subtract(newVO.getPayedValueDOC19()));

            jrVO.setDescriptionACC06("");
            jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
            jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
            jhVO.addJournalRow(jrVO);
          }

          res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
          if (res.isError()) {
View Full Code Here

        accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_SUPPLIER;
      }
      jhVO.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
      jhVO.setItemYearACC05(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));

      JournalRowVO jrVO = new JournalRowVO();
      jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
      jrVO.setAccountCodeAcc02ACC06(creditDebitAccountCode);
      jrVO.setAccountCodeACC06(customerSupplierCodeDOC19);
      jrVO.setAccountCodeTypeACC06(accountCodeTypeACC06);

      if (docType.equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_GENERIC_INVOICE))
        jrVO.setCreditAmountACC06(valueDOC19);
      else
        jrVO.setDebitAmountACC06(valueDOC19);

      jrVO.setDescriptionACC06("");
      jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
      jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
      jhVO.addJournalRow(jrVO);

      jrVO = new JournalRowVO();
      jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
      jrVO.setAccountCodeAcc02ACC06(accountCode);
      jrVO.setAccountCodeACC06(accountCode);
      jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

      if (docType.equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
          docType.equals(ApplicationConsts.SALE_GENERIC_INVOICE))
        jrVO.setDebitAmountACC06(valueDOC19);
      else
        jrVO.setCreditAmountACC06(valueDOC19);

      jrVO.setDescriptionACC06("");
      jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
      jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
      jhVO.addJournalRow(jrVO);


      Response res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
      if (res.isError()) {
View Full Code Here

        jhVO.setItemDateACC05(vo.getPaymentDateDOC27());
        Calendar cal = Calendar.getInstance();
        cal.setTime(vo.getPaymentDateDOC27());
        jhVO.setItemYearACC05(new BigDecimal(cal.get(Calendar.YEAR)));

        JournalRowVO jrVO = new JournalRowVO();
        jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
        jrVO.setAccountCodeAcc02ACC06(creditDebitAccountCode);
        jrVO.setAccountCodeACC06(vo.getCustomerSupplierCodeDOC27());
        jrVO.setAccountCodeTypeACC06(accountCodeTypeACC06);

        if (dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE)) {
          if (dVO.getPayedDOC28().booleanValue()) {
            jrVO.setCreditAmountACC06( dVO.getValueDOC19().subtract(dVO.getAlreadyPayedDOC19()) );
          }
          else {
            jrVO.setCreditAmountACC06(paymentValue);
          }
        }
        else {
          if (dVO.getPayedDOC28().booleanValue()) {
            jrVO.setDebitAmountACC06( dVO.getValueDOC19().subtract(dVO.getAlreadyPayedDOC19()) );
          }
          else {
            jrVO.setDebitAmountACC06(paymentValue);
          }
        }
        jrVO.setDescriptionACC06("");
        jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
        jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
        jhVO.addJournalRow(jrVO);

        jrVO = new JournalRowVO();
        jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
        jrVO.setAccountCodeAcc02ACC06( vo.getAccountCodeAcc02DOC27() );
        jrVO.setAccountCodeACC06( vo.getAccountCodeAcc02DOC27() );
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

        if (dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
            dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE))
          jrVO.setDebitAmountACC06(paymentValue);
        else
          jrVO.setCreditAmountACC06(paymentValue);

        jrVO.setDescriptionACC06("");
        jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
        jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
        jhVO.addJournalRow(jrVO);


        // check if there is a rounding on payment...
        if (dVO.getPayedDOC28().booleanValue() &&
           !dVO.getAlreadyPayedDOC19().add(paymentValue).equals(dVO.getValueDOC19())) {

          // another accounting movement must be performed, related to rounding...
          jrVO = new JournalRowVO();
          jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
          jrVO.setAccountCodeAcc02ACC06( dVO.getRoundingAccountCodeAcc02DOC19() );
          jrVO.setAccountCodeACC06( dVO.getRoundingAccountCodeAcc02DOC19() );
          jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

          if (dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_DESK_DOC_TYPE) ||
              dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
              dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
              dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
              dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
              dVO.getDocTypeDOC19().equals(ApplicationConsts.SALE_GENERIC_INVOICE))
            jrVO.setDebitAmountACC06(dVO.getValueDOC19().subtract(dVO.getAlreadyPayedDOC19().add(paymentValue)));
          else
            jrVO.setCreditAmountACC06(dVO.getValueDOC19().subtract(dVO.getAlreadyPayedDOC19().add(paymentValue)));

          jrVO.setDescriptionACC06("");
          jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
          jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
          jhVO.addJournalRow(jrVO);
        }

        res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
        if (res.isError()) {
View Full Code Here

         }

         // add taxable income rows to the accounting item...
         java.util.List taxableIncomes = ((VOListResponse)res).getRows();
         TaxableIncomeVO tVO = null;
         JournalRowVO jrVO = null;
         BigDecimal totalVat = new BigDecimal(0);
         Hashtable vats = new Hashtable(); // collections of: vat code,VatRowVO
         VatRowVO vatVO = null;
         for(int i=0;i<taxableIncomes.size();i++) {
           tVO = (TaxableIncomeVO)taxableIncomes.get(i);
           totalVat = totalVat.add(tVO.getVatValue());
           jrVO = new JournalRowVO();
           jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
           jrVO.setAccountCodeAcc02ACC06(costsAccountCodeAcc02);
           jrVO.setAccountCodeACC06(costsAccountCodeAcc02);
           jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

           if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
             jrVO.setDebitAmountACC06(tVO.getTaxableIncome().negate());
           else
             jrVO.setDebitAmountACC06(tVO.getTaxableIncome());
           jrVO.setDebitAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getDebitAmountACC06(),conv));

           jrVO.setDescriptionACC06("");
           jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
           jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
           jhVO.addJournalRow(jrVO);

           // prepare vat row for sale vat register...
           vatVO = (VatRowVO)vats.get(tVO.getVatCode());
           if (vatVO==null) {
             vatVO = new VatRowVO();
             vatVO.setCompanyCodeSys01ACC07(docVO.getCompanyCodeSys01DOC06());
             vatVO.setRegisterCodeAcc04ACC07(ApplicationConsts.VAT_REGISTER_PURCHASE);
             vatVO.setTaxableIncomeACC07(tVO.getTaxableIncome());
             vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
             vatVO.setVatCodeACC07(tVO.getVatCode());
             vatVO.setVatDateACC07(new java.sql.Date(System.currentTimeMillis()));
             vatVO.setVatDescriptionACC07(tVO.getVatDescription());

             if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
               vatVO.setVatValueACC07(tVO.getVatValue().negate());
             else
               vatVO.setVatValueACC07(tVO.getVatValue());
             vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));

             vatVO.setVatYearACC07(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));
           }
           else {
             vatVO.setTaxableIncomeACC07(vatVO.getTaxableIncomeACC07().add(tVO.getTaxableIncome()));
             vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
             if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
               vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()).negate());
             else
               vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()));
             vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));
           }
           vats.put(tVO.getVatCode(),vatVO);
         }

         // add total vat value to the accounting item...
         jrVO = new JournalRowVO();
         jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
         jrVO.setAccountCodeAcc02ACC06(vatAccountCodeAcc02);
         jrVO.setAccountCodeACC06(vatAccountCodeAcc02);
         jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

         if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
           jrVO.setDebitAmountACC06(totalVat.negate());
         else
           jrVO.setDebitAmountACC06(totalVat);
         jrVO.setDebitAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getDebitAmountACC06(),conv));

         jrVO.setDescriptionACC06("");
         jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
         jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
         jhVO.addJournalRow(jrVO);

         // add total debit value to the accounting item...
         jrVO = new JournalRowVO();
         jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
         jrVO.setAccountCodeAcc02ACC06(debitAccountCodeAcc02);
         jrVO.setAccountCodeACC06(docVO.getSupplierCodePUR01());
         jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_SUPPLIER);

         if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
           jrVO.setCreditAmountACC06(docVO.getTotalDOC06().negate());
         else
           jrVO.setCreditAmountACC06(docVO.getTotalDOC06());
         jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));

         jrVO.setDescriptionACC06("");
         jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
         jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
         jhVO.addJournalRow(jrVO);

         res = insJornalItemAction.insertJournalItem(jhVO,serverLanguageId,username);
         if (res.isError()) {
           throw new Exception(res.getErrorMessage());
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.