Class MInOut

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_M_InOut, I_Persistent, DocAction, IDocsPostProcess, Evaluatee

public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
Shipment/Receipt Model
Version:
$Id: MInOut.java,v 1.4 2006/07/30 00:51:03 jjanke Exp $ Modifications: Added the RMA functionality (Ashley Ramdass)
Author:
Jorg Janke, Karsten Thiemann, Schaeffer AG
  • Bug [ 1759431 ] Problems with VCreateFrom, victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
  • FR [ 1948157 ] Is necessary the reference for document reverse
  • FR [ 2520591 ] Support multiples calendar for Org, Armen Rizal, Goodwill Consulting
  • BF [ 1745154 ] Cost in Reversing Material Related Docs, Teo Sarca, teo.sarca@gmail.com
  • BF [ 2993853 ] Voiding/Reversing Receipt should void confirmations https://sourceforge.net/p/adempiere/bugs/2395/
  • See Also:
    • Field Details

      • NOT_FULLY_MATCHED_TO_ORDER

        public static final String NOT_FULLY_MATCHED_TO_ORDER
      • NOT_FULLY_MATCHED_TO_ORDER_GROUP_BY

        public static final String NOT_FULLY_MATCHED_TO_ORDER_GROUP_BY
      • FULL_OR_PARTIALLY_MATCHED_TO_ORDER

        public static final String FULL_OR_PARTIALLY_MATCHED_TO_ORDER
      • FULL_OR_PARTIALLY_MATCHED_TO_ORDER_GROUP_BY

        public static final String FULL_OR_PARTIALLY_MATCHED_TO_ORDER_GROUP_BY
      • NOT_FULLY_MATCHED_TO_INVOICE

        public static final String NOT_FULLY_MATCHED_TO_INVOICE
      • NOT_FULLY_MATCHED_TO_INVOICE_GROUP_BY

        public static final String NOT_FULLY_MATCHED_TO_INVOICE_GROUP_BY
      • FULL_OR_PARTIALLY_MATCHED_TO_INVOICE

        public static final String FULL_OR_PARTIALLY_MATCHED_TO_INVOICE
      • FULL_OR_PARTIALLY_MATCHED_TO_INVOICE_GROUP_BY

        public static final String FULL_OR_PARTIALLY_MATCHED_TO_INVOICE_GROUP_BY
      • m_lines

        protected MInOutLine[] m_lines
        Lines
      • m_confirms

        protected MInOutConfirm[] m_confirms
        Confirmations
      • m_partner

        protected MBPartner m_partner
        BPartner
      • m_reversal

        protected boolean m_reversal
        Reversal Flag
      • m_processMsg

        protected String m_processMsg
        Process Message
      • m_justPrepared

        protected boolean m_justPrepared
        Just Prepared Flag
      • docsPostProcess

        protected ArrayList<PO> docsPostProcess
    • Constructor Details

      • MInOut

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

        public MInOut(Properties ctx, int M_InOut_ID, String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        M_InOut_ID -
        trxName - trx name
      • MInOut

        public MInOut(Properties ctx, int M_InOut_ID, String trxName, String... virtualColumns)
        Parameters:
        ctx -
        M_InOut_ID -
        trxName -
        virtualColumns -
      • MInOut

        public MInOut(Properties ctx, ResultSet rs, String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set record
        trxName - transaction
      • MInOut

        public MInOut(MOrder order, int C_DocTypeShipment_ID, Timestamp movementDate)
        Order Constructor - create header only
        Parameters:
        order - order
        movementDate - optional movement date (default today)
        C_DocTypeShipment_ID - document type or 0
      • MInOut

        public MInOut(MInvoice invoice, int C_DocTypeShipment_ID, Timestamp movementDate, int M_Warehouse_ID)
        Invoice Constructor - create header only
        Parameters:
        invoice - invoice
        C_DocTypeShipment_ID - document type or 0
        movementDate - optional movement date (default today)
        M_Warehouse_ID - warehouse
      • MInOut

        public MInOut(MInOut original, int C_DocTypeShipment_ID, Timestamp movementDate)
        Copy Constructor - create header only
        Parameters:
        original - original
        movementDate - optional movement date (default today)
        C_DocTypeShipment_ID - document type or 0
    • Method Details

      • getNotFullyMatchedToOrder

        public static List<MInOut.MatchingRecord> getNotFullyMatchedToOrder(int C_BPartner_ID, int M_Product_ID, int C_OrderLine_ID, Timestamp from, Timestamp to, String trxName)
        Parameters:
        C_BPartner_ID -
        M_Product_ID -
        C_OrderLine_ID -
        from -
        to -
        trxName -
        Returns:
        list of material receipts not fully matched to order
      • getFullOrPartiallyMatchedToOrder

        public static List<MInOut.MatchingRecord> getFullOrPartiallyMatchedToOrder(int C_BPartner_ID, int M_Product_ID, int C_OrderLine_ID, Timestamp from, Timestamp to, String trxName)
        Parameters:
        C_BPartner_ID -
        M_Product_ID -
        C_OrderLine_ID -
        from -
        to -
        trxName -
        Returns:
        list of material receipts full or partially match to order
      • getNotFullyMatchedToInvoice

        public static List<MInOut.MatchingRecord> getNotFullyMatchedToInvoice(int C_BPartner_ID, int M_Product_ID, int C_InvoiceLine_ID, Timestamp from, Timestamp to, String trxName)
        Parameters:
        C_BPartner_ID -
        M_Product_ID -
        C_InvoiceLine_ID -
        from -
        to -
        trxName -
        Returns:
        list of material receipts not fully match to invoice
      • getFullOrPartiallyMatchedToInvoice

        public static List<MInOut.MatchingRecord> getFullOrPartiallyMatchedToInvoice(int C_BPartner_ID, int M_Product_ID, int C_InvoiceLine_ID, Timestamp from, Timestamp to, String trxName)
        Parameters:
        C_BPartner_ID -
        M_Product_ID -
        C_InvoiceLine_ID -
        from -
        to -
        trxName -
        Returns:
        list of material receipts full or partially match to invoice
      • createFrom

        public static MInOut createFrom(MOrder order, Timestamp movementDate, boolean forceDelivery, boolean allAttributeInstances, Timestamp minGuaranteeDate, boolean complete, String trxName)
        Create Shipment From Order
        Parameters:
        order - order
        movementDate - optional movement date
        forceDelivery - ignore order delivery rule
        allAttributeInstances - if true, all attribute set instances
        minGuaranteeDate - optional minimum guarantee date if all attribute instances
        complete - complete document (Process if false, Complete if true)
        trxName - transaction
        Returns:
        Shipment or null
      • copyFrom

        public static MInOut copyFrom(MInOut from, Timestamp dateDoc, Timestamp dateAcct, int C_DocType_ID, boolean isSOTrx, boolean counter, String trxName, boolean setOrder)
        Create new Shipment by copying
        Parameters:
        from - shipment
        dateDoc - date of the document date
        C_DocType_ID - doc type
        isSOTrx - sales order
        counter - create counter links
        trxName - trx
        setOrder - set the order link
        Returns:
        Shipment
      • copyFrom

        @Deprecated public static MInOut copyFrom(MInOut from, Timestamp dateDoc, int C_DocType_ID, boolean isSOTrx, boolean counter, String trxName, boolean setOrder)
        Deprecated.
        Create new Shipment by copying
        Parameters:
        from - shipment
        dateDoc - date of the document date
        C_DocType_ID - doc type
        isSOTrx - sales order
        counter - create counter links
        trxName - trx
        setOrder - set the order link
        Returns:
        Shipment
      • getDocStatusName

        public String getDocStatusName()
        Get Document Status Name
        Returns:
        Document Status Name
      • addDescription

        public void addDescription(String description)
        Add to Description
        Parameters:
        description - text
      • toString

        public String toString()
        String representation
        Overrides:
        toString in class X_M_InOut
        Returns:
        info
      • getDocumentInfo

        public String getDocumentInfo()
        Get Document Info
        Specified by:
        getDocumentInfo in interface DocAction
        Returns:
        document info (not translated)
      • createPDF

        public File createPDF()
        Create PDF
        Specified by:
        createPDF in interface DocAction
        Returns:
        File or null
      • createPDF

        public File createPDF(File file)
        Create PDF file
        Parameters:
        file - output file
        Returns:
        file if success
      • getLines

        public MInOutLine[] getLines(boolean requery)
        Get Lines of Shipment
        Parameters:
        requery - refresh from db
        Returns:
        lines
      • getLines

        public MInOutLine[] getLines()
        Get Lines of Shipment
        Returns:
        lines
      • getConfirmations

        public MInOutConfirm[] getConfirmations(boolean requery)
        Get Confirmations
        Parameters:
        requery - true to requery from DB
        Returns:
        array of Confirmations
      • copyLinesFrom

        public int copyLinesFrom(MInOut otherShipment, boolean counter, boolean setOrder)
        Copy Lines From other Shipment
        Parameters:
        otherShipment - shipment
        counter - set counter info
        setOrder - set order link
        Returns:
        number of lines copied
      • setReversal

        protected void setReversal(boolean reversal)
        Set reversal state (instance variable)
        Parameters:
        reversal - reversal
      • isReversal

        public boolean isReversal()
        Is Reversal
        Returns:
        true reversal state is set to true
      • setProcessed

        public void setProcessed(boolean processed)
        Set Processed. Propagate to Lines/Taxes
        Specified by:
        setProcessed in interface I_M_InOut
        Overrides:
        setProcessed in class X_M_InOut
        Parameters:
        processed - processed
      • getBPartner

        public MBPartner getBPartner()
        Get BPartner
        Returns:
        business partner
      • setC_DocType_ID

        public void setC_DocType_ID(String DocBaseType)
        Set Document Type
        Parameters:
        DocBaseType - MDocType.DOCBASETYPE_*
      • setC_DocType_ID

        public void setC_DocType_ID()
        Set Default C_DocType_ID. Based on IsSOTrx flag.
      • setBPartner

        public void setBPartner(MBPartner bp)
        Set Business Partner Defaults and Details
        Parameters:
        bp - business partner
      • createConfirmation

        public void createConfirmation()
        Create the missing next Confirmation
      • voidConfirmations

        protected void voidConfirmations()
        Void confirmations
      • setM_Warehouse_ID

        public void setM_Warehouse_ID(int M_Warehouse_ID)
        Set Warehouse and check/set Organization
        Specified by:
        setM_Warehouse_ID in interface I_M_InOut
        Overrides:
        setM_Warehouse_ID in class X_M_InOut
        Parameters:
        M_Warehouse_ID - id
      • getMovementType

        public static String getMovementType(Properties ctx, int C_DocType_ID, boolean issotrx, String trxName)
        Get Movement Type based on Document Type's DocBaseType and isSOTrx
        Parameters:
        ctx -
        C_DocType_ID - Document Type ID
        issotrx - is sales transaction
        trxName - transaction name
        Returns:
        Movement Type (MOVEMENTTYPE_*)
      • setMovementType

        public void setMovementType()
        Sets Movement Type based on Document Type's DocBaseType and isSOTrx
      • 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
      • afterSave

        protected boolean afterSave(boolean newRecord, boolean success)
        Description copied from class: PO
        Called after Save for Post-Save Operation.
        Default implementation is nop, to be implemented in sub-classes that needed it.
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - true if it is a new record
        success - true if save operation was success
        Returns:
        if save was a success
      • processIt

        public boolean processIt(String processAction)
        Process document
        Specified by:
        processIt in interface DocAction
        Parameters:
        processAction - document action
        Returns:
        true if performed
      • unlockIt

        public boolean unlockIt()
        Unlock Document.
        Specified by:
        unlockIt in interface DocAction
        Returns:
        true if success
      • invalidateIt

        public boolean invalidateIt()
        Invalidate Document
        Specified by:
        invalidateIt in interface DocAction
        Returns:
        true if success
      • prepareIt

        public String prepareIt()
        Prepare Document
        Specified by:
        prepareIt in interface DocAction
        Returns:
        new status (In Progress or Invalid)
      • isCustomerReturn

        public boolean isCustomerReturn()
        Check if Document is Customer Return.
        Returns:
        True if Document is Customer Return
      • approveIt

        public boolean approveIt()
        Approve Document
        Specified by:
        approveIt in interface DocAction
        Returns:
        true if success
      • rejectIt

        public boolean rejectIt()
        Reject Approval
        Specified by:
        rejectIt in interface DocAction
        Returns:
        true if success
      • completeIt

        public String completeIt()
        Complete Document
        Specified by:
        completeIt in interface DocAction
        Returns:
        new status (Complete, In Progress, Invalid, Waiting ..)
      • pendingCustomerConfirmations

        public boolean pendingCustomerConfirmations()
        Outstanding (not processed) Customer Confirmations ?
        Returns:
        true if there are pending Customer Confirmations (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation)
      • pendingConfirmations

        public boolean pendingConfirmations()
        Outstanding (not processed) Confirmations ?
        Returns:
        true if there are pending Confirmations
      • addDocsPostProcess

        protected void addDocsPostProcess(PO doc)
        Add doc for post processing (after processing of document action)
        Parameters:
        doc -
      • getDocsPostProcess

        public List<PO> getDocsPostProcess()
        Description copied from interface: IDocsPostProcess
        Get documents to process after Complete or after Posting
        Specified by:
        getDocsPostProcess in interface IDocsPostProcess
        Returns:
        List of doc to process after Complete or after Posting
      • createDropShipment

        protected MInOut createDropShipment()
        Automatically creates a customer shipment for any drop shipment material receipt. Based on createCounterDoc() by JJ.
        Returns:
        shipment if created else null
      • setDefiniteDocumentNo

        protected void setDefiniteDocumentNo()
        Set the definite document number after completed
      • checkMaterialPolicy

        protected void checkMaterialPolicy(MInOutLine line, BigDecimal qty)
        Check Material Policy. Create MInOutLineMA and set line ASI (if needed).
        Parameters:
        line -
        qty -
      • autoBalanceNegative

        protected BigDecimal autoBalanceNegative(MInOutLine line, MProduct product, BigDecimal qtyToReceive)
      • createCounterDoc

        protected MInOut createCounterDoc()
        Create Counter Document
        Returns:
        InOut
      • voidIt

        public boolean voidIt()
        Void Document.
        Specified by:
        voidIt in interface DocAction
        Returns:
        true if success
      • closeIt

        public boolean closeIt()
        Close Document.
        Specified by:
        closeIt in interface DocAction
        Returns:
        true if success
      • reverseCorrectIt

        public boolean reverseCorrectIt()
        Reverse Correction - same date
        Specified by:
        reverseCorrectIt in interface DocAction
        Returns:
        true if success
      • reverse

        protected MInOut reverse(boolean accrual)
        Reverse this document
        Parameters:
        accrual - true to create reversal document using current date, false to use the accounting date of this document
        Returns:
        reversal MInOut
      • reverseMatching

        protected boolean reverseMatching(Timestamp reversalDate)
        Reverse match invoice and match PO.
        Parameters:
        reversalDate -
        Returns:
        false if there errors, true otherwise
      • reverseAccrualIt

        public boolean reverseAccrualIt()
        Reverse Accrual - current date
        Specified by:
        reverseAccrualIt in interface DocAction
        Returns:
        false
      • reActivateIt

        public boolean reActivateIt()
        Re-activate
        Specified by:
        reActivateIt in interface DocAction
        Returns:
        false
      • getSummary

        public String getSummary()
        Get Summary
        Specified by:
        getSummary in interface DocAction
        Returns:
        Summary of Document
      • getProcessMsg

        public String getProcessMsg()
        Get Process Message
        Specified by:
        getProcessMsg in interface DocAction
        Returns:
        clear text error message
      • getDoc_User_ID

        public int getDoc_User_ID()
        Get Document Owner (Responsible)
        Specified by:
        getDoc_User_ID in interface DocAction
        Returns:
        AD_User_ID
      • getApprovalAmt

        public BigDecimal getApprovalAmt()
        Get Document Approval Amount
        Specified by:
        getApprovalAmt in interface DocAction
        Returns:
        0
      • getC_Currency_ID

        public int getC_Currency_ID()
        Get C_Currency_ID
        Specified by:
        getC_Currency_ID in interface DocAction
        Returns:
        Accounting Currency
      • isComplete

        public boolean isComplete()
        Document Status is Complete or Closed
        Returns:
        true if CO, CL or RE
      • moveOnHandToShipmentASI

        protected String moveOnHandToShipmentASI(MProduct product, int M_Locator_ID, int M_AttributeSetInstance_ID, BigDecimal qty, Timestamp dateMaterialPolicy, int M_InOutLine_ID, boolean reversal, String trxName)
        For product with mix of No ASI and ASI inventory, this move Non ASI on hand to the new ASI created at shipment line or shipment line ma
        Parameters:
        product -
        M_Locator_ID - shipment line locator id
        M_AttributeSetInstance_ID -
        qty -
        dateMaterialPolicy -
        M_InOutLine_ID -
        reversal -
        trxName -
        Returns:
        error doc status if there are any errors, null otherwise
      • createLineFrom

        public void createLineFrom(int C_OrderLine_ID, int C_InvoiceLine_ID, int M_RMALine_ID, int M_Product_ID, int C_UOM_ID, BigDecimal Qty, int M_Locator_ID)
        Create Line from orderline/invoiceline/rmaline
        Parameters:
        C_OrderLine_ID -
        C_InvoiceLine_ID -
        M_RMALine_ID -
        M_Product_ID -
        C_UOM_ID -
        Qty -
        M_Locator_ID -
      • updateFrom

        public void updateFrom(MOrder order, MInvoice invoice, MRMA rma)
        Update from order/invoice/rma
        • if linked to another order/invoice/rma - remove link
        • if no link set it
        Parameters:
        order -
        invoice -
        rma -