Class APRM_MatchingUtility
- java.lang.Object
-
- org.openbravo.advpaymentmngt.utility.APRM_MatchingUtility
-
public class APRM_MatchingUtility extends Object
-
-
Constructor Summary
Constructors Constructor Description APRM_MatchingUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FIN_Reconciliation
addNewDraftReconciliation(FIN_FinancialAccount financialAccount)
Creates a new draft reconciliation for the given financial accountstatic void
createAndMatchFinancialTransaction(String strFinancialAccountId, String strTransactionType, Date transactionDate, String strFinBankStatementLineId, Organization organization, FIN_FinancialAccount account, FIN_Payment payment, String description, GLItem glItem, boolean isReceipt, BigDecimal depositAmt, BigDecimal paymentAmt, Currency paymentCurrency, BigDecimal convertRate, BigDecimal sourceAmount, Campaign campaign, Project project, ABCActivity activity, SalesRegion salesRegion, Product product, BusinessPartner businessPartner, UserDimension1 user1, UserDimension2 user2, Costcenter costcenter, FIN_BankStatementLine bankStatementLine, VariablesSecureApp vars, ConnectionProvider conn, boolean throwException)
Creates a new financial transaction from the given parameters.static org.codehaus.jettison.json.JSONArray
createMessageInProcessView(String messageSearchKey, String msgType, Object... messageParams)
Returns a JSONArray with a message to be shown in the process viewstatic void
fixMixedLine(FIN_FinaccTransaction mixedLine)
Fix wrong financial transaction of a reconciliationstatic void
fixMixedLines(FIN_Reconciliation reconciliation)
Fix wrong financial transactions of a reconciliation.static FIN_BankStatementLine
getLockedBSL(String id)
static org.hibernate.ScrollableResults
getPendingToBeMatchedBankStatementLines(String strFinancialAccountId, String strReconciliationId)
Get the bank statement lines that are not yet matched to a transaction for the given financial account.static int
matchBankStatementLine(FIN_BankStatementLine _bankStatementLine, List<String> transactionIds, FIN_Reconciliation reconciliation, String matchLevel, boolean throwException)
Improved version ofmatchBankStatementLine(FIN_BankStatementLine, FIN_FinaccTransaction, FIN_Reconciliation, String, boolean)
which can handle a list of transactions for the same bank statement line.static boolean
matchBankStatementLine(FIN_BankStatementLine bankStatementLine, FIN_FinaccTransaction transaction, FIN_Reconciliation reconciliation, String matchLevel, boolean throwException)
Match a bank statement line with a financial account transaction.static OBError
processReconciliation(String strAction, FIN_Reconciliation reconciliation)
Process to process a reconciliationstatic OBError
processTransaction(VariablesSecureApp vars, ConnectionProvider conn, String strAction, FIN_FinaccTransaction transaction)
It calls the Transaction Process for the given transaction and action.static void
removePayment(VariablesSecureApp vars, ConnectionProvider conn, FIN_Payment payment)
Removes a paymentstatic void
removeTransaction(VariablesSecureApp vars, ConnectionProvider conn, FIN_FinaccTransaction transaction)
Removes a financial account transactionstatic void
unmatch(FIN_BankStatementLine bsline)
Remove the match of a bank statement line with a transactionstatic boolean
updateReconciliation(FIN_Reconciliation reconciliation, FIN_FinancialAccount financialAccount, boolean process)
Updates the dates of a given reconciliation and if the process parameter is true it processes the reconciliation
-
-
-
Method Detail
-
fixMixedLines
public static void fixMixedLines(FIN_Reconciliation reconciliation)
Fix wrong financial transactions of a reconciliation. If the fix is not possible, it launches an OBException- Parameters:
reconciliation
- The reconciliation whose lines are to be fixed
-
fixMixedLine
public static void fixMixedLine(FIN_FinaccTransaction mixedLine)
Fix wrong financial transaction of a reconciliation- Parameters:
mixedLine
- The financial transaction to be fixed
-
processReconciliation
public static OBError processReconciliation(String strAction, FIN_Reconciliation reconciliation) throws Exception
Process to process a reconciliation- Parameters:
strAction
- String with the action of the process. {P, D, R}reconciliation
- Reconciliation that needs to be processed- Returns:
- returns error/success message
- Throws:
Exception
-
getLockedBSL
public static FIN_BankStatementLine getLockedBSL(String id)
-
matchBankStatementLine
public static int matchBankStatementLine(FIN_BankStatementLine _bankStatementLine, List<String> transactionIds, FIN_Reconciliation reconciliation, String matchLevel, boolean throwException)
Improved version ofmatchBankStatementLine(FIN_BankStatementLine, FIN_FinaccTransaction, FIN_Reconciliation, String, boolean)
which can handle a list of transactions for the same bank statement line. The Bank statement line will be automatically split (and linked) as many times as transactions are selected. Session is cleared after every 100 transaction.- Returns:
- the number of matched transactions
-
matchBankStatementLine
public static boolean matchBankStatementLine(FIN_BankStatementLine bankStatementLine, FIN_FinaccTransaction transaction, FIN_Reconciliation reconciliation, String matchLevel, boolean throwException)
Match a bank statement line with a financial account transaction. If the bank statement has associated a transaction, it is first unmatched and then matched against the given transaction. If the bank statement line amount is different from the transaction amount, the process will automatically split the bank statement line in two (seesplitBankStatementLine(FIN_Reconciliation, FIN_BankStatementLine, FIN_FinaccTransaction)
- Returns:
- If success, the method automatically flushes and returns true. In case of exceptions, the method will either throw the exception or return false. This behavior is controlled by the throwException boolean parameter
-
unmatch
public static void unmatch(FIN_BankStatementLine bsline)
Remove the match of a bank statement line with a transaction- Parameters:
bsline
- Bank Statement Line to be unmatched from a transaction
-
removeTransaction
public static void removeTransaction(VariablesSecureApp vars, ConnectionProvider conn, FIN_FinaccTransaction transaction)
Removes a financial account transaction- Parameters:
vars
- VariablesSecureApp with the session data.conn
- ConnectionProvider with the connection being used.transaction
- Financial Account Transaction to be removed
-
removePayment
public static void removePayment(VariablesSecureApp vars, ConnectionProvider conn, FIN_Payment payment)
Removes a payment- Parameters:
vars
- VariablesSecureApp with the session data.conn
- ConnectionProvider with the connection being used.payment
- Payment to be removed
-
processTransaction
public static OBError processTransaction(VariablesSecureApp vars, ConnectionProvider conn, String strAction, FIN_FinaccTransaction transaction) throws Exception
It calls the Transaction Process for the given transaction and action.- Parameters:
vars
- VariablesSecureApp with the session data.conn
- ConnectionProvider with the connection being used.strAction
- String with the action of the process. {P, D, R}transaction
- FIN_FinaccTransaction that needs to be processed.- Returns:
- a OBError with the result message of the process.
- Throws:
Exception
-
getPendingToBeMatchedBankStatementLines
public static org.hibernate.ScrollableResults getPendingToBeMatchedBankStatementLines(String strFinancialAccountId, String strReconciliationId)
Get the bank statement lines that are not yet matched to a transaction for the given financial account. If the reconciliation passed as parameter is the last one, the method filters by the bank statement lines with transaction date less or equal than the reconciliation's ending date
-
addNewDraftReconciliation
public static FIN_Reconciliation addNewDraftReconciliation(FIN_FinancialAccount financialAccount)
Creates a new draft reconciliation for the given financial account
-
updateReconciliation
public static boolean updateReconciliation(FIN_Reconciliation reconciliation, FIN_FinancialAccount financialAccount, boolean process)
Updates the dates of a given reconciliation and if the process parameter is true it processes the reconciliation
-
createMessageInProcessView
public static org.codehaus.jettison.json.JSONArray createMessageInProcessView(String messageSearchKey, String msgType, Object... messageParams) throws org.codehaus.jettison.json.JSONException
Returns a JSONArray with a message to be shown in the process view- Parameters:
messageSearchKey
- String with the message to translate (seeOBMessageUtils.translateError(String)
msgType
- error, warning, success, infomessageParams
- parameters to be applied to the message text usingString.format(String, Object...)
- Returns:
- a JSONArray with a message to be shown in the process view
- Throws:
org.codehaus.jettison.json.JSONException
-
createAndMatchFinancialTransaction
public static void createAndMatchFinancialTransaction(String strFinancialAccountId, String strTransactionType, Date transactionDate, String strFinBankStatementLineId, Organization organization, FIN_FinancialAccount account, FIN_Payment payment, String description, GLItem glItem, boolean isReceipt, BigDecimal depositAmt, BigDecimal paymentAmt, Currency paymentCurrency, BigDecimal convertRate, BigDecimal sourceAmount, Campaign campaign, Project project, ABCActivity activity, SalesRegion salesRegion, Product product, BusinessPartner businessPartner, UserDimension1 user1, UserDimension2 user2, Costcenter costcenter, FIN_BankStatementLine bankStatementLine, VariablesSecureApp vars, ConnectionProvider conn, boolean throwException) throws Exception
Creates a new financial transaction from the given parameters. If the strFinBankStatementLineId is not blank, then it tries to match the new transaction to the bank statement line- Throws:
Exception
-
-