Error - org.adempiere.model.GenericPO cannot be cast to com.cattleya.model.MMovementTax

608 views
Skip to first unread message

shiju01

unread,
Mar 13, 2018, 10:15:00 AM3/13/18
to iDempiere

Error Log

WARNING: afterSave
java.lang.ClassCastException: org.adempiere.model.GenericPO cannot be cast to com.cattleya.model.MMovementTax
    at com.cattleya.model.MMovementTax.get(MMovementTax.java:98)
    at com.cattleya.model.CAT_MMovementLine.updateMovementTax(CAT_MMovementLine.java:793)
    at com.cattleya.model.CAT_StandardTaxProvider.recalculateTax(CAT_StandardTaxProvider.java:155)
    at com.cattleya.model.CAT_MMovementLine.afterSave(CAT_MMovementLine.java:650)
    at org.compiere.model.PO.saveFinish(PO.java:2285)
    at org.compiere.model.PO.saveUpdate(PO.java:2436)
    at org.compiere.model.PO.save(PO.java:2177)
    at org.compiere.model.GridTable.dataSavePO(GridTable.java:2240)
    at org.compiere.model.GridTable.dataSave(GridTable.java:1566)
    at org.compiere.model.GridTab.dataSave(GridTab.java:1004)
    at org.adempiere.webui.adwindow.ADTabpanel.dataSave(ADTabpanel.java:1751)
    at org.adempiere.webui.adwindow.CompositeADTabbox.dataSave(CompositeADTabbox.java:862)
    at org.adempiere.webui.adwindow.AbstractADWindowContent.onSave0(AbstractADWindowContent.java:2253)
    at org.adempiere.webui.adwindow.AbstractADWindowContent.onSaveCallback(AbstractADWindowContent.java:2246)
    at org.adempiere.webui.adwindow.AbstractADWindowContent.access$19(AbstractADWindowContent.java:2215)
    at org.adempiere.webui.adwindow.AbstractADWindowContent$30.onCallback(AbstractADWindowContent.java:2189)
    at org.adempiere.webui.adwindow.AbstractADWindowContent$30.onCallback(AbstractADWindowContent.java:1)
    at org.adempiere.webui.adwindow.validator.WindowValidatorManager$ChainCallback.start(WindowValidatorManager.java:150)
    at org.adempiere.webui.adwindow.validator.WindowValidatorManager.fireWindowValidatorEvent(WindowValidatorManager.java:129)
    at org.adempiere.webui.adwindow.AbstractADWindowContent.onSave(AbstractADWindowContent.java:2197)
    at org.adempiere.webui.adwindow.AbstractADWindowContent.onSave(AbstractADWindowContent.java:2147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.adempiere.webui.adwindow.ADWindowToolbar.doOnClick(ADWindowToolbar.java:435)
    at org.adempiere.webui.adwindow.ADWindowToolbar.onEvent(ADWindowToolbar.java:399)
    at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3161)
    at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3131)
    at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3073)
    at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
    at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1853)
    at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1625)
    at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1328)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:606)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:482)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:490)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:833)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:561)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:243)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
    at java.lang.Thread.run(Thread.java:748)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/******************************************************************************
 * Product: Adempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software; you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via in...@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/
package com.cattleya.model;
 
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
 
import org.adempiere.exceptions.DBException;
import org.adempiere.model.POWrapper;
import org.compiere.model.MTax;
import org.compiere.model.PO;
import org.compiere.model.Query;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
 
import org.compiere.model.MMovementLine;
import com.cattleya.model.CAT_MMovementLine;
 
/**
 *    Movement Tax Model
 *     
 *  @author shiju01
 *  @version $Id: MMovementTax.java,v 1.5 2006/10/06 00:42:24 jjanke Exp $
 *  
 *  IsSOTrx (Y) and IsTaxIncluded (N) is missing and is hard coded
 *  
 *  @author Teo Sarca, www.arhipac.ro
 *          <li>FR [ 2214883 ] Remove SQL code and Replace for Query
 */
public class MMovementTax extends X_M_MovementTax
{
    /**
     * 
     */
    private static final long serialVersionUID = -201846944112732519L;
 
