Package com.storedobject.core
Interface Financial
- All Known Implementing Classes:
CustomerInvoice,Invoice,JournalVoucher,SupplierInvoice
public interface Financial
The Financial interface represents a financial entity that can post ledger transactions.
It provides methods to check if the ledger is already posted and to post a ledger transaction.
It also provides a default method to post a ledger transaction using a TransactionManager.
- Author:
- Syam
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanDetermines whether the ledger can be reversed.static intgetBalanceType(Account account) Retrieves the balance type of the given account.static StringgetBalanceTypeValue(Account account) Retrieves the balance type value associated with the given account.static intgetCategory(Account account) Calculates and retrieves the category of the provided account based on its account status.static StringgetCategoryValue(Account account) Retrieves the category value of the given account.default JournalVouchergetReversalJournalVoucher(String reversalReason, boolean appendToNarration) Retrieves a reversal journal voucher based on the provided reversal reason and whether to append the reason to the narration.static intgetTransactionType(Account account) Determines the transaction type based on the account's status.static StringgetTransactionTypeValue(Account account) Retrieves the transaction type value for a given account.static booleanhasLimitCheck(Account account) Checks whether the given account has a limit check flag enabled.static booleanhasStrictBalanceControl(Account account) Determines if the given account has strict balance control enabled.static booleanisActive(SystemEntity systemEntity) Is a financial system active for this entity?static booleanIs a financial system active for this transaction manager?static booleanDetermines whether the provided account is classified as an asset.static booleanisDeepFrozen(Account account) Determines whether the provided account is deeply frozen.static booleanDetermines whether the given account qualifies as an expense.booleanChecks if the ledger is already posted.default booleanChecks whether the ledger is reversed.static booleanisLiability(Account account) Determines if the given account qualifies as a liability based on its category and balance type.static booleanDetermines if the provided account qualifies as a revenue account.static booleanDetermines if the given account is a special type of account.default List<JournalVoucher> Retrieves a list of journal vouchers associated with the current financial entity.voidpostLedger(TransactionManager transactionManager) Posts ledger transactions using the provided TransactionManager.default voidreverseLedger(TransactionManager transactionManager, String reversalReason, boolean appendToNarration) Reverses the ledger transactions using the provided transaction manager.default voidreverseLedger(Transaction transaction, String reversalReason, boolean appendToNarration) Reverses a ledger by creating and saving a reversal journal voucher for the provided transaction.
-
Method Details
-
isLedgerPosted
boolean isLedgerPosted()Checks if the ledger is already posted.- Returns:
- true if the ledger is already posted, false otherwise.
-
isLedgerReversed
default boolean isLedgerReversed()Checks whether the ledger is reversed.- Returns:
trueif the ledger is reversed,falseotherwise.
-
postLedger
Posts ledger transactions using the provided TransactionManager.- Parameters:
transactionManager- the TransactionManager used to post the ledger transaction- Throws:
Exception- if the ledger is already posted
-
canReverseLedger
default boolean canReverseLedger()Determines whether the ledger can be reversed. This method provides a default implementation that specifies the ledger cannot be reversed and always returns false. Override this method to customize the reversal behavior based on specific conditions.- Returns:
trueif the ledger can be reversed; otherwisefalse.
-
reverseLedger
default void reverseLedger(TransactionManager transactionManager, String reversalReason, boolean appendToNarration) throws Exception Reverses the ledger transactions using the provided transaction manager. This method delegates the reversal process to another method that works on a per-transaction basis.- Parameters:
transactionManager- the transaction manager used to handle the reversal processreversalReason- a string specifying the reason for the reversalappendToNarration- a boolean indicating whether to append the reversal reason to the narration- Throws:
Exception- if an error occurs during the reversal process
-
reverseLedger
default void reverseLedger(Transaction transaction, String reversalReason, boolean appendToNarration) throws Exception Reverses a ledger by creating and saving a reversal journal voucher for the provided transaction.- Parameters:
transaction- the transaction to be reversedreversalReason- the reason for reversing the transactionappendToNarration- whether to append the reversal reason to the narration- Throws:
Exception- if an error occurs during the reversal process
-
getReversalJournalVoucher
default JournalVoucher getReversalJournalVoucher(String reversalReason, boolean appendToNarration) throws Exception Retrieves a reversal journal voucher based on the provided reversal reason and whether to append the reason to the narration. This method performs the following checks: - Verifies that the ledger has been posted. - Confirms that the ledger supports reversal operations. - Ensures there is at least one journal voucher to reverse. If any of these conditions are not met, an exception is thrown.- Parameters:
reversalReason- the reason for reversing the journal voucherappendToNarration- a flag indicating whether the reversal reason should be appended to the voucher narration- Returns:
- the reversal journal voucher for the first available journal voucher
- Throws:
Exception- if: - the ledger is not posted, - the ledger does not support reversal, or - there are no journal vouchers to reverse
-
listJournalVouchers
Retrieves a list of journal vouchers associated with the current financial entity. If the current object is an instance ofStoredObject, it queries the relevant journal vouchers based on the owner's identifier. Otherwise, it returns an empty list.- Returns:
- a list of
JournalVoucherinstances tied to the financial entity, or an empty list if the object is not aStoredObject.
-
getCategory
Calculates and retrieves the category of the provided account based on its account status.- Parameters:
account- the account whose category is to be determined- Returns:
- an integer representing the category, determined by shifting the account's status bits and applying a mask
-
getCategoryValue
-
getBalanceType
Retrieves the balance type of the given account.- Parameters:
account- the account for which the balance type is to be determined- Returns:
- an integer representing the balance type, where the type is derived from the account's status
-
getBalanceTypeValue
-
getTransactionType
Determines the transaction type based on the account's status.- Parameters:
account- the account object whose status is used to determine the transaction type- Returns:
- an integer representing the calculated transaction type
-
getTransactionTypeValue
-
hasStrictBalanceControl
Determines if the given account has strict balance control enabled.- Parameters:
account- the account to evaluate- Returns:
trueif the account has strict balance control enabled,falseotherwise
-
hasLimitCheck
Checks whether the given account has a limit check flag enabled. This method examines the account's status by performing a bitwise operation to determine if the specific limit check flag is set.- Parameters:
account- the account to be checked- Returns:
- true if the account has the limit check flag enabled, false otherwise
-
isDeepFrozen
Determines whether the provided account is deeply frozen.- Parameters:
account- The account to check for the deep-frozen status.- Returns:
trueif the account is deeply frozen,falseotherwise.
-
isSpecial
Determines if the given account is a special type of account.- Parameters:
account- the account to check; can be an instance of AccountTitle, BranchAccount, or OffsetAccount- Returns:
- true if the account is an instance of AccountTitle, BranchAccount, or OffsetAccount; false otherwise
-
isAsset
Determines whether the provided account is classified as an asset.- Parameters:
account- the account to be evaluated- Returns:
- true if the account is categorized as an asset, otherwise false
-
isLiability
Determines if the given account qualifies as a liability based on its category and balance type.- Parameters:
account- the account to be evaluated- Returns:
- true if the account is classified as a liability, false otherwise
-
isExpense
Determines whether the given account qualifies as an expense.- Parameters:
account- the account to be checked.- Returns:
- true if the account's category is 1 and its balance type is 0, false otherwise.
-
isRevenue
Determines if the provided account qualifies as a revenue account.- Parameters:
account- The account object to be evaluated.- Returns:
trueif the account's category is 0 and the balance type is 1, otherwisefalse.
-
isActive
Is a financial system active for this entity?- Returns:
- True/false.
-
isActive
Is a financial system active for this transaction manager?- Returns:
- True/false.
-