Class MInvoice

    • Constructor Detail

      • MInvoice

        public MInvoice​(Properties ctx,
                        int C_Invoice_ID,
                        String trxName)
        Invoice Constructor
        Parameters:
        ctx - context
        C_Invoice_ID - invoice or 0 for new
        trxName - trx name
      • MInvoice

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

        public MInvoice​(MOrder order,
                        int C_DocTypeTarget_ID,
                        Timestamp invoiceDate)
        Create Invoice from Order
        Parameters:
        order - order
        C_DocTypeTarget_ID - target document type
        invoiceDate - date or null
      • MInvoice

        public MInvoice​(MInOut ship,
                        Timestamp invoiceDate)
        Create Invoice from Shipment
        Parameters:
        ship - shipment
        invoiceDate - date or null
      • MInvoice

        public MInvoice​(MInvoiceBatch batch,
                        MInvoiceBatchLine line)
        Create Invoice from Batch Line
        Parameters:
        batch - batch
        line - batch line
      • MInvoice

        public MInvoice​(MInvoice copy)
        Parameters:
        copy -
    • Method Detail

      • getOfBPartner

        public static MInvoice[] getOfBPartner​(Properties ctx,
                                               int C_BPartner_ID,
                                               String trxName)
        Get Payments Of BPartner
        Parameters:
        ctx - context
        C_BPartner_ID - id
        trxName - transaction
        Returns:
        array
      • copyFrom

        public static MInvoice copyFrom​(MInvoice from,
                                        Timestamp dateDoc,
                                        Timestamp dateAcct,
                                        int C_DocTypeTarget_ID,
                                        boolean isSOTrx,
                                        boolean counter,
                                        String trxName,
                                        boolean setOrder)
        Create new Invoice by copying
        Parameters:
        from - invoice
        dateDoc - date of the document date
        dateAcct - original account date
        C_DocTypeTarget_ID - target doc type
        isSOTrx - sales order
        counter - create counter links
        trxName - trx
        setOrder - set Order links
        Returns:
        Invoice
      • copyFrom

        public static MInvoice copyFrom​(MInvoice from,
                                        Timestamp dateDoc,
                                        Timestamp dateAcct,
                                        int C_DocTypeTarget_ID,
                                        boolean isSOTrx,
                                        boolean counter,
                                        String trxName,
                                        boolean setOrder,
                                        String documentNo)
        Create new Invoice by copying
        Parameters:
        from - invoice
        dateDoc - date of the document date
        dateAcct - original account date
        C_DocTypeTarget_ID - target doc type
        isSOTrx - sales order
        counter - create counter links
        trxName - trx
        setOrder - set Order links
        documentNo - Document Number for reversed invoices
        Returns:
        Invoice
      • copyFrom

        public static MInvoice copyFrom​(MInvoice from,
                                        Timestamp dateDoc,
                                        int C_DocTypeTarget_ID,
                                        boolean isSOTrx,
                                        boolean counter,
                                        String trxName,
                                        boolean setOrder)
        Deprecated.
        Create new Invoice by copying
        Parameters:
        from - invoice
        dateDoc - date of the document date
        C_DocTypeTarget_ID - target doc type
        isSOTrx - sales order
        counter - create counter links
        trxName - trx
        setOrder - set Order links
        Returns:
        Invoice
      • getPDFFileName

        public static String getPDFFileName​(String documentDir,
                                            int C_Invoice_ID)
        Get PDF File Name
        Parameters:
        documentDir - directory
        C_Invoice_ID - invoice
        Returns:
        file name
      • get

        public static MInvoice get​(int C_Invoice_ID)
        Get MInvoice from db
        Parameters:
        C_Invoice_ID - id
        Returns:
        MInvoice
      • get

        public static MInvoice get​(Properties ctx,
                                   int C_Invoice_ID)
        Get MInvoice from db
        Parameters:
        C_Invoice_ID - id
        Returns:
        MInvoice
      • 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
      • setBPartner

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

        public void setOrder​(MOrder order)
        Set Order References
        Parameters:
        order - order
      • setShipment

        public void setShipment​(MInOut ship)
        Set Shipment References
        Parameters:
        ship - shipment
      • setC_DocTypeTarget_ID

        public void setC_DocTypeTarget_ID​(String DocBaseType)
        Set Target Document Type
        Parameters:
        DocBaseType - doc type MDocType.DOCBASETYPE_
      • setC_DocTypeTarget_ID

        public void setC_DocTypeTarget_ID()
        Set Target Document Type. Based on SO flag AP/AP Invoice
      • getGrandTotal

        public BigDecimal getGrandTotal​(boolean creditMemoAdjusted)
        Get Grand Total
        Parameters:
        creditMemoAdjusted - adjusted for CM (negative)
        Returns:
        grand total
      • getTotalLines

        public BigDecimal getTotalLines​(boolean creditMemoAdjusted)
        Get Total Lines
        Parameters:
        creditMemoAdjusted - adjusted for CM (negative)
        Returns:
        total lines
      • getLines

        public MInvoiceLine[] getLines​(boolean requery)
        Get Invoice Lines
        Parameters:
        requery -
        Returns:
        lines
      • getLines

        public MInvoiceLine[] getLines()
        Get Lines of Invoice
        Returns:
        lines
      • renumberLines

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

        public int copyLinesFrom​(MInvoice otherInvoice,
                                 boolean counter,
                                 boolean setOrder)
        Copy Lines From other Invoice.
        Parameters:
        otherInvoice - invoice
        counter - create counter links
        setOrder - set order links
        Returns:
        number of lines copied
      • copyLinesFrom

        public int copyLinesFrom​(MInvoice otherInvoice,
                                 boolean counter,
                                 boolean setOrder,
                                 boolean copyClientOrg)
        Copy Lines From other Invoice.
        Parameters:
        otherInvoice - invoice
        counter - create counter links
        setOrder - set order links
        copyClientOrg - copy also Client and Org
        Returns:
        number of lines copied
      • setReversal

        public void setReversal​(boolean reversal)
        Set Reversal
        Parameters:
        reversal - reversal
      • isReversal

        public boolean isReversal()
        Is Reversal
        Returns:
        reversal
      • getTaxes

        public MInvoiceTax[] getTaxes​(boolean requery)
        Get Taxes
        Parameters:
        requery - requery
        Returns:
        array of taxes
      • addDescription

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

        public boolean isCreditMemo()
        Is it a Credit Memo?
        Returns:
        true if CM
      • setProcessed

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

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

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

        protected boolean beforeDelete()
        Before Delete
        Overrides:
        beforeDelete in class PO
        Returns:
        true if it can be deleted
      • afterDelete

        protected boolean afterDelete​(boolean success)
        After Delete
        Overrides:
        afterDelete in class PO
        Parameters:
        success - success
        Returns:
        deleted
      • getDocumentInfo

        public String getDocumentInfo()
        Get Document Info
        Specified by:
        getDocumentInfo in interface DocAction
        Returns:
        document info (untranslated)
      • afterSave

        protected boolean afterSave​(boolean newRecord,
                                    boolean success)
        After Save
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new
        success - success
        Returns:
        success
      • getAllocatedAmt

        public BigDecimal getAllocatedAmt()
        Get Allocated Amt in Invoice Currency
        Returns:
        pos/neg amount or null
      • testAllocation

        public boolean testAllocation​(boolean beingCompleted)
        Test Allocation (and set paid flag)
        Returns:
        true if updated
      • testAllocation

        public boolean testAllocation()
      • setIsPaid

        public static void setIsPaid​(Properties ctx,
                                     int C_BPartner_ID,
                                     String trxName)
        Set Paid Flag for invoices
        Parameters:
        ctx - context
        C_BPartner_ID - if 0 all
        trxName - transaction
      • getOpenAmt

        public BigDecimal getOpenAmt()
        Get Open Amount. Used by web interface
        Returns:
        Open Amt
      • getOpenAmt

        public BigDecimal getOpenAmt​(boolean creditMemoAdjusted,
                                     Timestamp paymentDate)
      • getOpenAmt

        public BigDecimal getOpenAmt​(boolean creditMemoAdjusted,
                                     Timestamp paymentDate,
                                     boolean requery)
        Get Open Amount
        Parameters:
        creditMemoAdjusted - adjusted for CM (negative)
        paymentDate - Payment Date
        Returns:
        Open Amt
      • getDocStatusName

        public String getDocStatusName()
        Get Document Status
        Returns:
        Document Status Clear Text
      • 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
      • getPDFFileName

        public String getPDFFileName​(String documentDir)
        Get PDF File Name
        Parameters:
        documentDir - directory
        Returns:
        file name
      • getCurrencyISO

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

        public int getPrecision()
        Get Currency Precision
        Returns:
        precision
      • 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)
      • calculateTaxTotal

        public boolean calculateTaxTotal()
        Calculate Tax and Total
        Returns:
        true if calculated
      • 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 ..)
      • 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
      • 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:
        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
      • setRMA

        public void setRMA​(MRMA rma)
        Parameters:
        rma -
      • isComplete

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

        public MOrder getOriginalOrder()
        Get original order
        Returns:
        order
      • 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)