Class Fact

java.lang.Object
org.compiere.acct.Fact

public final class Fact extends Object
Accounting Fact for Doc.
Create and save one or more FactLine for an accounting document.
Version:
$Id: Fact.java,v 1.2 2006/07/30 00:53:33 jjanke Exp $ BF [ 2789949 ] Multicurrency in matching posting
Author:
Jorg Janke
  • Field Details

  • Constructor Details

    • Fact

      public Fact(Doc document, MAcctSchema acctSchema, String defaultPostingType)
      Constructor
      Parameters:
      document - pointer to document
      acctSchema - Account Schema to create accounts
      defaultPostingType - the default Posting type (actual,..) for this posting
  • Method Details

    • dispose

      public void dispose()
      Dispose
    • createLine

      public FactLine createLine(DocLine docLine, MAccount account, int C_Currency_ID, BigDecimal debitAmt, BigDecimal creditAmt)
      Create and convert Fact Line. Used to create a DR and/or CR entry
      Parameters:
      docLine - the document line or null
      account - if null, line is not created
      C_Currency_ID - the currency
      debitAmt - debit amount, can be null
      creditAmt - credit amount, can be null
      Returns:
      Fact Line
    • add

      public void add(FactLine line)
      Add Fact Line
      Parameters:
      line - fact line
    • remove

      public void remove(FactLine line)
      Remove Fact Line
      Parameters:
      line - fact line
    • createLine

      public FactLine createLine(DocLine docLine, MAccount accountDr, MAccount accountCr, int C_Currency_ID, BigDecimal Amt)
      Create and convert Fact Line. Used to create either a DR or CR entry
      Parameters:
      docLine - Document Line or null
      accountDr - Account to be used if Amt is DR balance
      accountCr - Account to be used if Amt is CR balance
      C_Currency_ID - Currency
      Amt - if negative Cr else Dr
      Returns:
      FactLine
    • createLine

      public FactLine createLine(DocLine docLine, MAccount account, int C_Currency_ID, BigDecimal Amt)
      Create and convert Fact Line. Used to create either a DR or CR entry
      Parameters:
      docLine - Document line or null
      account - Account to be used
      C_Currency_ID - Currency
      Amt - if negative Cr else Dr
      Returns:
      FactLine
    • isPostingType

      public boolean isPostingType(String PostingType)
      Is Posting Type
      Parameters:
      PostingType - - see POST_*
      Returns:
      true if document is posting type
    • isConverted

      public boolean isConverted()
      Is converted
      Returns:
      true if converted
    • getAcctSchema

      public MAcctSchema getAcctSchema()
      Get AcctSchema
      Returns:
      AcctSchema
    • isSourceBalanced

      public boolean isSourceBalanced()
      Are the lines Source Balanced
      Returns:
      true if source lines balanced
    • getSourceBalance

      protected BigDecimal getSourceBalance()
      Get Source Balance Amount
      Returns:
      source balance
    • balanceSource

      public FactLine balanceSource()
      Create Source Line for Suspense Balancing.
      Only if Suspense Balancing is enabled and not a multi-currency document (double check as, otherwise the rule should not have fired).
      If not balanced, create balancing entry in currency of the document.
      Returns:
      Balancing FactLine or null
    • isSegmentBalanced

      public boolean isSegmentBalanced()
      Are all segments balanced
      Returns:
      true if segments are balanced
    • isSegmentBalanced

      public boolean isSegmentBalanced(String segmentType)
      Is Source Segment balanced.
      Parameters:
      segmentType - - see AcctSchemaElement.SEGMENT_*.
      Implemented only for Org. Other sensible candidates are Project, User1/2.
      Returns:
      true if segments are balanced
    • balanceSegments

      public void balanceSegments()
      Balance all segments. - For all balancing segments - For all segment values - If balance <> 0 create dueTo/dueFrom line overwriting the segment value
    • isAcctBalanced

      public boolean isAcctBalanced()
      Are the lines Accounting Balanced
      Returns:
      true if accounting lines are balanced
    • getAcctBalance

      protected BigDecimal getAcctBalance()
      Return Accounting Balance
      Returns:
      true if accounting lines are balanced
    • balanceAccounting

      public FactLine balanceAccounting()
      Balance Accounting Currency.
        If the accounting currency is not balanced,
            if Currency balancing is enabled
                create a new line using the currency balancing account with zero source balance
            or
                adjust the line with the largest balance sheet account
                or if no balance sheet account exist, the line with the largest amount
        
      Returns:
      FactLine
    • checkAccounts

      public boolean checkAccounts()
      Check Accounts of Fact Lines
      Returns:
      true if success
    • distribute

      public boolean distribute()
      GL Distribution of Fact Lines
      Returns:
      true if success
    • toString

      public String toString()
      String representation
      Overrides:
      toString in class Object
      Returns:
      String
    • getLines

      public FactLine[] getLines()
      Get Lines
      Returns:
      FactLine Array
    • save

      public boolean save(String trxName)
      Save Fact Lines
      Parameters:
      trxName - transaction
      Returns:
      true if all lines were saved
    • get_TrxName

      public String get_TrxName()
      Get Transaction Name
      Returns:
      trx nam