CSupplierTransaction
A Supplier Transaction is the Equivalent of a Standard transaction done in Evolution | Accounts Payable | Transactions | Standard. Supplier transactions affect the General Ledger and the Creditors Ledger and are typically used to post payments to suppliers since invoices done here do not affect Inventory or store as a source document.
The only required values are Account, Reference and TransactionCode. Notice how the Account property is set to an instance of the Customer class. The transaction code defines whether the transaction is a debit or credit (hence the Amount is always positive) and also determines which accounts to post to in the general ledger. There are a number of default transaction codes configured in a new Evolution database (such as IN and CN), but the list is often extended, so it would be wise to make transaction codes configurable in your application. Finally, the Post method is called. This processes the transaction to the account immediately and adjusts the account balance accordingly. Other interesting fields are the transaction date (defaults to current date), description (defaults to transaction code description) and order number (empty by default).
The following is a example of a Supplier Transaction using the IN Transaction Type
// Declare Supplier Transaction Class SupplierTransaction SuppTran = new SupplierTransaction(); //Instance of Supplier class SuppTran.Supplier = new Supplier("Supplier1"); SuppTran.TransactionCode = new TransactionCode(Module.AP, "IN"); SuppTran.TaxRate = new TaxRate("1"); SuppTran.Amount = 100; SuppTran.Reference = "AP_Ref1"; SuppTran.Description = "StringDescription"; //Post Method to Commit Transaction SuppTran.Post();
The following example posts supplier transactions as a batch using the same Audit number
{ ConsolidateSuppliers(); } private static GLBatch _batch = new GLBatch(); public static void ConsolidateSuppliers()//create method consolidatesuppliers { try { DatabaseContext.BeginTran(); _batch.Clear(); //Transaction 1 SupplierTransaction supptran = new SupplierTransaction(); supptran.GLDebitPosting += new TransactionBase.GLPostingEventHandler(supptran_GLDebitPosting); supptran.GLCreditPosting += new TransactionBase.GLPostingEventHandler(supptran_GLCreditPosting); supptran.Account = new Supplier("Supplier1"); supptran.Amount = 50; supptran.TaxRate = new TaxRate(7); supptran.Reference = supptran.Description = "inv1"; supptran.TransactionCode = new TransactionCode(Module.AP, "IN"); supptran.Post(); //Transaction 2 supptran = new SupplierTransaction(); supptran.GLDebitPosting += new TransactionBase.GLPostingEventHandler(supptran_GLDebitPosting); supptran.GLCreditPosting += new TransactionBase.GLPostingEventHandler(supptran_GLCreditPosting); supptran.Account = new Supplier("Supplier1"); supptran.Amount = 60; supptran.TaxRate = new TaxRate(7); supptran.Reference = supptran.Description = "inv2"; supptran.TransactionCode = new TransactionCode(Module.AP, "IN"); supptran.Post(); //Transaction 3 supptran = new SupplierTransaction(); supptran.GLDebitPosting += new TransactionBase.GLPostingEventHandler(supptran_GLDebitPosting); supptran.GLCreditPosting += new TransactionBase.GLPostingEventHandler(supptran_GLCreditPosting); supptran.Account = new Supplier("Supplier1"); supptran.Amount = 70; supptran.TaxRate = new TaxRate(7); supptran.Reference = supptran.Description = "inv3"; supptran.TransactionCode = new TransactionCode(Module.AP, "IN"); supptran.Post(); _batch.Post(); DatabaseContext.CommitTran(); } catch (Exception ex) { DatabaseContext.RollbackTran(); MessageBox.Show(ex.Message); } } static void supptran_GLCreditPosting(TransactionBase sender, TransactionBase.GLPostingEventArgs e) { _batch.Add((GLTransaction)e.GLTransaction.Clone()); e.Posted = true; } static void supptran_GLDebitPosting(TransactionBase sender, TransactionBase.GLPostingEventArgs e) { _batch.Add((GLTransaction)e.GLTransaction.Clone(), true, true); e.Posted = true; }