The following information provides Object API names, Required Fields, and information regarding posting and un-posting API calls.  
 
Journal Entry
The following fields are required on the Journal Entry Object: AcctSeed__Journal_Entry__c
Field Name    API Name Type
Journal Entry Name Name Text(80)
Journal Date AcctSeed__Journal_Date__c  Date
 
 
 
 
 
 
The following fields are required on the Journal Entry Line Object: AcctSeed__Journal_Entry_Line__c
 Field Name  API Name  Type  Notes
 Journal Entry  AcctSeed_Journal_Entry__c  Master Detail (Journal Entry)  
 Debit
 Credit
 AcctSeed__Debit__c
 AcctSeed__Credit__c
 Currency(16,2)  Either a debit or credit is required.
 GL Account  AcctSeed__GLAccount__c  Lookup (GL Account)  
 
Posting A Journal Entry Utilizing The Salesforce API 
There is a global class in the Accounting Cloud package called JournalEntryPostService. This class contains two static global methods. One is related to posting journal entry records called postJournalEntries and another is related to un-posting journal entry records called unpostJournalEntries.
 
You cannot call either method with more than 1,000 journal entry lines. If you need to post or un-post more than 1,000 journal entry lines you will need to call the class static method from a class which implements the Apex batchable interface.
 
Each method returns a list of post result records which will indicate if the journal entry was posted or un-posted successfully. If the record was not posted or un-posted successfully, an error code is provided, documenting the reason the record was not posted or un-posted.
 
The following error codes are supported for journal entry service:
  • LINE_COUNT_LIMIT_EXCEEDED - attempted to post a set of journal entry records where the aggregate number of lines exceeded 1000.
  • NO_LINES – the journal entry record does not have any associated journal entry lines and cannot be posted.
  • CLOSED_ACCOUNTING_PERIOD - accounting period associated with the journal entry is closed.
  • ALREADY_POSTED - record is already posted you are attempting to post
  • STATUS_NOT_APPROVED - record attempting to post has a status not equal to approved
  • ALREADY_UNPOSTED - record you are attempting to unpost is not posted
  • CREDITS_DEBITS_NOT_EQUAL - total number of credits do not equal total number of debits for the journal entry
  • CLEARED_BANK_RECONCILIATION - attempted to unpost a journal entry that has a journal entry line associated with a bank reconciliation
  • CLEARED_BANK_DEPOSIT - attempted to unpost a journal entry that has a journal entry line associated with a bank deposit

 

Example using the JournalEntryPostService class to post and unpost a set of journal entry records.
// Create account payable records to post and unpost
AcctSeed__Journal_Entry__c[] journalEntries = new List <AcctSeed__Journal_Entry__c>();
journalEntries.add(
new AcctSeed__Journal_Entry__c(
Name = 'My Journal Entry 1',
AcctSeed__Status__c = 'Approved',
AcctSeed__Journal_Date__c = System.today() + 30
)
);

journalEntries.add(
new AcctSeed__Journal_Entry__c(
Name = 'My Journal Entry 2',
AcctSeed__Status__c = 'Approved',
AcctSeed__Journal_Date__c = System.today() + 30
)
);

insert journalEntries;

// Create journal entry line records to post and unpost
AcctSeed__Journal_Entry_Line__c[] jeLines = new List <AcctSeed__Journal_Entry_Line__c> ();
List<AcctSeed__GL_Account__c> glAccounts = [Select Id From AcctSeed__GL_Account__c limit 2];

for (AcctSeed__Journal_Entry__c journalEntry : journalEntries) {
AcctSeed__Journal_Entry_Line__c objJournalEntryLine = new AcctSeed__Journal_Entry_Line__c();
objJournalEntryLine.AcctSeed__Journal_Entry__c = journalEntry.id;
objJournalEntryLine.AcctSeed__Date__c = System.today();
objJournalEntryLine.AcctSeed__Debit__c = 25;
objJournalEntryLine.AcctSeed__GL_Account__c = glAccounts[0].Id;
jeLines.add(objJournalEntryLine);

objJournalEntryLine = new AcctSeed__Journal_Entry_Line__c();
objJournalEntryLine.AcctSeed__Journal_Entry__c = journalEntry.id;
objJournalEntryLine.AcctSeed__Date__c = System.today();
objJournalEntryLine.AcctSeed__Credit__c = 25;
objJournalEntryLine.AcctSeed__GL_Account__c = glAccounts[1].Id;
jeLines.add(objJournalEntryLine);
}

insert jeLines;

// Call the post journal entry service
AcctSeed.PostResult[] postResults = AcctSeed.JournalEntryPostService.postJournalEntries(journalEntries);

// Loop through post results
for (AcctSeed.PostResult theResult : postResults) {
if (theResult.isSuccess) {
System.debug('Successfully posted journal entry: ' + theResult.id);
}
else {
System.debug('Error posting billing ' + 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 journal entry service
AcctSeed.PostResult[] unpostResults = AcctSeed.JournalEntryPostService.unpostJournalEntries(journalEntries);

// Loop through unpost results
for (AcctSeed.PostResult theResult : unpostResults) {
if (theResult.isSuccess) {
System.debug('Successfully unposted journal entry: ' + theResult.id);
}
else {
System.debug('Error unposting journal entry ' + theResult.id);
for (AcctSeed.PostResult.PostErrorResult errorResult: theResult.errors) {
System.debug('Error status code ' + errorResult.statusCode);
System.debug('Error message ' + errorResult.message);
}
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Dmitri Goncharov

    What are function names and return types in the JournalEntryPostService class? 

  • 0
    Avatar
    Chris Johnson

    Hi Dmitri,

    This article has been updated with an example using the JournalEntryPostService class.

Please sign in to leave a comment.