@IsTest
private class
CreateTransactionTest
{
@IsTest
private
static void
createTransaction()
{
System.runAs([select Id from User where Id = :UserInfo.getUserId()][0])
{
Test.startTest();
c2g__codaCompany__c company = c2g.CODAAPICompany_2_0.CreateTestCompany('ApexTestCompany', null, null);
Test.stopTest();
}
System.assertEquals('ApexTestCompany', c2g.CODAAPICompany_2_0.GetCurrentCompanies(null)[0]);
c2g__codaGeneralLedgerAccount__c gla = new
c2g__codaGeneralLedgerAccount__c();
gla.Name = 'Brochures';
gla.c2g__ReportingCode__c = 'xyz1';
gla.c2g__Type__c = 'Balance Sheet';
insert gla;
c2g__codaJournal__c journal = new
c2g__codaJournal__c();
journal.c2g__JournalDate__c = Date.today();
insert journal;
c2g__codaJournalLineItem__c journalLine1 = new
c2g__codaJournalLineItem__c();
journalLine1.c2g__LineType__c = 'General Ledger Account';
journalLine1.c2g__Journal__c = journal.Id;
journalLine1.c2g__GeneralLedgerAccount__c = gla.Id;
journalLine1.c2g__Value__c = 42;
c2g__codaJournalLineItem__c journalLine2 = new
c2g__codaJournalLineItem__c();
journalLine2.c2g__LineType__c = 'General Ledger Account';
journalLine2.c2g__Journal__c = journal.Id;
journalLine2.c2g__GeneralLedgerAccount__c = gla.Id;
journalLine2.c2g__Value__c = -42;
insert new
List<c2g__codaJournalLineItem__c> {journalLine1, journalLine2};
c2g.CODAAPIJournal_12_0.PostJournal(null, c2g.CODAAPICommon.getRef(journal.Id, null));
System.assertEquals(0, [select c2g__DocumentTotal__c from c2g__codaTransaction__c LIMIT 1][0].c2g__DocumentTotal__c);
}
}