    /**
     *     Get Tax Line for Movement Line
     *    @param line movement line
     *    @param precision currency precision
     *    @param oldTax if true old tax is returned
     *    @param trxName transaction name
     *    @return existing or new tax
     */
    public static MMovementTax get (MMovementLine line, int precision, 
        boolean oldTax, String trxName)
    {
        MMovementTax retValue = null;
        if (line == null || line.getM_Movement_ID() == 0)
            return null;
 
         
        CAT_I_M_MovementLine cat_line = POWrapper.create(line, CAT_I_M_MovementLine.class);
        int C_Tax_ID = cat_line.getC_Tax_ID();
        boolean isOldTax = oldTax && line.is_ValueChanged(CAT_MMovementLine.COLUMNNAME_C_Tax_ID); 
//        boolean isOldTax = oldTax && line.is_ValueChanged("C_Tax_ID"); 
        if (isOldTax)
        {
             
// TODO: Why? 
            // error1: COLUMNNAME_C_Tax_ID cannot be resolved or is not a field
            // error2: Cannot make a static reference to the non-static method getWrapper() from the type CAT_MMovementLine             
            // Object old = line.get_ValueOld(CAT_MMovementLine.getWrapper().COLUMNNAME_C_Tax_ID);
            // Object old = line.get_ValueOld("C_Tax_ID");
            Object old = line.get_ValueOld(CAT_MMovementLine.COLUMNNAME_C_Tax_ID);
            if (old == null)
                return null;
            C_Tax_ID = ((Integer)old).intValue();
        }
        if (C_Tax_ID == 0)
        {
//            if (!line.isDescription())
                s_log.warning("C_Tax_ID=0");
            return null;
        }
         
        retValue = new Query(line.getCtx(), Table_Name, "M_Movement_ID=? AND C_Tax_ID=?", trxName)
                        .setParameters(line.getM_Movement_ID(), C_Tax_ID)
                        .firstOnly();
         
        if (retValue != null)
        {
            retValue.set_TrxName(trxName);
            retValue.setPrecision(precision);
            if (s_log.isLoggable(Level.FINE)) s_log.fine("(old=" + oldTax + ") " + retValue);
            return retValue;
        }
        // If the old tax was required and there is no MMovementTax for that
        // return null, and not create another MMovementTax - teo_sarca [ 1583825 ]
        else {
            if (isOldTax)
                return null;
        }
         
        //    Create New
        retValue = new MMovementTax(line.getCtx(), 0, trxName);
        retValue.set_TrxName(trxName);
        retValue.setClientOrg(line);
        retValue.setM_Movement_ID(line.getM_Movement_ID());
        retValue.setC_Tax_ID(cat_line.getC_Tax_ID());
        retValue.setPrecision(precision);
//        retValue.setIsTaxIncluded(line.isTaxIncluded());                                                                 TODO: not there now!
        if (s_log.isLoggable(Level.FINE)) s_log.fine("(new) " + retValue);
        return retValue;
    }    //    get
     
    /**    Static Logger    */
    private static CLogger    s_log    = CLogger.getCLogger (MMovementTax.class);
     
     
    /**************************************************************************
     *     Persistency Constructor
     *    @param ctx context
     *    @param ignored ignored
     *    @param trxName transaction
     */
    public MMovementTax (Properties ctx, int ignored, String trxName)
    {
        super(ctx, 0, trxName);
        if (ignored != 0)
            throw new IllegalArgumentException("Multi-Key");
        setTaxAmt (Env.ZERO);
        setTaxBaseAmt (Env.ZERO);
        setIsTaxIncluded(false);
    }    //    MMovementTax
 
    /**
     *     Load Constructor.
     *     Set Precision and TaxIncluded for tax calculations!
     *    @param ctx context
     *    @param rs result set
     *    @param trxName transaction
     */
    public MMovementTax (Properties ctx, ResultSet rs, String trxName)
    {
        super(ctx, rs, trxName);
    }    //    MMovementTax
     
    /** Tax                            */
    private MTax         m_tax = null;
    /** Cached Precision            */
    private Integer        m_precision = null;
     
     
    /**
     *     Get Precision
     *     @return Returns the precision or 2
     */
    private int getPrecision ()
    {
        if (m_precision == null)
            return 2;
        return m_precision.intValue();
    }    //    getPrecision
 
    /**
     *     Set Precision
     *    @param precision The precision to set.
     */
    protected void setPrecision (int precision)
    {
        m_precision = new Integer(precision);
    }    //    setPrecision
 
