Page 1 of 1

Purchase Order - adding fields to the grid

PostPosted: Thu Feb 18, 2016 10:32 am
by Atronics
In the purchase order form, I want to populate UserdefinedFloat1 with IN_Main.Weight. How is this done?

Re: Purchase Order - adding fields to the grid  Topic is solved

PostPosted: Fri Feb 19, 2016 9:06 pm
by Mike.Sheen
Atronics wrote:In the purchase order form, I want to populate UserdefinedFloat1 with IN_Main.Weight. How is this done?


Pretty simple - add a handler for the lines added event of the purchase order, read the inventory item as an entity and set the UserDefinedFloat1 property of the purchase order line:

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      var purchaseOrder = (JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder)JiwaBusinessLogic;
      purchaseOrder.Lines.Added += PurchaseOrder_Lines_Added;
    }
   
   private void PurchaseOrder_Lines_Added(JiwaFinancials.Jiwa.JiwaPurchaseOrders.Line item)      
   {
      if (item.LineType == JiwaFinancials.Jiwa.JiwaPurchaseOrders.Line.OrderLineType.Inventory)
      {
         var inventory = new JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory();
         inventory.ReadRecord(item.InventoryID);
         item.UserDefinedFloat1 = inventory.Weight;
      }
   }


The attached plugin does this (in C# as you did not specify the preferred language).

I'd also like to direct you to the plugins and licencing post on this forum.

Re: Purchase Order - adding fields to the grid

PostPosted: Mon Feb 22, 2016 3:23 pm
by Atronics
Thanks, Mike.