Makes a lot of sense you need a Tax Schedule assigned for your type of script but I thought system gives you a ""valid tax schedule must be entered"" msg anyway. So seems like you should enforce it yourself. Several ways (all untested of course) - use the one that works:
1) UI Script: On your current script Panel PostLoad of pTotals
sTaxSch = """"
retVal = oBusObj.GetValue(""TaxSchedule$"", sTaxSch)
If sTaxSch = """" Then
sMsg = ""Please enter a Tax Schedule.""
retMsg = oSession.AsObject(oSession.UI).MessageBox("""", sMsg)
retVal = oScript.InvokeButton(""fldr.pHeader"")
Exit Sub
Else
'Run the current GP calc but watch for Division by Zero situations
End If
2) Panel PostLoad of pAddress of pLines - same as No 1 but dont' run GP calc.
3) UI Script: Panel OnExit script of pHeader
sTaxSch = """"
retVal = oBusObj.GetValue(""TaxSchedule$"", sTaxSch)
If sTaxSch = """" Then
sMsg = ""Please enter a Tax Schedule first.""
retMsg = oSession.AsObject(oSession.UI).MessageBox("""", sMsg)
retVal = oUIObj.SetFolderState(""pAddress,pLines,pTotals"", ""DISABLE"")
Else
retVal = oUIObj.SetFolderState(""pAddress,pLines,pTotals"", ""ENABLE"")
End If
4) Pre-Validate of CustomerNo
CustNo = value : DivNo = """" : sTaxSch = """"
retVal = oBusObj.GetValue(""ARDivisionNo$"", DivNo)
FullCustNo = DivNo & CustNo
Set oCust = oBusObj.AsObject(oBusObj.GetChildHandle(""CustomerNo""))
Found = oCust.Find(FullCustNo)
If Found = 1 Then
retVal = oCust.Find(""TaxSchedule$"", sTaxSch)
If sTaxSch = """" Then
sMsg = ""Oops default tax schdule is missing for "" & DivNo&""-""&CustNo
retVal = oScript.SetError(sMsg)
'or instead of error use MessageBox to give a warning
End If
Also Michael might be saying on Line Post-Write (or on Pre-Totals by traversing the lines from top to bottom) accumulate the ExtensionAmt but separate the Taxable Amt from Nontaxable Amt into your separate variables (maybe check the Tax Class for TX vs NT vs others). Then regardless on Pre-Totals do the GP calcs and the 2 UDF SetValue's and you're done. I like this because the issue with using UI scripts is just that it won't work if say you're V/I importing these orders or web service importing these orders (there's no UI). However you would need to be certain there are no exemptions in play that would make TX lines nontaxable. Of course I can't really speak for Michael :)