public function handle($upc, $json) { /** Adjust string index of pieces based on whether check digits have been included */ $man_id_start = 3; $fam_start = 8; $val_start = 11; if ($this->ean && CoreLocal::get('EanIncludeCheckDigits') == 1 || !$this->ean && CoreLocal::get('UpcIncludeCheckDigits') == 1) { $man_id_start = 2; $fam_start = 9; $val_start = 10; } $man_id = substr($upc, $man_id_start, 5); $fam = substr($upc, $fam_start, 3); $val = substr($upc, $val_start, 2); $db = Database::pDataConnect(); $query = "select Value,Qty from couponcodes where Code = '" . $val . "'"; $result = $db->query($query); $num_rows = $db->num_rows($result); if ($num_rows == 0) { $json['output'] = DisplayLib::boxMsg(_("coupon type unknown") . "<br />" . _("enter coupon manually"), '', false, DisplayLib::standardClearButton()); return $json; } $query2 = "SELECT reason, threshold FROM disableCoupon WHERE upc='{$upc}'"; $result2 = $db->query($query2); if ($result2 && $db->num_rows($result2) > 0) { $row = $db->fetch_row($result2); if ($row['threshold'] <= 0) { $json['output'] = DisplayLib::boxMsg($row['reason'], _("coupon disabled"), false, DisplayLib::standardClearButton()); return $json; } else { $transDB = Database::tDataConnect(); $q = "SELECT SUM(quantity) FROM localtemptrans WHERE upc='{$upc}'"; $r = $transDB->query($q); if ($transDB->num_rows($r) > 0) { $w = $transDB->fetch_row($r); $qty = $w[0]; if ($qty >= $row['threshold']) { $json['output'] = DisplayLib::boxMsg(_('coupon already applied'), '', false, DisplayLib::standardClearButton()); return $json; } } } } $row = $db->fetch_array($result); $value = $row["Value"]; $qty = $row["Qty"]; if ($fam == "992") { // 992 basically means blanket accept // Old method of asking cashier to assign a department // just creates confusion // Instead I just try to guess, otherwise use zero // (since that's what would happen anyway when the // confused cashier does a generic coupon tender) $value = MiscLib::truncate2($value); CoreLocal::set("couponupc", $upc); CoreLocal::set("couponamt", $value); $dept = 0; $db = Database::tDataConnect(); // SQL strings are indexed starting w/ one instead of zero // hence $man_id_start+1 $query = "select department from localtemptrans \n WHERE substring(upc," . ($man_id_start + 1) . ",5)='{$man_id}' \n GROUP BY department\n ORDER BY count(*) desc"; $result = $db->query($query); if ($db->num_rows($result) > 0) { $row = $db->fetch_row($result); $dept = $row['department']; } TransRecord::addCoupon($upc, $dept, $value); $json['output'] = DisplayLib::lastpage(); return $json; } // validate coupon $db = Database::tDataConnect(); $fam = substr($fam, 0, 2); /* the idea here is to track exactly which items in the transaction a coupon was previously applied to SQL strings are indexed starting w/ one instead of zero hence $man_id_start+1 */ $query = "select max(t.unitPrice) as unitPrice,\n max(t.department) as department,\n max(t.ItemQtty) as itemQtty,\n sum(case when c.quantity is null then 0 else c.quantity end) as couponQtty,\n max(case when c.quantity is not null then 0 else t.foodstamp end) as foodstamp,\n max(case when c.quantity is not null then 0 else t.tax end) as tax,\n max(t.emp_no) as emp_no,\n max(t.trans_no) as trans_no,\n t.trans_id from\n localtemptrans as t left join couponApplied as c\n on t.emp_no=c.emp_no and t.trans_no=c.trans_no\n and t.trans_id=c.trans_id\n where (substring(t.upc," . ($man_id_start + 1) . ",5)='{$man_id}'"; /* not right per the standard, but organic valley doesn't * provide consistent manufacturer ids in the same goddamn * coupon book */ if ($this->ean) { $query .= " or substring(t.upc," . $man_id_start . ",5)='{$man_id}'"; } $query .= ") and t.trans_status <> 'C'\n group by t.trans_id\n order by t.unitPrice desc"; $result = $db->query($query); $num_rows = $db->num_rows($result); /* no item w/ matching manufacturer */ if ($num_rows == 0) { $json['output'] = DisplayLib::boxMsg(_("product not found") . "<br />" . _("in transaction"), '', false, DisplayLib::standardClearButton()); return $json; } /* count up per-item quantites that have not yet had a coupon applied to them */ $available = array(); $emp_no = $transno = $dept = $foodstamp = $tax = -1; $act_qty = 0; while ($row = $db->fetch_array($result)) { if ($row["itemQtty"] - $row["couponQtty"] > 0) { $id = $row["trans_id"]; $available["{$id}"] = array(0, 0); $available["{$id}"][0] = $row["unitPrice"]; $available["{$id}"][1] += $row["itemQtty"]; $available["{$id}"][1] -= $row["couponQtty"]; $act_qty += $available["{$id}"][1]; } if ($emp_no == -1) { $emp_no = $row["emp_no"]; $transno = $row["trans_no"]; $dept = $row["department"]; $foodstamp = $row["foodstamp"]; $tax = $row['tax']; } } /* every line has maximum coupons applied */ if (count($available) == 0) { $json['output'] = DisplayLib::boxMsg(_("Coupon already applied") . "<br />" . _("for this item"), '', false, DisplayLib::standardClearButton()); return $json; } /* insufficient number of matching items */ if ($qty > $act_qty) { $msg = sprintf(_("coupon requires %d items"), $qty) . "<br />" . sprintf(_("there are only %d item(s)"), $act_qty) . "<br />" . _("in this transaction"); $json['output'] = DisplayLib::boxMsg($msg, '', false, DisplayLib::standardClearButton()); return $json; } /* free item, multiple choices needs work, obviously */ if ($value == 0 && count($available) > 1) { // decide which item(s) // manually by cashier maybe? } /* log the item(s) this coupon is being applied to */ $applied = 0; foreach (array_keys($available) as $id) { if ($value == 0) { $value = -1 * $available["{$id}"][0]; } if ($qty <= $available["{$id}"][1]) { $q = "INSERT INTO couponApplied \n (emp_no,trans_no,quantity,trans_id)\n VALUES (\n {$emp_no},{$transno},{$qty},{$id})"; $r = $db->query($q); $applied += $qty; } else { $q = "INSERT INTO couponApplied \n (emp_no,trans_no,quantity,trans_id)\n VALUES (\n {$emp_no},{$transno}," . $available["{$id}"][1] . ",{$id})"; $r = $db->query($q); $applied += $available["{$id}"][1]; } if ($applied >= $qty) { break; } } $value = MiscLib::truncate2($value); $json['udpmsg'] = 'goodBeep'; TransRecord::addCoupon($upc, $dept, $value, $foodstamp, $tax); $json['output'] = DisplayLib::lastpage(); $json['redraw_footer'] = True; return $json; }
public function handle($upc, $json) { $pos = 0; $first_req = array(); /* STEP 1 - REQUIRED FIELDS */ // remove prefix 8110 $pos += 4; // grab company prefix length, remove it from barcode $prefix_length = (int) $upc[$pos] + 6; $pos += 1; // grab company prefix, remove from barcode $first_req['man_id'] = substr($upc, $pos, $prefix_length); $pos += $prefix_length; // this way all prefixes map against // localtemptrans.upc[2,length] if ($prefix_length == 6) { $first_req['man_id'] = "0" . $first_req['man_id']; } // grab offer code, remove from barcode $offer = substr($upc, $pos, 6); $pos += 6; // read value length $val_length = (int) $upc[$pos]; $pos += 1; // read value $value = (int) substr($upc, $pos, $val_length); $pos += $val_length; // read primary requirement length $req_length = (int) $upc[$pos]; $pos += 1; // read primary requirement value $first_req['value'] = substr($upc, $pos, $req_length); $pos += $req_length; // read primary requirement type-code $first_req['code'] = $upc[$pos]; $pos += 1; // read primary requirement family code $first_req['family'] = substr($upc, $pos, 3); $pos += 3; /* END REQUIRED FIELDS */ /* example: barcode: 8110100707340143853100110110 company prefix length => 1 (+6) company prefix => 0070734 offer code => 014385 value length => 3 value => 100 primary req length => 1 primary req value => 1 primary req code => 0 primary req family => 110 */ /* STEP 2 - CHECK FOR OPTIONAL FIELDS */ // second required item $second_req = array(); $req_rules_code = 1; $duplicate_prefix_flag = false; if (isset($upc[$pos]) && $upc[$pos] == "1") { $pos += 1; $rules_code = $upc[$pos]; $pos += 1; $sr_length = (int) $upc[$pos]; $pos += 1; $second_req['value'] = substr($upc, $pos, $sr_length); $pos += $sr_length; $second_req['code'] = $upc[$pos]; $pos += 1; $second_req['family'] = substr($upc, $pos, 3); $pos += 3; $sm_length = (int) $upc[$pos] + 6; $pos += 1; if ($sm_length == 15) { // 9+6 $second_req['man_id'] = $first_req['man_id']; $duplicate_prefix_flag = true; } else { $second_req['man_id'] = substr($upc, $pos, $sm_length); $pos += $sm_length; if ($sm_length == 6) { $second_req['man_id'] = "0" . $second_req['man_id']; } } } // third required item $third_req = array(); if (isset($upc[$pos]) && $upc[$pos] == "2") { $pos += 1; $tr_length = (int) $upc[$pos]; $pos += 1; $third_req['value'] = substr($upc, $pos, $tr_length); $pos += $tr_length; $third_req['code'] = $upc[$pos]; $pos += 1; $third_req['family'] = substr($upc, $pos, 3); $pos += 3; $tm_length = (int) $upc[$pos] + 6; $pos += 1; if ($tm_length == 15) { // 9+6 $third_req['man_id'] = $first_req['man_id']; $duplicate_prefix_flag = true; } else { $third_req['man_id'] = substr($upc, $pos, $tm_length); $pos += $tm_length; if ($tm_length == 6) { $third_req['man_id'] = "0" . $third_req['man_id']; } } } if ($duplicate_prefix_flag) { $first_req['man_id'] .= $first_req['family']; $second_req['man_id'] .= $second_req['family']; $third_req['man_id'] .= $third_req['family']; } // expiration date if (isset($upc[$pos]) && $upc[$pos] == "3") { $pos += 1; $expires = substr($upc, $pos, 6); $pos += 6; $y = "20" . substr($expires, 0, 2); $m = substr($expires, 2, 2); $d = substr($expires, 4, 2); $tstamp = mktime(23, 59, 59, $m, $d, $y); if ($tstamp < time()) { $json['output'] = DisplayLib::boxMsg("Coupon expired {$m}/{$d}/{$y}"); return $json; } } // start date if (isset($upc[$pos]) && $upc[$pos] == "4") { $pos += 1; $starts = substr($upc, $pos, 6); $pos += 6; $y = "20" . substr($starts, 0, 2); $m = substr($starts, 2, 2); $d = substr($starts, 4, 2); $tstamp = mktime(0, 0, 0, $m, $d, $y); if ($tstamp > time()) { $json['output'] = DisplayLib::boxMsg("Coupon not valid until {$m}/{$d}/{$y}"); return $json; } } // serial number $serial = false; if (isset($upc[$pos]) && $upc[$pos] == "5") { $pos += 1; $serial_length = (int) $upc[$pos] + 6; $pos += 1; $serial = substr($upc, $pos, $serial_length); $pos += $serial_length; } // retailer $retailer = false; if (isset($upc[$pos]) && $upc[$pos] == "6") { $pos += 1; $rt_length = (int) $upc[$pos] + 6; $pos += 1; $retailer = substr($upc, $pos, $rt_length); $pos += $rt_length; } /* END OPTIONAL FIELDS */ /* STEP 3 - The Miscellaneous Field This field is also optional, but filling in the default values here will make code that validates coupons and calculates values consistent */ $misc = array('value_code' => 0, 'value_applies' => 0, 'store_coupon' => 0, 'no_multiply' => 0); if (isset($upc[$pos]) && $upc[$pos] == "9") { $pos += 1; $misc['value_code'] = $upc[$pos]; $pos += 1; $misc['value_applies'] = $upc[$pos]; $pos += 1; $misc['store_coupon'] = $upc[$pos]; $pos += 1; $misc['no_multiply'] = $upc[$pos]; $pos += 1; } /* END Miscellaneous Field */ /* STEP 4 - validate coupon requirements */ $primary = $this->validateRequirement($first_req, $json); if (!$primary && (count($second_req) == 0 || $req_rules_code == 1 || $req_rules_code == 2)) { // if the primary requirement isn't valid and // a) there are no more requirments, or // b) the primary requirement is mandatory // return the json. Error message should have been // set up by validateRequirement() return $json; } $secondary = $this->validateRequirement($second_req, $json); if (!$secondary && (count($third_req) == 0 || $req_rules_code == 1)) { // if the secondary requirment isn't valid and // a) there are no more requirments, or // b) all requirements are mandatory // return the json. Error message should have been // set up by validateRequirement() return $json; } $tertiary = $this->validateRequirement($third_req, $json); // compare requirement results with rules // return error message if applicable switch ($req_rules_code) { case '0': // any requirement can be used if (!$primary && !$secondary && !$tertiary) { return $json; } break; case '1': // all required if (!$primary || !$secondary || !$tertiary) { return $json; } break; case '2': // primary + second OR third if (!$primary) { return $json; } else { if (!$secondary && !$tertiary) { return $json; } } break; case '3': // either second or third. seems odd, may // be misreading documentation on this one if (!$secondary && !$tertiary) { return $json; } break; default: $json['output'] = DisplayLib::boxMsg("Malformed coupon"); return $json; } /* End requirement validation */ /* STEP 5 - determine coupon value */ $val_arr = $first_req; if ($misc['value_applies'] == 1) { $val_arr = $second_req; } else { if ($misc['value_applies'] == 2) { $val_arr = $third_req; } } $value = 0; switch ($misc['value_code']) { case '0': // value in cents // value in cents case '6': $value = MiscLib::truncate2($val_arr['value'] / 100.0); break; case '1': // free item $value = $val_arr['price']; break; case '2': // multiple free items $value = MiscLib::truncate2($val_arr['price'] * $val_arr['value']); break; case '5': // percent off $value = MiscLib::truncate2($val_arr['price'] * ($val_arr['value'] / 100.0)); break; default: $json['output'] = DisplayLib::boxMsg("Error: bad coupon"); return $json; } /* attempt to cram company prefix and offer code into 13 characters First character is zero Next characters are company prefix Remaining characters are offer code in base-36 The first zero is there so that the company prefix will "line up" with matching items in localtemptrans The offer code is converted to base-36 to reduce its character count. Offer code won't always fit. This is just best effort. I've already seen a real coupon using a 10 digit prefix. In theory there could even be a 12 digit prefix leaving no room for the offer code at all. */ $upc_start = "0" . $val_arr['man_id']; $offer = base_convert($offer, 10, 36); $remaining = 13 - strlen($upc_start); if (strlen($offer) < $remaining) { $offer = str_pad($offer, $remaining, '0', STR_PAD_LEFT); } elseif (strlen($offer) > $remaining) { $offer = substr($offer, 0, $remaining); } $coupon_upc = $upc_start . $offer; TransRecord::addCoupon($coupon_upc, $row['department'], -1 * $value); $json['output'] = DisplayLib::lastpage(); return $json; }
function preprocess() { $this->box_color = "coloredArea"; $this->msg = "Undo transaction"; if (isset($_REQUEST['reginput'])) { $trans_num = strtoupper($_REQUEST['reginput']); // clear/cancel undo attempt if ($trans_num == "" || $trans_num == "CL") { $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } // error: malformed transaction number if (!strpos($trans_num, "-")) { $this->box_color = "errorColoredArea"; $this->msg = "Transaction not found"; return True; } $temp = explode("-", $trans_num); // error: malformed transaction number (2) if (count($temp) != 3) { $this->box_color = "errorColoredArea"; $this->msg = "Transaction not found"; return True; } $emp_no = $temp[0]; $register_no = $temp[1]; $old_trans_no = $temp[2]; // error: malformed transaction number (3) if (!is_numeric($emp_no) || !is_numeric($register_no) || !is_numeric($old_trans_no)) { $this->box_color = "errorColoredArea"; $this->msg = "Transaction not found"; return True; } $db = 0; $query = ""; if ($register_no == CoreLocal::get("laneno")) { // look up transation locally $db = Database::tDataConnect(); $query = "select upc, description, trans_type, trans_subtype,\n trans_status, department, quantity, scale, unitPrice,\n total, regPrice, tax, foodstamp, discount, memDiscount,\n discountable, discounttype, voided, PercentDiscount,\n ItemQtty, volDiscType, volume, VolSpecial, mixMatch,\n matched, card_no, trans_id\n from localtranstoday where register_no = {$register_no}\n and emp_no = {$emp_no} and trans_no = {$old_trans_no}\n and datetime >= " . $db->curdate() . "\n and trans_status <> 'X'\n order by trans_id"; } else { if (CoreLocal::get("standalone") == 1) { // error: remote lookups won't work in standalone $this->box_color = "errorColoredArea"; $this->msg = "Transaction not found"; return True; } else { // look up transaction remotely $db = Database::mDataConnect(); $query = "select upc, description, trans_type, trans_subtype,\n trans_status, department, quantity, scale, unitPrice,\n total, regPrice, tax, foodstamp, discount, memDiscount,\n discountable, discounttype, voided, PercentDiscount,\n ItemQtty, volDiscType, volume, VolSpecial, mixMatch,\n matched, card_no, trans_id\n from dtransactions where register_no = {$register_no}\n and emp_no = {$emp_no} and trans_no = {$old_trans_no}\n and datetime >= " . $db->curdate() . "\n and trans_status <> 'X'\n order by trans_id"; } } $result = $db->query($query); // transaction not found if ($db->num_rows($result) < 1) { $this->box_color = "errorColoredArea"; $this->msg = "Transaction not found"; return True; } /* change the cashier to the original transaction's cashier */ $prevCashier = CoreLocal::get("CashierNo"); CoreLocal::set("CashierNo", $emp_no); CoreLocal::set("transno", Database::gettransno($emp_no)); /* rebuild the transaction, line by line, in reverse */ $card_no = 0; TransRecord::addcomment("VOIDING TRANSACTION {$trans_num}"); while ($row = $db->fetch_array($result)) { $card_no = $row["card_no"]; if ($row["upc"] == "TAX") { //TransRecord::addtax(); } elseif ($row["trans_type"] == "T") { if ($row["description"] == "Change") { TransRecord::addchange(-1 * $row["total"]); } elseif ($row["description"] == "FS Change") { TransRecord::addfsones(-1 * $row["total"]); } else { TransRecord::addtender($row["description"], $row["trans_subtype"], -1 * $row["total"]); } } elseif (strstr($row["description"], "** YOU SAVED")) { $temp = explode("\$", $row["description"]); TransRecord::adddiscount(substr($temp[1], 0, -3), $row["department"]); } elseif ($row["upc"] == "FS Tax Exempt") { TransRecord::addfsTaxExempt(); } elseif (strstr($row["description"], "% Discount Applied")) { $temp = explode("%", $row["description"]); TransRecord::discountnotify(substr($temp[0], 3)); } elseif ($row["description"] == "** Order is Tax Exempt **") { TransRecord::addTaxExempt(); } elseif ($row["description"] == "** Tax Excemption Reversed **") { TransRecord::reverseTaxExempt(); } elseif ($row["description"] == " * Manufacturers Coupon") { TransRecord::addCoupon($row["upc"], $row["department"], -1 * $row["total"]); } elseif (strstr($row["description"], "** Tare Weight")) { $temp = explode(" ", $row["description"]); TransRecord::addTare($temp[3] * 100); } elseif ($row["upc"] == "DISCOUNT") { //TransRecord::addTransDiscount(); } elseif ($row["trans_status"] != "M" && $row["upc"] != "0" && (is_numeric($row["upc"]) || strstr($row["upc"], "DP"))) { $row["trans_status"] = "V"; $row["total"] *= -1; $row["discount"] *= -1; $row["memDiscount"] *= -1; $row["quantity"] *= -1; $row["ItemQtty"] *= -1; TransRecord::addRecord($row); } } PrehLib::setMember($card_no, 1); CoreLocal::set("autoReprint", 0); /* do NOT restore logged in cashier until this transaction is complete */ $this->change_page($this->page_url . "gui-modules/undo_confirm.php"); return False; } return True; }
public function testTransRecord() { if (!class_exists('lttLib')) { include 'lttLib.php'; } lttLib::clear(); CoreLocal::set('infoRecordQueue', array()); TransRecord::addQueued('1234567890123', 'UNIT TEST', 1, 'UT', 1.99); $queue = CoreLocal::get('infoRecordQueue'); $this->assertInternalType('array', $queue); $this->assertEquals(1, count($queue)); $this->assertArrayHasKey(0, $queue); $this->assertInternalType('array', $queue[0]); $this->assertArrayHasKey('upc', $queue[0]); $this->assertEquals('1234567890123', $queue[0]['upc']); $this->assertArrayHasKey('description', $queue[0]); $this->assertEquals('UNIT TEST', $queue[0]['description']); $this->assertArrayHasKey('numflag', $queue[0]); $this->assertEquals(1, $queue[0]['numflag']); $this->assertArrayHasKey('charflag', $queue[0]); $this->assertEquals('UT', $queue[0]['charflag']); $this->assertArrayHasKey('regPrice', $queue[0]); $this->assertEquals(1.99, $queue[0]['regPrice']); TransRecord::emptyQueue(); $queue = CoreLocal::get('infoRecordQueue'); $this->assertInternalType('array', $queue); $this->assertEquals(0, count($queue)); $record = lttLib::genericRecord(); $record['upc'] = '1234567890123'; $record['description'] = 'UNIT TEST'; $record['numflag'] = 1; $record['charflag'] = 'UT'; $record['regPrice'] = 1.99; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); CoreLocal::set('taxTotal', 1.23); TransRecord::addtax(); $record = lttLib::genericRecord(); $record['upc'] = 'TAX'; $record['description'] = 'Tax'; $record['trans_type'] = 'A'; $record['total'] = 1.23; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addtender('UT TENDER', 'UT', 2.34); $record = lttLib::genericRecord(); $record['description'] = 'UT TENDER'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'UT'; $record['total'] = 2.34; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addcomment('UNIT TEST COMMENT'); $record = lttLib::genericRecord(); $record['description'] = 'UNIT TEST COMMENT'; $record['trans_type'] = 'C'; $record['trans_subtype'] = 'CM'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addchange(3.14, 'UT'); $record = lttLib::genericRecord(); $record['description'] = 'Change'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'UT'; $record['total'] = 3.14; $record['voided'] = 8; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addfsones(3); $record = lttLib::genericRecord(); $record['description'] = 'FS Change'; $record['trans_type'] = 'T'; $record['trans_subtype'] = 'FS'; $record['total'] = 3; $record['voided'] = 8; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::adddiscount(5.45, 25); $record = lttLib::genericRecord(); $record['description'] = '** YOU SAVED $5.45 **'; $record['trans_type'] = 'I'; $record['trans_status'] = 'D'; $record['department'] = 25; $record['voided'] = 2; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addfsTaxExempt(); $record = lttLib::genericRecord(); $record['upc'] = 'FS Tax Exempt'; $record['description'] = ' Fs Tax Exempt '; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['voided'] = 17; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::discountnotify(5); $record = lttLib::genericRecord(); $record['description'] = '** 5% Discount Applied **'; $record['trans_status'] = 'D'; $record['voided'] = 4; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addTaxExempt(); $record = lttLib::genericRecord(); $record['description'] = '** Order is Tax Exempt **'; $record['trans_status'] = 'D'; $record['voided'] = 10; $record['tax'] = 9; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(1, CoreLocal::get('TaxExempt')); lttLib::clear(); TransRecord::reverseTaxExempt(); $record = lttLib::genericRecord(); $record['description'] = '** Tax Exemption Reversed **'; $record['trans_status'] = 'D'; $record['voided'] = 10; $record['tax'] = 9; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(0, CoreLocal::get('TaxExempt')); lttLib::clear(); CoreLocal::set('casediscount', 7); TransRecord::addcdnotify(); $record = lttLib::genericRecord(); $record['description'] = '** 7% Case Discount Applied'; $record['trans_status'] = 'D'; $record['voided'] = 6; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addCoupon('0051234512345', 123, -1.23, 1); $record = lttLib::genericRecord(); $record['upc'] = '0051234512345'; $record['description'] = ' * Manufacturers Coupon'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'CP'; $record['trans_status'] = 'C'; $record['department'] = 123; $record['unitPrice'] = -1.23; $record['total'] = -1.23; $record['regPrice'] = -1.23; $record['foodstamp'] = 1; $record['quantity'] = 1; $record['ItemQtty'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addhousecoupon('0049999912345', 122, -1.22); $record = lttLib::genericRecord(); $record['upc'] = '0049999912345'; $record['description'] = ' * Store Coupon'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['department'] = 122; $record['unitPrice'] = -1.22; $record['total'] = -1.22; $record['regPrice'] = -1.22; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['discountable'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::additemdiscount(345, 3.45); $record = lttLib::genericRecord(); $record['upc'] = 'ITEMDISCOUNT'; $record['description'] = ' * Item Discount'; $record['trans_type'] = 'I'; $record['department'] = 345; $record['unitPrice'] = -3.45; $record['total'] = -3.45; $record['regPrice'] = -3.45; $record['quantity'] = 1; $record['ItemQtty'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addtare(5); $record = lttLib::genericRecord(); $record['description'] = '** Tare Weight 0.05 **'; $record['trans_status'] = 'D'; $record['voided'] = 6; lttLib::verifyRecord(1, $record, $this); $this->assertEquals(0.05, CoreLocal::get('tare')); lttLib::clear(); CoreLocal::set('transDiscount', 3.24); TransRecord::addTransDiscount(); $record = lttLib::genericRecord(); $record['upc'] = 'DISCOUNT'; $record['description'] = 'Discount'; $record['trans_type'] = 'S'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -3.24; $record['total'] = -3.24; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); TransRecord::addCashDrop('90.78'); $record = lttLib::genericRecord(); $record['upc'] = 'DROP'; $record['description'] = 'Cash Drop'; $record['trans_type'] = 'I'; $record['trans_status'] = 'X'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -90.78; $record['total'] = -90.78; $record['charflag'] = 'CD'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); $record = lttLib::genericRecord(); $record['upc'] = 'UNITTEST'; $record['description'] = 'Unit Test'; $record['department'] = 5; $record['numflag'] = 4; $record['charflag'] = 'UT'; $record['amount1'] = 1.23; $record['total'] = 1.23; $record['amount2'] = 1.24; $record['regPrice'] = 1.24; TransRecord::add_log_record($record); unset($record['amount1']); // not real column unset($record['amount2']); // not real column $record['trans_type'] = 'L'; $record['trans_subtype'] = 'OG'; $record['trans_status'] = 'D'; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); }