Page 1 of 1

Creating/importing a Stock Transfer from Excel

PostPosted: Tue Mar 30, 2021 6:12 pm
by DannyC
Hi,

Just about finished a plugin which will import a stock transfer from an Excel sheet.

The source sheet simply looks like this:
From PartNoTo PartNoQuantity
ExternalGHQ1235
8_FGTR4External3
PART56External10


It works pretty much OK except I need to programmatically replicate how the GUI finds the IN_SOH record to get the Available Quantity and allow me to populate the transfer quantity.
When I populate the line with transfer quantity it populates with 0 and available quantity is also 0.

In the Jiwa code I can see
Code: Select all
internal void GetInventoryDetails
& I'm assuming I need to call it? How? Or how could I populate the available quantity?

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Tue Mar 30, 2021 6:33 pm
by Mike.Sheen
If you call the AddLine method of the Lines, it calls GetInventoryDetails for you in that.

If you're not using AddLine already, try that instead of however you're currently adding lines to the transfer.

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Tue Mar 30, 2021 6:44 pm
by DannyC
OK.
I'm already using AddLine.

Should I be passing in an FromPartInventorySOHID?

EDIT: I think I have an answer. It seems I need to find a valid SOHID and pass that in to the AddLine. If I pass in an empty string it doesn't work.
What happens if there isn't enough stock on the IN_SOH record I'm using, but other records added up meet the quantity required?

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Tue Mar 30, 2021 6:52 pm
by Mike.Sheen
Right, so you must not be providing the SOH ID to that method then.

I need to programmatically replicate how the GUI finds the IN_SOH


So the way we do that (if transferring from SOH to External) is we show a search window and get the user to select SOH records, and then call AddLine, passing in the SOH ID along with other parameters.

If your sheet you are importing doesn't have the ID's, then you could query the database and get stock using a FIFO method, and call AddLine repeatedly with the various ID's and quantities.

Are you talking about transferring from SOH to External?

Re: Creating/importing a Stock Transfer from Excel  Topic is solved

PostPosted: Tue Mar 30, 2021 6:58 pm
by DannyC
Are you talking about transferring from SOH to External?


Yep. Doing it the other direction is fine.

you could query the database and get stock using a FIFO method

Doing that now to get a valid LinkID.

call AddLine repeatedly

So to answer my last question, if I need to transfer 25 units, and IN_SOH has 3 records of 15, 7 and 3, then I need to AddLine one by one and set the Transfer quantity to match the SOH quantity until I reach my desired transfer quantity?

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Wed Mar 31, 2021 11:15 am
by DannyC
Just to wrap this up for those playing at home, yes I needed to do another AddLine until I exhausted the available SOH records to meet my transfer quantity.

All good. Nice little plugin!

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Wed Mar 31, 2021 11:48 am
by Mike.Sheen
If someone responds to a post of yours, I don't think it's a good idea to edit your original post (beyond minor spelling errors) - otherwise a lot of continuity gets lost - I responded to this post:

OK.
I'm already using AddLine.


And then after responding it changed to:

OK.
I'm already using AddLine.

Should I be passing in an FromPartInventorySOHID?


And then changed again to (this time at least annotated with an EDIT footnote):

OK.
I'm already using AddLine.

Should I be passing in an FromPartInventorySOHID?

EDIT: I think I have an answer. It seems I need to find a valid SOHID and pass that in to the AddLine. If I pass in an empty string it doesn't work.
What happens if there isn't enough stock on the IN_SOH record I'm using, but other records added up meet the quantity required?


Confused the hell outta me!

Re: Creating/importing a Stock Transfer from Excel

PostPosted: Wed Mar 31, 2021 4:56 pm
by DannyC
I don't think it's a good idea to edit your original post

You're assuming it was edited after you answered. Wrong.

It was edited before you answered but by the time I had hit submit/save then your reply appeared. So we must've been typing at the same time & your reply happened to hit the thread before my edit.

Let's not get our knickers in a knot, I'm not so stupid to edit a post after a response.