Class MOrder

  • All Implemented Interfaces:
    Serializable, Cloneable, Comparator<Object>, I_C_Order, I_Persistent, DocAction, Evaluatee

    public class MOrder
    extends X_C_Order
    implements DocAction
    Order Model. Please do not set DocStatus and C_DocType_ID directly. They are set in the process() method. Use DocAction and C_DocTypeTarget_ID instead.
    Version:
    $Id: MOrder.java,v 1.5 2006/10/06 00:42:24 jjanke Exp $
    Author:
    Jorg Janke, victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
  • FR [ 2520591 ] Support multiples calendar for Org, Teo Sarca, www.arhipac.ro
  • BF [ 2419978 ] Voiding PO, requisition don't set on NULL
  • BF [ 2892578 ] Order should autoset only active price lists https://sourceforge.net/p/adempiere/feature-requests/873/, Michael Judd, www.akunagroup.com
  • BF [ 2804888 ] Incorrect reservation of products with attributes
  • See Also:
    Serialized Form
    • Field Detail

      • m_lines

        protected MOrderLine[] m_lines
        Order Lines
      • m_taxes

        protected MOrderTax[] m_taxes
        Tax Lines
      • m_forceCreation

        protected boolean m_forceCreation
        Force Creation of order
      • m_processMsg

        protected String m_processMsg
        Process Message
      • m_justPrepared

        protected boolean m_justPrepared
        Just Prepared Flag
    • Constructor Detail

      • MOrder

        public MOrder​(Properties ctx,
                      int C_Order_ID,
                      String trxName)
        Default Constructor
        Parameters:
        ctx - context
        C_Order_ID - order to load, (0 create new order)
        trxName - trx name
      • MOrder

        public MOrder​(MProject project,
                      boolean IsSOTrx,
                      String DocSubTypeSO)
        Project Constructor
        Parameters:
        project - Project to create Order from
        IsSOTrx - sales order
        DocSubTypeSO - if SO DocType Target (default DocSubTypeSO_OnCredit)
      • MOrder

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

      • copyFrom

        public static MOrder copyFrom​(MOrder from,
                                      Timestamp dateDoc,
                                      int C_DocTypeTarget_ID,
                                      boolean isSOTrx,
                                      boolean counter,
                                      boolean copyASI,
                                      String trxName)
        Create new Order by copying
        Parameters:
        from - order
        dateDoc - date of the document date
        C_DocTypeTarget_ID - target document type
        isSOTrx - sales order
        counter - create counter links
        copyASI - copy line attributes Attribute Set Instance, Resaouce Assignment
        trxName - trx
        Returns:
        Order
      • setClientOrg

        public void setClientOrg​(int AD_Client_ID,
                                 int AD_Org_ID)
        Overwrite Client/Org if required
        Overrides:
        setClientOrg in class PO
        Parameters:
        AD_Client_ID - client
        AD_Org_ID - org
      • addDescription

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

        public void setAD_User_ID​(int AD_User_ID)
        Set Business Partner Contact (Ship+Bill)
        Specified by:
        setAD_User_ID in interface I_C_Order
        Overrides:
        setAD_User_ID in class X_C_Order
        Parameters:
        AD_User_ID - user
      • setShip_BPartner_ID

        public void setShip_BPartner_ID​(int C_BPartner_ID)
        Set Ship Business Partner
        Parameters:
        C_BPartner_ID - bpartner
      • setShip_Location_ID

        public void setShip_Location_ID​(int C_BPartner_Location_ID)
        Set Ship Business Partner Location
        Parameters:
        C_BPartner_Location_ID - bp location
      • setShip_User_ID

        public void setShip_User_ID​(int AD_User_ID)
        Set Ship Business Partner Contact
        Parameters:
        AD_User_ID - user
      • setC_DocTypeTarget_ID

        public void setC_DocTypeTarget_ID​(String DocSubTypeSO_x)
        Set Target Sales Document Type
        Parameters:
        DocSubTypeSO_x - SO sub type - see DocSubTypeSO_*
      • setC_DocTypeTarget_ID

        public void setC_DocTypeTarget_ID()
        Set Target Document Type. Standard Order or PO
      • setBPartner

        public void setBPartner​(MBPartner bp)
        Set Business Partner Defaults and Details. SOTrx should be set.
        Parameters:
        bp - business partner
      • copyLinesFrom

        public int copyLinesFrom​(MOrder otherOrder,
                                 boolean counter,
                                 boolean copyASI)
        Copy Lines From other Order
        Parameters:
        otherOrder - order
        counter - set counter info
        copyASI - copy line attributes Attribute Set Instance, Resaouce Assignment
        Returns:
        number of lines copied
      • getDocumentInfo

        public String getDocumentInfo()
        Get Document Info
        Specified by:
        getDocumentInfo in interface DocAction
        Returns:
        document info (untranslated)
      • 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
      • setM_PriceList_ID

        public void setM_PriceList_ID​(int M_PriceList_ID)
        Set Price List (and Currency, TaxIncluded) when valid
        Specified by:
        setM_PriceList_ID in interface I_C_Order
        Overrides:
        setM_PriceList_ID in class X_C_Order
        Parameters:
        M_PriceList_ID - price list
      • getLines

        public MOrderLine[] getLines​(String whereClause,
                                     String orderClause)
        Get Lines of Order
        Parameters:
        whereClause - where clause or null (starting with AND)
        orderClause - order clause
        Returns:
        lines
      • getLines

        public MOrderLine[] getLines​(boolean requery,
                                     String orderBy)
        Get Lines of Order
        Parameters:
        requery - requery
        orderBy - optional order by column
        Returns:
        lines
      • getLines

        public MOrderLine[] getLines()
        Get Lines of Order. (used by web store)
        Returns:
        lines
      • renumberLines

        public void renumberLines​(int step)
        Renumber Lines
        Parameters:
        step - start and step
      • isOrderLine

        public boolean isOrderLine​(int C_OrderLine_ID)
        Does the Order Line belong to this Order
        Parameters:
        C_OrderLine_ID - line
        Returns:
        true if part of the order
      • getTaxes

        public MOrderTax[] getTaxes​(boolean requery)
        Get Taxes of Order
        Parameters:
        requery - requery
        Returns:
        array of taxes
      • getInvoices

        public MInvoice[] getInvoices()
        Get Invoices of Order
        Returns:
        invoices
      • getC_Invoice_ID

        public int getC_Invoice_ID()
        Get latest Invoice of Order
        Returns:
        invoice id or 0
      • getShipments

        public MInOut[] getShipments()
        Get Shipments of Order
        Returns:
        shipments
      • getCurrencyISO

        public String getCurrencyISO()
        Get ISO Code of Currency
        Returns:
        Currency ISO
      • getPrecision

        public int getPrecision()
        Get Currency Precision
        Returns:
        precision
      • getDocStatusName

        public String getDocStatusName()
        Get Document Status
        Returns:
        Document Status Clear Text
      • setDocAction

        public void setDocAction​(String DocAction,
                                 boolean forceCreation)
        Set DocAction
        Parameters:
        DocAction - doc action
        forceCreation - force creation
      • setProcessed

        public void setProcessed​(boolean processed)
        Set Processed. Propagate to Lines/Taxes
        Specified by:
        setProcessed in interface I_C_Order
        Overrides:
        setProcessed in class X_C_Order
        Parameters:
        processed - processed
      • validatePaySchedule

        public boolean validatePaySchedule()
        Validate Order Pay Schedule
        Returns:
        pay schedule is valid
      • beforeSave

        protected boolean beforeSave​(boolean newRecord)
        Before Save
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - new
        Returns:
        save
      • afterSave

        protected boolean afterSave​(boolean newRecord,
                                    boolean success)
        After Save
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new
        success - success
        Returns:
        true if can be saved
      • beforeDelete

        protected boolean beforeDelete()
        Before Delete
        Overrides:
        beforeDelete in class PO
        Returns:
        true of it can be deleted
      • 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)
      • calculateFreightCharge

        protected boolean calculateFreightCharge()
      • explodeBOM

        protected boolean explodeBOM()
        Explode non stocked BOM.
        Returns:
        true if bom exploded
      • reserveStock

        protected boolean reserveStock​(MDocType dt,
                                       MOrderLine[] lines)
        Reserve Inventory. Counterpart: MInOut.completeIt()
        Parameters:
        dt - document type or null
        lines - order lines (ordered by M_Product_ID for deadlock prevention)
        Returns:
        true if (un) reserved
      • calculateTaxTotal

        public boolean calculateTaxTotal()
        Calculate Tax and Total
        Returns:
        true if tax total calculated
      • createPaySchedule

        protected boolean createPaySchedule()
        (Re) Create Pay Schedule
        Returns:
        true if valid schedule
      • 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 ..)
      • landedCostAllocation

        protected String landedCostAllocation()
      • createPOSPayments

        protected String createPOSPayments()
      • setDefiniteDocumentNo

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

        protected MInOut createShipment​(MDocType dt,
                                        Timestamp movementDate)
        Create Shipment
        Parameters:
        dt - order document type
        movementDate - optional movement date (default today)
        Returns:
        shipment or null
      • createInvoice

        protected MInvoice createInvoice​(MDocType dt,
                                         MInOut shipment,
                                         Timestamp invoiceDate)
        Create Invoice
        Parameters:
        dt - order document type
        shipment - optional shipment
        invoiceDate - invoice date
        Returns:
        invoice or null
      • createCounterDoc

        protected MOrder createCounterDoc()
        Create Counter Document
        Returns:
        counter order
      • voidIt

        public boolean voidIt()
        Void Document. Set Qtys to 0 - Sales: reverse all documents
        Specified by:
        voidIt in interface DocAction
        Returns:
        true if success
      • createReversals

        protected boolean createReversals()
        Create Shipment/Invoice Reversals
        Returns:
        true if success
      • closeIt

        public boolean closeIt()
        Close Document. Cancel not delivered Quantities
        Specified by:
        closeIt in interface DocAction
        Returns:
        true if success
      • reopenIt

        public String reopenIt()
      • reverseCorrectIt

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

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

        public boolean reActivateIt()
        Re-activate.
        Specified by:
        reActivateIt in interface DocAction
        Returns:
        true if success
      • 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
      • deleteMatchPOCostDetail

        protected String deleteMatchPOCostDetail​(MOrderLine line)
      • isComplete

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

        public void setProcessMessage​(String processMsg)
        Set process message
        Parameters:
        processMsg -
      • getTaxProviders

        public MTaxProvider[] getTaxProviders()
        Get tax providers
        Returns:
        array of tax provider
      • getDocTypeID

        public int getDocTypeID()
        Returns C_DocType_ID (or C_DocTypeTarget_ID if C_DocType_ID is not set)
      • getPaymentAmt

        public BigDecimal getPaymentAmt()
        Returns:
        payment amount for order (prepayment + invoice payment)