I'm on a mission to see how many errors I can encounter when building a down payment invoice via DI-API. My latest encounter came at me like this.
'-5002: 10000100 - Document total value must be zero or greater than zero' when the Down Payment Invoice (DPI) .add() phase was encountered for just 2 orders out of 70+. The Sales Order (SO) was successfully created.
So I adapted my code to include:
DownDOC.DocTotal = SaleDOC.DocTotal
This then gave me a new error.
'-5002: There is a difference between the document total and its components'
So I figured I would attempt explicitly define line and tax totals for the DPI.
For iLoop As Integer = 0 To SaleDOC.Lines.Count - 1 SaleDOC.Lines.SetCurrentLine(iLoop) With DownDOC.Lines If .BaseEntry <> 0 Then .Add() End If If SaleDOC.Lines.TreeType <> BoItemTreeTypes.iIngredient Then .BaseEntry = lngDocEntry .BaseType = BoObjectTypes.oOrders .BaseLine = iLoop .LineTotal = SaleDOC.Lines.LineTotal 'ADDED .TaxTotal = SaleDOC.Lines.TaxTotal 'ADDED End If End With Next
Yet the '-5002: There is a difference between the document total and its components' error persists.
Since all my other orders import with no issue, I investigated the two orders and determined that these two both contained products that were out of stock. I tested creating the SO's manually and was prompted with 'Item Availability Check'. Is there some other action happening with the DI-API when an out of stock item is encountered?