Overview
- Object API names
- Required fields for inserting a record
- Post and Unpost via Global Class
Field Name | API Name | Type |
Vendor Contact Employee Either an Account, Contact or User can be a payee. One is required and only on can be used. |
AcctSeed__Vendor__c AcctSeed__Contact__c AcctSeed__Employee__c |
Lookup (Account) Lookup(Contact) Lookup (User) |
Payee Reference | AcctSeed__Payee_Reference__c | Text (250) |
Field Name | API Name | Type |
Account Payable | AcctSeed__Account_Payable__c | Master-Detail (Account Payable) |
Amount__c | AcctSeed__Amount__c | Currency (16,2) |
Expense GL Account This field is not needed if a default Expense GL Account is set on the Account |
AcctSeed__Expense_GL_Account__C | Lookup (GL Account) |
The following provides information when using the API for the creation of records in the Account Payable cycle.
There is a global class in the Accounting Seed Financial Suite managed package called AccountPayablePostService. This class can be called through Apex Code external to the Accounting Seed Financial Suite package to post or unpost a set of account payable 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 postAccountPayables. The other static method is related to unposting account payable records and is called unpostAccountPayables.
You cannot call either the post or unpost methods with a set of account payable records where the aggregate line count is more than 1,000 account payable lines. If you need to post or unpost more than 1,000 account payable lines, 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 AccountPayablePostService class:
Account Payable Post Method
LINE_COUNT_LIMIT_EXCEEDED - Attempted to post a set of account payable records where the aggregate number of account payable lines exceeded 1,000.
CLOSED_ACCOUNTING_PERIOD - Accounting period associated with the account payable is closed.
ALREADY_POSTED - The record has already been posted.
STATUS_NOT_APPROVED - The account payable status is not approved.
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.
Account Payable Unpost Method
LINE_COUNT_LIMIT_EXCEEDED - Attempted to unpost a set of account payable records where the aggregate number of account payable lines exceeded 1,000.
CLOSED_ACCOUNTING_PERIOD - Accounting period associated with the account payable is closed.
AP_DISBURSEMENTS_EXIST – Account payable record has associated AP disbursement records and cannot be un-posted.
AP_CREDIT_MEMOS_EXIST - AP credit memo exist which are associated with this account payable. You must delete all AP credit memos before you can unpost.
SYSTEM_EXCEPTION - Internal exception.
Example using the AccountPayablePostService class to post and unpost a set of account payable records.
// Create account payable records to post and unpost AcctSeed__Account_Payable__c[] payables = new List <AcctSeed__Account_Payable__c> (); payables.add( new AcctSeed__Account_Payable__c( AcctSeed__Vendor__c = [Select Id From Account limit 1].Id, AcctSeed__Payee_Reference__c = 'ThisIsATestPayeeReference123' ) ); payables.add( new AcctSeed__Account_Payable__c( AcctSeed__Vendor__c = [Select Id From Account limit 1].Id, AcctSeed__Payee_Reference__c = 'ThisIsATestPayeeReference456' ) ); insert payables; // Create account payable line records to post and unpost AcctSeed__Account_Payable_Line__c[] apLines = new List <AcctSeed__Account_Payable_Line__c> (); AcctSeed__GL_Account__c glAccount = [Select Id From AcctSeed__GL_Account__c Where AcctSeed__Type__c = 'Expense' limit 1]; for (AcctSeed__Account_Payable__c ap : payables) { AcctSeed__Account_Payable_Line__c apLine = new AcctSeed__Account_Payable_Line__c(); apLine.AcctSeed__Account_Payable__c = ap.Id; apLine.AcctSeed__Amount__c = 45; apLine.AcctSeed__Expense_GL_Account__c = glAccount.Id; apLines.add(apLine); apLine = new AcctSeed__Account_Payable_Line__c(); apLine.AcctSeed__Account_Payable__c = ap.Id; apLine.AcctSeed__Amount__c = 25; apLine.AcctSeed__Expense_GL_Account__c = glAccount.Id; apLines.add(apLine); } insert apLines; // Call the post service AcctSeed.PostResult[] postResults = AcctSeed.AccountPayablePostService.postAccountPayables(payables); // Loop through post results for (AcctSeed.PostResult theResult : postResults) { if (theResult.isSuccess) { System.debug('Successfully posted account payable: ' + theResult.id); } else { System.debug('Error posting account payable ' + 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.AccountPayablePostService.unpostAccountPayables(payables); // Loop through unpost results for (AcctSeed.PostResult theResult : unpostResults) { if (theResult.isSuccess) { System.debug('Successfully unposted account payable: ' + theResult.id); } else { System.debug('Error unposting account payable ' + 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.