Package org.jallinone.accounting.movements.java

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


          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());
View Full Code Here


      Hashtable itemsTaxableIncomeRows = new Hashtable(); // collection of pairs <vatcode,TaxableIncomeVO>
      totalTaxableIncome = new BigDecimal(0);
      BigDecimal totalVat = new BigDecimal(0);
      String vatCode = null;
      String vatDescr = null;
      TaxableIncomeVO tVO = null;
      pstmt = conn.prepareStatement(
        "update DOC02_SELLING_ITEMS set TAXABLE_INCOME=?,VAT_VALUE=?,VALUE=?,TOTAL_DISCOUNT=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  "+
        "where COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and "+
        "VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
        "VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
        "VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
        "VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
        "VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? "
      );
      for(int i=0;i<detailItemRows.size();i++) {
        detailItemVO = (DetailSaleDocRowVO)detailItemRows.get(i);

        if (customerVatValue==null) {
          vatCode = detailItemVO.getVatCodeItm01DOC02();
          vatDescr = detailItemVO.getVatDescriptionDOC02();
          vatPerc = detailItemVO.getValueReg01DOC02().doubleValue()*(1d-detailItemVO.getDeductibleReg01DOC02().doubleValue()/100d)/100;
        }
        else {
          vatCode = customerVatCode;
          vatDescr = customerVatDescription;
          vatPerc = customerVatValue.doubleValue()/100d;
        }

        detailItemVO.setVatValueDOC02(detailItemVO.getTaxableIncomeDOC02().multiply(new BigDecimal(vatPerc)).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));
        detailItemVO.setValueDOC02(detailItemVO.getTaxableIncomeDOC02().add(detailItemVO.getVatValueDOC02()));

        totalTaxableIncome = totalTaxableIncome.add(detailItemVO.getTaxableIncomeDOC02());
        totalVat = totalVat.add(detailItemVO.getVatValueDOC02());

        tVO = (TaxableIncomeVO)itemsTaxableIncomeRows.get(vatCode);
        if (tVO==null) {
          tVO = new TaxableIncomeVO();
          tVO.setRowType(tVO.ITEM_ROW_TYPE);
          tVO.setVatCode(vatCode);
          tVO.setVatDescription(vatDescr);
          tVO.setVatValue(new BigDecimal(0));
          tVO.setTaxableIncome(new BigDecimal(0));
          itemsTaxableIncomeRows.put(vatCode,tVO);
        }
        tVO.setTaxableIncome(tVO.getTaxableIncome().add(detailItemVO.getTaxableIncomeDOC02()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));
        tVO.setVatValue(tVO.getVatValue().add(detailItemVO.getVatValueDOC02()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));

        pstmt.setBigDecimal(1,detailItemVO.getTaxableIncomeDOC02());
        pstmt.setBigDecimal(2,detailItemVO.getVatValueDOC02());
        pstmt.setBigDecimal(3,detailItemVO.getValueDOC02());
        pstmt.setBigDecimal(4,detailItemVO.getTotalDiscountDOC02());
        pstmt.setString(5,username);
        pstmt.setTimestamp(6,new java.sql.Timestamp(System.currentTimeMillis()));
        pstmt.setString(7,detailItemVO.getCompanyCodeSys01DOC02());
        pstmt.setString(8,detailItemVO.getDocTypeDOC02());
        pstmt.setBigDecimal(9,detailItemVO.getDocYearDOC02());
        pstmt.setBigDecimal(10,detailItemVO.getDocNumberDOC02());
        pstmt.setString(11,detailItemVO.getItemCodeItm01DOC02());

        pstmt.setString(12,detailItemVO.getVariantTypeItm06DOC02());
        pstmt.setString(13,detailItemVO.getVariantCodeItm11DOC02());
        pstmt.setString(14,detailItemVO.getVariantTypeItm07DOC02());
        pstmt.setString(15,detailItemVO.getVariantCodeItm12DOC02());
        pstmt.setString(16,detailItemVO.getVariantTypeItm08DOC02());
        pstmt.setString(17,detailItemVO.getVariantCodeItm13DOC02());
        pstmt.setString(18,detailItemVO.getVariantTypeItm09DOC02());
        pstmt.setString(19,detailItemVO.getVariantCodeItm14DOC02());
        pstmt.setString(20,detailItemVO.getVariantTypeItm10DOC02());
        pstmt.setString(21,detailItemVO.getVariantCodeItm15DOC02());

        pstmt.execute();
      }
      pstmt.close();

      // update vat values, activities rows and calculate totals...
      Hashtable actsTaxableIncomeRows = new Hashtable(); // collection of pairs <vatcode,TaxableIncomeVO>
      pstmt = conn.prepareStatement("update DOC13_SELLING_ACTIVITIES set TAXABLE_INCOME=?,VAT_VALUE=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ACTIVITY_CODE_SAL09=?");
      for(int i=0;i<actsRows.size();i++) {
        actVO = (SaleDocActivityVO)actsRows.get(i);

        if (customerVatValue==null) {
          vatCode = actVO.getVatCodeSal09DOC13();
          vatDescr = actVO.getVatDescriptionDOC13();
          vatPerc = actVO.getValueReg01DOC13().doubleValue()*(1d-actVO.getVatDeductibleDOC13().doubleValue()/100d)/100;
        }
        else {
          vatCode = customerVatCode;
          vatDescr = customerVatDescription;
          vatPerc = customerVatValue.doubleValue()/100d;
        }

        actVO.setVatValueDOC13(actVO.getTaxableIncomeDOC13().multiply(new BigDecimal(vatPerc)).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));

        totalTaxableIncome = totalTaxableIncome.add(actVO.getTaxableIncomeDOC13());
        totalVat = totalVat.add(actVO.getVatValueDOC13());

        tVO = (TaxableIncomeVO)actsTaxableIncomeRows.get(vatCode);
        if (tVO==null) {
          tVO = new TaxableIncomeVO();
          tVO.setRowType(tVO.ACTIVITY_ROW_TYPE);
          tVO.setVatCode(vatCode);
          tVO.setVatDescription(vatDescr);
          tVO.setVatValue(new BigDecimal(0));
          tVO.setTaxableIncome(new BigDecimal(0));
          actsTaxableIncomeRows.put(vatCode,tVO);
        }
        tVO.setTaxableIncome(tVO.getTaxableIncome().add(actVO.getTaxableIncomeDOC13()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));
        tVO.setVatValue(tVO.getVatValue().add(actVO.getVatValueDOC13()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));

        pstmt.setBigDecimal(1,actVO.getTaxableIncomeDOC13());
        pstmt.setBigDecimal(2,actVO.getVatValueDOC13());
        pstmt.setString(3,username);
        pstmt.setTimestamp(4,new java.sql.Timestamp(System.currentTimeMillis()));
        pstmt.setString(5,actVO.getCompanyCodeSys01DOC13());
        pstmt.setString(6,actVO.getDocTypeDOC13());
        pstmt.setBigDecimal(7,actVO.getDocYearDOC13());
        pstmt.setBigDecimal(8,actVO.getDocNumberDOC13());
        pstmt.setString(9,actVO.getActivityCodeSal09DOC13());
        pstmt.execute();
      }
      pstmt.close();

      // update vat values, value charges rows and calculate totals...
      Hashtable chargesTaxableIncomeRows = new Hashtable(); // collection of pairs <vatcode,TaxableIncomeVO>
      pstmt = conn.prepareStatement("update DOC03_SELLING_CHARGES set TAXABLE_INCOME=?,VAT_VALUE=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and CHARGE_CODE_SAL06=?");
      for(int i=0;i<chargesRows.size();i++) {
        chargeVO = (SaleDocChargeVO)chargesRows.get(i);
        if (chargeVO.getValueDOC03()!=null) {
          if (customerVatValue==null) {
            vatCode = chargeVO.getVatCodeSal06DOC03();
            vatDescr = chargeVO.getVatDescriptionDOC03();
            vatPerc = chargeVO.getValueReg01DOC03().doubleValue()*(1d-chargeVO.getVatDeductibleDOC03().doubleValue()/100d)/100;
          }
          else {
            vatCode = customerVatCode;
            vatDescr = customerVatDescription;
            vatPerc = customerVatValue.doubleValue()/100d;
          }

          chargeVO.setVatValueDOC03(chargeVO.getTaxableIncomeDOC03().multiply(new BigDecimal(vatPerc)).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));

          totalTaxableIncome = totalTaxableIncome.add(chargeVO.getTaxableIncomeDOC03());
          totalVat = totalVat.add(chargeVO.getVatValueDOC03());

          tVO = (TaxableIncomeVO)chargesTaxableIncomeRows.get(vatCode);
          if (tVO==null) {
            tVO = new TaxableIncomeVO();
            tVO.setRowType(tVO.CHARGE_ROW_TYPE);
            tVO.setVatCode(vatCode);
            tVO.setVatDescription(vatDescr);
            tVO.setVatValue(new BigDecimal(0));
            tVO.setTaxableIncome(new BigDecimal(0));
            chargesTaxableIncomeRows.put(vatCode,tVO);
          }
          tVO.setTaxableIncome(tVO.getTaxableIncome().add(chargeVO.getTaxableIncomeDOC03()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));
          tVO.setVatValue(tVO.getVatValue().add(chargeVO.getVatValueDOC03()).setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP));

          pstmt.setBigDecimal(1,chargeVO.getTaxableIncomeDOC03());
          pstmt.setBigDecimal(2,chargeVO.getVatValueDOC03());
          pstmt.setString(3,username);
          pstmt.setTimestamp(4,new java.sql.Timestamp(System.currentTimeMillis()));
View Full Code Here

           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());
View Full Code Here

TOP

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

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.