Examples of JournalHeaderVO


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

            "select VAT_VALUE,RECORD_NUMBER from ACC07_VAT_ROWS where COMPANY_CODE_SYS01=? and REGISTER_CODE_ACC04=? and "+
            "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

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

   * 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 {
    JournalHeaderVO vo = (JournalHeaderVO)persistentObject;
    vo.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
    vo.setItemYearACC05(new BigDecimal(new java.util.Date().getYear()+1900));
  }
View Full Code Here

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

      if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
          docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE) ||
          docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_INVOICE_DOC_TYPE) ||
          docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE) ||
          docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE)) {
        JournalHeaderVO jhVO = new JournalHeaderVO();
        jhVO.setCompanyCodeSys01ACC05(docVO.getCompanyCodeSys01DOC01());
        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE))
          jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_SALE_RETAIL);
        else
          jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_SALE_INVOICE);
        jhVO.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
        jhVO.setItemYearACC05(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));
        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE))
          jhVO.setDescriptionACC05(
              t3+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()
          );
        else if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
          jhVO.setDescriptionACC05(
              t4+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()+" - "+
              t5+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
          );
        else
          jhVO.setDescriptionACC05(
              t6+" "+docVO.getDocSequenceDOC01()+"/"+docVO.getDocYearDOC01()+" - "+
              t5+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
          );

        // determine account codes defined for the current customer...
        pstmt = conn.prepareStatement(
          "select CREDIT_ACCOUNT_CODE_ACC02,ITEMS_ACCOUNT_CODE_ACC02,ACTIVITIES_ACCOUNT_CODE_ACC02,CHARGES_ACCOUNT_CODE_ACC02 "+
          "from SAL07_CUSTOMERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
        );
        pstmt.setString(1,pk.getCompanyCodeSys01DOC01());
        pstmt.setBigDecimal(2,docVO.getProgressiveReg04DOC01());
        rset = pstmt.executeQuery();
        if (!rset.next()) {
          rset.close();
          throw new Exception("customer not found");
        }
        String creditAccountCodeAcc02 = rset.getString(1);
        String itemsAccountCodeAcc02 = rset.getString(2);
        String actAccountCodeAcc02 = rset.getString(3);
        String chargesAccountCodeAcc02 = rset.getString(4);
        rset.close();
        pstmt.close();

        // determine account code defined for vat in sale vat register...
        pstmt = conn.prepareStatement(
          "select ACCOUNT_CODE_ACC02 from ACC04_VAT_REGISTERS where COMPANY_CODE_SYS01=? and REGISTER_CODE=?"
        );
        pstmt.setString(1,pk.getCompanyCodeSys01DOC01());
        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE))
          pstmt.setString(2,ApplicationConsts.VAT_REGISTER_RETAIL);
        else
          pstmt.setString(2,ApplicationConsts.VAT_REGISTER_SELLING);
        rset = pstmt.executeQuery();
        if (!rset.next()) {
          rset.close();
          throw new Exception("vat register not found");
        }
        String vatAccountCodeAcc02 = rset.getString(1);
        rset.close();
        pstmt.close();

        // calculate taxable income rows, grouped by vat code...
        res = taxableIncomeAction.updateTaxableIncomes(
            variant1Descriptions,
            variant2Descriptions,
            variant3Descriptions,
            variant4Descriptions,
            variant5Descriptions,
            pk, serverLanguageId, username);
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }

        // 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

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

       pstmt2 = conn.prepareStatement(
        "INSERT INTO DOC28_PAYMENT_DISTRIBUTION(COMPANY_CODE_SYS01,PROGRESSIVE_DOC27,PROGRESSIVE_DOC19,"+
        "PAYMENT_VALUE,PAYED,CREATE_USER,CREATE_DATE) VALUES (?,?,?,?,?,?,?)"
      );

      JournalHeaderVO jhVO = null;
      HashMap map = new HashMap();
      String bankAccountCode = null;
      BigDecimal progressiveDOC27 = null;

      for(int i=0;i<oldVOs.size();i++) {
        oldVO = (ExpirationVO)oldVOs.get(i);
        newVO = (ExpirationVO)newVOs.get(i);

        res = org.jallinone.commons.server.QueryUtilExtension.updateTable(
            conn,
            new UserSessionParameters(username),
            pkAttrs,
            oldVO,
            newVO,
            "DOC19_EXPIRATIONS",
            attribute2dbField,
            "Y",
            "N",
            null,
            true
        );
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }


        map.put(ApplicationConsts.COMPANY_CODE_SYS01,newVO.getCompanyCodeSys01DOC19());
        map.put(ApplicationConsts.PARAM_CODE,ApplicationConsts.BANK_ACCOUNT);
        res = userParamAction.loadUserParam(map,serverLanguageId,username);
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }
        bankAccountCode = ((VOResponse)res).getVo().toString();

        // generate an accounting item if the row has been payed...
        if (!oldVO.getPayedDOC19().booleanValue() && newVO.getPayedDOC19().booleanValue()) {

          // insert record in DOC27...
          progressiveDOC27 = CompanyProgressiveUtils.getInternalProgressive(
             newVO.getCompanyCodeSys01DOC19(),
             "DOC27_PAYMENTS",
             "PROGRESSIVE",
             conn
          );
          pstmt3.setString(1,newVO.getCompanyCodeSys01DOC19());
          pstmt3.setBigDecimal(2,progressiveDOC27);
          pstmt3.setDate(3,newVO.getPayedDateDOC19());
          pstmt3.setBigDecimal(4,newVO.getPayedValueDOC19());
          pstmt3.setString(5,newVO.getCustomerSupplierCodeDOC19());
          pstmt3.setString(6,newVO.getRealAccountCodeAcc02DOC19());
          pstmt3.setString(7,newVO.getRealPaymentTypeCodeReg11DOC19());
          pstmt3.setString(8,newVO.getCurrencyCodeReg03DOC19());
          pstmt3.setBigDecimal(9,newVO.getProgressiveReg04DOC19());
          pstmt3.setString(10,username);
          pstmt3.setTimestamp(11,new java.sql.Timestamp(System.currentTimeMillis()));
          pstmt3.execute();

          // insert record in DOC28...
          pstmt2.setString(1,newVO.getCompanyCodeSys01DOC19());
          pstmt2.setBigDecimal(2,progressiveDOC27);
          pstmt2.setBigDecimal(3,newVO.getProgressiveDOC19());
          pstmt2.setBigDecimal(4,newVO.getPayedValueDOC19());
          pstmt2.setString(5,"Y");
          pstmt2.setString(6,username);
          pstmt2.setTimestamp(7,new java.sql.Timestamp(System.currentTimeMillis()));
          pstmt2.execute();

          jhVO = new JournalHeaderVO();
          jhVO.setCompanyCodeSys01ACC05(newVO.getCompanyCodeSys01DOC19());
          String creditDebitAccountCode = null;
          String accountCodeTypeACC06 = null;
          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)) {
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_INVOICE_PROCEEDS);
            jhVO.setDescriptionACC05(
                newVO.getDescriptionDOC19()+" - "+
                t1+" "+newVO.getName_1DOC19()+" "+(newVO.getName_2DOC19()==null?"":newVO.getName_2DOC19())
            );

            // determine account codes defined for the current customer...
            pstmt = conn.prepareStatement(
              "select CREDIT_ACCOUNT_CODE_ACC02 from SAL07_CUSTOMERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
            );
            pstmt.setString(1,newVO.getCompanyCodeSys01DOC19());
            pstmt.setBigDecimal(2,newVO.getProgressiveReg04DOC19());
            ResultSet rset = pstmt.executeQuery();
            if (!rset.next()) {
              rset.close();
              throw new Exception("customer not found");
            }
            creditDebitAccountCode = rset.getString(1);
            rset.close();
            pstmt.close();

            accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_CUSTOMER;
          }
          else {
            jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_PURCHASE_INVOICE_PAYED);
            jhVO.setDescriptionACC05(
                newVO.getDescriptionDOC19()+" - "+
                t2+" "+newVO.getName_1DOC19()+" "+(newVO.getName_2DOC19()==null?"":newVO.getName_2DOC19())
            );

            // determine account codes defined for the current supplier...
            pstmt = conn.prepareStatement(
              "select DEBIT_ACCOUNT_CODE_ACC02 from PUR01_SUPPLIERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
            );
            pstmt.setString(1,newVO.getCompanyCodeSys01DOC19());
            pstmt.setBigDecimal(2,newVO.getProgressiveReg04DOC19());
            ResultSet rset = pstmt.executeQuery();
            if (!rset.next()) {
              rset.close();
              throw new Exception("supplier not found");
            }
            creditDebitAccountCode = rset.getString(1);
            rset.close();
            pstmt.close();

            accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_SUPPLIER;
          }

          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()) {
            throw new Exception(res.getErrorMessage());
View Full Code Here

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

        }
        accountCode = ((VOResponse)res).getVo().toString();
      }

      // generate an accounting item, since the row has been payed...
      JournalHeaderVO jhVO = new JournalHeaderVO();
      jhVO.setCompanyCodeSys01ACC05(companyCode);
      String creditDebitAccountCode = null;
      String accountCodeTypeACC06 = null;
      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)) {
        jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_INVOICE_PROCEEDS);
        jhVO.setDescriptionACC05(
            descriptionDOC19+" - "+
            t1+" "+name_1DOC19+" "+(name_2DOC19==null?"":name_2DOC19)
        );

        // determine account codes defined for the current customer...
        pstmt = conn.prepareStatement(
          "select CREDIT_ACCOUNT_CODE_ACC02 from SAL07_CUSTOMERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
        );
        pstmt.setString(1,companyCode);
        pstmt.setBigDecimal(2,progressiveReg04DOC19);
        rset = pstmt.executeQuery();
        if (!rset.next()) {
          rset.close();
          throw new Exception("customer not found");
        }
        creditDebitAccountCode = rset.getString(1);
        rset.close();
        pstmt.close();

        accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_CUSTOMER;
      }
      else {
        jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_PURCHASE_INVOICE_PAYED);
        jhVO.setDescriptionACC05(
            descriptionDOC19+" - "+
            t2+" "+name_1DOC19+" "+(name_2DOC19==null?"":name_2DOC19)
        );

        // determine account codes defined for the current supplier...
        pstmt = conn.prepareStatement(
          "select DEBIT_ACCOUNT_CODE_ACC02 from PUR01_SUPPLIERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
        );
        pstmt.setString(1,companyCode);
        pstmt.setBigDecimal(2,progressiveReg04DOC19);
        rset = pstmt.executeQuery();
        if (!rset.next()) {
          rset.close();
          throw new Exception("supplier not found");
        }
        creditDebitAccountCode = rset.getString(1);
        rset.close();
        pstmt.close();

        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()) {
        throw new Exception(res.getErrorMessage());
View Full Code Here

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

        "ROUNDING_ACCOUNT_CODE_ACC02=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  "+
        "WHERE COMPANY_CODE_SYS01=? AND PROGRESSIVE=?"
      );

      PaymentDistributionVO dVO = null;
      JournalHeaderVO jhVO = null;
      String creditDebitAccountCode = null;
      String accountCodeTypeACC06 = null;
      BigDecimal paymentValue = null;
      for(int i=0;i<payDistrs.size();i++) {
        dVO = (PaymentDistributionVO)payDistrs.get(i);
        dVO.setProgressiveDoc27DOC28(vo.getProgressiveDOC27());

        res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
            conn,
            new UserSessionParameters(username),
            dVO,
            "DOC28_PAYMENT_DISTRIBUTION",
            attribute2dbField,
            "Y",
            "N",
            null,
            true
        );
        if (res.isError()) {
          throw new Exception(res.getErrorMessage());
        }

        paymentValue = dVO.getPaymentValueDOC28();
        if (!dVO.getCurrencyCodeREG03().equals(vo.getCurrencyCodeReg03DOC27())) {
          paymentValue = CurrencyConversionUtils.convertCurrencyToCurrency(
            vo.getPaymentDateDOC27(),
            dVO.getPaymentValueDOC28(),
            vo.getCurrencyCodeReg03DOC27(),
            dVO.getCurrencyCodeREG03(),
            conn
          );
        }

        pstmt2.setString(1,dVO.getPayedDOC28().booleanValue()?"Y":"N");
        pstmt2.setBigDecimal(2,dVO.getAlreadyPayedDOC19().add(paymentValue));
        pstmt2.setBigDecimal(3,dVO.getAlreadyPayedDOC19().add(paymentValue));
        pstmt2.setString(4,vo.getPaymentTypeCodeReg11DOC27());
        pstmt2.setString(5,vo.getAccountCodeAcc02DOC27());
        pstmt2.setString(6,dVO.getRoundingAccountCodeAcc02DOC19());
        pstmt2.setString(7,username);
        pstmt2.setTimestamp(8,new java.sql.Timestamp(System.currentTimeMillis()));
        pstmt2.setString(9,dVO.getCompanyCodeSys01DOC28());
        pstmt2.setBigDecimal(10,dVO.getProgressiveDoc19DOC28());
        pstmt2.execute();




        jhVO = new JournalHeaderVO();
        jhVO.setCompanyCodeSys01ACC05(vo.getCompanyCodeSys01DOC27());
        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)) {
          jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_INVOICE_PROCEEDS);
          jhVO.setDescriptionACC05(
              dVO.getDescriptionDOC19()+" - "+
              t1+" "+vo.getName_1REG04()+" "+(vo.getName_2REG04()==null?"":vo.getName_2REG04())
          );

          // determine account codes defined for the current customer...
          pstmt = conn.prepareStatement(
            "select CREDIT_ACCOUNT_CODE_ACC02 from SAL07_CUSTOMERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
          );
          pstmt.setString(1,vo.getCompanyCodeSys01DOC27());
          pstmt.setBigDecimal(2,vo.getProgressiveReg04DOC27());
          ResultSet rset = pstmt.executeQuery();
          if (!rset.next()) {
            rset.close();
            throw new Exception("customer not found");
          }
          creditDebitAccountCode = rset.getString(1);
          rset.close();
          pstmt.close();

          accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_CUSTOMER;
        }
        else {
          jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_PURCHASE_INVOICE_PAYED);
          jhVO.setDescriptionACC05(
              dVO.getDescriptionDOC19()+" - "+
              t2+" "+vo.getName_1REG04()+" "+(vo.getName_2REG04()==null?"":vo.getName_2REG04())
          );

          // determine account codes defined for the current supplier...
          pstmt = conn.prepareStatement(
            "select DEBIT_ACCOUNT_CODE_ACC02 from PUR01_SUPPLIERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
          );
          pstmt.setString(1,vo.getCompanyCodeSys01DOC27());
          pstmt.setBigDecimal(2,vo.getProgressiveReg04DOC27());
          ResultSet rset = pstmt.executeQuery();
          if (!rset.next()) {
            rset.close();
            throw new Exception("supplier not found");
          }
          creditDebitAccountCode = rset.getString(1);
          rset.close();
          pstmt.close();

          accountCodeTypeACC06 = ApplicationConsts.ACCOUNT_TYPE_SUPPLIER;
        }

        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()) {
          throw new Exception(res.getErrorMessage());
View Full Code Here

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

    if (detailFrame.getControlSbil().getValue()!=null &&
        ((BigDecimal)detailFrame.getControlSbil().getValue()).doubleValue()!=0) {
      return new ErrorResponse("there is a lack of balance between debit and credit amounts");
    }

    JournalHeaderVO vo = (JournalHeaderVO)newPersistentObject;
    for(int i=0;i<gridModel.getRowCount();i++)
      vo.addJournalRow((JournalRowVO)gridModel.getObjectForRow(i));

    Response response = ClientUtils.getData("insertJournalItem",vo);
    if (!response.isError()) {
      JOptionPane.showMessageDialog(
          ClientUtils.getParentFrame(detailFrame),
View Full Code Here

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

   * 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 {
    JournalHeaderVO vo = (JournalHeaderVO)persistentObject;
    vo.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
    vo.setItemYearACC05(new BigDecimal(new java.util.Date().getYear()+1900));
  }
View Full Code Here

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

       if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_INVOICE_FROM_DN_DOC_TYPE) ||
           docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_INVOICE_FROM_PD_DOC_TYPE) ||
           docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_INVOICE_DOC_TYPE) ||
           docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE)
       ) {
         JournalHeaderVO jhVO = new JournalHeaderVO();
         jhVO.setCompanyCodeSys01ACC05(docVO.getCompanyCodeSys01DOC06());
         jhVO.setAccountingMotiveCodeAcc03ACC05(ApplicationConsts.MOTIVE_PURCHASE_INVOICE);
         jhVO.setItemDateACC05(new java.sql.Date(System.currentTimeMillis()));
         jhVO.setItemYearACC05(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));

         if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
           jhVO.setDescriptionACC05(
               t5+" "+docVO.getDocSequenceDOC06()+"/"+docVO.getDocYearDOC06()+" - "+
               t6+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
           );
         else
           jhVO.setDescriptionACC05(
               t7+" "+docVO.getDocSequenceDOC06()+"/"+docVO.getDocYearDOC06()+" - "+
               t6+" "+docVO.getName_1REG04()+" "+(docVO.getName_2REG04()==null?"":docVO.getName_2REG04())
           );

         // determine account codes defined for the current customer...
         pstmt = conn.prepareStatement(
             "select DEBIT_ACCOUNT_CODE_ACC02,COSTS_ACCOUNT_CODE_ACC02 from PUR01_SUPPLIERS where COMPANY_CODE_SYS01=? and PROGRESSIVE_REG04=?"
         );
         pstmt.setString(1,pk.getCompanyCodeSys01DOC06());
         pstmt.setBigDecimal(2,docVO.getProgressiveReg04DOC06());
         rset = pstmt.executeQuery();
         if (!rset.next()) {
           rset.close();
           throw new Exception("supplier not found");
         }
         String debitAccountCodeAcc02 = rset.getString(1);
         String costsAccountCodeAcc02 = rset.getString(2);
         rset.close();
         pstmt.close();

         // determine account code defined for vat in sale vat register...
         pstmt = conn.prepareStatement(
             "select ACCOUNT_CODE_ACC02 from ACC04_VAT_REGISTERS where COMPANY_CODE_SYS01=? and REGISTER_CODE=?"
         );
         pstmt.setString(1,pk.getCompanyCodeSys01DOC06());
         pstmt.setString(2,ApplicationConsts.VAT_REGISTER_PURCHASE);
         rset = pstmt.executeQuery();
         if (!rset.next()) {
           rset.close();
           throw new Exception("vat register not found");
         }
         String vatAccountCodeAcc02 = rset.getString(1);
         rset.close();
         pstmt.close();

         // calculate taxable income rows, grouped by vat code...
         res = taxableIncomeAction.calcTaxableIncomes(docVO,serverLanguageId,username);
         if (res.isError()) {
           throw new Exception(res.getErrorMessage());
         }

         // 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
Copyright © 2018 www.massapi.com. 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.