Page 1 of 1

SO Force Branch according to Warehouse

PostPosted: Thu Jul 14, 2016 5:08 pm
by 2can2
Hi, I picked up from one of the previous posts how to force the SO branch according to which Warehouse the SO is in. I am checking on the Logical Warehouse Description but would far rather be checking against the PhysicalID or Physical.Description but can't seem to access either?
I also discovered another issue, If I create a New credit Note and if the previous SO showed a Branch other than Sydney it DOES NOT change the Branch to Sydney? However creating a New Invoice it forces the Branch correctly as per the code? Do I need to cater for Credit Notes separately? Thanks.
Code below.

Code: Select all
   Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      AddHandler salesOrderForm.SalesOrder.CreateEnd, AddressOf CreateEnd
      AddHandler salesOrderForm.SalesOrder.SaveStart, AddressOf SaveStart
      AddHandler salesOrderForm.SalesOrder.ReadEnd, AddressOf ReadEnd
      AddHandler salesOrderForm.SalesOrder.PropertyChanged, AddressOf PropertyChanged
    End Sub

      Private Sub CreateEnd(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)      
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(salesOrder.client, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
''   *** For Warehouse 'Alexandria, Branch = Sydney ** 14/07/16 DH    
''    msgbox (" salesOrder.Branch.Description = " & salesOrder.Branch.Description )
      If salesOrder.Warehouse.Description = "Alexandria" Then
          salesorder.Branch.ReadRecordFromDescription("Sydney")
      End If
   End Sub
   
   Private Sub SaveStart(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)      
''   *** NOT NEEDED - used CreateEnd ***
End Sub
   
   Private Sub ReadEnd(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)      
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(salesOrder.client, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
' lock   
      salesOrderForm.BranchLookup.Enabled = False
      salesOrderForm.lblBranch.Enabled = False
   End Sub
   
   
   Private Sub PropertyChanged(sender As Object, e As System.EventArgs)      
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)      
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(salesOrder.client, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
' lock   
      salesOrderForm.BranchLookup.Enabled = False
      salesOrderForm.lblBranch.Enabled = False
   End Sub
End Class

Re: SO Force Branch according to Warehouse

PostPosted: Sun Jul 31, 2016 1:06 pm
by Mike.Sheen
Hi Doug,

2can2 wrote:I am checking on the Logical Warehouse Description but would far rather be checking against the PhysicalID or Physical.Description but can't seem to access either?


You can - in your code you supplied, you are doing the following:

Code: Select all
If salesOrder.Warehouse.Description = "Alexandria" Then
          salesorder.Branch.ReadRecordFromDescription("Sydney")
      End If


Just replace this with the following:

Code: Select all
If salesOrder.Warehouse.LogicalWarehouseCollection.PhysicalWarehouse.Description = "PlaceYourPhysicalWarehouseDescriptionHere" Then
          salesorder.Branch.ReadRecordFromDescription("Sydney")
      End If


2can2 wrote:I also discovered another issue, If I create a New credit Note and if the previous SO showed a Branch other than Sydney it DOES NOT change the Branch to Sydney? However creating a New Invoice it forces the Branch correctly as per the code? Do I need to cater for Credit Notes separately?


I didn't have this issue. My branch was correctly changed when I created a credit note. Can you provide a plugin which demonstrates the issue ?

Mike

Re: SO Force Branch according to Warehouse  Topic is solved

PostPosted: Thu Aug 04, 2016 6:29 pm
by 2can2
Thanks Mike, all good with your code.