    /**
     *     Get Tax
     *    @return tax
     */
    protected MTax getTax()
    {
        if (m_tax == null)
            m_tax = MTax.get(getCtx(), getC_Tax_ID());
        return m_tax;
    }    //    getTax
     
     
    /**************************************************************************
     *     Calculate/Set Tax Base Amt from Movement Lines
     *     @return true if tax calculated
     */
    public boolean calculateTaxFromLines ()
    {
        BigDecimal taxBaseAmt = Env.ZERO;
        BigDecimal taxAmt = Env.ZERO;
        //
        boolean documentLevel = getTax().isDocumentLevel();
        MTax tax = getTax();
        //
        String sql = " SELECT ml.LineNetAmt, COALESCE(ml.TaxAmt,0), 'Y' "    // m.IsSOTrx
            + " FROM M_MovementLine ml "
            + " INNER JOIN M_Movement m ON (ml.M_Movement_ID=m.M_Movement_ID) "
            + " WHERE ml.M_Movement_ID=? AND ml.C_Tax_ID=? ";
        PreparedStatement pstmt = null;
        ResultSet rs = null;
         
        try
        {
            pstmt = DB.prepareStatement (sql, get_TrxName());
            pstmt.setInt (1, getM_Movement_ID());
            pstmt.setInt (2, getC_Tax_ID());
            rs = pstmt.executeQuery ();
            while (rs.next ())
            {
                //    BaseAmt
                BigDecimal baseAmt = rs.getBigDecimal(1);
                taxBaseAmt = taxBaseAmt.add(baseAmt);
                //    TaxAmt
                BigDecimal amt = rs.getBigDecimal(2);
                if (amt == null)
                    amt = Env.ZERO;
                boolean isSOTrx = "Y".equals(rs.getString(3));
                //
                // phib [ 1702807 ]: manual tax should never be amended
                // on line level taxes
                if (!documentLevel && amt.signum() != 0 && !isSOTrx)    //    manually entered
                    ;
                else if (documentLevel || baseAmt.signum() == 0)
                    amt = Env.ZERO;
                else    // calculate line tax
                    amt = tax.calculateTax(baseAmt, isTaxIncluded(), getPrecision());
                //
                taxAmt = taxAmt.add(amt);
            }
        }
        catch (SQLException e)
        {
            throw new DBException(e, sql);
        }
        finally
        {
            DB.close(rs, pstmt);
            rs = null; pstmt = null;
        }
         
        //    Calculate Tax
        if (documentLevel || taxAmt.signum() == 0)
            taxAmt = tax.calculateTax(taxBaseAmt, isTaxIncluded(), getPrecision());
        setTaxAmt(taxAmt);
 
        //    Set Base
        if (isTaxIncluded())
            setTaxBaseAmt (taxBaseAmt.subtract(taxAmt));
        else
            setTaxBaseAmt (taxBaseAmt);
        return true;
    }    //    calculateTaxFromLines
 
    /**
     *     String Representation
     *    @return info
     */
    public String toString ()
    {
        StringBuilder sb = new StringBuilder ("MMovementTax[");
        sb.append("M_Movement_ID=").append(getM_Movement_ID())
            .append(",C_Tax_ID=").append(getC_Tax_ID())
            .append(", Base=").append(getTaxBaseAmt()).append(",Tax=").append(getTaxAmt())
            .append ("]");
        return sb.toString ();
    }    //    toString
 
    /**
     *     Overwrite Client Org if different
     *    @param po persistent object
     */
    protected void setClientOrg (PO po)
    {
        setClientOrg(po.getAD_Client_ID(), po.getAD_Org_ID());
    }    //    setClientOrg
     
}    //    MMovementTax

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/******************************************************************************
 * Product: iDempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software, you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program, if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via in...@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/
package com.cattleya.model;

import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;

/** Generated Interface for M_MovementTax
 *  @author iDempiere (generated)
 *  @version Release 5.1
 */
@SuppressWarnings("all")
public interface I_M_MovementTax
{

    /** TableName=M_MovementTax */
    public static final String Table_Name = "M_MovementTax";

    /** AD_Table_ID=1000001 */
    public static final int Table_ID = MTable.getTable_ID(Table_Name);

    KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);

    /** AccessLevel = 1 - Org
     */
    BigDecimal accessLevel = BigDecimal.valueOf(1);

    /** Load Meta Data */

    /** Column name AD_Client_ID */
    public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";

    /** Get Client.
      * Client/Tenant for this installation.
      */
    public int getAD_Client_ID();

    /** Column name AD_Org_ID */
    public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";

    /** Set Organization.
      * Organizational entity within client
      */
    public void setAD_Org_ID (int AD_Org_ID);

    /** Get Organization.
      * Organizational entity within client
      */
    public int getAD_Org_ID();

    /** Column name Created */
    public static final String COLUMNNAME_Created = "Created";

    /** Get Created.
      * Date this record was created
      */
    public Timestamp getCreated();

    /** Column name CreatedBy */
    public static final String COLUMNNAME_CreatedBy = "CreatedBy";

    /** Get Created By.
      * User who created this records
      */
    public int getCreatedBy();

    /** Column name C_Tax_ID */
    public static final String COLUMNNAME_C_Tax_ID = "C_Tax_ID";

    /** Set Tax.
      * Tax identifier
      */
    public void setC_Tax_ID (int C_Tax_ID);

    /** Get Tax.
      * Tax identifier
      */
    public int getC_Tax_ID();

    public org.compiere.model.I_C_Tax getC_Tax() throws RuntimeException;

    /** Column name C_TaxProvider_ID */
    public static final String COLUMNNAME_C_TaxProvider_ID = "C_TaxProvider_ID";

    /** Set Tax Provider      */
    public void setC_TaxProvider_ID (int C_TaxProvider_ID);

    /** Get Tax Provider      */
    public int getC_TaxProvider_ID();

    public org.compiere.model.I_C_TaxProvider getC_TaxProvider() throws RuntimeException;

    /** Column name IsActive */
    public static final String COLUMNNAME_IsActive = "IsActive";

    /** Set Active.
      * The record is active in the system
      */
    public void setIsActive (boolean IsActive);

    /** Get Active.
      * The record is active in the system
      */
    public boolean isActive();

    /** Column name IsTaxIncluded */
    public static final String COLUMNNAME_IsTaxIncluded = "IsTaxIncluded";

    /** Set Price includes Tax.
      * Tax is included in the price
      */
    public void setIsTaxIncluded (boolean IsTaxIncluded);

    /** Get Price includes Tax.
      * Tax is included in the price
      */
    public boolean isTaxIncluded();

    /** Column name M_Movement_ID */
    public static final String COLUMNNAME_M_Movement_ID = "M_Movement_ID";

    /** Set Inventory Move.
      * Movement of Inventory
      */
    public void setM_Movement_ID (int M_Movement_ID);

    /** Get Inventory Move.
      * Movement of Inventory
      */
    public int getM_Movement_ID();

    public org.compiere.model.I_M_Movement getM_Movement() throws RuntimeException;

    /** Column name M_MovementTax_UU */
    public static final String COLUMNNAME_M_MovementTax_UU = "M_MovementTax_UU";

    /** Set M_MovementTax_UU      */
    public void setM_MovementTax_UU (String M_MovementTax_UU);

    /** Get M_MovementTax_UU      */
    public String getM_MovementTax_UU();

    /** Column name Processed */
    public static final String COLUMNNAME_Processed = "Processed";

    /** Set Processed.
      * The document has been processed
      */
    public void setProcessed (boolean Processed);

    /** Get Processed.
      * The document has been processed
      */
    public boolean isProcessed();

    /** Column name TaxAmt */
    public static final String COLUMNNAME_TaxAmt = "TaxAmt";

    /** Set Tax Amount.
      * Tax Amount for a document
      */
    public void setTaxAmt (BigDecimal TaxAmt);

    /** Get Tax Amount.
      * Tax Amount for a document
      */
    public BigDecimal getTaxAmt();

    /** Column name TaxBaseAmt */
    public static final String COLUMNNAME_TaxBaseAmt = "TaxBaseAmt";

    /** Set Tax base Amount.
      * Base for calculating the tax amount
      */
    public void setTaxBaseAmt (BigDecimal TaxBaseAmt);

    /** Get Tax base Amount.
      * Base for calculating the tax amount
      */
    public BigDecimal getTaxBaseAmt();

    /** Column name Updated */
    public static final String COLUMNNAME_Updated = "Updated";

    /** Get Updated.
      * Date this record was updated
      */
    public Timestamp getUpdated();

    /** Column name UpdatedBy */
    public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";

    /** Get Updated By.
      * User who updated this records
      */
    public int getUpdatedBy();
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/******************************************************************************
 * Product: iDempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software, you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program, if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via in...@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package com.cattleya.model;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.model.*;

/** Generated Model for M_MovementTax
 *  @author iDempiere (generated)
 *  @version Release 5.1 - $Id$ */
public class X_M_MovementTax extends PO implements I_M_MovementTax, I_Persistent
{

    /**
     *
     */
    private static final long serialVersionUID = 20180223L;

    /** Standard Constructor */
    public X_M_MovementTax (Properties ctx, int M_MovementTax_ID, String trxName)
    {
      super (ctx, M_MovementTax_ID, trxName);
      /** if (M_MovementTax_ID == 0)
        {
            setC_Tax_ID (0);
            setIsTaxIncluded (false);
            setM_Movement_ID (0);
            setProcessed (false);
            setTaxAmt (Env.ZERO);
            setTaxBaseAmt (Env.ZERO);
        } */
    }

    /** Load Constructor */
    public X_M_MovementTax (Properties ctx, ResultSet rs, String trxName)
    {
      super (ctx, rs, trxName);
    }

    /** AccessLevel
      * @return 1 - Org
      */
    protected int get_AccessLevel()
    {
      return accessLevel.intValue();
    }

    /** Load Meta Data */
    protected POInfo initPO (Properties ctx)
    {
      POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
      return poi;
    }

    public String toString()
    {
      StringBuffer sb = new StringBuffer ("X_M_MovementTax[")
        .append(get_ID()).append("]");
      return sb.toString();
    }

