Cash Receipt API
Overview
The following provides information when using the API for the creation of Cash Receipt records including the following:
- Object API names
- Required fields for inserting a record
- Post & Unpost Apex Class methods
The cash receipt object is a common integration point for the Accounting Seed Financial Suite. Please note the following:
- The cash receipt is a single object. The billing cash receipt is a junction object that matches a cash receipt to a billing.
- Both the cash receipt and billing cash receipt automatically post when a record is created. There is no need to call a posting process.
- Below are the required fields for cash receipt and billing cash receipt.
The following fields are required on the cash receipt object: AcctSeed__Cash_Receipt__c
Field Name | API Name | Data Type |
---|---|---|
Customer | AcctSeed__Account__c |
Lookup(Account) |
Payment Reference | AcctSeed__Amount__c |
Text(255) |
Amount | AcctSeed__Amount__c |
Currency(16,2) |
The following fields are required on the Billing Cash Receipt object: AcctSeed__Billing_Cash_Receipt__c
Field Name | API Name | Data Type |
---|---|---|
Billing | AcctSeed__Billing__c |
Master-Detail(Billing) |
Cash Receipt | AcctSeed__Cash_Receipt__c |
Master-Detail(Cash Receipt) |
Accounting Period | AcctSeed__Accounting_Period__c |
Lookup(Accounting Period) |
Amount | AcctSeed__Applied_Amount__c |
Currency(16,2) |
Cash Receipt Post and Unpost
The following provides information when using the API for the posting or unposting a Cash Receipt via Apex Code. With the release of Accounting Seed Financial Suite 2.21, there is a global class in the Accounting Seed Financial Suite managed package called CashReceiptPostService. This class can be called through Apex Code external to the Accounting Seed Financial Suite package to post or unpost a set of cash receipt records. Please note the following:
This class contains two static global methods. One of the static methods is related to posting cash receipt records and is called postCashReceipts. The other static method is related to unposting cash receipt records and is called unpostCashReceipts.
You cannot call either the post or unpost methods with a set of cash receipt records where the number of cash receipts is more than 1,000. If you need to post or unpost more than 1,000 cash receipts, 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 billing 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 Receipt Post Service Error Codes
Cash Receipt Post Method
- LINE_COUNT_LIMIT_EXCEEDED - Attempted to post a set of cash receipt records where the number of cash receipts exceeds 1,000.
- STATUS_NOT_APPROVED - The billing posting status is not approved.
- ALREADY_POSTED - Record you are attempting to post is already posted.
- NO_UNAPPLIED_CASH_CONTROL_ACCOUNT_DEFINED - No Unapplied Cash GL Control Account is defined on the accounting settings tab.
- CLOSED_ACCOUNTING_PERIOD - The accounting period associated with the cash receipt is closed.
- SYSTEM_EXCEPTION - Internal exception.
Cash Receipt Unpost Method
- LINE_COUNT_LIMIT_EXCEEDED - Attempted to post a set of cash receipt records where the number of cash receipts exceeds 1,000.
- BILLING_CASH_RECEIPTS_EXIST - Billing cash receipts exist associated with the cash receipt. You must delete all billing cash receipts before you can unpost.
- CLEARED_BANK_RECONCILIATION -The cash receipt is associated with a bank reconciliation. You must unassociate the cash receipt from the bank reconciliation before you have unpost.
- CLEARED_BANK_DEPOSIT - The cash receipt is associated with a bank deposit. You must unassociate the cash receipt from the bank deposit before you have unpost.
- CLOSED_ACCOUNTING_PERIOD - The accounting period associated with the cash receipt is closed.
- SYSTEM_EXCEPTION - Internal exception.
Code Example
// Create cash receipt records to post and unpost
AcctSeed__Cash_Receipt__c[] receipts = new List <AcctSeed__Cash_Receipt__c>();
receipts.add(
new AcctSeed__Cash_Receipt__c(
AcctSeed__Account__c = [Select Id From Account limit 1].Id,
AcctSeed__Amount__c = 34,
AcctSeed__Payment_Reference__c = 'ThisIsATestPaymentReference123'
)
);
receipts.add(
new AcctSeed__Cash_Receipt__c(
AcctSeed__Account__c = [Select Id From Account limit 1].Id,
AcctSeed__Amount__c = 67,
AcctSeed__Payment_Reference__c = 'ThisIsATestPaymentReference456'
)
);
// Initial insert auto posts cash receipts
insert receipts;
// Unpost the cash receipts
AcctSeed.PostResult[] unpostResults = AcctSeed.CashReceiptPostService.unpostCashReceipts(receipts);
// Loop through unpost results
for (AcctSeed.PostResult theResult : unpostResults) {
if (theResult.isSuccess) {
System.debug('Successfully unposted cash receipt: ' + theResult.id);
}
else {
System.debug('Error unposting cash receipt ' + theResult.id);
for (AcctSeed.PostResult.PostErrorResult errorResult: theResult.errors) {
System.debug('Error status code ' + errorResult.statusCode);
System.debug('Error message ' + errorResult.message);
}
}
}
// Post the cash receipts
AcctSeed.PostResult[] postResults = AcctSeed.CashReceiptPostService.postCashReceipts(receipts);
// Loop through post results
for (AcctSeed.PostResult theResult : postResults) {
if (theResult.isSuccess) {
System.debug('Successfully posted billing: ' + 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);
}
}
}