示例#1
0
 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();
 }
示例#2
0
 function testItemsEntry()
 {
     CoreLocal::set('mfcoupon', 0);
     CoreLocal::set('itemPD', 0);
     CoreLocal::set('multiple', 0);
     CoreLocal::set('quantity', 0);
     CoreLocal::set('refund', 0);
     CoreLocal::set('toggletax', 0);
     CoreLocal::set('togglefoodstamp', 0);
     CoreLocal::set('toggleDiscountable', 0);
     CoreLocal::set('nd', 0);
     // test regular price item
     lttLib::clear();
     $u = new UPC();
     $this->assertEquals(true, $u->check('666'));
     $json = $u->parse('666');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0000000000666';
     $record['description'] = 'EXTRA BAG';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['department'] = 13;
     $record['tax'] = 1;
     $record['quantity'] = 1;
     $record['unitPrice'] = 0.05;
     $record['total'] = 0.05;
     $record['regPrice'] = 0.05;
     $record['ItemQtty'] = 1;
     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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     lttLib::verifyRecord(2, $record, $this);
     // test quantity multiplier
     lttLib::clear();
     CoreLocal::set('quantity', 2);
     CoreLocal::set('multiple', 1);
     $u = new UPC();
     $this->assertEquals(true, $u->check('666'));
     $json = $u->parse('666');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0000000000666';
     $record['description'] = 'EXTRA BAG';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['department'] = 13;
     $record['tax'] = 1;
     $record['quantity'] = 2;
     $record['unitPrice'] = 0.05;
     $record['total'] = 0.1;
     $record['regPrice'] = 0.05;
     $record['ItemQtty'] = 2;
     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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     lttLib::verifyRecord(2, $record, $this);
     // test refund
     lttLib::clear();
     CoreLocal::set('quantity', 0);
     CoreLocal::set('multiple', 0);
     CoreLocal::set('refund', 1);
     CoreLocal::set('refundComment', 'TEST REFUND');
     $u = new UPC();
     $this->assertEquals(true, $u->check('666'));
     $json = $u->parse('666');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0000000000666';
     $record['description'] = 'EXTRA BAG';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['trans_status'] = 'R';
     $record['department'] = 13;
     $record['tax'] = 1;
     $record['quantity'] = -1;
     $record['unitPrice'] = 0.05;
     $record['total'] = -0.05;
     $record['regPrice'] = 0.05;
     $record['ItemQtty'] = 1;
     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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     lttLib::verifyRecord(2, $record, $this);
     // test sale item
     lttLib::clear();
     CoreLocal::set('refund', 0);
     CoreLocal::set('refundComment', '');
     $u = new UPC();
     $this->assertEquals(true, $u->check('4627'));
     $json = $u->parse('4627');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0000000004627';
     $record['description'] = 'PKALE';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['department'] = 513;
     $record['foodstamp'] = 1;
     $record['discounttype'] = 1;
     $record['discountable'] = 1;
     $record['quantity'] = 1;
     $record['cost'] = 1.3;
     $record['unitPrice'] = 1.99;
     $record['total'] = 1.99;
     $record['regPrice'] = 2.29;
     $record['discount'] = 0.3;
     $record['ItemQtty'] = 1;
     $record['mixMatch'] = '943';
     lttLib::verifyRecord(1, $record, $this);
     $drecord = lttLib::genericRecord();
     $drecord['description'] = '** YOU SAVED $0.30 **';
     $drecord['trans_type'] = 'I';
     $drecord['department'] = 513;
     $drecord['trans_status'] = 'D';
     $drecord['voided'] = 2;
     lttLib::verifyRecord(2, $drecord, $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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     $record['discount'] *= -1;
     lttLib::verifyRecord(3, $record, $this);
     // test member sale
     lttLib::clear();
     CoreLocal::set('isMember', 1);
     $u = new UPC();
     $this->assertEquals(true, $u->check('0003049488122'));
     $json = $u->parse('0003049488122');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0003049488122';
     $record['description'] = 'MINERAL WATER';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['department'] = 188;
     $record['foodstamp'] = 1;
     $record['discounttype'] = 2;
     $record['discountable'] = 1;
     $record['quantity'] = 1;
     $record['cost'] = 2.06;
     $record['unitPrice'] = 2.49;
     $record['total'] = 2.49;
     $record['regPrice'] = 3.15;
     $record['memDiscount'] = 0.66;
     $record['ItemQtty'] = 1;
     lttLib::verifyRecord(1, $record, $this);
     $drecord = lttLib::genericRecord();
     $drecord['description'] = '** YOU SAVED $0.66 **';
     $drecord['trans_type'] = 'I';
     $drecord['department'] = 188;
     $drecord['trans_status'] = 'D';
     $drecord['voided'] = 2;
     lttLib::verifyRecord(2, $drecord, $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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     $record['memDiscount'] *= -1;
     lttLib::verifyRecord(3, $record, $this);
     // test member sale as non-member
     lttLib::clear();
     CoreLocal::set('isMember', 0);
     $u = new UPC();
     $this->assertEquals(true, $u->check('0003049488122'));
     $json = $u->parse('0003049488122');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '0003049488122';
     $record['description'] = 'MINERAL WATER';
     $record['trans_type'] = 'I';
     $record['trans_subtype'] = 'NA';
     $record['department'] = 188;
     $record['foodstamp'] = 1;
     $record['discounttype'] = 2;
     $record['discountable'] = 1;
     $record['quantity'] = 1;
     $record['cost'] = 2.06;
     $record['unitPrice'] = 3.15;
     $record['total'] = 3.15;
     $record['regPrice'] = 3.15;
     $record['memDiscount'] = 0.66;
     $record['ItemQtty'] = 1;
     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['quantity'] *= -1;
     $record['ItemQtty'] *= -1;
     $record['voided'] = 1;
     $record['trans_status'] = 'V';
     $record['memDiscount'] *= -1;
     lttLib::verifyRecord(2, $record, $this);
 }