Functions related to the database
static COREPOS\pos\lib\Database::getsubtotals |
( |
| ) |
|
|
static |
Load values from subtotals view into session. Essentially refreshes totals in the session.
9May14 Andy I belive this query is equivalent to the old subtotals => lttsubtotals => lttsummary I've omitted tax since those are already calculated separately. A few conditions here should obviously be more configurable, but first I want to get rid of or simply the old nested views
fsEligible is the complicated one. That's:
- Total foodstampable items
- Minus transaction-level discount on those items
- Minus any foodstamp tenders already applied. localtemptrans.total is negative on tenders so the query uses an addition sign but in effect it's subracting. $replacementQ = " SELECT CASE WHEN MAX(trans_id) IS NULL THEN 0 ELSE MAX(trans_id) END AS LastID, MAX(card_no) AS card_no, SUM(total) AS runningTotal, SUM(CASE WHEN discounttype=1 THEN total ELSE 0 END) AS discountTTL, SUM(CASE WHEN discounttype IN (2,3) THEN total ELSE 0 END) AS staffSpecial, SUM(CASE WHEN discounttype=4 THEN total ELSE 0 END) AS discountTTL, SUM(CASE WHEN trans_type='T' THEN total ELSE 0 END) AS tenderTotal, MAX(percentDiscount) AS percentDiscount, SUM(CASE WHEN discountable=0 THEN 0 ELSE total END) as discountableTotal, SUM(CASE WHEN discountable=0 THEN 0 ELSE total END) * (MAX(percentDiscount)/100.00) AS transDiscount, SUM(CASE WHEN trans_subtype IN ('MI', 'CX') THEN total ELSE 0 END) AS chargeTotal, SUM(CASE WHEN department=990 THEN total ELSE 0 END) as paymentTotal, SUM(CASE WHEN numflag=1 THEN total ELSE 0 END) as localTotal, SUM(CASE WHEN trans_status='V' THEN total ELSE 0 END) as voidTotal, ( SUM(CASE WHEN foodstamp=1 THEN total ELSE 0 END)
- ((MAX(percentDiscount)/100.00) SUM(CASE WHEN foodstamp=1 AND discountable=1 THEN total ELSE 0 END))
- SUM(CASE WHEN trans_subtype IN ('EF','FS') THEN total ELSE 0 END) ) AS fsEligble FROM localtemptrans AS l WHERE trans_type <> 'L' ";
If FS eligible amount is greater than the current transaction total and total is positive, limit the eligible amount to the current total. This may not be technically correct but the resulting change causes a lot of headaches depending what kind of change is allowed for earlier tenders, if change is allowed for those tenders at all.
The other case is a refund to FS. Over-tendering on a refund doesn't make any sense.
static COREPOS\pos\lib\Database::rotateTempData |
( |
| ) |
|
|
static |
Rotate current transaction data Current data in translog.localtemptrans is inserted into:
- translog.dtransactions
- translog.localtrans
- translog.localtranstoday (if not a view)
- translog.localtrans_today (if present)
- Returns
- [boolean] success or failure
Success or failure is based on whether or not the insert into translog.dtransactions succeeds. That's the most important query in terms of ensuring data flows properly to the server.
If store_id column is present in lane dtransactions table and the lane's store_id has been configured, assign that value to the column. Otherwise it may be handled but some other mechanism such as triggers or column default values.