Script to Block Users From Invoicing Zero Quantities

Locked
COBS Tech Support
Site Admin
Posts: 101
Joined: Sat May 15, 2021 9:57 am

Script to Block Users From Invoicing Zero Quantities

Post by COBS Tech Support »

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.

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
Locked