Overview
- Object API names
- Required fields for inserting a record
- Post and Unpost via a Global Class
Field Name | API Name | Type |
Cash Disbursement Batch | AcctSeed__Cash_Disbursement_Batch__c | Master-Detail (Cash Disbursement Batch) |
Check Reference Note: Check is used if paper check, Reference is used for electronic payment |
AcctSeed__Check_Number__c AcctSeed__Reference__c |
Number (18,0) Text (200) |
Disbursement Date | AcctSeed__Disbursement_Date__c | Date |
Amount | AcctSeed__Amount__c | Currency 16,2 |
Vendor | AcctSeed__Vendor__c | Lookup Account |
Accounting Period | AcctSeed__Accounting_Period__c | Lookup Accounting Period |
Debit GL Account | AcctSeed__Debit_GL_Account__c | Lookup GL Account |
Bank Account | AcctSeed__Bank_Account__c | Lookup GL Account |
Type | AcctSeed__Type__c | Pick list (Check, Electronic) |
Overview
There is a global class in the Accounting Seed Financial Suite managed package called CashDisbursementPostService. This class can be called through Apex Code external to the Accounting Seed Financial Suite package to post or unpost a set of cash disbursement records.
Please note the following:
-
This class contains two static global methods. One of the static methods is related to posting account payable records and is called postCashDisbursements. The other static method is related to unposting account payable records and is called unpostCashDisbursements.
-
You cannot call either the post or unpost methods with a set of cash disbursement records of more than 1,000. If you need to post or unpost more than 1,000 cash disbursements, you will need to call the class static method from a class which supports batch apex.
-
Each method returns a list of post result records, which will indicate if the account payable was posted or unposted successfully. If the record was not posted or unposted successfully, an error status code is provided documenting the reason the record was not posted or unposted.
-
The following error status codes are supported for the CashDisbursementPostService class:
Cash Disbursement Post Method
-
LINE_COUNT_LIMIT_EXCEEDED - Attempted to post a set of cash disbursement with a count greater than 1,000.
-
CLOSED_ACCOUNTING_PERIOD - Accounting period associated with the account payable is closed.
-
PAYMENT_STATUS_VOID - The cash disbursement has been voided and cannot be posted.
-
ALREADY_POSTED - The record has already been posted.
-
NO_CONTROL_AP_ACCOUNT_DEFINED – An Account Payable GL Account needs to be defined on the account settings tab to post the account payable records.
-
SYSTEM_EXCEPTION - Internal exception.
Cash Disbursement Unpost Method
-
LINE_COUNT_LIMIT_EXCEEDED - Attempted to unpost a set of cash disbursement with a count greater than 1,000.
- CLOSED_ACCOUNTING_PERIOD - Accounting period associated with the account payable is closed.
- CLEARED_BANK_RECONCILIATION - The cash disbursement is associated with a bank reconciliation and cannot be unposted.
- SYSTEM_EXCEPTION - Internal exception.
Example using the CashDisbursementPostService class to post and unpost a set of cash disbursement records.
// Create cash disbursement records to post and unpost AcctSeed__Cash_Disbursement_Batch__c[] cashDisbursementBatch = new List<AcctSeed__Cash_Disbursement_Batch__c>(); cashDisbursementBatch.add( new AcctSeed__Cash_Disbursement_Batch__c( AcctSeed__Starting_Check_Number__c = 1, Name = 'Test Batch' ) ); cashDisbursementBatch.add( new AcctSeed__Cash_Disbursement_Batch__c( AcctSeed__Starting_Check_Number__c = 2, Name = 'Test Batch 2' ) ); insert cashDisbursementBatch; AcctSeed__Cash_Disbursement__c[] cashDisbursements = new List<AcctSeed__Cash_Disbursement__c>(); AcctSeed__GL_Account__c glAccount = [Select Id From AcctSeed__GL_Account__c Where AcctSeed__Bank__c = true limit 1]; Account acct = [Select Id From Account Limit 1]; Contact contact = [Select Id From Contact Limit 1]; AcctSeed__Accounting_Period__c acctPeriod = [Select Id, AcctSeed__Start_Date__c From AcctSeed__Accounting_Period__c Where AcctSeed__Status__c = 'Open' Limit 1]; cashDisbursements.add( new AcctSeed__Cash_Disbursement__c( AcctSeed__Cash_Disbursement_Batch__c = cashDisbursementBatch[0].Id, AcctSeed__Amount__c = 12, AcctSeed__Bank_Account__c = glAccount.Id, AcctSeed__Vendor__c = acct.Id, AcctSeed__Accounting_Period__c = acctPeriod.Id ) ); cashDisbursements.add( new AcctSeed__Cash_Disbursement__c( AcctSeed__Cash_Disbursement_Batch__c = cashDisbursementBatch[0].Id, AcctSeed__Amount__c = 123, AcctSeed__Bank_Account__c = glAccount.Id, AcctSeed__Contact__c = contact.Id, AcctSeed__Accounting_Period__c = acctPeriod.Id ) ); insert cashDisbursements; // Call the post service AcctSeed.PostResult[] postResults = AcctSeed.CashDisbursementPostService.postCashDisbursements(cashDisbursements); // Loop through post results for (AcctSeed.PostResult theResult : postResults) { if (theResult.isSuccess) { System.debug('Successfully posted cash disbursement: ' + theResult.id); } else { System.debug('Error posting cash disbursement ' + theResult.id); for (AcctSeed.PostResult.PostErrorResult errorResult: theResult.errors) { System.debug('Error status code ' + errorResult.statusCode); System.debug('Error message ' + errorResult.message); } } } // Call the unpost service AcctSeed.PostResult[] unpostResults = AcctSeed.CashDisbursementPostService.unpostCashDisbursements(cashDisbursements); // Loop through unpost results for (AcctSeed.PostResult theResult : unpostResults) { if (theResult.isSuccess) { System.debug('Successfully unposted cash disbursement: ' + theResult.id); } else { System.debug('Error unposting cash disbursement ' + theResult.id); for (AcctSeed.PostResult.PostErrorResult errorResult: theResult.errors) { System.debug('Error status code ' + errorResult.statusCode); System.debug('Error message ' + errorResult.message); } } }
Comments
0 comments
Article is closed for comments.