IFS Smartfreight plugin and dangerous goods  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

IFS Smartfreight plugin and dangerous goods

Postby DannyC » Mon Apr 12, 2021 11:18 pm

I can see there's a few lines of code in the IFS Smartfreight plugin which seems to pass onto IFS if an item is a DG.

How do we specify in inventory maintenance if an item is DG? And then what tweak needs to be made (if any) to the plugin?
Is it just a matter of a custom setting checkbox?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: IFS Smartfreight plugin and dangerous goods

Postby SBarnes » Tue Apr 13, 2021 7:34 am

Dangerous Goods is not just one field like y/n it is a series of fields that must be specified such as the properties of the class are, which is related to the Australian Code for the Transport of Dangerous Goods by Road & Rail Guide

Code: Select all
    <Serializable()>
    <CLSCompliant(True)>
    Public Class dgdetails

        Private Property _amt As Integer
        Private Property _size As Decimal

        ''' <summary>
        ''' Gets or sets the product id. Your Product ID to assist with identification within SmartFreight®
        ''' </summary>
        ''' <value>The product id.</value>
        Public Property productid As String

        ''' <summary>
        ''' Gets or sets the DG Technical Name.
        ''' </summary>
        ''' <value>The DG Technical Name.</value>
        Public Property techname As String

        ''' <summary>
        ''' Gets or sets the DG Common Name.
        ''' </summary>
        ''' <value>The DG Common Name.</value>
        Public Property commonname As String

        ''' <summary>
        ''' Gets or sets the DG class.
        ''' </summary>
        ''' <value>The DG class.</value>
        Public Property [class] As String

        ''' <summary>
        ''' Gets or sets the DG Sub-Class if applicable
        ''' </summary>
        ''' <value>The DGDG Sub-Class.</value>
        Public Property subclass As String

        ''' <summary>
        ''' Gets or sets the DG Packaging Group
        ''' </summary>
        ''' <value>The DG Packaging Group.</value>
        Public Property packgroup As String

        ''' <summary>
        ''' Gets or sets the DG UN number
        ''' </summary>
        ''' <value>The DG UN number.</value>
        Public Property unnumber As String

        ''' <summary>
        ''' Gets or sets the DG Quantity.
        ''' </summary>
        ''' <value>The DG Quantity.</value>
        Public Property amt As Integer
            Get
                Return _amt
            End Get
            Set(value As Integer)
                _amt = value
                amtSpecified = True
            End Set
        End Property

        <System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>
        <System.Xml.Serialization.XmlIgnore()>
        Public Property amtSpecified As Boolean

        ''' <summary>
        ''' Gets or sets the DG quantity ether in KG, Litres or M3.
        ''' </summary>
        ''' <value>The DG quantity ether in KG, Litres or M3.</value>
        Public Property size As Decimal
            Get
                Return _size
            End Get
            Set(value As Decimal)
                _size = value
                sizeSpecified = True
            End Set
        End Property

        <System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>
        <System.Xml.Serialization.XmlIgnore()>
        Public Property sizeSpecified As Boolean

        ''' <summary>
        ''' Gets or sets the DG Unit of measure. Must be KG or L or M3 (Kilos or Litres or Volume)
        ''' </summary>
        ''' <value>The DG Unit of measure.</value>
        Public Property um As String

        ''' <summary>
        ''' Gets or sets the DG Packaging. CARTON OR PALLET OR DRUM ONLY
        ''' </summary>
        ''' <value>The DG Packaging.</value>
        Public Property desc As String

        ''' <summary>
        ''' Gets or sets the DG ERG / Hazchem Code
        ''' </summary>
        ''' <value>The DG ERG / Hazchem Code.</value>
        Public Property erg As String
    End Class
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: IFS Smartfreight plugin and dangerous goods

Postby DannyC » Tue Apr 13, 2021 9:43 am

sure but
How do we specify in inventory maintenance if an item is DG? And then what tweak needs to be made (if any) to the plugin?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: IFS Smartfreight plugin and dangerous goods

Postby Mike.Sheen » Tue Apr 13, 2021 10:58 am

