Add new Consignment Note  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Add new Consignment Note

Postby Ernst » Wed Sep 28, 2022 10:26 am

DateError.jpg


JIWA 721..
Keep getting this date error, even though my consign date is formatted correctly. Is this the lastsaveddate giving a problem.

Any suggestions to try?

Code is.

If SalesOrderH.Carrier.ConsignmentNoteCollection.Count = 0 Then
Dim MyConsignNote As New JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote
MyConsignNote.ConsignmentNoteNo = "LUB" & SalesOrder.InvoiceNo & salesorder.CurrentHistoryNo
MyConsignNote.ConsignmentNoteDate = Date.Now
SalesOrderH.Carrier.ConsignmentNoteCollection.Add(MyConsignNote)
End If
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Add new Consignment Note  Topic is solved

Postby SBarnes » Wed Sep 28, 2022 11:19 am

For starters the con note is a collection item so you can't just new one up you should be using the factory to create one, below is code that works without complaint, it isn't exactly what you are looking for but is similar, I suspect you not using the factory is causing your issue


Code: Select all
List<ConsignmentNote> consignmentNotes = carrier.ConsignmentNoteCollection.Cast<ConsignmentNote>().ToList();
               ConsignmentNote foundConnote = consignmentNotes.FirstOrDefault(c => c.ConsignmentNoteNo == request.Connotenumber);
               if(foundConnote == null)
               {
                  foundConnote = manager.CollectionItemFactory.CreateCollectionItem<ConsignmentNote>();
                  carrier.ConsignmentNoteCollection.Add(foundConnote);
                  
               }
               foundConnote.ConsignmentNoteNo = request.Connotenumber;
               foundConnote.ConsignmentNoteDate = DateTime.Parse( request.Condate);
               
               foundConnote.ExGSTAmount = request.Rate;
               foundConnote.GSTAmount = request.Gstamount;
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add new Consignment Note

Postby Ernst » Wed Sep 28, 2022 4:08 pm

Thanks Stuart, eventually got it working with this piece of VB code, the C# does not convert to VB very well.

Thanks for the help.

If SalesOrderH.Carrier.ConsignmentNoteCollection.Count = 0 Then

Dim MyConsignNote As New JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote
MyConsignNote = Salesorder.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote)
SalesOrderH.Carrier.ConsignmentNoteCollection.Add(MyConsignNote)
MyConsignNote.ConsignmentNoteNo = "LUB" & SalesOrder.InvoiceNo & salesorder.CurrentHistoryNo
MyConsignNote.ConsignmentNoteDate = Date.Now

End If
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Add new Consignment Note

Postby Mike.Sheen » Wed Sep 28, 2022 4:15 pm

You should modify this line

Code: Select all
         Dim MyConsignNote As New JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote


to not NEW, just declare:

Code: Select all
         Dim MyConsignNote As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote


New-ing is pointless, as the next line uses the factory to obtain a new instance of the ConsignmentNote:

Code: Select all
         MyConsignNote = Salesorder.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.ConsignmentNote)


What CollectionItemFactory.CreateCollectionItem does for you is the new-ing and setting of the Manager class and other stuff - it returns a new-ed instance of the type requested.

As for conversion - I don't see any glaring issues with converted code:
ConvertedCode.png
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Add new Consignment Note

Postby SBarnes » Wed Sep 28, 2022 6:48 pm

eventually got it working with this piece of VB code, the C# does not convert to VB very well.


Ah another reason in favour for just going with c# :lol:

Seriously though happy you got it going in the end, happy to help.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add new Consignment Note

Postby Ernst » Thu Oct 06, 2022 12:56 pm

Thanks Mike have removed the New.

These are all the lovely errors, when you try and compile the converted VB,

Capture3.PNG
Capture3.PNG (42.91 KiB) Viewed 996 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Add new Consignment Note

Postby Mike.Sheen » Thu Oct 06, 2022 12:58 pm

Ernst wrote:Thanks Mike have removed the New.

These are all the lovely errors, when you try and compile the converted VB,

Capture3.PNG


You're just missing a few using statements. 2 or 3 usings and that'll clear right up.

Or fully namespace the types in question.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Add new Consignment Note

Postby SBarnes » Thu Oct 06, 2022 1:01 pm

And the error about request is due to the fact that the sample code came from a REST api plugin
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 34 guests