    public org.compiere.model.I_C_Tax getC_Tax() throws RuntimeException
    {
        return (org.compiere.model.I_C_Tax)MTable.get(getCtx(), org.compiere.model.I_C_Tax.Table_Name)
            .getPO(getC_Tax_ID(), get_TrxName());    }

    /** Set Tax.
        @param C_Tax_ID
        Tax identifier
      */
    public void setC_Tax_ID (int C_Tax_ID)
    {
        if (C_Tax_ID < 1)
            set_ValueNoCheck (COLUMNNAME_C_Tax_ID, null);
        else
            set_ValueNoCheck (COLUMNNAME_C_Tax_ID, Integer.valueOf(C_Tax_ID));
    }

    /** Get Tax.
        @return Tax identifier
      */
    public int getC_Tax_ID ()
    {
        Integer ii = (Integer)get_Value(COLUMNNAME_C_Tax_ID);
        if (ii == null)
             return 0;
        return ii.intValue();
    }

    public org.compiere.model.I_C_TaxProvider getC_TaxProvider() throws RuntimeException
    {
        return (org.compiere.model.I_C_TaxProvider)MTable.get(getCtx(), org.compiere.model.I_C_TaxProvider.Table_Name)
            .getPO(getC_TaxProvider_ID(), get_TrxName());    }

    /** Set Tax Provider.
        @param C_TaxProvider_ID Tax Provider      */
    public void setC_TaxProvider_ID (int C_TaxProvider_ID)
    {
        if (C_TaxProvider_ID < 1)
            set_ValueNoCheck (COLUMNNAME_C_TaxProvider_ID, null);
        else
            set_ValueNoCheck (COLUMNNAME_C_TaxProvider_ID, Integer.valueOf(C_TaxProvider_ID));
    }

    /** Get Tax Provider.
        @return Tax Provider      */
    public int getC_TaxProvider_ID ()
    {
        Integer ii = (Integer)get_Value(COLUMNNAME_C_TaxProvider_ID);
        if (ii == null)
             return 0;
        return ii.intValue();
    }

    /** Set Price includes Tax.
        @param IsTaxIncluded
        Tax is included in the price
      */
    public void setIsTaxIncluded (boolean IsTaxIncluded)
    {
        set_Value (COLUMNNAME_IsTaxIncluded, Boolean.valueOf(IsTaxIncluded));
    }

    /** Get Price includes Tax.
        @return Tax is included in the price
      */
    public boolean isTaxIncluded ()
    {
        Object oo = get_Value(COLUMNNAME_IsTaxIncluded);
        if (oo != null)
        {
             if (oo instanceof Boolean)
                 return ((Boolean)oo).booleanValue();
            return "Y".equals(oo);
        }
        return false;
    }

    public org.compiere.model.I_M_Movement getM_Movement() throws RuntimeException
    {
        return (org.compiere.model.I_M_Movement)MTable.get(getCtx(), org.compiere.model.I_M_Movement.Table_Name)
            .getPO(getM_Movement_ID(), get_TrxName());    }

    /** Set Inventory Move.
        @param M_Movement_ID
        Movement of Inventory
      */
    public void setM_Movement_ID (int M_Movement_ID)
    {
        if (M_Movement_ID < 1)
            set_ValueNoCheck (COLUMNNAME_M_Movement_ID, null);
        else
            set_ValueNoCheck (COLUMNNAME_M_Movement_ID, Integer.valueOf(M_Movement_ID));
    }

    /** Get Inventory Move.
        @return Movement of Inventory
      */
    public int getM_Movement_ID ()
    {
        Integer ii = (Integer)get_Value(COLUMNNAME_M_Movement_ID);
        if (ii == null)
             return 0;
        return ii.intValue();
    }

    /** Set M_MovementTax_UU.
        @param M_MovementTax_UU M_MovementTax_UU      */
    public void setM_MovementTax_UU (String M_MovementTax_UU)
    {
        set_ValueNoCheck (COLUMNNAME_M_MovementTax_UU, M_MovementTax_UU);
    }

    /** Get M_MovementTax_UU.
        @return M_MovementTax_UU      */
    public String getM_MovementTax_UU ()
    {
        return (String)get_Value(COLUMNNAME_M_MovementTax_UU);
    }