DannyC wrote:sure but
How do we specify in inventory maintenance if an item is DG? And then what tweak needs to be made (if any) to the plugin?


We don't have anything baked in - but you would need to add a custom field to inventory to specify the dangerous goods category (if any) the product is, and then modify the IFS Smartfreight plugin to look at that and populate the dgdetails property of the connote class when sending it to the IFS web service.

As always, if you modify a plugin... modify a copy and not our standard plugin.
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: IFS Smartfreight plugin and dangerous goods

Postby DannyC » Thu Oct 07, 2021 12:05 pm

populate the dgdetails property of the connote class

Have been trying to get this working for several weeks now but still no joy.

I'm pretty sure I am populating all the relevant information but nothing is getting written to the XML. I am sure I'm missing an .add somewhere to add the DG information to the connote but at this stage I think I'll need to give up and ask the brains trust. Attached is my plugin with dgdetails getting populated.

I'm not exporting the XML to smartfreight at this stage, just writing the XML to disk so I can analyse prior to sending. See line 334.
Attachments
Plugin Attkey IFS Smartfreight.xml
(469.45 KiB) Downloaded 62 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: IFS Smartfreight plugin and dangerous goods

Postby SBarnes » Sat Oct 09, 2021 12:32 pm

I haven't tested it and this may not be the only problem but you need to change

Code: Select all
Dim dgdetail As New XML.dgdetails
            
            dgdetail.class = DGClass
            dgdetail.commonname = DGcommonname
            dgdetail.packgroup = DGpackaginggroup
            dgdetail.techname = DGtechname
            dgdetail.unnumber = DGUN
            dgdetail.um = DGum
            dgdetail.size = DGQty
            
            My.Computer.FileSystem.WriteAllText("D:\Danny\DGExport.XML", conNote.Serialise.InnerXml, True, System.Text.Encoding.Default)


to

Code: Select all
Dim dgdetail As New XML.dgdetails
            
            dgdetail.class = DGClass
            dgdetail.commonname = DGcommonname
            dgdetail.packgroup = DGpackaginggroup
            dgdetail.techname = DGtechname
            dgdetail.unnumber = DGUN
            dgdetail.um = DGum
            dgdetail.size = DGQty
            
            
             conNote.dgdetails = dgdetail
            
            My.Computer.FileSystem.WriteAllText("D:\Danny\DGExport.XML", conNote.Serialise.InnerXml, True, System.Text.Encoding.Default)


without attaching your dgdetail object to the the conNote object's dgdetail property the XML serialiser will see the property as null or empty and definitely won't try and create XML off it, whether this is the final correct structure I don't know as there are come tweaks in the serialise function itself but if its not in the first pass by the XML serialiser itself you definitely wouldn't be able to tweak it anyway.

The
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: IFS Smartfreight plugin and dangerous goods

Postby DannyC » Tue Oct 12, 2021 1:57 pm

Pretty sure that's all it was. Thx Stuart.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: IFS Smartfreight plugin and dangerous goods

Postby DannyC » Thu Feb 16, 2023 12:29 pm

This one has been on the backburner for quite some time but my client has resurrected it.

I am still trying to get the correct XML format that Smartfreight will accept for dangerous goods.
Here's a link to the Smartfreight documentation https://smartfreight.atlassian.net/wiki ... ods+import

Attached is a trimmed version of my plugin. Trimmed in that there's nothing going to SF, I am just writing the XML to disk for now.
Also attached is a sample XML output which is incorrect.

When I have just 1 DG on a sales order, it displays the dg details OK although the tag is not correct. It should say <freightlinedetails> but it says <dgdetails>.

It's worse when I have multiple DGs on a sales order, as each DG item needs to have it's own block of <freightlinedetails> with a desc = "[inner]", i.e. <desc>[inner]</desc>

At the moment, each <freightlinedetails> refers to a line on the freight grid - which is correct, no issues there. But within that <freightlinedetails> when DGs exist on the order, they need to have their own separate <freightlinedetails> with a desc = '[inner]'.
That tells Smartfreight that any following <freightlinedetails> with that desc is a child of the previous <freightlinedetails> as per this comment on the link above
Inners should be used to define multiple Dangerous Goods records allocated against a single freight line detail. Please refer to Inners for more details.


