Complete

Sage 200 Web Portal Purchase Invoice and Credit forms feature automatic checks on the Reference fields.

You can find out more details about the Web portal here:

Purchase Ledger Invoice and Credit Duplicate Check to be automatic and check Opening Balance Invoices/Credit References

the checks should be automatic on 1st and 2nd Reference 

the check should also check Opening Balance Invoices in a Invoice is entered as it is currently possible to enter an Invoice Reference with the same reference as a Opening Balance Invoice

Parents
  • And it would also be nice if it could be configured to match just the reference, not the date as well.

    But for the moment, here's a script to make the 1st reference check automatic:

    'Sage.MMS.PurchaseLedger.PurchaseInvoiceForm.vbs
    'Make the first reference check automatic
    'GTSageDev
    Imports Sage.Accounting
    Imports Sage.Common.Amendability
    Imports System
    Imports Microsoft.VisualBasic
    
    Module addInModule
        Private referenceMaskedTextBox As AmendableControl
        Private instrument As PurchaseLedger.PurchaseNotificationInstrument
        Private lastInstrumentNo As String
        Private lastDate As Date
        Public Sub Main
    	referenceMaskedTextBox = form.FindControlByName("referenceMaskedTextBox")
    	AddHandler referenceMaskedTextBox.Validated, AddressOf referenceTextBox_Validated
    	AddHandler form.BeginSave, AddressOf form_BeginSave
        End Sub
        Private Sub referenceTextBox_Validated(sender As Object, e As EventArgs)
            instrument = GetInstrument()
            If instrument IsNot Nothing _
            AndAlso instrument.Trader IsNot Nothing _
            AndAlso instrument.InstrumentNo > "" _
            AndAlso (instrument.InstrumentNo <> lastInstrumentNo Or instrument.InstrumentDate <> lastDate) Then
                Try
                    instrument.ValidateReference(instrument.Trader, instrument.InstrumentNo, instrument.InstrumentDate)
                Catch ex10752Exception As Sage.Accounting.Exceptions.Ex10752Exception   'ok - no action
                Catch ex10751Exception As Sage.Accounting.Exceptions.Ex10751Exception   'duplicate
                    Sage.MMS.ExceptionMessageBox.Show(ex10751Exception)
                Catch exception As System.Exception
                    Sage.Common.Exceptions.ExceptionManager.HandleUnexpectedException(exception)
                End Try
                lastInstrumentNo = instrument.InstrumentNo
                lastDate = instrument.InstrumentDate
            End If
        End Sub
    
        Private Sub form_BeginSave(sender As Object, e As System.ComponentModel.CancelEventArgs)
            instrument = GetInstrument()
    
            If instrument IsNot Nothing AndAlso instrument.InstrumentNo > "" Then
                Try
                    instrument.ValidateReference(instrument.Trader, instrument.InstrumentNo, instrument.InstrumentDate)
                Catch ex10752Exception As Sage.Accounting.Exceptions.Ex10752Exception   'ok - no action
                Catch ex10751Exception As Sage.Accounting.Exceptions.Ex10751Exception   'duplicate
                    e.Cancel = (MsgBox(ex10751Exception.Message, MsgBoxStyle.OkCancel Or MsgBoxStyle.Exclamation, form.Text) = MsgBoxResult.Cancel)
                End Try
            End If
            lastInstrumentNo = ""
            lastDate = Date.MinValue
        End Sub
    
        Private Function GetInstrument() As PurchaseLedger.PurchaseNotificationInstrument
            'BoundObjects isn't reliable...
            Dim binding = referenceMaskedTextBox.UnderlyingControl.DataBindings("Text")
            If binding IsNot Nothing Then
                Return binding.DataSource
            Else
                Return Nothing
            End If
        End Function
    End Module

Comment
  • And it would also be nice if it could be configured to match just the reference, not the date as well.

    But for the moment, here's a script to make the 1st reference check automatic:

    'Sage.MMS.PurchaseLedger.PurchaseInvoiceForm.vbs
    'Make the first reference check automatic
    'GTSageDev
    Imports Sage.Accounting
    Imports Sage.Common.Amendability
    Imports System
    Imports Microsoft.VisualBasic
    
    Module addInModule
        Private referenceMaskedTextBox As AmendableControl
        Private instrument As PurchaseLedger.PurchaseNotificationInstrument
        Private lastInstrumentNo As String
        Private lastDate As Date
        Public Sub Main
    	referenceMaskedTextBox = form.FindControlByName("referenceMaskedTextBox")
    	AddHandler referenceMaskedTextBox.Validated, AddressOf referenceTextBox_Validated
    	AddHandler form.BeginSave, AddressOf form_BeginSave
        End Sub
        Private Sub referenceTextBox_Validated(sender As Object, e As EventArgs)
            instrument = GetInstrument()
            If instrument IsNot Nothing _
            AndAlso instrument.Trader IsNot Nothing _
            AndAlso instrument.InstrumentNo > "" _
            AndAlso (instrument.InstrumentNo <> lastInstrumentNo Or instrument.InstrumentDate <> lastDate) Then
                Try
                    instrument.ValidateReference(instrument.Trader, instrument.InstrumentNo, instrument.InstrumentDate)
                Catch ex10752Exception As Sage.Accounting.Exceptions.Ex10752Exception   'ok - no action
                Catch ex10751Exception As Sage.Accounting.Exceptions.Ex10751Exception   'duplicate
                    Sage.MMS.ExceptionMessageBox.Show(ex10751Exception)
                Catch exception As System.Exception
                    Sage.Common.Exceptions.ExceptionManager.HandleUnexpectedException(exception)
                End Try
                lastInstrumentNo = instrument.InstrumentNo
                lastDate = instrument.InstrumentDate
            End If
        End Sub
    
        Private Sub form_BeginSave(sender As Object, e As System.ComponentModel.CancelEventArgs)
            instrument = GetInstrument()
    
            If instrument IsNot Nothing AndAlso instrument.InstrumentNo > "" Then
                Try
                    instrument.ValidateReference(instrument.Trader, instrument.InstrumentNo, instrument.InstrumentDate)
                Catch ex10752Exception As Sage.Accounting.Exceptions.Ex10752Exception   'ok - no action
                Catch ex10751Exception As Sage.Accounting.Exceptions.Ex10751Exception   'duplicate
                    e.Cancel = (MsgBox(ex10751Exception.Message, MsgBoxStyle.OkCancel Or MsgBoxStyle.Exclamation, form.Text) = MsgBoxResult.Cancel)
                End Try
            End If
            lastInstrumentNo = ""
            lastDate = Date.MinValue
        End Sub
    
        Private Function GetInstrument() As PurchaseLedger.PurchaseNotificationInstrument
            'BoundObjects isn't reliable...
            Dim binding = referenceMaskedTextBox.UnderlyingControl.DataBindings("Text")
            If binding IsNot Nothing Then
                Return binding.DataSource
            Else
                Return Nothing
            End If
        End Function
    End Module

Children
No Data