Purchase Invoice first invoice in warehouse produces error - 7.00.157 and prior only

Error is produced when attempting to enter the first purchase invoice for a warehouse - " The controls value cannot be set outside the range determined by the 'MinValue' and 'MaxValue' properties. "

Please run the attached SQL script to resolve the error message.

SQL Process Knowledge Required

Please note that you must have advanced SQL knowledge to complete the following steps.



Insert Seed Purchase Invoice Data
INSERT INTO PI_Main( CreditorID, PI_MainID, IN_LogicalID, FreightTaxID, DutyTaxID, InsuranceTaxID, Status, TotalLineTax, AdjTax, LastSavedDateTime, InvoiceDate, DueDate) Select (SELECT top 1 c.CreditorID from CR_Main c) as CreditorID, 'JIWA' + LEFT(REPLACE(NEWID(), '-', ''), 16) as PI_MainID, l.IN_LogicalID, 'GST01000000000000000', 'GST01000000000000000', 'GST01000000000000000', 1, 0, 0, '2016-6-30', '2016-6-30', '2016-6-30' FROM IN_Logical l where l.IN_LogicalID not in (select pi.IN_LogicalID from PI_Main pi where pi.IN_LogicalID = l.IN_LogicalID)