I think the attached plugin is fairly self explanatory, but it has some custom fields for inventory which define the DG fields. They need to be populated, particularly the UN number.
I am doing a For Next to iterate through the sales order lines, checks their DG values, and write out a new <dgdetails> for each DG. But it's only displaying 1 <dgdetails> despite having multiple DGs on the sales order.
And the <dgdetails> should say <freightlinedetails> with a tag within i.e. <desc>[inner]</desc>.

I just need some assistance to get the correct format expected by Smartfreight.

v 7.2.1 SR14
Attachments
Plugin DG IFS Smartfreight.xml
(467.85 KiB) Downloaded 37 times
Smartfreight_RC_100669.XML
(1.2 KiB) Downloaded 38 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: IFS Smartfreight plugin and dangerous goods

Postby SBarnes » Thu Feb 16, 2023 12:42 pm

Although I am better at this with Json than XML, most things don't use XML anymore given how verbose it is, here is sample of the property name
Code: Select all
public class Person
{
    [System.Xml.Serialization.XmlElement(ElementName = "firstNameField")]
    public string FirstName { get; set; }
}


As for the structure of classes to produce the right output if you have a sample of the xml you are trying to get to this try using this site its work for me in the past and beat the hell out of coding it by hand.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: IFS Smartfreight plugin and dangerous goods

Postby Mike.Sheen » Thu Feb 16, 2023 1:06 pm

DannyC wrote:I am still trying to get the correct XML format that Smartfreight will accept for dangerous goods.


I suspect the issues I encountered with the XML format needed when I first wrote the IFS plugin is still there and also includes the dangerous goods.

If you look in the IFS Smartfreight plugin, you'll see a comment block with a little story I wrote:

Code: Select all
' About the SmartFreight XML Format
' =================================
' Unfortunately the smartfreight XML format does not map nicely to a POCO's with lists.  An example is the freightlines.
'
'Example showing multiple freight lines:
'<connotes>
'   <connote>
'       <freightlinedetails>
'           <ref>MY REF 1111</ref>
'           <desc>CARTON</desc>
'           <amt>6</amt>
'           <wgt>52.45</wgt>
'       </freightlinedetails>
'       <freightlinedetails>
'           <desc>PALLET</desc>
'           <amt>1</amt>
'           <wgt>112</wgt>
'       </freightlinedetails>
'   </connote>
'</connotes>

'Example showing multiple freight lines if it were mappable directly to a POCO:
'<connotes>
'   <connote>
'       <freightlinedetails>
'           <freightlinedetail>
'               <ref>MY REF 1111</ref>
'               <desc>CARTON</desc>
'               <amt>6</amt>
'               <wgt>52.45</wgt>
'           </freightlinedetail>
'           <freightlinedetail>
'               <desc>PALLET</desc>
'               <amt>1</amt>
'               <wgt>112</wgt>
'           <freightlinedetail>
'       </freightlinedetails>
'   </connote>
'</connotes>
'
' So, we can't simply serialise the whole connote - we need to serialise then remove the freightlines node,
' then add the each freightline manually.  If we didn't have to do this, serialise would be as simple as:
'Dim stringWriter As New System.IO.StringWriter
'Dim xmlSerializer As New System.Xml.Serialization.XmlSerializer(GetType(XML.connote))
'Dim xmlNamespaces As New System.Xml.Serialization.XmlSerializerNamespaces()
'xmlNamespaces.Add("", "")

'xmlSerializer.Serialize(stringWriter, Me, xmlNamespaces)

'Return stringWriter.ToString
'stringWriter.Close()
'stringWriter.Dispose()


In that method that comment is in, is the code to manually serialise the POCO classes to the format Smartfreight wanted. Normally you would just point the XML serialiser to an object and it would spit out the XML - but we couldn't do that because Smartfreight obviously didn't use industry accepted serialiser/deserialisers, so that code is there to painfully construct the xml document in the format it wants.

You'll need to do the same.
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

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 34 guests