Difference between revisions of "CSupplierAllocations"

From Sage Evolution SDK | Documentation Portal
Jump to: navigation, search
(Created page with "Supplier Transactions like Invoices can be allocated to Contra Supplier Transactions like Supplier Payments. All Supplier related transactions will appear in the PostAP table....")
(No difference)

Revision as of 12:47, 22 October 2015

Supplier Transactions like Invoices can be allocated to Contra Supplier Transactions like Supplier Payments. All Supplier related transactions will appear in the PostAP table. In PostAP Accountlink determines which Supplier Account the transaction is for and the outstanding field determines what amount can still be allocated. A fully Allocated transaction will have a outstanding value of 0.

The callocs field contains the allocation to the related transaction an example would be I=6;A=50;D=20150622 where I = Autoidx , A = Amount Allocated , D = Allocation Date

To Allocate two transactions you would require the Autoidx of the transaction in the PostAP for both transactions as follows:

SupplierTransaction invoice = new SupplierTransaction(5);// AutoIdx of debit transaction in PostAP table SupplierTransaction payment = new SupplierTransaction(8);// AutoIdx of credit transaction in PostAP table invoice.Allocations.Add(payment); invoice.Allocations.Save(); Allocations can also be done at the time of posting as folows:

//An invoice is posted. SupplierTransaction invoice = new SupplierTransaction(); invoice.Account = new Supplier("Supplier1"); invoice.TransactionCode = new TransactionCode(Module.AP, "IN"); invoice.Amount = 500.50; invoice.TaxRate = new TaxRate(7); invoice.Reference = "SINV12348902"; invoice.Description = "Supplier Invoice"; invoice.Post();

//A payment is posted. SupplierTransaction payment = new SupplierTransaction(); payment.Account = new Supplier("Supplier1"); payment.TransactionCode = new TransactionCode(Module.AP, "PM"); payment.Amount = 1000.00; payment.Reference = "EFT"; payment.Description = "Payment"; payment.Post();

//We allocate the in-memory payment object to the invoice object invoice.Allocations.Add(payment); //Don't forget to call save! invoice.Allocations.Save(); The Following example allocates a supplier payment to a existing order invoice by creating and using the allocateorder method to get the supplier transaction id

{

   //Post a supplier payment
   SupplierTransaction payment = new SupplierTransaction();
   payment.Account = new Supplier("Supplier1");
   payment.TransactionCode = new TransactionCode(Module.AP, "PM");
   payment.OrderNo = "PO0018";
   payment.Amount = 20;
   payment.Reference = "PM123";
   payment.Description = "Payment Made";
   payment.Post();
   //Use method allocateOrder to find order number and allocate to payment
   allocateOrder(payment);

}

private void allocateOrder(DrCrTransaction transaction) {

   string criteria = string.Format("Order_No = '{0}'", transaction.OrderNo);
   if (transaction.Outstanding == 0)
       return;
   if (transaction.Outstanding > 0)
       criteria += " and Outstanding < 0";
   else
       criteria += " and Outstanding > 0";
   DataTable matches = SupplierTransaction.List(transaction.Account, criteria);
   if (matches.Rows.Count > 0)
   {
       foreach (DataRow match in matches.Rows)
       {
           //terminate if satisfied
           if (transaction.Outstanding == 0)
               break;
           SupplierTransaction relatedTran = new SupplierTransaction((Int64)match["Autoidx"]);
           transaction.Allocations.Add(relatedTran);
       }
       transaction.Allocations.Save();
   }

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