Ejemplo n.º 1
0
 public function addDiscountLine()
 {
     TransRecord::addcdnotify();
 }
Ejemplo n.º 2
0
 private static function deptOpenRing($dept, $price, $discount, $ret)
 {
     /**
       Enforce memberOnly flag
     */
     if ($dept['memberOnly'] > 0) {
         switch ($dept['memberOnly']) {
             case 1:
                 // member only, no override
                 if (CoreLocal::get('isMember') == 0) {
                     $ret['output'] = DisplayLib::boxMsg(_(_('Department is member-only'), _('Enter member number first'), false, array('Member Search [ID]' => 'parseWrapper(\'ID\');', 'Dismiss [clear]' => 'parseWrapper(\'CL\');')));
                     return $ret;
                 }
                 break;
             case 2:
                 // member only, can override
                 if (CoreLocal::get('isMember') == 0) {
                     if (CoreLocal::get('msgrepeat') == 0 || CoreLocal::get('lastRepeat') != 'memberOnlyDept') {
                         CoreLocal::set('boxMsg', _('Department is member-only<br />' . '[enter] to continue, [clear] to cancel'));
                         CoreLocal::set('lastRepeat', 'memberOnlyDept');
                         $ret['main_frame'] = $my_url . 'gui-modules/boxMsg2.php';
                         return $ret;
                     } else {
                         if (CoreLocal::get('lastRepeat') == 'memberOnlyDept') {
                             CoreLocal::set('lastRepeat', '');
                         }
                     }
                 }
                 break;
             case 3:
                 // anyone but default non-member
                 if (CoreLocal::get('memberID') == '0') {
                     $ret['output'] = DisplayLib::boxMsg(_(_('Department is member-only'), _('Enter member number first'), false, array('Member Search [ID]' => 'parseWrapper(\'ID\');', 'Dismiss [clear]' => 'parseWrapper(\'CL\');')));
                     return $ret;
                 } else {
                     if (CoreLocal::get('memberID') == CoreLocal::get('defaultNonMem')) {
                         $ret['output'] = DisplayLib::boxMsg(_(_('Department not allowed with this member'), '', false, DisplayLib::standardClearButton()));
                         return $ret;
                     }
                 }
                 break;
         }
     }
     $deptmax = $dept['dept_limit'] ? $dept['dept_limit'] : 0;
     $deptmin = $dept['dept_minimum'] ? $dept['dept_minimum'] : 0;
     $tax = $dept["dept_tax"];
     $foodstamp = $dept['dept_fs'] != 0 ? 1 : 0;
     $deptDiscount = $dept["dept_discount"];
     list($tax, $foodstamp, $deptDiscount) = self::applyToggles($tax, $foodstamp, $deptDiscount);
     if ($price > $deptmax && (CoreLocal::get('OpenRingHardMinMax') || CoreLocal::get("msgrepeat") == 0)) {
         CoreLocal::set("boxMsg", "\$" . $price . " " . _("is greater than department limit"));
         $maxButtons = array('Confirm [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();');
         // remove Confirm button/text if hard limits enforced
         if (CoreLocal::get('OpenRingHardMinMax')) {
             array_shift($maxButtons);
         }
         CoreLocal::set('boxMsgButtons', $maxButtons);
         $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php';
     } elseif ($price < $deptmin && (CoreLocal::get('OpenRingHardMinMax') || CoreLocal::get("msgrepeat") == 0)) {
         CoreLocal::set("boxMsg", "\$" . $price . " " . _("is lower than department minimum"));
         $minButtons = array('Confirm [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();');
         if (CoreLocal::get('OpenRingHardMinMax')) {
             array_shift($minButtons);
         }
         CoreLocal::set('boxMsgButtons', $minButtons);
         $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php';
     } else {
         if (CoreLocal::get("casediscount") > 0) {
             TransRecord::addcdnotify();
             CoreLocal::set("casediscount", 0);
         }
         TransRecord::addRecord(array('upc' => $price . 'DP' . $dept['dept_no'], 'description' => $dept['dept_name'], 'trans_type' => 'D', 'department' => $dept['dept_no'], 'quantity' => CoreLocal::get('quantity'), 'ItemQtty' => CoreLocal::get('quantity'), 'unitPrice' => $price, 'total' => $price * CoreLocal::get('quantity'), 'regPrice' => $price, 'tax' => $tax, 'foodstamp' => $foodstamp, 'discountable' => $deptDiscount, 'voided' => 0, 'discount' => $discount));
         CoreLocal::set("ttlflag", 0);
         CoreLocal::set("msgrepeat", 0);
         if (CoreLocal::get("itemPD") > 0) {
             TransRecord::adddiscount($discount, $dept);
         }
         $ret['output'] = DisplayLib::lastpage();
         $ret['redraw_footer'] = true;
         $ret['udpmsg'] = 'goodBeep';
     }
     return $ret;
 }
Ejemplo n.º 3
0
 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();
 }