Package org.jallinone.expirations.java

Examples of org.jallinone.expirations.java.PaymentDistributionVO


        "PAYED=?,PAYED_VALUE=?,ALREADY_PAYED=?,REAL_PAYMENT_TYPE_CODE_REG11=?,REAL_ACCOUNT_CODE_ACC02=?,"+
        "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);
View Full Code Here


      return new ErrorResponse("you need to specify at least one expiration");
    PaymentVO payVO = (PaymentVO)frame.getPayForm().getVOModel().getValueObject();

  // check total amount...
    BigDecimal total = new BigDecimal(0);
    PaymentDistributionVO vo = null;
    for(int i=0;i<exp.size();i++) {
      vo = (PaymentDistributionVO)exp.get(i);
      if (vo.getPaymentValueDOC28()==null)
        return new ErrorResponse("expirations must have a payment value");

      total = total.add(vo.getPaymentValueDOC28());
    }
    if ( payVO.getPaymentValueDOC27().subtract(total).doubleValue()!=0)
      return new ErrorResponse("payments specified for expirations are not equal to the total payment value");

    Response res = ClientUtils.getData("insertPayment",new Object[]{
View Full Code Here

   * Callback method invoked when the user has clicked on the insert button
   * @param valueObject empty value object just created: the user can manage it to fill some attribute values
   */
  public void createValueObject(ValueObject valueObject) throws Exception {
    PaymentVO payVO = (PaymentVO)frame.getPayForm().getVOModel().getValueObject();
    PaymentDistributionVO vo = (PaymentDistributionVO)valueObject;
    vo.setCompanyCodeSys01DOC28(payVO.getCompanyCodeSys01DOC27());
    vo.setPayedDOC28(Boolean.FALSE);
  }
View Full Code Here

   * @param oldValue old cell value (before cell editing)
   * @param newValue new cell value (just edited)
   * @return <code>true</code> if cell value is valid, <code>false</code> otherwise
   */
  public boolean validateCell(int rowNumber,String attributeName,Object oldValue,Object newValue) {
    PaymentDistributionVO vo = (PaymentDistributionVO)frame.getGrid().getVOListTableModel().getObjectForRow(rowNumber);
    PaymentVO payVO = (PaymentVO)frame.getPayForm().getVOModel().getValueObject();
    BigDecimal res = new BigDecimal(0);
    if (vo!=null && vo.getValueDOC19()!=null && vo.getAlreadyPayedDOC19()!=null)
      res = vo.getValueDOC19().subtract(vo.getAlreadyPayedDOC19());


    if (attributeName.equals("payedDOC28") &&
        Boolean.TRUE.equals(newValue) &&
        vo.getPaymentValueDOC28()==null
    ) {
      if (vo.getCurrencyCodeREG03().equals(payVO.getCurrencyCodeReg03DOC27()))
        vo.setPaymentValueDOC28( res );
      else {
        CurrencyConvVO convVO = null;
        for(int i=0;i<frame.getCurrConvs().size();i++) {
          convVO = (CurrencyConvVO)frame.getCurrConvs().get(i);
          if (convVO.getCurrencyCode2Reg03REG06().equals(vo.getCurrencyCodeREG03())) {
            vo.setPaymentValueDOC28( res.divide(convVO.getValueREG06(),vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP) );
            break;
          }
        }
      }
    }
    else if (attributeName.equals("paymentValueDOC28")) {
      // check for total amount...
      BigDecimal total = new BigDecimal(0);
      if (newValue!=null)
        total = total.add((BigDecimal)newValue);
      for(int i=0;i<frame.getGrid().getVOListTableModel().getRowCount();i++) {
        vo = (PaymentDistributionVO)frame.getGrid().getVOListTableModel().getObjectForRow(i);
        if (i!=rowNumber &&
            vo.getPaymentValueDOC28()!=null)
          total = total.add(vo.getPaymentValueDOC28());
      }
      if (payVO.getPaymentValueDOC27()==null || payVO.getPaymentValueDOC27().subtract(total).doubleValue()<0)
        return false;

      vo = (PaymentDistributionVO)frame.getGrid().getVOListTableModel().getObjectForRow(rowNumber);
      if (newValue!=null) {
        BigDecimal conv = (BigDecimal)newValue;
        if (!vo.getCurrencyCodeREG03().equals(payVO.getCurrencyCodeReg03DOC27())) {
          CurrencyConvVO convVO = null;
          for(int i=0;i<frame.getCurrConvs().size();i++) {
            convVO = (CurrencyConvVO)frame.getCurrConvs().get(i);
            if (convVO.getCurrencyCode2Reg03REG06().equals(vo.getCurrencyCodeREG03())) {
              conv = conv.multiply(convVO.getValueREG06());
              break;
            }
          }
        }
        if (conv.equals(vo.getValueDOC19().subtract(vo.getAlreadyPayedDOC19())))
          vo.setPayedDOC28(Boolean.TRUE);
      }
    }
    return true;
  }
View Full Code Here

        public void codeValidated(boolean validated) {}

        public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
          ExpirationVO vo = (ExpirationVO)expController.getLookupVO();
          PaymentDistributionVO pVO = (PaymentDistributionVO)grid.getVOListTableModel().getObjectForRow(grid.getSelectedRow());
          if (vo!=null && vo.getProgressiveDOC19()!=null) {
            BigDecimal res = vo.getValueDOC19().subtract(vo.getAlreadyPayedDOC19());
            CurrencyConvVO convVO = null;
            if (vo.getCurrencyCodeReg03DOC19().equals(controlCurrency.getValue()))
              pVO.setPaymentValueDOC28( res );
            else {
              for(int i=0;i<currConvs.size();i++) {
                convVO = (CurrencyConvVO)currConvs.get(i);
                if (convVO.getCurrencyCode2Reg03REG06().equals(vo.getCurrencyCodeReg03DOC19())) {
                  pVO.setPaymentValueDOC28( res.divide(convVO.getValueREG06(),vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP) );
                  break;
                }
              }
            }
          }
          else {
            pVO.setPaymentValueDOC28(null);
          }
        }

        public void beforeLookupAction(ValueObject parentVO) {
          PaymentVO vo = (PaymentVO)payForm.getVOModel().getValueObject();
View Full Code Here

      return true;
    }


    public int getDecimals(int row) {
      PaymentDistributionVO vo = (PaymentDistributionVO)grid.getVOListTableModel().getObjectForRow(row);
      if (vo!=null && vo.getDecimalsREG03()!=null)
        return vo.getDecimalsREG03().intValue();
      else
        return 0;
    }
View Full Code Here

        return 0;
    }


    public String getCurrencySymbol(int row) {
      PaymentDistributionVO vo = (PaymentDistributionVO)grid.getVOListTableModel().getObjectForRow(row);
      if (vo!=null && vo.getCurrencySymbolREG03()!=null)
        return vo.getCurrencySymbolREG03();
      else
      return "E";
    }
View Full Code Here

TOP

Related Classes of org.jallinone.expirations.java.PaymentDistributionVO

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.