Add lines to stocktake

Discussions relating to plugin development, and the Jiwa API.

Add lines to stocktake

Postby DannyC » Thu Sep 12, 2019 4: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?
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Add lines to stocktake

Postby Mike.Sheen » Thu Sep 12, 2019 5: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
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Add lines to stocktake

Postby DannyC » Sat Jul 25, 2020 10:21 am

Have just been helping a client doing stocktakes in Bin Location mode.

I think this feature to add lines might be OK in Part No mode, but Bin Location mode, when you specify a specific bin in the From/To range, it will only show items with SOH in that bin - fair enough. But if other part numbers are found in that bin, there's no way to add those items.

Ideally it would be great if there was a line at the bottom (like most transactional grids) when a new partno can be added.
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron