Package org.idempiere.acct.doc
Class FactLine
java.lang.Object
org.compiere.model.PO
org.compiere.model.X_Fact_Acct
org.idempiere.acct.doc.FactLine
- All Implemented Interfaces:
Serializable,Cloneable,Comparator<Object>,I_Fact_Acct,I_Persistent,Evaluatee
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:
-
Field Summary
Fields inherited from class org.compiere.model.X_Fact_Acct
POSTINGTYPE_Actual, POSTINGTYPE_AD_Reference_ID, POSTINGTYPE_Budget, POSTINGTYPE_Commitment, POSTINGTYPE_Reservation, POSTINGTYPE_StatisticalFields inherited from class org.compiere.model.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, LOCAL_TRX_PREFIX, log, m_attachment, m_idOld, m_IDs, m_KeyColumns, m_optimisticLockingColumns, p_ctx, p_info, UUID_NEW_RECORD, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_IDFields inherited from interface org.compiere.model.I_Fact_Acct
accessLevel, COLUMNNAME_A_Asset_ID, COLUMNNAME_Account_ID, COLUMNNAME_AD_Client_ID, COLUMNNAME_AD_Org_ID, COLUMNNAME_AD_OrgTrx_ID, COLUMNNAME_AD_Table_ID, COLUMNNAME_AmtAcctCr, COLUMNNAME_AmtAcctDr, COLUMNNAME_AmtSourceCr, COLUMNNAME_AmtSourceDr, COLUMNNAME_C_AcctSchema_ID, COLUMNNAME_C_Activity_ID, COLUMNNAME_C_BPartner_ID, COLUMNNAME_C_Campaign_ID, COLUMNNAME_C_Charge_ID, COLUMNNAME_C_CostCenter_ID, COLUMNNAME_C_Currency_ID, COLUMNNAME_C_Department_ID, COLUMNNAME_C_Employee_ID, COLUMNNAME_C_LocFrom_ID, COLUMNNAME_C_LocTo_ID, COLUMNNAME_C_Period_ID, COLUMNNAME_C_Project_ID, COLUMNNAME_C_ProjectPhase_ID, COLUMNNAME_C_ProjectTask_ID, COLUMNNAME_C_SalesRegion_ID, COLUMNNAME_C_SubAcct_ID, COLUMNNAME_C_Tax_ID, COLUMNNAME_C_UOM_ID, COLUMNNAME_Created, COLUMNNAME_CreatedBy, COLUMNNAME_CustomFieldText1, COLUMNNAME_CustomFieldText2, COLUMNNAME_CustomFieldText3, COLUMNNAME_CustomFieldText4, COLUMNNAME_DateAcct, COLUMNNAME_DateTrx, COLUMNNAME_Description, COLUMNNAME_Fact_Acct_ID, COLUMNNAME_Fact_Acct_UU, COLUMNNAME_GL_Budget_ID, COLUMNNAME_GL_Category_ID, COLUMNNAME_IsActive, COLUMNNAME_Line_ID, COLUMNNAME_M_AttributeSetInstance_ID, COLUMNNAME_M_Locator_ID, COLUMNNAME_M_Product_ID, COLUMNNAME_M_Warehouse_ID, COLUMNNAME_PostingType, COLUMNNAME_Qty, COLUMNNAME_Record_ID, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, COLUMNNAME_User1_ID, COLUMNNAME_User2_ID, COLUMNNAME_UserElement1_ID, COLUMNNAME_UserElement2_ID, Model, Table_ID, Table_Name -
Constructor Summary
ConstructorsConstructorDescriptionFactLine(Properties ctx, int AD_Table_ID, int Record_ID, int Line_ID, String trxName) Constructor -
Method Summary
Modifier and TypeMethodDescriptionCreate reverse accrual (flip CR/DR) of the linevoidaddDescription(String description) Set Descriptionprotected booleanbeforeSave(boolean newRecord) Called before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.booleanconvert()Convert to Accounted CurrencyvoidcurrencyCorrect(BigDecimal deltaAmount) Adjust Accounting Amount.Get AccountGet Accounted BalanceintGet AD_Org_ID (balancing segment).intIf not set yet(still 0), get/derive Sales Region from Doc, DocLine or Account Combination.Get Document LineReturns Source Balance of linebooleanReturns true if this FactLine and the given FactLine have the same accounting dimensions.booleanIs Account on Balance SheetbooleanIs Debit Source BalanceCreate Reversal (negate DR/CR) of the linevoidsetAccount(MAcctSchema acctSchema, MAccount acct) Set Account InfovoidsetAmtAcct(int C_Currency_ID, BigDecimal AmtAcctDr, BigDecimal AmtAcctCr) Set Accounted Amounts rounded by standard precision of currencyvoidsetAmtAcct(BigDecimal AmtAcctDr, BigDecimal AmtAcctCr) Set Accounted Amounts (alternative: call convert)booleansetAmtSource(int C_Currency_ID, BigDecimal AmtSourceDr, BigDecimal AmtSourceCr) Set Source AmountsvoidsetDocumentInfo(Doc doc, DocLine docLine) Set Document InfovoidsetDocumentTextInfo(MAcctSchema acctSchema) voidsetLocation(int C_Location_ID, boolean isFrom) Set LocationvoidsetLocationFromBPartner(int C_BPartner_Location_ID, boolean isFrom) Set Location from Business Partner LocationvoidsetLocationFromLocator(int M_Locator_ID, boolean isFrom) Set Location from Locator (M_Warehouse)voidsetLocationFromOrg(int AD_Org_ID, boolean isFrom) Set Location from Organization (AD_OrgInfo)voidsetM_Locator_ID(int M_Locator_ID) Set Warehouse Locator.
- will reset Organization to 0 -toString()To StringbooleanupdateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier) Update Line with reversed Original Amount in Accounting Currency.booleanupdateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier, FactLine otherLine) Update Line with reversed Original Amount in Accounting Currency.booleanupdateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier, FactLine otherLine, boolean updateTaxAndAmounts) Update Line with reversed Original Amount in Accounting Currency.Methods inherited from class org.compiere.model.X_Fact_Acct
get_AccessLevel, getA_Asset_ID, getAccount_ID, getAD_OrgTrx_ID, getAD_Table, getAD_Table_ID, getAmtAcctCr, getAmtAcctDr, getAmtSourceCr, getAmtSourceDr, getC_AcctSchema, getC_AcctSchema_ID, getC_Activity, getC_Activity_ID, getC_BPartner, getC_BPartner_ID, getC_Campaign, getC_Campaign_ID, getC_Charge, getC_Charge_ID, getC_CostCenter, getC_CostCenter_ID, getC_Currency, getC_Currency_ID, getC_Department, getC_Department_ID, getC_Employee, getC_Employee_ID, getC_LocFrom, getC_LocFrom_ID, getC_LocTo, getC_LocTo_ID, getC_Period, getC_Period_ID, getC_Project, getC_Project_ID, getC_ProjectPhase, getC_ProjectPhase_ID, getC_ProjectTask, getC_ProjectTask_ID, getC_SalesRegion, getC_SubAcct, getC_SubAcct_ID, getC_Tax, getC_Tax_ID, getC_UOM, getC_UOM_ID, getCustomFieldText1, getCustomFieldText2, getCustomFieldText3, getCustomFieldText4, getDateAcct, getDateTrx, getDescription, getFact_Acct_ID, getFact_Acct_UU, getGL_Budget, getGL_Budget_ID, getGL_Category, getGL_Category_ID, getKeyNamePair, getLine_ID, getM_AttributeSetInstance, getM_AttributeSetInstance_ID, getM_Locator, getM_Locator_ID, getM_Product, getM_Product_ID, getM_Warehouse, getM_Warehouse_ID, getPostingType, getQty, getRecord_ID, getUser1, getUser1_ID, getUser2, getUser2_ID, getUserElement1_ID, getUserElement2_ID, initPO, setA_Asset_ID, setAccount_ID, setAD_OrgTrx_ID, setAD_Table_ID, setAmtAcctCr, setAmtAcctDr, setAmtSourceCr, setAmtSourceDr, setC_AcctSchema_ID, setC_Activity_ID, setC_BPartner_ID, setC_Campaign_ID, setC_Charge_ID, setC_CostCenter_ID, setC_Currency_ID, setC_Department_ID, setC_Employee_ID, setC_LocFrom_ID, setC_LocTo_ID, setC_Period_ID, setC_Project_ID, setC_ProjectPhase_ID, setC_ProjectTask_ID, setC_SalesRegion_ID, setC_SubAcct_ID, setC_Tax_ID, setC_UOM_ID, setCustomFieldText1, setCustomFieldText2, setCustomFieldText3, setCustomFieldText4, setDateAcct, setDateTrx, setDescription, setFact_Acct_ID, setFact_Acct_UU, setGL_Budget_ID, setGL_Category_ID, setLine_ID, setM_AttributeSetInstance_ID, setM_Product_ID, setM_Warehouse_ID, setPostingType, setQty, setRecord_ID, setUser1_ID, setUser2_ID, setUserElement1_ID, setUserElement2_IDMethods inherited from class org.compiere.model.PO
afterDelete, afterInsertWithValues, afterSave, beforeDelete, buildInsertSQL, buildInsertSQL, buildUpdateSQL, buildUUIDSubquery, checkImmutable, clearCrossTenantSafe, clone, columnExists, columnExists, compare, copyPO, copyValues, copyValues, createAttachment, delete, delete, delete_Accounting, delete_Tree, deleteEx, deleteEx, doOrganizationCheckForSave, doVerificationForDelete, doVerificationForSave, dump, dump, equals, firePostDeleteEvent, get_Attribute, get_Attributes, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_deleteStatement, get_deleteTranslationsSQL, get_deleteTreeSQL, get_DisplayValue, get_HashMap, get_ID, get_IDOld, get_KeyColumns, get_Logger, get_OptimisticLockingColumns, get_QueryTimeout, get_Table_ID, get_TableAttribute, get_TableAttributeAsBoolean, get_TableAttributeAsInt, get_TableAttributes, get_TableName, get_Translation, get_Translation, get_Translation, get_Translation, get_Translation, get_TrxName, get_UUID, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueE, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_WhereClause, get_WhereClause, get_xmlDocument, get_xmlString, getAD_Client_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getDoc, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getUUIDColumnName, getUUIDColumnName, hashCode, insert_Accounting, insert_Tree, insert_Tree, is_Changed, is_ColumnLoaded, is_hasCustomTree, is_Immutable, is_new, is_Partial, is_UseOptimisticLocking, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isCrossTenantSafe, isLogSQLScript, isMandatoryOK, isPdfAttachment, isReplication, load, load, load, load, loadByUU, loadComplete, loadDefaults, loadPO, loadSpecial, lobSave, lock, makeImmutable, postDelete, resetStateAfterDelete, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveCrossTenantSafe, saveCrossTenantSafeEx, saveCrossTenantSafeEx, saveEx, saveEx, saveFinish, saveNew_afterSetID, saveNew_getID, saveNewSpecial, saveReplica, saveUpdate, set_Attribute, set_ColumnLoaded, set_ColumnUpdateable, set_CustomColumn, set_CustomColumnReturningBoolean, set_DocumentNoForNewRecord, set_IDForNewRecord, set_OptimisticLockingColumns, set_Partial, set_QueryTimeout, set_TrxName, set_TrxName, set_UseOptimisticLocking, set_UUIDForNewRecord, set_Value, set_Value, set_Value, set_Value, set_ValueE, set_ValueForNewRecord, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueOfColumn, set_ValueOfColumnReturningBoolean, set_ValueOfColumnReturningBoolean, setAD_Client_ID, setAD_Org_ID, setClientOrg, setClientOrg, setCrossTenantSafe, setDoc, setDocWorkflowMgr, setIsActive, setProcessedOn, setReplication, setStandardDefaults, setUpdateable, setUpdatedBy, setupDeleteActionsForTransactionEvent, toInsertSQL, unlock, update_Tree, validForeignKeys, validForeignKeysExMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface org.compiere.model.I_Fact_Acct
getAD_Client_ID, getCreated, getCreatedBy, getUpdated, getUpdatedBy, isActive, setAD_Org_ID, setIsActiveMethods inherited from interface org.compiere.model.I_Persistent
save
-
Constructor Details
-
FactLine
Constructor- Parameters:
ctx- contextAD_Table_ID- - Table of Document SourceRecord_ID- - Record of documentLine_ID- - Optional line idtrxName- transaction
-
-
Method Details
-
reverse
Create Reversal (negate DR/CR) of the line- Parameters:
description- new description- Returns:
- reversal line
-
accrue
Create reverse accrual (flip CR/DR) of the line- Parameters:
description- new description- Returns:
- reverse accrual line
-
setAccount
Set Account Info- Parameters:
acctSchema- account schemaacct- account
-
setAmtSource
Set Source Amounts- Parameters:
C_Currency_ID- currencyAmtSourceDr- source amount drAmtSourceCr- source amount cr- Returns:
- true, if any of the amount is not zero
-
setAmtAcct
Set Accounted Amounts (alternative: call convert)- Parameters:
AmtAcctDr- acct amount drAmtAcctCr- acct amount cr
-
setAmtAcct
Set Accounted Amounts rounded by standard precision of currency- Parameters:
C_Currency_ID- currencyAmtAcctDr- acct amount drAmtAcctCr- acct amount cr
-
setDocumentInfo
Set Document Info- Parameters:
doc- documentdocLine- doc line
-
setDocumentTextInfo
-
getDocLine
Get Document Line- Returns:
- doc line
-
addDescription
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_IDin interfaceI_Fact_Acct- Overrides:
setM_Locator_IDin classX_Fact_Acct- Parameters:
M_Locator_ID- locator
-
setLocation
public void setLocation(int C_Location_ID, boolean isFrom) Set Location- Parameters:
C_Location_ID- locationisFrom- true - from, false - to.
-
setLocationFromLocator
public void setLocationFromLocator(int M_Locator_ID, boolean isFrom) Set Location from Locator (M_Warehouse)- Parameters:
M_Locator_ID- locatorisFrom- 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 locationisFrom- from
-
setLocationFromOrg
public void setLocationFromOrg(int AD_Org_ID, boolean isFrom) Set Location from Organization (AD_OrgInfo)- Parameters:
AD_Org_ID- orgisFrom- true - from, false - to.
-
getSourceBalance
Returns Source Balance of line- Returns:
- source balance
-
isDrSourceBalance
public boolean isDrSourceBalance()Is Debit Source Balance- Returns:
- true if DR source balance
-
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
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
Get Account- Returns:
- account
-
toString
To String- Overrides:
toStringin classX_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_IDin interfaceI_Fact_Acct- Overrides:
getAD_Org_IDin classPO- Returns:
- AD_Org_ID
-
getC_SalesRegion_ID
public int getC_SalesRegion_ID()If not set yet(still 0), get/derive Sales Region from Doc, DocLine or Account Combination.- Specified by:
getC_SalesRegion_IDin interfaceI_Fact_Acct- Overrides:
getC_SalesRegion_IDin classX_Fact_Acct- Returns:
- C_SalesRegion_ID
-
beforeSave
protected boolean beforeSave(boolean newRecord) Description copied from class:POCalled before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.- Overrides:
beforeSavein classPO- Parameters:
newRecord- true if it is a new record- Returns:
- true if record can be saved
-
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- tableRecord_ID- recordLine_ID- linemultiplier- 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- tableRecord_ID- recordLine_ID- linemultiplier- targetQty/documentQtyotherLine- reversal line created before this. if not null, this reversal should reverse the opposite sign.- Returns:
- true if success
-
updateReverseLine
public boolean updateReverseLine(int AD_Table_ID, int Record_ID, int Line_ID, BigDecimal multiplier, FactLine otherLine, boolean updateTaxAndAmounts) Update Line with reversed Original Amount in Accounting Currency. Also copies original dimensions like Project, etc. Called from Doc_MatchInv- Parameters:
AD_Table_ID- tableRecord_ID- recordLine_ID- linemultiplier- targetQty/documentQtyotherLine- reversal line created before this. if not null, this reversal should reverse the opposite sign.updateTaxAndAmounts- define if it must update tax and amounts, useful if they are already set in the origin- 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
-
hasSameAccountingDimensions
Returns true if this FactLine and the given FactLine have the same accounting dimensions.- Parameters:
other- the FactLine to compare with- Returns:
- true if both FactLines have identical accounting dimensions
-