Journal Entry API

Overview

The following provides information regarding insertion and posting and un-posting API calls for the Journal Entry Object:

The following fields are required on the Journal Entry Object: AcctSeed__Journal_Entry__c

Field Name API Name Data Type
Journal Entry Name Name Text(80)

The following fields are required on the Journal Entry Line Object: AcctSeed__Journal_Entry_Line__c

Field Name API Name Data Type
Journal Entry Name Master Detail(Journal Entry)
Debit/Credit AcctSeed__Debit__c
AcctSeed__Credit__c
Currency(16,2)
GL Account AcctSeed__GLAccount__c Lookup(GL Account)

Either a debit or credit is required.

Journal Entry Post and Unpost

There is a global class in the 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.

Journal Entry Post Service Error Codes

The following error codes are supported for journal entry service:

Code Example

// 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'
    )
);

journalEntries.add(
    new AcctSeed__Journal_Entry__c(
        Name = 'My Journal Entry 2'
     )
);

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__Debit__c = 25;
    objJournalEntryLine.AcctSeed__GL_Account__c = glAccounts[0].Id;
    objJournalEntryLine.AcctSeed__Account__c = [select id from account limit 1].id;
    jeLines.add(objJournalEntryLine);

    objJournalEntryLine = new AcctSeed__Journal_Entry_Line__c();
    objJournalEntryLine.AcctSeed__Journal_Entry__c = journalEntry.id;
    objJournalEntryLine.AcctSeed__Credit__c = 25;
    objJournalEntryLine.AcctSeed__GL_Account__c = glAccounts[1].Id;
    objJournalEntryLine.AcctSeed__Account__c = [select id from account limit 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);
        }
    }
}