예제 #1
0
 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();
 }
예제 #2
0
 function testOpenRings()
 {
     lttLib::clear();
     $d = new DeptKey();
     $this->assertEquals(true, $d->check('100DP10'));
     $json = $d->parse('100DP10');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '1DP1';
     $record['description'] = 'BBAKING';
     $record['trans_type'] = 'D';
     $record['department'] = 1;
     $record['quantity'] = 1;
     $record['foodstamp'] = 1;
     $record['unitPrice'] = 1.0;
     $record['total'] = 1.0;
     $record['regPrice'] = 1.0;
     $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);
     lttLib::clear();
     CoreLocal::set('refund', 1);
     CoreLocal::set('refundComment', 'TEST REFUND');
     $d = new DeptKey();
     $this->assertEquals(true, $d->check('100DP10'));
     $json = $d->parse('100DP10');
     $this->assertInternalType('array', $json);
     $record = lttLib::genericRecord();
     $record['upc'] = '1DP1';
     $record['description'] = 'BBAKING';
     $record['trans_type'] = 'D';
     $record['trans_status'] = 'R';
     $record['department'] = 1;
     $record['quantity'] = -1;
     $record['foodstamp'] = 1;
     $record['unitPrice'] = 1.0;
     $record['total'] = -1.0;
     $record['regPrice'] = 1.0;
     $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);
 }