Inventory Import Debtor Partno  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Inventory Import Debtor Partno

Postby Ernst » Mon Jun 24, 2024 10:06 am

Given that we now can add to the inventory Import, like adding Notes, debtor specific pricing etc. Has anybody embarked on creating a plugin to import debtor partno, that they are willing to share.

Thanks.
User avatar
Ernst
Kohai
Kohai
 
Posts: 233
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Inventory Import Debtor Partno

Postby SBarnes » Mon Jun 24, 2024 11:17 am

Whilst I have not tried debtor part numbers, one thing I would recommend you do is have a column that cotanins both the things you need namely the Debtor account number and the debtor part number seperated by something like a pipe(|) as I know this method has worked as away of doing other fields that require two bits of data.

Other than this is should be fairly simple as the debtor part number object has a Debtor entity object on it that has ReadRecordFromAccountNo that could be used to load trhe debtor and throw an exception if it doesn't find the debtor and the property to set to the part number is DebtorPartNo.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: Inventory Import Debtor Partno

Postby Ernst » Tue Jun 25, 2024 8:34 am

OK Thanks, Ive given them an Excel spreadsheet, they can copy paste SQL to get it loaded. Works for the moment. If I have to add to the import, its going to have to be C#, and Oh my G. on that..:)
User avatar
Ernst
Kohai
Kohai
 
Posts: 233
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Inventory Import Debtor Partno

Postby SBarnes » Tue Jun 25, 2024 8:49 am

Ernst wrote:Oh my G. on that..:)


Oh my Great Language to use :lol:

Actually, in all seriousness it does not have to be c#, a decompiler like Telerik Just Decompile will show it to you in vb.net if you really must below for example is the inventory notes plugin all you have to do is find the DLL under program data.

The problem you are having is like the internet the examples available are in the more popular/used language.

Code: Select all
Imports JiwaFinancials.Jiwa.JiwaApplication
Imports JiwaFinancials.Jiwa.JiwaApplication.Notes
Imports JiwaFinancials.Jiwa.JiwaApplication.Plugin
Imports JiwaFinancials.Jiwa.JiwaInventory
Imports JiwaFinancials.Jiwa.JiwaInventory.Import
Imports System
Imports System.Collections
Imports System.Runtime.CompilerServices

Public Class BusinessLogicPlugin
    Inherits MarshalByRefObject
    Implements IJiwaBusinessLogicPlugin
    Public Sub New()
        MyBase.New()
    End Sub

    Private Sub AppendProperties(ByVal destinationPropertyCollection As JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection)
        Dim newDestinationProperty As DestinationProperty = destinationPropertyCollection.Manager.CollectionItemFactory.CreateCollectionItem(Of DestinationProperty)()
        newDestinationProperty.RecID = "Inventory.Note.NoteType"
        newDestinationProperty.Caption = "Inventory Note Type"
        newDestinationProperty.SetterMethod = Sub(inventory As Inventory, value As String, rowData As String, row As String(), rowNo As Integer, mapping As Mapping) Me.SetNoteInfo(inventory, value, rowData, row, rowNo, mapping)
        Dim strArrays() As String = { "InventoryNoteType", "Inventory Note Type", "NoteType", "Note Type" }
        newDestinationProperty.Aliases = strArrays
        destinationPropertyCollection.Add(newDestinationProperty)
        newDestinationProperty = destinationPropertyCollection.Manager.CollectionItemFactory.CreateCollectionItem(Of DestinationProperty)()
        newDestinationProperty.RecID = "Inventory.Note.NoteText"
        newDestinationProperty.Caption = "Inventory Note Text"
        newDestinationProperty.SetterMethod = Sub(inventory As Inventory, value As String, rowData As String, row As String(), rowNo As Integer, mapping As Mapping) Me.SetNoteInfo(inventory, value, rowData, row, rowNo, mapping)
        strArrays = New String() { "InventoryNoteText", "Inventory Note Text", "NoteText", "Note Text", "Note" }
        newDestinationProperty.Aliases = strArrays
        destinationPropertyCollection.Add(newDestinationProperty)
    End Sub

    Private Sub DestinationProperties_ReadEnd(ByVal sender As Object, ByVal e As EventArgs)
        Me.AppendProperties(DirectCast(sender, JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection))
    End Sub

    Public Overrides Function InitializeLifetimeService() As Object
        Return Nothing
    End Function

    Private Sub SetNoteInfo(ByRef Inventory As JiwaFinancials.Jiwa.JiwaInventory.Inventory, ByVal Value As String, ByVal RowData As String, ByVal Row As String(), ByVal RowNo As Integer, ByVal Mapping As JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping)
        Dim noteTypeDescription As String = ""
        Dim noteText As String = ""
        Dim myLoop As Integer = 1
        Dim strArrays As String() = Row
        Dim num As Integer = 0
        While num < CInt(strArrays.Length)
            Dim cell As String = strArrays(num)
            Dim recID As String = Mapping.MappingCollection(myLoop).DestinationProperty.RecID
            If (recID IsNot Nothing) Then
                If (recID = "Inventory.Note.NoteType") Then
                    noteTypeDescription = cell.Trim()
                    Mapping.MappingCollection(myLoop).HasBeenSet = True
                ElseIf (recID = "Inventory.Note.NoteText") Then
                    noteText = cell.Trim()
                    Mapping.MappingCollection(myLoop).HasBeenSet = True
                End If
            End If
            myLoop = myLoop + 1
            num = num + 1
        End While
        Dim noteType As JiwaFinancials.Jiwa.JiwaApplication.Notes.NoteType = Nothing
        If (noteTypeDescription.Trim().Length > 0) Then
            Dim found As Boolean = False
            For Each existingNoteType As JiwaFinancials.Jiwa.JiwaApplication.Notes.NoteType In Inventory.Notes.NoteTypeCollection
                If (existingNoteType.Description.ToUpper() = noteTypeDescription.ToUpper()) Then
                    noteType = existingNoteType
                    found = True
                    Exit For
                End If
            Next
            If (Not found) Then
                Throw New Exception(String.Format("Note Type '{0}' not found", noteTypeDescription))
            End If
        End If
        Dim note As JiwaFinancials.Jiwa.JiwaApplication.Notes.Note = Inventory.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaFinancials.Jiwa.JiwaApplication.Notes.Note)()
        If (noteType IsNot Nothing) Then
            note.NoteType = noteType
        End If
        note.NoteText = noteText
        Inventory.Notes.Add(note)
    End Sub

    Public Sub Setup(ByVal JiwaBusinessLogic As IJiwaBusinessLogic, ByVal Plugin As JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin) Implements IJiwaBusinessLogicPlugin.Setup
        If (TypeOf JiwaBusinessLogic Is JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport) Then
            Dim inventoryImport As JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport = DirectCast(JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport)
            Me.AppendProperties(inventoryImport.DestinationProperties)
            AddHandler inventoryImport.DestinationProperties.ReadEnd,  New IJiwaCollection.ReadEndEventHandler(Of DestinationProperty)(AddressOf Me.DestinationProperties_ReadEnd)
        End If
    End Sub
