Class MPayment

  • All Implemented Interfaces:
    Serializable, Cloneable, Comparator<Object>, I_C_Payment, I_Persistent, PaymentInterface, DocAction, IDocsPostProcess, ProcessCall, Evaluatee

    public class MPayment
    extends X_C_Payment
    implements DocAction, ProcessCall, PaymentInterface, IDocsPostProcess
    Payment Model. - retrieve and create payments for invoice
      Event chain
      - Payment inserted
          C_Payment_Trg fires
              update DocumentNo with payment summary
      - Payment posted (C_Payment_Post)
          create allocation line
              C_Allocation_Trg fires
                  Update C_BPartner Open Item Amount
          update invoice (IsPaid)
          link invoice-payment if batch
    
      Lifeline:
      -   Created by VPayment or directly
      -   When changed in VPayment
          - old payment is reversed
          - new payment created
    
      When Payment is posed, the Allocation is made
      
    Version:
    $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
    Author:
    Jorg Janke, victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
  • FR [ 1948157 ] Is necessary the reference for document reverse, Carlos Ruiz - globalqss [ 2141475 ] Payment <> allocations must not be completed - implement lots of validations on prepareIt
  • See Also:
    Serialized Form
    • Field Detail

      • m_mBankAccountProcessors

        protected MBankAccountProcessor[] m_mBankAccountProcessors
        Temporary Bank Account Processors
      • m_mBankAccountProcessor

        protected MBankAccountProcessor m_mBankAccountProcessor
        Temporary Bank Account Processor
      • s_log

        protected static CLogger s_log
        Logger
      • m_errorMessage

        protected String m_errorMessage
        Error Message
      • REVERSE_INDICATOR

        public static String REVERSE_INDICATOR
        Reversal Indicator
      • m_processMsg

        protected String m_processMsg
        Process Message
      • m_justPrepared

        protected boolean m_justPrepared
        Just Prepared Flag
      • m_justCreatedAllocInv

        protected MAllocationHdr m_justCreatedAllocInv
    • Constructor Detail

      • MPayment

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

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

      • getOfBPartner

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

        public void resetNew()
        Reset Payment to new status
      • isCashTrx

        public boolean isCashTrx()
        Is Cash Trx
        Returns:
        true if Cash Trx
      • isCashbookTrx

        public boolean isCashbookTrx()
        Is Cashbook Trx
        Returns:
        true if this is a cashbook trx
      • setCreditCard

        public boolean setCreditCard​(String TrxType,
                                     String creditCardType,
                                     String creditCardNumber,
                                     String creditCardVV,
                                     int creditCardExpMM,
                                     int creditCardExpYY)
        Set Credit Card. Need to set PatmentProcessor after Amount/Currency Set
        Parameters:
        TrxType - Transaction Type see TRX_
        creditCardType - CC type
        creditCardNumber - CC number
        creditCardVV - CC verification
        creditCardExpMM - CC Exp MM
        creditCardExpYY - CC Exp YY
        Returns:
        true if valid
      • setCreditCard

        public boolean setCreditCard​(String TrxType,
                                     String creditCardType,
                                     String creditCardNumber,
                                     String creditCardVV,
                                     String creditCardExp)
        Set Credit Card - Exp. Need to set PatmentProcessor after Amount/Currency Set
        Parameters:
        TrxType - Transaction Type see TRX_
        creditCardType - CC type
        creditCardNumber - CC number
        creditCardVV - CC verification
        creditCardExp - CC Exp
        Returns:
        true if valid
      • setBankACH

        public boolean setBankACH​(MPaySelectionCheck preparedPayment)
        Set ACH BankAccount Info
        Parameters:
        preparedPayment -
        Returns:
        true if valid
      • setBankACH

        public boolean setBankACH​(int C_BankAccount_ID,
                                  boolean isReceipt,
                                  String tenderType,
                                  String routingNo,
                                  String accountNo)
        Set ACH BankAccount Info
        Parameters:
        C_BankAccount_ID - bank account
        isReceipt - true if receipt
        tenderType - - Direct Debit or Direct Deposit
        routingNo - routing
        accountNo - account
        Returns:
        true if valid
      • setBankCash

        public boolean setBankCash​(int C_BankAccount_ID,
                                   boolean isReceipt,
                                   String tenderType)
        Set Cash BankAccount Info
        Parameters:
        C_BankAccount_ID - bank account
        isReceipt - true if receipt
        tenderType - - Cash (Payment)
        Returns:
        true if valid
      • setBankCheck

        public boolean setBankCheck​(int C_BankAccount_ID,
                                    boolean isReceipt,
                                    String checkNo)
        Set Check BankAccount Info
        Parameters:
        C_BankAccount_ID - bank account
        isReceipt - true if receipt
        checkNo - check no
        Returns:
        true if valid
      • setBankCheck

        public boolean setBankCheck​(int C_BankAccount_ID,
                                    boolean isReceipt,
                                    String routingNo,
                                    String accountNo,
                                    String checkNo)
        Set Check BankAccount Info
        Parameters:
        C_BankAccount_ID - bank account
        isReceipt - true if receipt
        routingNo - routing no
        accountNo - account no
        checkNo - chack no
        Returns:
        true if valid
      • setBankAccountDetails

        public void setBankAccountDetails​(int C_BankAccount_ID)
        Set Bank Account Details. Look up Routing No and Bank Acct No
        Parameters:
        C_BankAccount_ID - bank account
      • setAccountAddress

        public void setAccountAddress​(String name,
                                      String street,
                                      String city,
                                      String state,
                                      String zip,
                                      String country)
        Set Account Address
        Parameters:
        name - name
        street - street
        city - city
        state - state
        zip - zip
        country - country
      • processOnline

        public boolean processOnline()
        Process Payment
        Returns:
        true if approved
      • startProcess

        public boolean startProcess​(Properties ctx,
                                    ProcessInfo pi,
                                    Trx trx)
        Process Online Payment. implements ProcessCall after standard constructor Called when pressing the Process_Online button in C_Payment
        Specified by:
        startProcess in interface ProcessCall
        Parameters:
        ctx - Context
        pi - Process Info
        trx - transaction
        Returns:
        true if the next process should be performed
      • beforeSave

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

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

        public BigDecimal getAllocatedAmt()
        Get Allocated Amt in Payment Currency
        Returns:
        amount or null
      • testAllocation

        public boolean testAllocation()
        Test Allocation (and set allocated flag)
        Returns:
        true if updated
      • setIsAllocated

        public static void setIsAllocated​(Properties ctx,
                                          int C_BPartner_ID,
                                          String trxName)
        Set Allocated Flag for payments
        Parameters:
        ctx - context
        C_BPartner_ID - if 0 all
        trxName - trx
      • setErrorMessage

        public void setErrorMessage​(String errorMessage)
        Set Error Message
        Parameters:
        errorMessage - error message
      • getErrorMessage

        public String getErrorMessage()
        Get Error Message
        Returns:
        error message
      • setPaymentProcessor

        public boolean setPaymentProcessor()
        Set BankAccount and PaymentProcessor
        Returns:
        true if found
      • setPaymentProcessor

        public boolean setPaymentProcessor​(String tender,
                                           String CCType,
                                           int C_PaymentProcessor_ID)
        Set BankAccount and PaymentProcessor
        Parameters:
        tender - TenderType see TENDER_
        CCType - CC Type see CC_
        Returns:
        true if found
      • getCreditCards

        public ValueNamePair[] getCreditCards()
        Get Accepted Credit Cards for PayAmt (default 0)
        Returns:
        credit cards
      • getCreditCards

        public ValueNamePair[] getCreditCards​(BigDecimal amt)
        Get Accepted Credit Cards for amount
        Parameters:
        amt - trx amount
        Returns:
        credit cards
      • getCreditCardPair

        protected ValueNamePair getCreditCardPair​(String CreditCardType)
        Get Type and name pair
        Parameters:
        CreditCardType - credit card Type
        Returns:
        pair
      • setCreditCardExp

        public boolean setCreditCardExp​(String mmyy)
        CreditCard Exp MMYY
        Parameters:
        mmyy - Exp in form of mmyy
        Returns:
        true if valid
      • getCreditCardExp

        public String getCreditCardExp​(String delimiter)
        CreditCard Exp MMYY
        Parameters:
        delimiter - / - or null
        Returns:
        Exp
      • setDocumentNo

        protected void setDocumentNo()
        Set DocumentNo to Payment info. If there is a R_PnRef that is set automatically
      • setAmount

        public void setAmount​(int C_Currency_ID,
                              BigDecimal payAmt)
        Set Payment Amount
        Parameters:
        C_Currency_ID - currency
        payAmt - amount
      • setBP_BankAccount

        public void setBP_BankAccount​(MBPBankAccount ba)
        Set Info from BP Bank Account
        Parameters:
        ba - BP bank account
      • saveToBP_BankAccount

        public boolean saveToBP_BankAccount​(MBPBankAccount ba)
        Save Info from BP Bank Account
        Parameters:
        ba - BP bank account
        Returns:
        true if saved
      • setC_DocType_ID

        protected void setC_DocType_ID()
        Set Doc Type bases on IsReceipt
      • setC_DocType_ID

        public void setC_DocType_ID​(boolean isReceipt)
        Set Doc Type
        Parameters:
        isReceipt - is receipt
      • verifyDocType

        protected boolean verifyDocType​(MPaymentAllocate[] pAllocs)
        Verify Document Type with Invoice
        Parameters:
        pAllocs -
        Returns:
        true if ok
      • verifyPaymentAllocateVsHeader

        protected boolean verifyPaymentAllocateVsHeader​(MPaymentAllocate[] pAllocs)
        Verify Payment Allocate is ignored (must not exists) if the payment header has charge/invoice/order
        Parameters:
        pAllocs -
        Returns:
        true if ok
      • verifyPaymentAllocateSum

        protected boolean verifyPaymentAllocateSum​(MPaymentAllocate[] pAllocs)
        Verify Payment Allocate Sum must be equal to the Payment Amount
        Parameters:
        pAllocs -
        Returns:
        true if ok
      • getCurrencyISO

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

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

        public String getCreditCardName()
        Get Name of Credit Card
        Returns:
        Name
      • getCreditCardName

        public String getCreditCardName​(String CreditCardType)
        Get Name of Credit Card
        Parameters:
        CreditCardType - credit card type
        Returns:
        Name
      • addDescription

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

        public BigDecimal getPayAmt​(boolean absolute)
        Get Pay Amt
        Parameters:
        absolute - if true the absolute amount (i.e. negative if payment)
        Returns:
        amount
      • getPayAmtInCents

        public int getPayAmtInCents()
        Get Pay Amt in cents
        Returns:
        amount in cents
      • 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)
      • 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 ..)
      • addDocsPostProcess

        protected void addDocsPostProcess​(PO doc)
      • setDefiniteDocumentNo

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

        protected MPayment createCounterDoc()
        Create Counter Document
        Returns:
        payment
      • allocateIt

        public boolean allocateIt()
        Allocate It. Only call when there is NO allocation as it will create duplicates. If an invoice exists, it allocates that otherwise it allocates Payment Selection.
        Returns:
        true if allocated
      • allocateInvoice

        protected boolean allocateInvoice()
        Allocate single AP/AR Invoice
        Returns:
        true if allocated
      • allocatePaySelection

        protected boolean allocatePaySelection()
        Allocate Payment Selection
        Returns:
        true if allocated
      • deAllocate

        protected void deAllocate​(boolean accrual)
        De-allocate Payment. Unkink Invoices and Orders and delete Allocations
        Parameters:
        accrual -
      • 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
        Specified by:
        reverseCorrectIt in interface DocAction
        Returns:
        true if success
      • getC_BankStatementLine_ID

        protected int getC_BankStatementLine_ID()
        Get Bank Statement Line of payment or 0
        Returns:
        id or 0
      • reverseAccrualIt

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

        public boolean reActivateIt()
        Re-activate
        Specified by:
        reActivateIt in interface DocAction
        Returns:
        true if success
      • 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
      • 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:
        amount payment(AP) or write-off(AR)
      • voidOnlinePayment

        protected boolean voidOnlinePayment()
      • getCompletedPaymentIDs

        public static int[] getCompletedPaymentIDs​(int C_Order_ID,
                                                   int C_Invoice_ID,
                                                   String trxName)
      • getJustCreatedAllocInv

        public MAllocationHdr getJustCreatedAllocInv()