The activate_on_post_events() function is used to get ActivePOS events
import time def f(ev): message("Unique event number: %s" % ev.op_id) message("Event type: %s" % ev.type) message("Terminal ID: %s" % ev.pos_terminal) message("Terminal name: %s" % ev.pos_terminal_name) message("Associated video channel: %s" % ev.associated_channel) message("Flags: %s" % ev.flags) message("Position number: %s" % ev.position) message("Text: %s" % ev.text) message("Price per unit: %0.2f" % (ev.price/100.0)) message("Weight: %0.3f" % (ev.weight/1000.0)) message("Quantity: %s" % ev.quantity) message("Article: %s" % ev.article) message("Barcode: %s" % ev.barcode) message("Location: %s" % ev.location) message("Time of arrival on server: %s" % time.strftime("%H:%M:%S %d.%m.%Y", time.localtime(ev.ts_received/1000000))) message("Time indicated on receipt: %s" % time.strftime("%H:%M:%S %d.%m.%Y", time.localtime(ev.ts_in_receipt/1000000))) activate_on_pos_events(f)
The price is given in whole numbers in pennies, and the weight is given in grams. The reception time of the message may differ from the time recorded on the point-of-sale terminal. The reception is used to find the required moment in a video archive, while the time on the monitored cash register is used for searching.
A script can find suspicious situations. You can use the pos_fraud() function to attract the operator's attention and record an alarm event on a receipt. You can create a filter to search and highlight based on the presence of such event in a receipt.
import time def f(ev): if time.localtime().tm_hour < 23: return if ev.type!="POS_POSITION_ADD": return u = ev.text.decode("utf-8").upper().encode("utf-8") for w in ["BEER", "WINE", "VODKA", "COGNAC"]: if u.find(w) != -1: pos_fraud(ev, "Alcohol after 11pm") return activate_on_pos_events(f)
The upper() function converts a string to uppercase (all capital letters). In order for the conversion to work, the string must be in the Unicode (strings in TRASSIR are encoded in UTF-8).