Difference between revisions of "C Cashbook Batches"

From Sage Evolution SDK | Documentation Portal
Jump to: navigation, search
(Created page with "Cashbook Batches can be created and populated by the SDK. However they cannot be processed through the SDK. '''The following example displays how to create and save a Cashboo...")
(No difference)

Revision as of 15:33, 22 October 2015

Cashbook Batches can be created and populated by the SDK. However they cannot be processed through the SDK.

The following example displays how to create and save a Cashbook Batch.

{

   string BatchNum = "CB001";
   //check if Batch code exists in pastel
   if (CashbookBatch.FindByCode(BatchNum) == -1)
   {
       // Batch code does not exist, so create it
       CashbookBatch createbatch = new CashbookBatch();
       createbatch.Code = BatchNum;
       createbatch.Description = "CB Batch";
       createbatch.Owner = new Agent("Admin");
       createbatch.Save();
   }

   CashbookBatch batch = new CashbookBatch(BatchNum);

   CashbookBatchDetail detail = new CashbookBatchDetail();
   detail.Date = DateTime.Today;
   detail.LineModule = CashbookBatchDetail.Module.Ledger;//Specify the line module
   detail.Account = new GLAccount("Advertising");
   detail.Credit = 500;
   detail.Description = "Ledger Transaction";
   detail.Reference = "Ref001";
   detail.Tax = 50;
   detail.TaxType = new TaxRate(1);//Specify a tax type
   detail.TaxAccount = new GLAccount("Accruals");//Specify a tax account
   batch.Detail.Add(detail);
   batch.Save();//Save each CashbookBatchDetail seperately or comment out to save all together

   detail = new CashbookBatchDetail();
   detail.Date = DateTime.Today;
   detail.LineModule = CashbookBatchDetail.Module.Payables;
   detail.Supplier = new Supplier("Supplier1");
   detail.Debit = 500;
   detail.Description = "Supplier Transaction";
   detail.Reference = "Ref001";
   batch.Detail.Add(detail);
   batch.Save();

   detail = new CashbookBatchDetail();
   detail.Date = DateTime.Today;
   detail.LineModule = CashbookBatchDetail.Module.Receivables;
   detail.Customer = new Customer("Customer1");
   detail.Debit = 500;
   detail.Description = "Customer Transaction";
   detail.Reference = "Ref001";
   batch.Detail.Add(detail);
   batch.Save();

   //If required the clone method can be used to copy the previous line
   batch = new CashbookBatch(batch.Code);
   batch.Detail.Add(detail.Clone());
   batch.Save();

} - See more at: http://kb.pastel.co.za/article.php?id=1985#sthash.ldpwc6QC.dpuf