Stock Tansfer API sample code  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Stock Tansfer API sample code

Postby dimuthu » Wed Mar 11, 2015 2:33 pm

Hi Mike,

I need to create a stock transfer ( to increase the Qty ) for items in one of our custom programs. I could not find out any samples done for stock transfer in the API documentation of my version ( http://help.jiwa.com.au/Jiwa7/7.00.105/ ... index.aspx ).

There are samples done for the SalesOrder API. That helped a lot to use in my .net custom program.

Could you please send me same kind of sample for stock transfer.

Thanks
Dimuthu
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: Stock Tansfer API sample code

Postby Mike.Sheen » Tue Mar 17, 2015 9:56 am

Hi Dimuthu,

The following snippet of code creates a new stock transfer and adds an item which is to have the SOH increased by a quantity of 5.

Code: Select all
JiwaApplication.Manager.Instance.Logon("JiwaMike", "JiwaDemo7115", JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password")

Dim stockTransfer As JiwaStockTransfer.StockTransfer = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaStockTransfer.StockTransfer)(Nothing)
stockTransfer.CreateNew()
stockTransfer.TransferDate = JiwaApplication.Manager.Instance.SysDateTime

Dim line As New JiwaStockTransfer.Line
line.FromInventory.PartNo = "External"

line.ToInventory.ReadRecordFromPartNo("1170")
line.TransferQuantity = 5
line.ToPartExpiryDate = JiwaApplication.Manager.Instance.SysDateTime   ' <-- The need for this seems to be a bug, but just setting the expiry date is a workaround - otherwise the Save method fails later.

stockTransfer.Lines.Add(line)
stockTransfer.Save()


Mike
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Stock Tansfer API sample code

Postby dimuthu » Wed Mar 18, 2015 10:38 am

Thanks Mike.
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: Stock Tansfer API sample code

Postby dimuthu » Wed Mar 18, 2015 5:13 pm

Hi Mike,

Could you please assist me with this.

I tried your code but it didn't work. Not sure I'm doing something wrong.

After calling the "stockTransfer.Save()" method I called the "stockTransfer.ActivateRecord()". Then it throws me "Please save the stock take first. at JiwaFinancials.Jiwa.JiwaStockTransfer.StockTransfer.ActivateRecord() " error message. When I checked in Jiwa stock transfer has been created.

Also I need to get the TransferNo after calling the save method. I tried to get the value ( "TransferNo = stockTransfer.TransferNo.ToString" ) but no value is passed.

Is there any way that we can add items to a lines collection something within a FOR loop and finally call the save method ?

Could you please check my attached coding.

Regards
Dimuthu
Attachments
stock trans.jpg
Jiwa Screen shot
Coding.txt
My coding
(3.42 KiB) Downloaded 1272 times
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: Stock Tansfer API sample code

Postby Mike.Sheen » Wed Mar 18, 2015 7:56 pm

Hi Dimuthu,

After saving you should always read the transfer before attempting to modify the transfer in any way.

You should obtain the RecID (NOT the TransferNo as you are) after saving, then read using the RecID. Then you can call the Activate method.

Also, omit the following lines:

Code: Select all
line.Clear()
line = Nothing


As the line you have added to the collection is a pointer to the item in the lines collection, by calling clear and setting it to nothing you are destroying the item now in the collection.

Mike
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Stock Tansfer API sample code

Postby dimuthu » Thu Mar 19, 2015 11:51 am

Thanks Mike. I did as you mentioned. Called the record activate method after the Read method.

.Save()
.Read(.RecID)

.ActivateRecord()

But when calling the "ActivateRecord()" , program throws "JiwaFinancials.Jiwa.JiwaApplication.Exceptions.RecordNotFoundException: General Ledger Account Not Found".

Regards
Dimuthu
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: Stock Tansfer API sample code  Topic is solved

Postby Mike.Sheen » Thu Mar 19, 2015 3:33 pm

dimuthu wrote:Thanks Mike. I did as you mentioned. Called the record activate method after the Read method.

.Save()
.Read(.RecID)

.ActivateRecord()

But when calling the "ActivateRecord()" , program throws "JiwaFinancials.Jiwa.JiwaApplication.Exceptions.RecordNotFoundException: General Ledger Account Not Found".

Regards
Dimuthu


Dimuthu,

That works for me - my complete code is as follows:

Code: Select all
JiwaApplication.Manager.Instance.Logon("JiwaMike", "JiwaDemo7115", JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password")

Dim stockTransfer As JiwaStockTransfer.StockTransfer = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaStockTransfer.StockTransfer)(Nothing)
stockTransfer.CreateNew()
stockTransfer.TransferDate = JiwaApplication.Manager.Instance.SysDateTime

Dim line As New JiwaStockTransfer.Line
line.FromInventory.PartNo = "External"

line.ToInventory.ReadRecordFromPartNo("1170")
line.TransferQuantity = 5
line.ToPartExpiryDate = JiwaApplication.Manager.Instance.SysDateTime   ' <-- The need for this seems to be a bug, but just setting the expiry date is a workaround - otherwise the Save method fails later.

stockTransfer.Lines.Add(line)
stockTransfer.Save()

stockTransfer.Read(stockTransfer.RecID)
stockTransfer.ActivateRecord()


I'm guessing you've not tried this in the demo data? The above works fine for me in demo data. The message you are getting suggests there is a General Ledger account missing or not defined - it's the journal posting during the activate which requires the GL accounts and that will be what is throwing the exception. The journals associated with a transfer are the inventory value and inventory write on accounts - make sure the inventory items you are using have those accounts set, and if the stock transfer reason is configured to override the write on account that it also is configured to a valid account.

Also, if using warehouse masking then make sure the appropriate inventory value and write on accounts exist for the warehouse you are transferring in on.

Mike
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Stock Tansfer API sample code

Postby dimuthu » Thu Mar 19, 2015 4:45 pm

Thanks Mike. Found what causing the issue.

I had "line.ToInventory.InventoryID = Trim(ToInventoryID)" instead of "line.ToInventory.ReadRecordFromPartNo(Trim(Row("PartNo").ToString))"

Now it worked. Thanks for your help.

Regards
Dimuthu
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: Stock Tansfer API sample code

Postby DannyC » Fri May 29, 2015 1:22 pm

Mike or Scott,

I am using this thread as a basis for developing a plugin to use the File Watcher to import a Stock Transfer.
I have figured out the bulk of the import & I can successfully import a CSV file into a new transfer.

My problem is when I am writing off stock (i.e To External).
Currently all stock transferred from an inventory item to External is displaying in red with available quantity = 0.
I do not know how to programatically get the SOH details so things like FromPartInventorySOHID, FromPartOriginalQuantity, AvailableQuantity and other required details such as the writeoff/on ledger codes.

Attached is my plugin so far. the main sub starts at line 638.
I am having trouble at line 678.

Cheers

Danny
Attachments
Plugin File Watcher Stock Transfer.xml
(57.68 KiB) Downloaded 1283 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests