Payable API

Overview

The following provides information when using the API for the creation of records in the Account Payable cycle of Accounting Seed including the following:

The following fields are required on the Payable object: AcctSeed__Account_Payable__c

Field Name API Name Data Type
Vendor AcctSeed__Vendor__c Lookup(Account)
Contact AcctSeed__Contact__c Lookup(Contact)
Employee AcctSeed__Employee__c Lookup(User)
Payment Reference AcctSeed__Amount__c Text(255)
Payee Reference AcctSeed__Payee_Reference__c Text(255)

Either a Vendor, Contact, or Employee is required.

The following fields are required on the Payable Line object: AcctSeed__Account_Payable_Line__c

Field Name API Name Data Type
Payable AcctSeed__Account_Payable__c Master-Detail(Account Payable)
Unit Cost AcctSeed__Unit_Cost__c Currency(16,2)
Quantity AcctSeed__Quantity__c Number(12,6)
Expense GL Account AcctSeed__Expense_GL_Account__c Lookup(GL Account)

Payable Post and Unpost

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:

Payable Post Service Error Codes

Account Payable Post Method

Account Payable Unpost Method

Code Example

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