Simple transaction with number range
The following section describes how transactions with an associated number range can be created.
Example code
// Load transactions via LoadTransactions()
errorcode = manager.LoadTransactions();
// Add error handling here
// Load Num Ranges
errorcode = manager.LoadNumRanges();
// Add error handling here
IData noRangeData = manager.NumRanges;
int numRangeID = 0;
int currNo = -1;
// Find Number Range DAta
foreach (INumRange nr in noRangeData) {
if (nr.Code == "Lohn") {
numRangeID = nr.ID;
currNo = nr.CurrNum;
}
}
// Create a transaction instance
ITransaction transaction = new Transaction();
// Assign number range to transaction
transaction.NumRangeFID = numRangeID;
transaction.TransactionTypeFID = (int)TransactionType.Simple;
// Set transaction DocNum. Topal will therefore
// retrieve the next available Number from Database the given number range
transaction.DocNum = currNo;
transaction.DocType = "LO";
DateTime date = DateTime.Today;
transaction.DocDate = new DateTime(date.Year, date.Month, date.Day);
manager.LoadAccounts();
IPosting posting1 = new Posting();
posting1.AccountFID = manager.FindAccountID("1020");
posting1.Text = "Test Case Single Transaction Posting #1";
posting1.FreeCode = "SN_1002";
posting1.Amount = paymentAmount;
posting1.FcAmount = paymentAmount;
posting1.ExchangeRate = 1;
posting1.IsDebit = true;
posting1.IsInclusive = false;
IPosting posting2 = new Posting();
posting2.AccountFID = manager.FindAccountID("3200");
posting2.Text = "TestCase Single Transaction Posting #2";
posting2.FreeCode = "Free 2";
posting2.Amount = paymentAmount;
posting2.FcAmount = paymentAmount;
posting2.ExchangeRate = 1;
posting2.IsDebit = false;
posting2.IsInclusive = false;
transaction.Postings.Add(posting1);
transaction.Postings.Add(posting2);
errorcode = manager.SaveTransaction(transaction);
// Add error handling here
UNDER CONSTRUCTION