Esempio n. 1
0
 public function testPatronageChecks()
 {
     $config = FannieConfig::factory();
     $task = new PatronageCheckTask();
     $dbc = FannieDB::get($config->get('OP_DB'));
     $dbc->query('TRUNCATE TABLE patronage');
     $p = new PatronageModel($dbc);
     $p->cardno(1);
     $p->FY(2000);
     $p->check_number(1);
     $p->cashed_date(null);
     $p->cashed_here(0);
     $p->save();
     $dbc = FannieDB::get($config->get('TRANS_DB'));
     $dbc->query('TRUNCATE TABLE dlog_15');
     $d = new DLog15Model($dbc);
     $d->tdate('2000-01-01 00:00:00');
     $d->trans_type('T');
     $d->description('REBATE CHECK');
     $d->total(1.23);
     $d->card_no(1);
     $d->save();
     $task->run();
     $dbc = FannieDB::get($config->get('OP_DB'));
     $p->reset();
     $p->cardno(1);
     $p->FY(2000);
     $loaded = $p->load();
     $this->assertEquals(true, $loaded, 'Failed to load patronage record');
     $this->assertEquals('2000-01-01 00:00:00', $p->cashed_date(), 'Cashed date missing');
     $this->assertEquals(1, $p->cashed_here(), 'Not marked as cashed');
 }
Esempio n. 2
0
 public function post_id_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $prep = $dbc->prepare('
         INSERT INTO patronage
         (cardno, purchase, discounts, rewards, net_purch, tot_pat, cash_pat, equit_pat, FY)
         SELECT cardno,
             purchase,
             discounts,
             rewards,
             net_purch,
             ?,
             ?,
             ?,
             FY
         FROM patronage_workingcopy
         WHERE FY=?
             AND cardno=?');
     $args = array(FormLib::get('cash') + FormLib::get('retain'), FormLib::get('cash'), FormLib::get('retain'), FormLib::get('fy'), $this->id);
     $this->success = $dbc->execute($prep, $args);
     if ($this->success) {
         $pat = new PatronageModel($dbc);
         $pat->cardno($this->id);
         $pat->FY(FormLib::get('fy'));
         $number = GumLib::allocateCheck($patronage, false);
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $pat->check_number($number);
         $pat->save();
     }
     return true;
 }