Cash Disbursement API

Overview

The following provides information when using the API for the creation of records in the Cash Disbursement recognition cycles of Accounting Seed including the following:

Cash disbursements represent funds paid to a vendor. Below are the required fields for a Cash Disbursement.

Field Name API Name Data Type
Cash Disbursement Batch AcctSeed__Cash_Disbursement_Batch__c Lookup(Account)
Check Number AcctSeed__Check_Number__c Number(18,0)
Check Reference AcctSeed__Amount__c 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 Picklist(Check, Electronic)

Check is used if paper check, Reference is used for electronic payment

Cash Disbursement Post and Unpost

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.

Cash Disbursement Post Service Error Codes

The following error status codes are supported for the CashDisbursementPostService class:

Cash Disbursement Post Method

Cash Disbursement Unpost Method

Code Example

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