****************************************************************
** SALE.PRG - point of sale transaction handler
** J Osako 29 Jan 1996 'This code is cursed'
** Copyright 1996 The Used Computer Store, All Rights Reserved
****************************************************************
*PROCEDURE main
itemno = 1
item = NULL
serialnum = NULL
*************
** open the DBFs used in sales
IF !USED('Atom')
USE Atom IN 12
SELECT Atom
* INDEX ON (DTOS(tr_date)+timestamp) TAG nucleus
* INDEX ON (DTOS(tr_date)+timestamp)+(STR(itemno)) TAG particle
SET ORDER TO particle
ENDIF
IF !USED('Atemp')
USE Atemp IN 13
SELECT Atemp
* INDEX ON (DTOS(tr_date)+timestamp) TAG nucleus2
* INDEX ON (DTOS(tr_date)+timestamp+(STR(itemno))) TAG particle2
SET ORDER TO particle2
ENDIF
IF !USED('payform')
USE payform IN 14
SELECT payform
* INDEX ON (DTOS(tr_date)+timestamp) TAG green
SET ORDER TO green
SET RELATION TO (DTOS(tr_date)+timestamp) INTO Trans_Re ADDITIVE
ENDIF
IF !USED('wty')
USE wty IN 25
ENDIF
IF .F. && dummy code for the project mangler
DO in_item
DO get_cust
ENDIF
gotten = in_item()
DO WHILE gotten AND !get_cust() && was the get_cust() cancelled?
gotten = in_item() && was the whole trans. cancelled?
ENDDO
IF !gotten && if cancelled, erase everything it created
SELECT atom
DELETE ALL FOR (tr_date = M.tr_date AND timestamp = M.timestamp)
ELSE
SELECT Slaves && employee's ssn is the relation key
SCATTER MEMVAR FIELD ssn && between trans_re and slaves
SELECT Customer && similiar for cust_num between
SCATTER MEMVAR FIELD cust_num && trans_re and customer
INSERT INTO Trans_re FROM MEMVAR && set the record node
SELECT Atom
FOR cnt = 1 TO dups
REPORT FORM receipt ALL;
FOR (Atom.tr_date = M.tr_date AND Atom.timestamp = M.timestamp);
TO PRINTER
ENDFOR
EJECT
ENDIF
CLOSE MEMO ALL && do cleanup on the memos
RETURN