Add lines to stocktake  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Add lines to stocktake

Postby DannyC » Thu Sep 12, 2019 3:54 pm

For version 7.2.x

Based on viewtopic.php?f=26&t=1156 I have been able to populate lines on a new stocktake from Excel.
Once the stocktake is saved, no extra lines can be added.
I get it when the stocktake has been activated, but if a stocktake has only been saved, why cannot lines be added?

As a workaround, I was hoping to create a button on the ribbon to allow a user to load up more lines from Excel using similar code to the above thread but even that wont work. Basically what I'm trying to do is use the stocktake.FindStock method to add lines.

To assist your reply, lets assume the stocktake is in Bin Location mode.
My Excel sheet would have 3 columns:
Bin | PartNo | QtyFound

How could I add lines to an existing stocktake?
DannyC
Jiwa Kohai
Jiwa Kohai
 
Posts: 325
Joined: Fri Mar 22, 2013 11:23 am
Topics Solved: 10

Re: Add lines to stocktake  Topic is solved

Postby Mike.Sheen » Thu Sep 12, 2019 4:41 pm

DannyC wrote:if a stocktake has only been saved, why cannot lines be added?


A silly bug. Fixed in DEV-7777 in 07.02.01 SR1

DannyC wrote:As a workaround, I was hoping to create a button on the ribbon to allow a user to load up more lines from Excel using similar code to the above thread but even that wont work. Basically what I'm trying to do is use the stocktake.FindStock method to add lines.

To assist your reply, lets assume the stocktake is in Bin Location mode.
My Excel sheet would have 3 columns:
Bin | PartNo | QtyFound

How could I add lines to an existing stocktake?


This is how we add lines in the stock take business logic - you just need to do the following for each line in your excel sheet:
Code: Select all
' Check first to make sure we are not going to create a duplicate line
For Each stockTakeLine In StockTakeLines
   If stockTakeLine.PartNo = partNo Then
      If Mode = StockTakeModes.PartNo Then ' Don't allow the same part twice
         found = True
      ElseIf Mode = StockTakeModes.BinLocation Then ' Don't allow the same part /bin location combination twice
         If stockTakeLine.BinLocation = binLocation Then
            found = True
         End If
      End If
   End If
Next

If Not found Then
   stockTakeLine = Manager.CollectionItemFactory.CreateCollectionItem(Of StockTakeLine)

   stockTakeLine.BinLocation = .Sanitise(SQLReader, "BinLocationDesc")
   stockTakeLine.InventoryID = .Sanitise(SQLReader, "IN_Main_InventoryID")
   stockTakeLine.PartNo = .Sanitise(SQLReader, "PartNo")
   stockTakeLine.Description = .Sanitise(SQLReader, "IN_Main_Description")
   stockTakeLine.UseSerialNo = .Sanitise(SQLReader, "UseSerialNo")
   stockTakeLine.QuantityDecimalPlaces = .Sanitise(SQLReader, "DecimalPlaces")
   stockTakeLine.UseExpiryDate = .Sanitise(SQLReader, "UseExpiryDate")
   stockTakeLine.DefaultBinLocation = .Sanitise(SQLReader, "IN_BinLocation_Description")
   stockTakeLine.LastCost = .Sanitise(SQLReader, "IN_Main_LCost")
   stockTakeLine.UseStandardCost = .Sanitise(SQLReader, "UseStandardCost")
   stockTakeLine.StandardCost = .Sanitise(SQLReader, "StandardCost")

   StockTakeLines.Add(stockTakeLine)

   stockTakeLine.FindSOH()
End If


The FindSOH() method is not publicly accessible, so you'll have to use some reflection to invoke that after adding your line. The StockTakeLines.Add(stockTakeLine) will fire the necessary event to add the row to the grid and populate it, so you don't have to worry about that.

If you want us to do a complete plugin, I estimate around 30 to 40 mins time will be needed.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Jiwa Shihan
Jiwa Shihan
 
Posts: 1447
Joined: Tue Feb 12, 2008 10:12 am
Location: North Sydney
Topics Solved: 486


Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron