C Journal Batches
From Sage Evolution SDK | Documentation Portal
Revision as of 15:34, 22 October 2015 by Admin (Talk | contribs) (Created page with "Journal Batches can be created and populated by the SDK. However they cannot be processed. '''The following example displays how to create and save a Journal Batch.''' {...")
Journal Batches can be created and populated by the SDK. However they cannot be processed.
The following example displays how to create and save a Journal Batch.
{
string BatchNum = "JB002";
//check if Batch code exists in pastel
if (JournalBatch.FindByCode(BatchNum) == -1)
{
// Batch code does not exist, then create it
JournalBatch createbatch = new JournalBatch();
createbatch.Code = BatchNum;
createbatch.Description = "JB Batch";
createbatch.Owner = new Agent("Admin");
createbatch.Save();
}
JournalBatch batch = new JournalBatch(BatchNum);
var detail = new JournalBatchDetail();
detail.Date = DateTime.Today;
detail.Account = new GLAccount("Advertising");
detail.Debit = 500;
detail.Description = "So and so";
detail.Reference = "Ref001";
batch.Detail.Add(detail);
batch.Save();//Save each JournalBatchDetail seperately or comment out to save both together
detail = new JournalBatchDetail();
detail.Date = DateTime.Today;
detail.Account = new GLAccount("Advertising");
detail.Credit = 500;
detail.Description = "So and so";
detail.Reference = "Ref001";
detail.Tax = 50;
detail.TaxRate = new TaxRate(1);//Specify a tax type
detail.TaxAccount = new GLAccount("Accruals");//Specify a tax account
batch.Detail.Add(detail);
batch.Save();
//If required the clone method can be used to copy the previous line
batch = new JournalBatch(batch.Code);
batch.Detail.Add(detail.Clone());
batch.Save();
} - See more at: http://kb.pastel.co.za/article.php?id=1984#sthash.gr9H0QMI.dpuf