Service Manager. Credit Goods into Stock  Topic is solved

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

Service Manager. Credit Goods into Stock

Postby DannyC » Tue Feb 23, 2016 3:37 pm

Hi,

On the Service Manager, Customer Returns tab, I want to change the warehouse for the Credit Note when Credit Goods Into Stock is ticked.
If not ticked, just leave as current warehouse.

I have it working - to a point.
The credit note warehouse is changing, but it seems to be setting the overall Jiwa warehouse without changing the bottom status bar. I know because when I open sales orders or purchase orders or other module the warehouse of the opened form is the adjusted warehouse.

How can I stop that from happening, so that if Credit Goods into Stock is ticked, I can set the warehouse the credit should go to without changing the Jiwa current warehouse?
This is my code so far
Code: Select all
Public Class BusinessLogicPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaBusinessLogicPlugin
   'Private _ServiceJob As JiwaFinancials.Jiwa.JiwaServiceManager.Job
    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
      If TypeOf(JiwaBusinessLogic) Is JiwaFinancials.Jiwa.JiwaServiceManager.Job Then
         Dim jobObject As JiwaFinancials.Jiwa.JiwaServiceManager.Job = DirectCast(JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaServiceManager.Job)
         AddHandler jobObject.CreateCustomerReturnCreditNoteBeforeSalesOrderSave, AddressOf ChgCreditWarehouse
         '_ServiceJob = jobObject   
      End If
    End Sub
   
   Public Sub ChgCreditWarehouse(ByVal SalesOrder As JiwaSales.SalesOrder.SalesOrder)
      If SalesOrder.CreditIntoStock = True Then
         ' salesOrder.LogicalWarehouseResidingIn.IN_LogicalID = "DEB9E973927E486B8E81"        'This doesn't work
         SalesOrder.Warehouse.IN_LogicalID = "DEB9E973927E486B8E81"
      Else
         Exit Sub
      End If
   End Sub
End Class


Second question, ideally I'd like to pop up a warehouse selection box so the user can choose the warehouse. Not quite so important but would be handy.

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Service Manager. Credit Goods into Stock

Postby DannyC » Tue Mar 08, 2016 9:36 am

Hi guys,

Never mind with the original post.
I think I have this one sussed. I managed to get a warehouse selection to pop up and the destination credit note gets the chosen warehouse.

If anyone wants to see the plugin, I can post it here.

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Service Manager. Credit Goods into Stock

Postby DannyC » Fri Mar 11, 2016 11:42 am

Hi,

Damn - nearly had it working!
So although I have the credit note getting created in the selected warehouse, unfortunately the stock is landing in the original warehouse. It needs to go into the selected warehouse.
I can't work out how to get the SOH to land in the selected warehouse.
Hoping you can help me on this one.

Here is the whole BusinessLogicPlugin class.
Code: Select all
Public Class BusinessLogicPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaBusinessLogicPlugin
    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
      If TypeOf(JiwaBusinessLogic) Is JiwaFinancials.Jiwa.JiwaServiceManager.Job Then
         Dim jobObject As JiwaFinancials.Jiwa.JiwaServiceManager.Job = DirectCast(JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaServiceManager.Job)
         AddHandler jobObject.CreateCustomerReturnCreditNoteBeforeSalesOrderSave, AddressOf ChgCreditWarehouse
      End If
    End Sub
   
   Public Sub ChgCreditWarehouse(ByVal SalesOrder As JiwaSales.SalesOrder.SalesOrder)
      If SalesOrder.CreditIntoStock = True Then
         With JiwaApplication.Manager.Instance.Search   
            .Clear
            .CurrentOption = 1            
            .SetDefaultSearch(JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswLogicalWarehouse)
            .UsePinBoard = False         
            
            If .Show(salesOrder.Client) = System.Windows.Forms.DialogResult.OK Then
               If .Results.Count <> 0 Then