End Class
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: Inventory Import Debtor Partno

Postby Ernst » Tue Jun 25, 2024 12:29 pm

It Kind of works, but then you get an error like this..

To few type arguments on line 90

AddHandler inventoryImport.DestinationProperties.ReadEnd, New IJiwaCollection.ReadEndEventHandler(Of DestinationProperty)(AddressOf Me.DestinationProperties_ReadEnd)

What is that supposed to mean? See attached plugin.
Attachments
Plugin IMportNotes Test vb.xml
(30.04 KiB) Downloaded 86 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 233
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Inventory Import Debtor Partno  Topic is solved

Postby SBarnes » Tue Jun 25, 2024 12:42 pm

See the attached.

Code: Select all
AddHandler inventoryImport.DestinationProperties.ReadEnd, New IJiwaCollection.ReadEndEventHandler(Of DestinationProperty)(AddressOf Me.DestinationProperties_ReadEnd)


Is the problem what it is confused by is the Jiwa collection starts life as an interface as shown below

Code: Select all
Public Interface IJiwaCollection(Of T)
    Event Adding(ByVal item As T, ByRef e As System.ComponentModel.CancelEventArgs)
    Event Added(ByVal item As T)
    Event Removing(ByVal item As T)
    Event Removed(ByVal item As T)
    Event Changed(ByVal item As T, ByVal e As System.ComponentModel.PropertyChangedEventArgs)
    Event ClearStart(sender As Object, e As System.EventArgs)
    Event Cleared(sender As Object, e As System.EventArgs)
    Event ReadEnd(sender As Object, e As System.EventArgs)
    Event SaveEnd As IJiwaCommonInterfaces.SaveEndDelegate
    Event ReOrdered(sender As Object, e As System.EventArgs)

    ReadOnly Property Count As Integer
    Default ReadOnly Property Item(ByVal RecID As String) As T
    Default ReadOnly Property Item(ByVal index As Integer) As T
    ReadOnly Property Contains(ByVal RecID As String) As Boolean
    Property Reading As Boolean
    Property IsAdding As Boolean
    Property IsRemoving As Boolean
    Property IsReordering As Boolean
    Property RecIDIsGUID As Boolean
    Property Tag As Object
    Property AsynchronousSave As Boolean
    Property IsSaving As Boolean
    Property Manager As Manager
    Property SuppressItemNoAdjustment As Boolean

    Sub Add(ByVal item As T)
    Sub Remove(ByVal item As T)
    Sub RemoveAll()
    Sub Clear()
    Sub CleanUp()
    Sub Read()
    Sub iSave()
    Sub Save()
    Sub Setup()
    Function GetEnumerator() As System.Collections.IEnumerator

End Interface


and then the actual generic Jiwa Collection has the event

Code: Select all
 Public Event ReadEnd(sender As Object, e As System.EventArgs) Implements IJiwaCollection(Of T).ReadEnd


It's basically trying to use the generic rather than the fact that the destination property collection is typed by its declaration of
Code: Select all
Public Class DestinationPropertyCollection
    Inherits JiwaApplication.JiwaCollection(Of DestinationProperty)
Attachments
Plugin IMportNotes Test vb v2.xml
(29.98 KiB) Downloaded 82 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182


Return to Technical and or Programming

Who is online

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

cron