Example #1
0
 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);
 }
Example #2
0
 public function defaultPrompt()
 {
     if (CoreLocal::get("enableFranking") != 1) {
         return parent::defaultPrompt();
     }
     if ($this->amount === False) {
         return parent::disabledPrompt();
     }
     $ref = trim(CoreLocal::get("CashierNo")) . "-" . trim(CoreLocal::get("laneno")) . "-" . trim(CoreLocal::get("transno"));
     $msg = "<br />" . _("insert") . " " . $this->name_string . ' for $' . sprintf('%.2f', $this->amount) . '<br />';
     if (CoreLocal::get("LastEquityReference") == $ref) {
         $msg .= "<div style=\"background:#993300;color:#ffffff;\n                margin:3px;padding: 3px;\">\n                There was an equity sale on this transaction. Did it get\n                endorsed yet?</div>";
     }
     CoreLocal::set("boxMsg", $msg);
     CoreLocal::set('strEntered', 100 * $this->amount . $this->tender_code);
     CoreLocal::set('boxMsgButtons', array('Endorse [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
     return MiscLib::base_url() . 'gui-modules/boxMsg2.php?endorse=check&endorseAmt=' . $this->amount;
 }
Example #3
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();
 }
Example #4
0
 function parse($str)
 {
     /**
       If customer card is available, prevent other tenders
       unless specficially allowed (e.g., coupons).
     */
     if (CoreLocal::get('PaycardsBlockTenders') == 1) {
         $tender_code = strtoupper(substr($str, -2));
         $exceptions = strtoupper(CoreLocal::get('PaycardsBlockExceptions'));
         $except_array = preg_split('/[^A-Z]+/', $exceptions, 0, PREG_SPLIT_NO_EMPTY);
         if (CoreLocal::get('ccTermState') == 'ready' && !in_array($tender_code, $except_array)) {
             CoreLocal::set('boxMsg', _('Tender customer card before other tenders'));
             CoreLocal::set('boxMsgButtons', array('Charge Card [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
             CoreLocal::set('strEntered', 'CCFROMCACHE');
             $ret = $this->default_json();
             $ret['main_frame'] = MiscLib::baseURL() . 'gui-modules/boxMsg2.php';
             return $ret;
         }
     }
     if (strlen($str) > 2) {
         $left = substr($str, 0, strlen($str) - 2);
         $right = substr($str, -2);
         $ret = PrehLib::tender($right, $left);
         return $ret;
     } else {
         $ret = $this->default_json();
         $base_object = new TenderModule($str, False);
         $tender_object = 0;
         $map = CoreLocal::get("TenderMap");
         if (is_array($map) && isset($map[$str])) {
             $class = $map[$str];
             $tender_object = new $class($str, False);
         }
         $errors = $base_object->ErrorCheck();
         if ($errors !== True) {
             $ret['output'] = $errors;
             return $ret;
         }
         if (is_object($tender_object)) {
             $errors = $tender_object->ErrorCheck();
             if ($errors !== True) {
                 $ret['output'] = $errors;
                 return $ret;
             }
         }
         if (is_object($tender_object) && !$tender_object->AllowDefault()) {
             $ret['output'] = $tender_object->DisabledPrompt();
             return $ret;
         } elseif (is_object($tender_object) && $tender_object->AllowDefault()) {
             CoreLocal::set('RepeatAgain', true);
             $ret['main_frame'] = $tender_object->DefaultPrompt();
             return $ret;
         } else {
             if ($base_object->AllowDefault()) {
                 CoreLocal::set('RepeatAgain', true);
                 $ret['main_frame'] = $base_object->DefaultPrompt();
                 return $ret;
             } else {
                 $ret['output'] = $base_object->DisabledPrompt();
                 return $ret;
             }
         }
     }
 }
Example #5
0
 public function add()
 {
     parent::add();
     TransRecord::addfsTaxExempt();
 }