PdcStatusManagement.CalcLiveInvoiceStatus

From External Bemet Wiki
Jump to navigation Jump to search

Declaration

CalcLiveInvoiceStatus(strCalcNr As String, strTFRIDList As IStrings, strDelNrList As IStrings, strDelPosList As IStrings) As String

Description

This function is used before saving a sales invoice. It requires a calculation number, and lists with all the TFR_IDs, delivery note numbers, and delivery note positions of all the lines in the invoice. It will use those to calculate what the status of that calculation would become after saving the invoice. It will return the status identifier of that status as a result.

Notes

The stringlists that you pass as parameters all need to have the same length. They are a replacement of a list of objects where every object contains 3 string properties.

Code example

This code example is from the CanSave function of the SalesInvoice.vb class. It calculates the future status of a calculation and checks if this status is allowed.

'collect IDs
		Dim aTFRIDList As List(Of Integer) = New List(Of Integer)
		Dim aDeliveryNoteNrList As List(Of String) = New List(Of String)
		Dim aCalcNrList As List(Of String) = New List(Of String)
		For Each aLine As SalesInvoiceLine In _InvoiceLineList
			aTFRIDList.Add(aLine.TermInvoiceLineID) 'Collect all TFR_IDs 
			If Not aDeliveryNoteNrList.Contains(aLine.DlvryNoteNr) Then 'Collect unique delivery note numbers
				aDeliveryNoteNrList.Add(aLine.DlvryNoteNr)
			End If
			If Not aCalcNrList.Contains(aLine.CalcNr) Then
				aCalcNrList.Add(aLine.CalcNr)
			End If
		Next
'Calculate and try statuses
			For Each aCalcNr In aCalcNrList
			'check calcstatus, use CalcLiveInvoiceStatus to see what the status would become if all selected tfr lines are invoiced
			Dim strFutureStatus As String = PDC.App.Calculations.StatusManagement.CalcLiveInvoiceStatus(aCalcNr, aTFRIDStringList, aDelNoteNrStringList, aDelNotePosStringList)
			Dim strError As String = ""
			If Not PDC.App.Calculations.StatusManagement.TryStatus(aCalcNr, strFutureStatus) Then
				strError = PDC.App.LastError
				_ErrMsg.Append(strError)
				Return False
			End If
		Next

Availability

Available since August 2020 (From version 5.6)