'                  msgbox(.Fields(1).FieldValue.ToString)                  
                  Dim logicalWarehouse As JiwaApplication.Inventory.Warehouse.LogicalWarehouse = JiwaApplication.Manager.Instance.PhysicalWarehouseCollection.FindLogicalWarehouse(.Fields(1).FieldValue.ToString)
                  Dim logicalWH_Entity As New JiwaApplication.Entities.LogicalWarehouse
                  logicalWH_Entity.ReadRecord(.Fields(1).FieldValue.ToString)

                  If logicalWarehouse IsNot Nothing Then
                     salesOrder.LogicalWarehouseResidingIn = logicalWH_Entity
                     salesOrder.Warehouse = logicalWarehouse
'                     msgbox (salesOrder.LogicalWarehouseResidingIn.Description)
                  End If
                                    
               Else
                  Throw New JiwaApplication.Exceptions.ClientCancelledException
               End If
            Else
               Throw New JiwaApplication.Exceptions.ClientCancelledException
            End If
         End With


      Else
         Exit Sub
      End If
   End Sub
End Class



Thanks

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Service Manager. Credit Goods into Stock  Topic is solved

Postby Scott.Pearce » Tue Mar 15, 2016 11:24 am

The implementation of warehouses seems to be a little muddled in sales orders. Further, if we change the warehouse of the sales order after adding the lines, the lines don't get told about the change! So what we can do is remove and re-add the lines after we change warehouse:

Code: Select all
Public Sub ChgCreditWarehouse(ByVal SalesOrder As JiwaSales.SalesOrder.SalesOrder)
  If SalesOrder.CreditIntoStock = True Then
    With JiwaApplication.Manager.Instance.Search   
      .Clear
      .CurrentOption = 1           
      .SetDefaultSearch(JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswLogicalWarehouse)
      .UsePinBoard = False         
      
      If .Show(salesOrder.Client) = System.Windows.Forms.DialogResult.OK Then
         If .Results.Count <> 0 Then
         Dim IN_LogicalID As String = .Fields(1).FieldValue.ToString()
         If IN_LogicalID IsNot Nothing AndAlso IN_LogicalID.Trim.Length > 0 Then
            Dim selectedLogicalWarehouse As JiwaApplication.Inventory.Warehouse.LogicalWarehouse = JiwaApplication.Manager.Instance.PhysicalWarehouseCollection.FindLogicalWarehouse(IN_LogicalID) 
            If selectedLogicalWarehouse IsNot Nothing Then
               salesOrder.Warehouse =  selectedLogicalWarehouse
               salesOrder.SalesOrderLines.RemoveAll
               Dim selectedTask As JiwaFinancials.Jiwa.JiwaServiceManager.Task = jobObject.Tasks(jobObject.SelectedTaskNo)
               selectedTask.CustomerReturns.AddToSalesOrder (salesOrder)
            End If
         End If
         End If
      End If
    End With
  End If
End Sub      


Note that the ChgCreditWarehouse function requires a job object, so I made your jobObject declaration global to the class. Please find the full plugin attached.
Attachments
Plugin Service Manager - Credit Customer Returns into Specific Warehouse.xml
(33.83 KiB) Downloaded 756 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Service Manager. Credit Goods into Stock

Postby DannyC » Tue Mar 15, 2016 5:42 pm

Thx Scott.

When I use your code, I get an error on this line
Code: Select all
Dim selectedTask As JiwaFinancials.Jiwa.JiwaServiceManager.Task = jobObject.Tasks(jobObject.SelectedTaskNo)

Object reference not set to an instance of an object

In JiwaDemo database, when I import the plugin I get a different error on this line
Code: Select all
salesOrder.SalesOrderLines.RemoveAll

Argument 'Key' is not a valid value.
Module: Remove

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Service Manager. Credit Goods into Stock

Postby Scott.Pearce » Wed Mar 16, 2016 7:55 am

Which version are you importing into?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Service Manager. Credit Goods into Stock

Postby DannyC » Thu Mar 17, 2016 10:13 am

7.0.149
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Service Manager. Credit Goods into Stock

Postby Scott.Pearce » Thu Mar 17, 2016 10:20 am

I just downloaded and imported the plugin into a fresh 7.0.149 demo database and then tested a customer return. No problems, plugin worked fine.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests