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(); }
/** 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 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); }