    /** Set Processed.
        @param Processed
        The document has been processed
      */
    public void setProcessed (boolean Processed)
    {
        set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed));
    }

    /** Get Processed.
        @return The document has been processed
      */
    public boolean isProcessed ()
    {
        Object oo = get_Value(COLUMNNAME_Processed);
        if (oo != null)
        {
             if (oo instanceof Boolean)
                 return ((Boolean)oo).booleanValue();
            return "Y".equals(oo);
        }
        return false;
    }

    /** Set Tax Amount.
        @param TaxAmt
        Tax Amount for a document
      */
    public void setTaxAmt (BigDecimal TaxAmt)
    {
        set_ValueNoCheck (COLUMNNAME_TaxAmt, TaxAmt);
    }

    /** Get Tax Amount.
        @return Tax Amount for a document
      */
    public BigDecimal getTaxAmt ()
    {
        BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_TaxAmt);
        if (bd == null)
             return Env.ZERO;
        return bd;
    }

    /** Set Tax base Amount.
        @param TaxBaseAmt
        Base for calculating the tax amount
      */
    public void setTaxBaseAmt (BigDecimal TaxBaseAmt)
    {
        set_ValueNoCheck (COLUMNNAME_TaxBaseAmt, TaxBaseAmt);
    }

    /** Get Tax base Amount.
        @return Base for calculating the tax amount
      */
    public BigDecimal getTaxBaseAmt ()
    {
        BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_TaxBaseAmt);
        if (bd == null)
             return Env.ZERO;
        return bd;
    }

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/******************************************************************************
 * Product: iDempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software, you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program, if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via in...@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/
package com.cattleya.model;

import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
import org.compiere.model.*;

/** Generated Interface for M_MovementLine
 *  @author iDempiere (generated)
 *  @version Release 5.1
 */
@SuppressWarnings("all")
public interface CAT_I_M_MovementLine extends org.compiere.model.I_M_MovementLine
{

    /** TableName=M_MovementLine */
    public static final String Table_Name = "M_MovementLine";

    /** AD_Table_ID=324 */
    public static final int Table_ID = 324;

    KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);

    /** AccessLevel = 1 - Org
     */
    BigDecimal accessLevel = BigDecimal.valueOf(1);

    /** Load Meta Data */

    /** Column name AD_Client_ID */
    public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";

    /** Get Client.
      * Client/Tenant for this installation.
      */
    public int getAD_Client_ID();

    /** Column name AD_Org_ID */
    public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";

    /** Set Organization.
      * Organizational entity within client
      */
    public void setAD_Org_ID (int AD_Org_ID);

    /** Get Organization.
      * Organizational entity within client
      */
    public int getAD_Org_ID();

    /** Column name ConfirmedQty */
    public static final String COLUMNNAME_ConfirmedQty = "ConfirmedQty";

    /** Set Confirmed Quantity.
      * Confirmation of a received quantity
      */
    public void setConfirmedQty (BigDecimal ConfirmedQty);

    /** Get Confirmed Quantity.
      * Confirmation of a received quantity
      */
    public BigDecimal getConfirmedQty();

    /** Column name Created */
    public static final String COLUMNNAME_Created = "Created";

    /** Get Created.
      * Date this record was created
      */
    public Timestamp getCreated();

    /** Column name CreatedBy */
    public static final String COLUMNNAME_CreatedBy = "CreatedBy";

    /** Get Created By.
      * User who created this records
      */
    public int getCreatedBy();

    /** Column name C_Tax_ID */
    public static final String COLUMNNAME_C_Tax_ID = "C_Tax_ID";

    /** Set Tax.
      * Tax identifier
      */
    public void setC_Tax_ID (int C_Tax_ID);

    /** Get Tax.
      * Tax identifier
      */
    public int getC_Tax_ID();

    public org.compiere.model.I_C_Tax getC_Tax() throws RuntimeException;

    /** Column name DD_OrderLine_ID */
    public static final String COLUMNNAME_DD_OrderLine_ID = "DD_OrderLine_ID";

    /** Set Distribution Order Line      */
    public void setDD_OrderLine_ID (int DD_OrderLine_ID);

    /** Get Distribution Order Line      */
    public int getDD_OrderLine_ID();

    public org.eevolution.model.I_DD_OrderLine getDD_OrderLine() throws RuntimeException;

    /** Column name Description */
    public static final String COLUMNNAME_Description = "Description";

    /** Set Description.
      * Optional short description of the record
      */
    public void setDescription (String Description);

    /** Get Description.
      * Optional short description of the record
      */
    public String getDescription();

    /** Column name IsActive */
    public static final String COLUMNNAME_IsActive = "IsActive";

    /** Set Active.
      * The record is active in the system
      */
    public void setIsActive (boolean IsActive);

    /** Get Active.
      * The record is active in the system
      */
    public boolean isActive();

    /** Column name Line */
    public static final String COLUMNNAME_Line = "Line";

    /** Set Line No.
      * Unique line for this document
      */
    public void setLine (int Line);

    /** Get Line No.
      * Unique line for this document
      */
    public int getLine();

    /** Column name LineNetAmt */
    public static final String COLUMNNAME_LineNetAmt = "LineNetAmt";

    /** Set Line Amount.
      * Line Extended Amount (Quantity * Actual Price) without Freight and Charges
      */
    public void setLineNetAmt (BigDecimal LineNetAmt);

    /** Get Line Amount.
      * Line Extended Amount (Quantity * Actual Price) without Freight and Charges
      */
    public BigDecimal getLineNetAmt();

    /** Column name LineTotalAmt */
    public static final String COLUMNNAME_LineTotalAmt = "LineTotalAmt";

    /** Set Line Total.
      * Total line amount incl. Tax
      */
    public void setLineTotalAmt (BigDecimal LineTotalAmt);

    /** Get Line Total.
      * Total line amount incl. Tax
      */
    public BigDecimal getLineTotalAmt();

    /** Column name M_AttributeSetInstance_ID */
    public static final String COLUMNNAME_M_AttributeSetInstance_ID = "M_AttributeSetInstance_ID";

    /** Set Attribute Set Instance.
      * Product Attribute Set Instance
      */
    public void setM_AttributeSetInstance_ID (int M_AttributeSetInstance_ID);

    /** Get Attribute Set Instance.
      * Product Attribute Set Instance
      */
    public int getM_AttributeSetInstance_ID();

    public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException;

    /** Column name M_AttributeSetInstanceTo_ID */
    public static final String COLUMNNAME_M_AttributeSetInstanceTo_ID = "M_AttributeSetInstanceTo_ID";

    /** Set Attribute Set Instance To.
      * Target Product Attribute Set Instance
      */
    public void setM_AttributeSetInstanceTo_ID (int M_AttributeSetInstanceTo_ID);

    /** Get Attribute Set Instance To.
      * Target Product Attribute Set Instance
      */
    public int getM_AttributeSetInstanceTo_ID();

    public I_M_AttributeSetInstance getM_AttributeSetInstanceTo() throws RuntimeException;

    /** Column name M_Locator_ID */
    public static final String COLUMNNAME_M_Locator_ID = "M_Locator_ID";

    /** Set Locator.
      * Warehouse Locator
      */
    public void setM_Locator_ID (int M_Locator_ID);

    /** Get Locator.
      * Warehouse Locator
      */
    public int getM_Locator_ID();

    public I_M_Locator getM_Locator() throws RuntimeException;

    /** Column name M_LocatorTo_ID */
    public static final String COLUMNNAME_M_LocatorTo_ID = "M_LocatorTo_ID";

    /** Set Locator To.
      * Location inventory is moved to
      */
    public void setM_LocatorTo_ID (int M_LocatorTo_ID);

    /** Get Locator To.
      * Location inventory is moved to
      */
    public int getM_LocatorTo_ID();

    public I_M_Locator getM_LocatorTo() throws RuntimeException;

    /** Column name M_Movement_ID */
    public static final String COLUMNNAME_M_Movement_ID = "M_Movement_ID";

    /** Set Inventory Move.
      * Movement of Inventory
      */
    public void setM_Movement_ID (int M_Movement_ID);

    /** Get Inventory Move.
      * Movement of Inventory
      */
    public int getM_Movement_ID();

    public org.compiere.model.I_M_Movement getM_Movement() throws RuntimeException;

    /** Column name M_MovementLine_ID */
    public static final String COLUMNNAME_M_MovementLine_ID = "M_MovementLine_ID";

    /** Set Move Line.
      * Inventory Move document Line
      */
    public void setM_MovementLine_ID (int M_MovementLine_ID);

    /** Get Move Line.
      * Inventory Move document Line
      */
    public int getM_MovementLine_ID();

    /** Column name M_MovementLine_UU */
    public static final String COLUMNNAME_M_MovementLine_UU = "M_MovementLine_UU";

    /** Set M_MovementLine_UU      */
    public void setM_MovementLine_UU (String M_MovementLine_UU);

    /** Get M_MovementLine_UU      */
    public String getM_MovementLine_UU();

    /** Column name MovementQty */
    public static final String COLUMNNAME_MovementQty = "MovementQty";

    /** Set Movement Quantity.
      * Quantity of a product moved.
      */
    public void setMovementQty (BigDecimal MovementQty);

    /** Get Movement Quantity.
      * Quantity of a product moved.
      */
    public BigDecimal getMovementQty();

    /** Column name M_Product_ID */
    public static final String COLUMNNAME_M_Product_ID = "M_Product_ID";

    /** Set Product.
      * Product, Service, Item
      */
    public void setM_Product_ID (int M_Product_ID);

    /** Get Product.
      * Product, Service, Item
      */
    public int getM_Product_ID();

    public org.compiere.model.I_M_Product getM_Product() throws RuntimeException;

    /** Column name PriceActual */
    public static final String COLUMNNAME_PriceActual = "PriceActual";

    /** Set Unit Price.
      * Actual Price
      */
    public void setPriceActual (BigDecimal PriceActual);

    /** Get Unit Price.
      * Actual Price
      */
    public BigDecimal getPriceActual();

    /** Column name PriceCost */
    public static final String COLUMNNAME_PriceCost = "PriceCost";

    /** Set Cost Price.
      * Price per Unit of Measure including all indirect costs (Freight, etc.)
      */
    public void setPriceCost (BigDecimal PriceCost);

    /** Get Cost Price.
      * Price per Unit of Measure including all indirect costs (Freight, etc.)
      */
    public BigDecimal getPriceCost();

    /** Column name Processed */
    public static final String COLUMNNAME_Processed = "Processed";

    /** Set Processed.
      * The document has been processed
      */
    public void setProcessed (boolean Processed);

    /** Get Processed.
      * The document has been processed
      */
    public boolean isProcessed();

    /** Column name ReversalLine_ID */
    public static final String COLUMNNAME_ReversalLine_ID = "ReversalLine_ID";

    /** Set Reversal Line.
      * Use to keep the reversal line ID for reversing costing purpose
      */
    public void setReversalLine_ID (int ReversalLine_ID);

    /** Get Reversal Line.
      * Use to keep the reversal line ID for reversing costing purpose
      */
    public int getReversalLine_ID();

    public org.compiere.model.I_M_MovementLine getReversalLine() throws RuntimeException;

    /** Column name ScrappedQty */
    public static final String COLUMNNAME_ScrappedQty = "ScrappedQty";

    /** Set Scrapped Quantity.
      * The Quantity scrapped due to QA issues
      */
    public void setScrappedQty (BigDecimal ScrappedQty);

    /** Get Scrapped Quantity.
      * The Quantity scrapped due to QA issues
      */
    public BigDecimal getScrappedQty();

    /** Column name TargetQty */
    public static final String COLUMNNAME_TargetQty = "TargetQty";

    /** Set Target Quantity.
      * Target Movement Quantity
      */
    public void setTargetQty (BigDecimal TargetQty);

    /** Get Target Quantity.
      * Target Movement Quantity
      */
    public BigDecimal getTargetQty();

    /** Column name TaxAmt */
    public static final String COLUMNNAME_TaxAmt = "TaxAmt";

    /** Set Tax Amount.
      * Tax Amount for a document
      */
    public void setTaxAmt (BigDecimal TaxAmt);

    /** Get Tax Amount.
      * Tax Amount for a document
      */
    public BigDecimal getTaxAmt();

    /** Column name Updated */
    public static final String COLUMNNAME_Updated = "Updated";

    /** Get Updated.
      * Date this record was updated
      */
    public Timestamp getUpdated();

    /** Column name UpdatedBy */
    public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";

    /** Get Updated By.
      * User who updated this records
      */
    public int getUpdatedBy();

    /** Column name Value */
    public static final String COLUMNNAME_Value = "Value";

    /** Set Search Key.
      * Search key for the record in the format required - must be unique
      */
    public void setValue (String Value);

    /** Get Search Key.
      * Search key for the record in the format required - must be unique
      */
    public String getValue();
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





}


