Class FactLine

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_Fact_Acct, I_Persistent, Evaluatee

public final class FactLine extends X_Fact_Acct
Accounting Fact Entry.
Version:
$Id: FactLine.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $ Contributor(s): Chris Farley: Fix Bug [ 1657372 ] M_MatchInv records can not be balanced https://sourceforge.net/forum/message.php?msg_id=4151117 Carlos Ruiz - globalqss: Add setAmtAcct method rounded by Currency Armen Rizal, Goodwill Consulting
  • BF [ 1745154 ] Cost in Reversing Material Related Docs Bayu Sistematika -
  • BF [ 2213252 ] Matching Inv-Receipt generated unproperly value for src amt Teo Sarca
  • FR [ 2819081 ] FactLine.getDocLine should be public https://sourceforge.net/p/adempiere/feature-requests/764/
  • Author:
    Jorg Janke
    See Also:
    • Constructor Details

      • FactLine

        public FactLine(Properties ctx, int AD_Table_ID, int Record_ID, int Line_ID, String trxName)
        Constructor
        Parameters:
        ctx - context
        AD_Table_ID - - Table of Document Source
        Record_ID - - Record of document
        Line_ID - - Optional line id
        trxName - transaction
    • Method Details

      • reverse

        public FactLine reverse(String description)
        Create Reversal (negate DR/CR) of the line
        Parameters:
        description - new description
        Returns:
        reversal line
      • accrue

        public FactLine accrue(String description)
        Create reverse accrual (flip CR/DR) of the line
        Parameters:
        description - new description
        Returns:
        reverse accrual line
      • setAccount

        public void setAccount(MAcctSchema acctSchema, MAccount acct)
        Set Account Info
        Parameters:
        acctSchema - account schema
        acct - account
      • setAmtSource

        public boolean setAmtSource(int C_Currency_ID, BigDecimal AmtSourceDr, BigDecimal AmtSourceCr)
        Set Source Amounts
        Parameters:
        C_Currency_ID - currency
        AmtSourceDr - source amount dr
        AmtSourceCr - source amount cr
        Returns:
        true, if any of the amount is not zero
      • setAmtAcct

        public void setAmtAcct(BigDecimal AmtAcctDr, BigDecimal AmtAcctCr)
        Set Accounted Amounts (alternative: call convert)
        Parameters:
        AmtAcctDr - acct amount dr
        AmtAcctCr - acct amount cr
      • setAmtAcct

        public void setAmtAcct(int C_Currency_ID, BigDecimal AmtAcctDr, BigDecimal AmtAcctCr)
        Set Accounted Amounts rounded by standard precision of currency
        Parameters:
        C_Currency_ID - currency
        AmtAcctDr - acct amount dr
        AmtAcctCr - acct amount cr
      • setDocumentInfo

        public void setDocumentInfo(Doc doc, DocLine docLine)
        Set Document Info
        Parameters:
        doc - document
        docLine - doc line
      • getDocLine

        public DocLine getDocLine()
        Get Document Line
        Returns:
        doc line
      • addDescription

        public void addDescription(String description)
        Set Description
        Parameters:
        description - description
      • setM_Locator_ID

        public void setM_Locator_ID(int M_Locator_ID)
        Set Warehouse Locator.
        - will reset Organization to 0 -
        Specified by:
        setM_Locator_ID in interface I_Fact_Acct
        Overrides:
        setM_Locator_ID in class X_Fact_Acct
        Parameters:
        M_Locator_ID - locator
      • setLocation

        public void setLocation(int C_Location_ID, boolean isFrom)
        Set Location
        Parameters:
        C_Location_ID - location
        isFrom - true - from, false - to.
      • setLocationFromLocator

        public void setLocationFromLocator(int M_Locator_ID, boolean isFrom)
        Set Location from Locator (M_Warehouse)
        Parameters:
        M_Locator_ID - locator
        isFrom - true - from, false - to.
      • setLocationFromBPartner

        public void setLocationFromBPartner(int C_BPartner_Location_ID, boolean isFrom)
        Set Location from Business Partner Location
        Parameters:
        C_BPartner_Location_ID - bp location
        isFrom - from
      • setLocationFromOrg

        public void setLocationFromOrg(int AD_Org_ID, boolean isFrom)
        Set Location from Organization (AD_OrgInfo)
        Parameters:
        AD_Org_ID - org
        isFrom - true - from, false - to.
      • getSourceBalance

        public BigDecimal getSourceBalance()
        Returns Source Balance of line
        Returns:
        source balance
      • isDrSourceBalance

        public boolean isDrSourceBalance()
        Is Debit Source Balance
        Returns:
        true if DR source balance
      • getAcctBalance

        public BigDecimal getAcctBalance()
        Get Accounted Balance
        Returns:
        accounting balance
      • isBalanceSheet

        public boolean isBalanceSheet()
        Is Account on Balance Sheet
        Returns:
        true if account is a balance sheet account
      • currencyCorrect

        public void currencyCorrect(BigDecimal deltaAmount)
        Adjust Accounting Amount.
          Example:    1       -1      1       -1
          Old         100/0   100/0   0/100   0/100
          New         99/0    101/0   0/99    0/101
          
        Parameters:
        deltaAmount - delta amount
      • convert

        public boolean convert()
        Convert to Accounted Currency
        Returns:
        true if converted
      • getAccount

        public MAccount getAccount()
        Get Account
        Returns:
        account
      • toString

        public String toString()
        To String
        Overrides:
        toString in class X_Fact_Acct
        Returns:
        String
      • getAD_Org_ID

        public int getAD_Org_ID()
        Get AD_Org_ID (balancing segment).
        (if not set directly - from document line, document, account, locator)

        Note that Locator needs to be set before - otherwise segment balancing might produce the wrong results

        Specified by:
        getAD_Org_ID in interface I_Fact_Acct
        Overrides:
        getAD_Org_ID in class PO
        Returns:
        AD_Org_ID
      • getC_SalesRegion_ID

        public int getC_SalesRegion_ID()
        Get/derive Sales Region
        Specified by:
        getC_SalesRegion_ID in interface I_Fact_Acct
        Overrides:
        getC_SalesRegion_ID in class X_Fact_Acct
        Returns:
        C_SalesRegion_ID
      • beforeSave

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

        public boolean updateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier)
        Update Line with reversed Original Amount in Accounting Currency. Also copies original dimensions like Project, etc. Called from Doc_MatchInv
        Parameters:
        AD_Table_ID - table
        Record_ID - record
        Line_ID - line
        multiplier - targetQty/documentQty
        Returns:
        true if success
      • updateReverseLine

        public boolean updateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier, FactLine otherLine)
        Update Line with reversed Original Amount in Accounting Currency. Also copies original dimensions like Project, etc. Called from Doc_MatchInv
        Parameters:
        AD_Table_ID - table
        Record_ID - record
        Line_ID - line
        multiplier - targetQty/documentQty
        otherLine - reversal line created before this. if not null, this reversal should reverse the opposite sign.
        Returns:
        true if success

        NOTE: otherLine is required in cases where the original DR/CR postings are done in the same account. In this case looking just for the first posting is wrong and results in a non-balanced reversal posting