Class MCostDetail

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_M_CostDetail, I_Persistent, Evaluatee

public class MCostDetail extends X_M_CostDetail
Cost Detail Model
Version:
$Id: MCostDetail.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
Author:
Jorg Janke, Armen Rizal, Goodwill Consulting
  • BF: 2431123 Return Trx changes weighted average cost
  • BF: 1568752 Average invoice costing: landed costs incorrectly applied, Armen Rizal and Bayu Cahya
  • BF [ 2129781 ] Cost Detail not created properly for multi acc schema, Teo Sarca
  • BF [ 2847648 ] Manufacture and shipment cost errors https://sourceforge.net/p/adempiere/libero/237/, red1 FR: [ 2214883 ] Remove SQL code and Replace for Query
  • See Also:
    • Field Details

    • Constructor Details

      • MCostDetail

        public MCostDetail(Properties ctx, String M_CostDetail_UU, String trxName)
        UUID based Constructor
        Parameters:
        ctx - Context
        M_CostDetail_UU - UUID key
        trxName - Transaction
      • MCostDetail

        public MCostDetail(Properties ctx, int M_CostDetail_ID, String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        M_CostDetail_ID - id
        trxName - trx
      • MCostDetail

        public MCostDetail(Properties ctx, ResultSet rs, String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - trx
      • MCostDetail

        @Deprecated public MCostDetail(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_CostElement_ID, BigDecimal amt, BigDecimal qty, String description, String trxName)
        Deprecated.
        New Constructor
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_CostElement_ID - optional cost element for Freight
        amt - Amount
        qty - Quantity
        description - optional description
        trxName - transaction
      • MCostDetail

        public MCostDetail(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_CostElement_ID, BigDecimal amt, BigDecimal qty, String description, Timestamp dateAcct, int Ref_CostDetail_ID, String trxName)
        New Constructor
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_CostElement_ID - optional cost element for Freight
        amt - Amount
        qty - Quantity
        description - optional description
        dateAcct - account date
        Ref_CostDetail_ID - referenced cost detail
        trxName - transaction
    • Method Details

      • createOrder

        @Deprecated public static boolean createOrder(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_OrderLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create New Cost Detail record for Purchase Orders. Called from Doc_MatchPO.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_OrderLine_ID - order
        M_CostElement_ID - optional cost element for Freight
        Amt - amt total amount
        Qty - qty
        Description - optional description
        trxName - transaction
        Returns:
        true if created
      • createOrder

        public static boolean createOrder(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_OrderLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for Purchase Orders. Called from Doc_MatchPO.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_OrderLine_ID - order
        M_CostElement_ID - optional cost element for Freight
        Amt - amt total amount
        Qty - qty
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if created
      • createInvoice

        @Deprecated public static boolean createInvoice(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_InvoiceLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create New Cost Detail record for AP Invoices. Called from Doc_Invoice - for Invoice Adjustments.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_InvoiceLine_ID - invoice
        M_CostElement_ID - optional cost element for Freight
        Amt - amt
        Qty - qty
        Description - optional description
        trxName - transaction
        Returns:
        true if created
      • createInvoice

        public static boolean createInvoice(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_InvoiceLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for AP Invoices. Called from Doc_Invoice - for Invoice Adjustments.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_InvoiceLine_ID - invoice
        M_CostElement_ID - optional cost element for Freight
        Amt - amt
        Qty - qty
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if created
      • createShipment

        @Deprecated public static boolean createShipment(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InOutLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, boolean IsSOTrx, String trxName)
        Deprecated.
        Create New Cost Detail record for SO Shipments. Called from Doc_MInOut - for SO Shipments.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_InOutLine_ID - shipment
        M_CostElement_ID - optional cost element for Freight
        Amt - amt
        Qty - qty
        Description - optional description
        IsSOTrx - sales order
        trxName - transaction
        Returns:
        true if no error
      • createShipment

        public static boolean createShipment(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InOutLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, boolean IsSOTrx, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for SO Shipments. Called from Doc_MInOut - for SO Shipments.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_InOutLine_ID - shipment
        M_CostElement_ID - optional cost element for Freight
        Amt - amt
        Qty - qty
        Description - optional description
        IsSOTrx - sales order
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if no error
      • createInventory

        @Deprecated public static boolean createInventory(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InventoryLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create New Cost Detail record for Physical Inventory. Called from Doc_Inventory.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_InventoryLine_ID - order
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        trxName - transaction
        Returns:
        true if no error
      • createInventory

        public static boolean createInventory(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InventoryLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for Physical Inventory. Called from Doc_Inventory.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_InventoryLine_ID - order
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if no error
      • createMovement

        @Deprecated public static boolean createMovement(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MovementLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, boolean from, String Description, String trxName)
        Deprecated.
        Create New Cost Detail record for Inventory Movements. Called from Doc_Movement.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_MovementLine_ID - movement
        M_CostElement_ID - optional cost element for Freight
        Amt - amt total amount
        Qty - qty
        from - if true the from (reduction)
        Description - optional description
        trxName - transaction
        Returns:
        true if no error
      • createMovement

        public static boolean createMovement(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MovementLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, boolean from, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for Inventory Movements. Called from Doc_Movement.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_MovementLine_ID - movement
        M_CostElement_ID - optional cost element for Freight
        Amt - amt total amount
        Qty - qty
        from - if true the from (reduction)
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if no error
      • createProduction

        @Deprecated public static boolean createProduction(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_ProductionLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create New Cost Detail record for Production. Called from Doc_Production.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_ProductionLine_ID - production line
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        trxName - transaction
        Returns:
        true if no error
      • createProduction

        public static boolean createProduction(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_ProductionLine_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create New Cost Detail record for Production. Called from Doc_Production.
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        M_ProductionLine_ID - production line
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if no error
      • createMatchInvoice

        @Deprecated public static boolean createMatchInvoice(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MatchInv_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create cost detail record for Match Invoice (M_MatchInv).
        Parameters:
        as -
        AD_Org_ID -
        M_Product_ID -
        M_AttributeSetInstance_ID -
        M_MatchInv_ID -
        M_CostElement_ID -
        Amt -
        Qty -
        Description -
        trxName -
        Returns:
        true if no error
      • createMatchInvoice

        public static boolean createMatchInvoice(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MatchInv_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create cost detail record for Match Invoice (M_MatchInv).
        Parameters:
        as -
        AD_Org_ID -
        M_Product_ID -
        M_AttributeSetInstance_ID -
        M_MatchInv_ID -
        M_CostElement_ID -
        Amt -
        Qty -
        Description -
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName -
        Returns:
        true if no error
      • createProjectIssue

        @Deprecated public static boolean createProjectIssue(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_ProjectIssue_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, String trxName)
        Deprecated.
        Create Cost Detail for Project Issue (C_ProjectIssue). Called from Doc_ProjectIssue
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_ProjectIssue_ID - project issue line
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        trxName - transaction
        Returns:
        true if no error
      • createProjectIssue

        public static boolean createProjectIssue(MAcctSchema as, int AD_Org_ID, int M_Product_ID, int M_AttributeSetInstance_ID, int C_ProjectIssue_ID, int M_CostElement_ID, BigDecimal Amt, BigDecimal Qty, String Description, Timestamp DateAcct, int Ref_CostDetail_ID, String trxName)
        Create Cost Detail for Project Issue (C_ProjectIssue). Called from Doc_ProjectIssue
        Parameters:
        as - accounting schema
        AD_Org_ID - org
        M_Product_ID - product
        M_AttributeSetInstance_ID - asi
        C_ProjectIssue_ID - project issue line
        M_CostElement_ID - optional cost element
        Amt - amt total amount
        Qty - qty
        Description - optional description
        DateAcct - account date
        Ref_CostDetail_ID - reference cost detail
        trxName - transaction
        Returns:
        true if no error
      • getOrder

        public static MCostDetail getOrder(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int C_OrderLine_ID, int M_CostElement_ID, Timestamp DateAcct, String trxName)
      • getInvoice

        public static MCostDetail getInvoice(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int C_InvoiceLine_ID, int M_CostElement_ID, Timestamp DateAcct, String trxName)
      • getShipment

        public static MCostDetail getShipment(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InOutLine_ID, int M_CostElement_ID, String trxName)
      • getInventory

        public static MCostDetail getInventory(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_InventoryLine_ID, int M_CostElement_ID, String trxName)
      • getMovement

        public static MCostDetail getMovement(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MovementLine_ID, int M_CostElement_ID, boolean from, String trxName)
      • getProduction

        public static MCostDetail getProduction(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_ProductionLine_ID, String trxName)
      • getProduction

        public static MCostDetail getProduction(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_ProductionLine_ID, int M_CostElement_ID, String trxName)
      • getMatchInvoice

        public static MCostDetail getMatchInvoice(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int M_MatchInv_ID, int M_CostElement_ID, String trxName)
      • getProjectIssue

        public static MCostDetail getProjectIssue(MAcctSchema as, int M_Product_ID, int M_AttributeSetInstance_ID, int C_ProjectIssue_ID, int M_CostElement_ID, String trxName)
      • get

        @Deprecated public static MCostDetail get(Properties ctx, String whereClause, int ID, int M_AttributeSetInstance_ID, String trxName)
        Deprecated.
        Get Cost Detail
        Parameters:
        ctx - context
        whereClause - where clause
        ID - 1st parameter
        M_AttributeSetInstance_ID - ASI
        trxName - trx
        Returns:
        cost detail
      • get

        public static MCostDetail get(Properties ctx, String whereClause, int ID, int M_AttributeSetInstance_ID, int C_AcctSchema_ID, String trxName)
        Get Cost Detail
        Parameters:
        ctx - context
        whereClause - where clause for record id (1st parameter)
        ID - record id (1st parameter)
        M_AttributeSetInstance_ID - ASI (2nd parameter)
        C_AcctSchema_ID - accounting schema (3rd parameter)
        trxName - trx
        Returns:
        cost detail
      • list

        public static List<MCostDetail> list(Properties ctx, String whereClause, int ID, int M_AttributeSetInstance_ID, int C_AcctSchema_ID, String trxName)
        Get Cost Detail Records
        Parameters:
        ctx - context
        whereClause - where clause for record id (1st parameter)
        ID - record id (1st parameter)
        M_AttributeSetInstance_ID - ASI (2nd parameter)
        C_AcctSchema_ID - accounting schema (3rd parameter)
        trxName - trx
        Returns:
        list of cost detail record
      • processProduct

        public static boolean processProduct(MProduct product, String trxName)
        Process Cost Details for product
        Parameters:
        product - product
        trxName - transaction
        Returns:
        true if no error
      • processProduct

        public static boolean processProduct(MAcctSchema as, MProduct product, Timestamp dateAcct, String trxName)
        Process Cost Details for product
        Parameters:
        as - accounting schema
        product - product
        dateAcct - account date
        trxName - transaction
        Returns:
        true if no error
      • setAmt

        public void setAmt(BigDecimal Amt)
        Set Amt
        Specified by:
        setAmt in interface I_M_CostDetail
        Overrides:
        setAmt in class X_M_CostDetail
        Parameters:
        Amt - amt
      • setQty

        public void setQty(BigDecimal Qty)
        Set Qty
        Specified by:
        setQty in interface I_M_CostDetail
        Overrides:
        setQty in class X_M_CostDetail
        Parameters:
        Qty - qty
      • isOrder

        public boolean isOrder()
        Is Order
        Returns:
        true if has order line
      • isInvoice

        public boolean isInvoice()
        Is Invoice
        Returns:
        true if has invoice line
      • isShipment

        public boolean isShipment()
        Is Shipment
        Returns:
        true if has sales order shipment line
      • isVendorRMA

        public boolean isVendorRMA()
        Returns:
        true if shipment line belongs to return to vendor (vendor RMA)
      • isDelta

        public boolean isDelta()
        Is this a Delta Record (previously processed)?
        Returns:
        true if delta is not null
      • beforeSave

        protected boolean beforeSave(boolean newRecord)
        Description copied from class: PO
        Called before Save for Pre-Save Operation.
        Default implementation is nop, to be implemented in sub-classes that needed it.
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - true if it is a new record
        Returns:
        true if record can be saved
      • beforeDelete

        protected boolean beforeDelete()
        Description copied from class: PO
        Execute before Delete operations.
        Default implementation is nop, to be implemented in sub-classes that needed it.
        Overrides:
        beforeDelete in class PO
        Returns:
        true if record can be deleted
      • toString

        public String toString()
        String Representation
        Overrides:
        toString in class X_M_CostDetail
        Returns:
        info
      • process

        public boolean process()
        Process Cost Detail Record. The record is saved if processed.
        Returns:
        true if processed
      • process

        protected boolean process(MAcctSchema as, MProduct product, MCostElement ce, int Org_ID, int M_ASI_ID)
        Process cost detail record
        Parameters:
        as - accounting schema
        product - product
        ce - cost element
        Org_ID - org - corrected for costing level
        M_ASI_ID - - asi corrected for costing level
        Returns:
        true if cost ok
      • periodClosedCheckForDocsAfterBackDateTrx

        public static void periodClosedCheckForDocsAfterBackDateTrx(int AD_Client_ID, int C_AcctSchema_ID, int M_Product_ID, int M_CostDetail_ID, Timestamp DateAcct, String trxName)
        Period Closed Check for Documents after the Back-Date Transaction
        Parameters:
        AD_Client_ID - Client of the back-date transaction
        C_AcctSchema_ID - Accounting schema of the back-date transaction
        M_Product_ID - Product of the back-date transaction
        M_CostDetail_ID - Cost detail of the back-date transaction
        DateAcct - Account date of the back-date transaction
        trxName - Transaction name
      • getDateAcct

        public static Timestamp getDateAcct(int tableID, int recordID, String trxName)
        Get Account Date
        Parameters:
        tableID - Transaction table
        recordID - Record ID of this document
        trxName - Transaction name
        Returns:
        accounting date