function testTenderDbRecords() { lttLib::clear(); $t = new TenderModule('CA', 1.0); $t->add(); $record = lttLib::genericRecord(); $record['trans_type'] = 'T'; $record['trans_subtype'] = 'CA'; $record['description'] = 'Cash'; $record['total'] = -1.0; lttLib::verifyRecord(1, $record, $this); CoreLocal::set('currentid', 1); $v = new Void(); $this->assertEquals(true, $v->check('VD')); $json = $v->parse('VD'); $this->assertInternalType('array', $json); $record['total'] *= -1; $record['voided'] = 1; $record['trans_status'] = 'V'; lttLib::verifyRecord(2, $record, $this); }
public function testHouseCoupons() { if (!class_exists('lttLib')) { include dirname(__FILE__) . '/lttLib.php'; } /** TEST 1: minType M, discountType Q */ lttLib::clear(); $upc = new UPC(); $upc->parse('0000000000111'); $upc->parse('0000000000234'); $hc = new HouseCoupon(); $hc->handle('0049999900001', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900001'; $record['description'] = 'MIXED+QUANTITY'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -2.39; $record['total'] = -2.39; $record['regPrice'] = -2.39; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); /** TEST 2: no minimum, discountType %D */ lttLib::clear(); $upc = new UPC(); $upc->parse('0000000001009'); $upc->parse('0000000001011'); $hc = new HouseCoupon(); $hc->handle('0049999900002', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900002'; $record['description'] = '%DEPARTMENT'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -0.75; $record['total'] = -0.75; $record['regPrice'] = -0.75; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); /** TEST 3: minimum D, discountType F */ lttLib::clear(); $dept = new DeptKey(); $dept->parse('2300DP10'); $dept->parse('200DP10'); $hc = new HouseCoupon(); $hc->handle('0049999900003', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900003'; $record['description'] = '5OFF25DEPT'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -5.0; $record['total'] = -5.0; $record['regPrice'] = -5.0; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); /** TEST 4: minimum MX, discountType F */ lttLib::clear(); $dept = new DeptKey(); $dept->parse('900DP10'); $upc = new UPC(); $upc->parse('0000000000234'); $hc = new HouseCoupon(); $hc->handle('0049999900004', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900004'; $record['description'] = 'MIXCROSS'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -1.0; $record['total'] = -1.0; $record['regPrice'] = -1.0; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); /** TEST 5: minType Q, discountType PI */ lttLib::clear(); $upc = new UPC(); $upc->parse('0000000000111'); $upc->parse('0000000000234'); $hc = new HouseCoupon(); $hc->handle('0049999900005', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900005'; $record['description'] = 'PERITEM'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -1.0; $record['total'] = -1.0; $record['regPrice'] = -1.0; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); /** TEST 6: dept qty minimum, discountType %D */ lttLib::clear(); $upc = new UPC(); $upc->parse('0000000001009'); $upc->parse('0000000001011'); $hc = new HouseCoupon(); $hc->handle('0049999900006', array()); $record = lttLib::genericRecord(); $record['upc'] = '0049999900006'; $record['description'] = 'DEPTQTY'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'IC'; $record['trans_status'] = 'C'; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = -0.75; $record['total'] = -0.75; $record['regPrice'] = -0.75; $record['discountable'] = 1; lttLib::verifyRecord(3, $record, $this); lttLib::clear(); }
public function testScreenDisplay() { lttLib::clear(); $u = new UPC(); $u->check('666'); $u->parse('666'); $records = DisplayLib::screenDisplay(0, 1); $item = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => 0.05, 'status' => 'T', 'lineColor' => '004080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 1); $spec = array(1 => $item); $this->assertEquals(count($records), count($spec)); $view = $this->getViewVersion(0, 2); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); } $t = new TenderModule('CA', 1.0); $t->add(); $tender = array('description' => '', 'comment' => 'Cash', 'total' => -1.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'T', 'trans_status' => '', 'voided' => 0, 'trans_id' => 2); $spec[2] = $tender; $records = DisplayLib::screenDisplay(0, 2); $view = $this->getViewVersion(0, 2); $this->assertEquals(count($records), count($spec)); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); } CoreLocal::set('memberID', 1); CoreLocal::set('isMember', 1); CoreLocal::set('percentDiscount', 10); CoreLocal::set('memType', 1); PrehLib::ttl(); $notify = array('description' => '** 10% Discount Applied **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => '0', 'trans_status' => 'D', 'voided' => 4, 'trans_id' => 3); $discount = array('description' => '', 'comment' => 'Discount', 'total' => 0.0, 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 5, 'trans_id' => 4); $subtotal = array('description' => 'Subtotal -0.95, Tax0.00 #1', 'comment' => 'Total ', 'total' => -0.95, 'status' => '', 'lineColor' => '000000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 3, 'trans_id' => 5); $spec[3] = $notify; $spec[4] = $discount; $spec[5] = $subtotal; $records = DisplayLib::screenDisplay(0, 5); $view = $this->getViewVersion(0, 5); $this->assertEquals(count($records), count($spec)); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); } CoreLocal::set('quantity', 2); CoreLocal::set('multiple', 1); $u = new UPC(); $u->check('4627'); $u->parse('4627'); $item = array('description' => 'PKALE', 'comment' => '2 @ 1.99', 'total' => 3.98, 'status' => 'F', 'lineColor' => '408080', 'discounttype' => 1, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 6); $notice = array('description' => '** YOU SAVED $0.60 **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'D', 'voided' => 2, 'trans_id' => 7); $spec[6] = $item; $spec[7] = $notice; $records = DisplayLib::screenDisplay(0, 7); $view = $this->getViewVersion(0, 7); $this->assertEquals(count($records), count($spec)); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); } CoreLocal::set('quantity', 0); CoreLocal::set('multiple', 0); CoreLocal::set('currentid', 1); $v = new Void(); $v->check('VD'); $v->parse('VD'); $void = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => -0.05, 'status' => 'VD', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'V', 'voided' => 1, 'trans_id' => 8); $spec[8] = $void; $spec[1]['voided'] = 1; $records = DisplayLib::screenDisplay(0, 8); $view = $this->getViewVersion(0, 8); $this->assertEquals(count($records), count($spec)); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); } TransRecord::addFsTaxExempt(); $fs = array('description' => '', 'comment' => 'FS Tax Exempt', 'total' => 0.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 17, 'trans_id' => 9); $spec[9] = $fs; $records = DisplayLib::screenDisplay(0, 9); $view = $this->getViewVersion(0, 9); $this->assertEquals(count($records), count($spec)); foreach (array_keys($records) as $i) { $this->assertArrayHasKey($i, $records); $this->assertArrayHasKey($i, $spec); $this->compareArrays($records[$i], $spec[$i]); $this->compareArrays($records[$i], $view[$i]); $this->compareArrays($spec[$i], $view[$i]); } CoreState::memberReset(); lttLib::clear(); }
/** Add a taxable, non-foodstampable item record, shift it, and verify */ function testTaxFoodShift() { if (!class_exists('lttLib')) { include dirname(__FILE__) . '/lttLib.php'; } lttLib::clear(); $upc = new UPC(); $upc->parse('0000000000111'); $record = lttLib::genericRecord(); $record['upc'] = '0000000000111'; $record['description'] = 'WYNDMERE 5-8 DRAM BOTTLE'; $record['trans_type'] = 'I'; $record['trans_subtype'] = 'NA'; $record['trans_status'] = ''; $record['department'] = 103; $record['quantity'] = 1; $record['ItemQtty'] = 1; $record['unitPrice'] = 1.65; $record['total'] = 1.65; $record['regPrice'] = 1.65; $record['tax'] = 1; $record['discountable'] = 1; $record['mixMatch'] = '499'; lttLib::verifyRecord(1, $record, $this); $tfs = new TaxFoodShift(); $tfs->parse('TFS'); $record['tax'] = 0; $record['foodstamp'] = 1; lttLib::verifyRecord(1, $record, $this); lttLib::clear(); }
public function testMercuryE2E() { if (!class_exists('lttLib')) { include dirname(__FILE__) . '/lttLib.php'; } lttLib::clear(); $plugins = CoreLocal::get('PluginList'); if (!in_array('Paycards', $plugins)) { $plugins[] = 'Paycards'; CoreLocal::set('PluginList', $plugins); } /** Initialize session stuff to run a test transaction */ CoreLocal::set('CCintegrate', 1); CoreLocal::set('RegisteredPaycardClasses', array('MercuryE2E')); CoreLocal::set('PaycardsTerminalID', '99'); CoreLocal::set('PaycardsTenderCodeCredit', 'CC'); CoreLocal::set('PaycardsTenderCodeVisa', ''); CoreLocal::set('CacheCardType', 'CREDIT'); CoreLocal::set('ttlflag', 1); CoreLocal::set('amtdue', 0.01); CoreLocal::set('CashierNo', 9999); CoreLocal::set('laneno', 99); CoreLocal::set('transno', 1); CoreLocal::set('training', 1); /** Run parser on test PAN. Verify result and appropriate session vars initialized */ $parser = new paycardEntered(); // source: Visa Test Card using Sign&Pay w/ test keys $pan = '02E600801F2E2700039B25423430303330302A2A2A2A2A2A363738315E544553542F4D50535E313531322A2A2A2A2A2A2A2A2A2A2A2A2A3F3B3430303330302A2A2A2A2A2A363738313D313531322A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A3FA7284186B3E8E1A3E2AD8548E732DBB5B33285117FB1B0CDBA6D732E5DF031DE3CB590DE2E02BDEF6182373B7401A3E3D304013C85D3BEFDEBF552A3C30914246B0145538F2E5856885CAA06FF64E201CB974CD506ADDCB22C9F3BF500C62310C9C88B56FD2BDF6E59481BC4B6C4F034264B2C38F8FF6F4405D563AA7D49B82221111010000000E001BFXXXX03'; $this->assertEquals(true, $parser->check($pan), 'Parser does not handle input'); $json = $parser->parse($pan); $url = 'plugins/Paycards/gui/paycardboxMsgAuth.php'; $this->assertEmpty($json['output'], 'Parser error message: ' . $json['output']); $this->assertEquals($url, substr($json['main_frame'], -1 * strlen($url)), 'No redirect to auth page'); $this->assertEquals(0.01, CoreLocal::get('paycard_amount')); $this->assertEquals(PaycardLib::PAYCARD_MODE_AUTH, CoreLocal::get('paycard_mode')); $this->assertEquals(PaycardLib::PAYCARD_TYPE_ENCRYPTED, CoreLocal::get('paycard_type')); // mercury's gateway is returning weird errors; // don't feel like addressing it right now return; /** Submit transaction to processor. Verify return value and check database for an appropriate auth record */ $this->emptyPaycardTables(); $processor = new MercuryE2E(); $auth_result = $processor->doSend(PaycardLib::PAYCARD_MODE_AUTH); $this->assertEquals(PaycardLib::PAYCARD_ERR_OK, $auth_result, 'Authorization attempt produced error: ' . $auth_result . ' : ' . CoreLocal::get('boxMsg')); $db = Database::tDataConnect(); $ptrans = $db->query('SELECT * FROM PaycardTransactions'); $row = $db->fetch_row($ptrans); $this->assertEquals(date('Ymd'), $row['dateID']); $this->assertEquals(9999, $row['empNo']); $this->assertEquals(99, $row['registerNo']); $this->assertEquals(1, $row['transNo']); $this->assertEquals(1, $row['transID']); $this->assertEquals('MercuryE2E', $row['processor']); $this->assertEquals('Credit', $row['cardType']); $this->assertEquals('Sale', $row['transType']); $this->assertEquals(0.01, $row['amount']); $this->assertEquals('Visa', $row['issuer']); $this->assertEquals(0, $row['commErr']); $this->assertEquals(200, $row['httpCode']); $this->assertEquals(1, $row['validResponse']); $this->assertEquals(1, $row['xResultCode']); $this->assertEquals(0, $row['xResponseCode']); $this->assertNotEmpty($row['xApprovalNumber']); $this->assertNotEmpty($row['xResultMessage']); $this->assertNotEmpty($row['xTransactionID']); $this->assertNotEmpty($row['xToken']); $this->assertNotEmpty($row['xProcessorRef']); $this->assertNotEmpty($row['xAcquirerRef']); $this->assertEquals('************', substr($row['PAN'], 0, 12)); /** cleanup test transaction record(s) */ $this->emptyPaycardTables(); }
public function testPrehLib() { if (!class_exists('lttLib')) { include 'lttLib.php'; } lttLib::clear(); TransRecord::addcomment('peek'); $peek = PrehLib::peekItem(); $this->assertEquals('peek', $peek); lttLib::clear(); CoreLocal::set('percentDiscount', 5); CoreLocal::set('transDiscount', 0.51); CoreLocal::set('taxTotal', 1.45); CoreLocal::set('fsTaxExempt', 1.11); CoreLocal::set('amtdue', 9.550000000000001); // should add four records PrehLib::finalttl(); // verify discount record $record = lttLib::genericRecord(); $record['description'] = 'Discount'; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['unitPrice'] = -0.51; $record['voided'] = 5; lttLib::verifyRecord(1, $record, $this); // verify subtotal record $record = lttLib::genericRecord(); $record['upc'] = 'Subtotal'; $record['description'] = 'Subtotal'; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['unitPrice'] = 0.34; $record['voided'] = 11; lttLib::verifyRecord(2, $record, $this); // verify fs tax exempt record $record = lttLib::genericRecord(); $record['upc'] = 'Tax'; $record['description'] = 'FS Taxable'; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['unitPrice'] = 1.11; $record['voided'] = 7; lttLib::verifyRecord(3, $record, $this); // verify total record $record = lttLib::genericRecord(); $record['upc'] = 'Total'; $record['description'] = 'Total'; $record['trans_type'] = 'C'; $record['trans_status'] = 'D'; $record['unitPrice'] = 9.550000000000001; $record['voided'] = 11; lttLib::verifyRecord(4, $record, $this); lttLib::clear(); CoreLocal::set('cashierAge', 17); CoreLocal::set('cashierAgeOverride', 0); list($age_required, $json) = PrehLib::ageCheck(21, array()); $this->assertEquals(true, $age_required); $this->assertInternalType('array', $json); CoreLocal::set('cashierAgeOverride', 1); list($age_required, $json) = PrehLib::ageCheck(21, array()); $this->assertEquals(true, $age_required); $this->assertInternalType('array', $json); CoreLocal::set('memAge', date('Ymd', strtotime('21 years ago'))); list($age_required, $json) = PrehLib::ageCheck(21, array()); $this->assertEquals(false, $age_required); $this->assertInternalType('array', $json); CoreLocal::set('memAge', date('Ymd', strtotime('20 years ago'))); list($age_required, $json) = PrehLib::ageCheck(21, array()); $this->assertEquals(true, $age_required); $this->assertInternalType('array', $json); }