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:
    Serialized Form
    • Constructor Detail

      • 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

        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)
        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 - amt
        Qty - qty
        Description - optional description
        trxName - transaction
    • Method Detail

      • 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,
                                          String trxName)
        Create New Order Cost Detail 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
      • 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,
                                            String trxName)
        Create New Invoice Cost Detail 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
      • 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,
                                             String trxName)
        Create New Shipment Cost Detail 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
      • 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,
                                              String trxName)
        Create New Order Cost Detail 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
      • 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,
                                             String trxName)
        Create New Order Cost Detail for 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
      • 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,
                                               String trxName)
        Create New Order Cost Detail 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
      • 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,
                                                 String trxName)
        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
      • 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,
                                                 String trxName)
        Create Cost Detail for Project Issue. 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
      • get

        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
        ID - 1st parameter
        M_AttributeSetInstance_ID - ASI
        trxName - trx
        Returns:
        cost detail
      • processProduct

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

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

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

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

        public boolean isVendorRMA()
        Returns:
        true if return to vendor
      • isDelta

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

        protected boolean beforeDelete()
        Before Delete
        Overrides:
        beforeDelete in class PO
        Returns:
        false if processed
      • 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 for cost 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