c2g.CODAAPICashMatching_8_0global with sharing class CODAAPICashMatching_8_0 This service class provides cash matching functionality. Properties
Methods
Matchwebservice static c2g.CODAAPICommon.Reference Match(c2g.CODAAPICommon_8_0.Context context, c2g.CODAAPICashMatchingTypes_8_0.Configuration configuration, c2g.CODAAPICashMatchingTypes_8_0.Item[] items, c2g.CODAAPICashMatchingTypes_8_0.Analysis analysis) This service allows you to match outstanding transactions for a selected account. See "About Cash Matching" in the FinancialForce Help for more details. Input Parameters
Return ValueThis web service returns a CODAAPICommon.Reference object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Cash Matching API's Match method can be used to match Sales Invoice to Sales Credit Note. Below is the sample code //to perform that operation. //This is the account to which all SINs and SCNs belong. This is the account that you would choose if you //were doing cash matching from the UI. Account acct = [SELECT Id, Name FROM Account WHERE Name ='Cambridge Auto' LIMIT 1]; //Setup the match operation CODAAPICashMatchingTypes_8_0.Configuration configuration = new CODAAPICashMatchingTypes_8_0.Configuration(); configuration.Account = CODAAPICommon.getRef(acct.Id, null); //Choose Document or Account depending on the Currency Mode you would choose if you were doing this from the UI. configuration.MatchingCurrencyMode = CODAAPICashMatchingTypes_8_0.enumMatchingCurrencyMode.Document; //a4Q4K0000004ICMUA2 is the ID of the period you want to perform the cash matching for. CODAPeriod__c period = [SELECT Id, Name, StartDate__c FROM CODAPeriod__c WHERE Name = '2020/008' AND OwnerCompany__c = 'a4Q4K0000004ICMUA2']; //It can be taken as System.today(); if you want today's date on Cash Matching History Detail. This is the same Matching Date //as you would have chosen on the UI. configuration.MatchingDate = period.StartDate__c; //As the matching is happening today so you can choose today's date. This is the same Discount Date that is provided //from the cash matching UI. configuration.DiscountDate = System.today(); configuration.MatchingPeriod = CODAAPICommon.getRef(period.Id, null); //'32832059', '32832062' and '32832065' are the names of three documents SIN, SCN, Cash Entry(receipt) List<CODATransactionLineItem__c> transLines = [SELECT Id, Name, DocumentOutstandingValue__c, SystemModstamp FROM CODATransactionLineItem__c WHERE Name IN ('32832059', '32832062', '32832065')]; List<CODAAPICashMatchingTypes_8_0.Item> items = new List<CODAAPICashMatchingTypes_8_0.Item>(); for (CODATransactionLineItem__c trans : transLines) { CODAAPICashMatchingTypes_8_0.Item item = new CODAAPICashMatchingTypes_8_0.Item(); items.add(item); item.TransactionLineItem = CODAAPICommon.getRef(trans.Id, null); item.TransactionLineItemSystemModStamp = trans.SystemModstamp; if (trans.name == '32832059') {//name of TLI for SIN item.Paid = 110.0;//outstanding amount of SIN TLI item.Discount = 0; item.WriteOff = 0; } else if (trans.name =='32832062') {//name of TLI for SCN item.Paid = -22.0;//outstanding amount of SCN TLI item.Discount = 0; item.WriteOff = 0; } else if (trans.name =='32832065') {//name of TLI for CE item.Paid = -88.0;//amount of CE TLI item.Discount = 0; item.WriteOff = 0; } } // Finally, perform the match CODAAPICommon_8_0.Context context = new CODAAPICommon_8_0.Context(); //a4Q4K0000004ICMUA2 is the ID of the current company to which all these documents belong CODACompany__c company = [SELECT Id, Name, CustomerSettlementDiscount__c, CustomerWriteOff__c FROM CODACompany__c WHERE Id = 'a4Q4K0000004ICMUA2']; context.CompanyName = company.Name; CODAAPICashMatchingTypes_8_0.Analysis analysisInfoAPI = new CODAAPICashMatchingTypes_8_0.Analysis(); analysisInfoAPI.DiscountGLA = CODAAPICommon.getRef(company.CustomerSettlementDiscount__c, null); analysisInfoAPI.WriteOffGLA = CODAAPICommon.getRef(company.CustomerWriteOff__c, null); CODAAPICommon.Reference matchReference = CODAAPICashMatching_8_0.Match(context, configuration, items, analysisInfoAPI); //Verifying the results now. Below code is optional. System.assert(matchReference.Id != null); //'32832059', '32832062' and '32832065' are the names of TLIs for the documents which you just matched. List<CODATransactionLineItem__c> updatedTransLines = [SELECT Id, MatchingStatus__c, Name, DocumentOutstandingValue__c, Transaction__r.CashEntry__c, SystemModstamp FROM CODATransactionLineItem__c WHERE Name in ('32832059', '32832062', '32832065')]; for (CODATransactionLineItem__c updatedTrans : updatedTransLines) { System.assert(updatedTrans.MatchingStatus__c == 'Matched'); } Unmatchwebservice static c2g.CODAAPICommon.Reference Unmatch(c2g.CODAAPICommon_8_0.Context context, c2g.CODAAPICashMatchingTypes_8_0.Configuration configuration, c2g.CODAAPICommon.Reference matchingReference, c2g.CODAAPICashMatchingTypes_8_0.enumUndoReason undoReason) This service allows you to undo a previous match. See "About Cash Matching" in the FinancialForce Help for more details. Input Parameters
Return ValueThis web service returns a CODAAPICommon.Reference object. |