Script to Block Users From Invoicing Zero Quantities
Posted: Fri May 21, 2021 11:53 am
The following script scans an invoice or related transaction before saving it to the database and prevents the transaction from being saved if a product item with a zero invoice quantity is found. The script must be saved in your main ..\CAPITAL folder with the filename R-ITOTAL.MAC.
Refer to the product documentation for more information.
Refer to the product documentation for more information.
Code: Select all
* Prevent zero stock quantities
If .Not. ReadTranValue("NEW")
Return
Endif
Declare nMaxCount Type Number
Declare nCount Type Number
nCount := 0
nMaxCount := ReadItemValue("STOCKID", -1)
:Loop
nCount := nCount + 1
If nCount > nMaxCount
Goto End
Endif
If .Not. IsEmpty(ReadItemValue("STOCKID", nCount)) .And. IsEmpty(ReadItemValue("QTY", nCount))
Echo("Sorry, this transaction contains a product line item with a zero quantity. Please correct before you continue.",, TRUE)
Return FALSE
Endif
Goto Loop
:End
Return TRUE