CAT_I_M_Movement.java
CAT_I_M_MovementLine.java
CAT_MMovement.java
CAT_MMovementLine.java
CAT_StandardTaxProvider.java
CattleyaModelFactory.java
X_M_MovementTax.java
CAT_ITaxProvider.java
CAT_ITaxProviderFactory.java

Dwi Rahman Ismail

unread,
Mar 14, 2018, 5:50:50 AM3/14/18
to iDempiere
Hi,


when i make new modification for create lines from i got the error like this and i am solving with override the method i want to use,

regards
    public static final String COLUMNNAME_M_LocatorTo_ID = "M_LocatorTo_ID...

shiju01

unread,
Mar 14, 2018, 6:39:29 AM3/14/18
to iDempiere

Thanks .. will check that ... but i think this is little more complex than that am using POWrapper technic to extend the Inventory Move to generate Tax from Movement Lines

While debug i found the error is triggered from line .firtOnly in MMoventTax


  retValue = new Query(line.getCtx(), Table_Name, "M_Movement_ID=? AND C_Tax_ID=?", trxName)
                        .setParameters(line.getM_Movement_ID(), C_Tax_ID)
                        .firstOnly();


The error might be triggered either from one of the  foreign keys M_Movement_ID or TaxProvider_ID in MMovementTax table

MMovement ans MMovementLine has a POWrapper

TaxProvider is separately re-implemented inside the model class only for the Movement and MovementLine  
...
Reply all
Reply to author
Forward
0 new messages