public function findVSPForTradeData(TradeData $tradeData)
 {
     $sql = "\n            SELECT 'VSP' as purchase, DATE_FORMAT(l.date,'%m%d%Y') as purchase_date, rq.quantity\n            FROM " . $this->table . " rq\n              LEFT JOIN " . self::TABLE_LOT . " l ON l.id = rq.lot_id\n              LEFT JOIN " . self::TABLE_REBALANCER_ACTION . " ra On ra.id = rq.rebalancer_action_id\n            WHERE ra.job_id = :jobId AND rq.system_client_account_id = :accountId AND rq.security_id = :securityId\n        ";
     $paramaters = array('jobId' => $tradeData->getJobId(), 'accountId' => $tradeData->getAccountId(), 'securityId' => $tradeData->getSecurityId());
     $results = $this->db->query($sql, $paramaters);
     return $results;
 }
Exemplo n.º 2
0
 public function testSetVsps()
 {
     $vsps = array(array('purchase' => 'VSP', 'purchase_date' => '02132013', 'quantity' => 70));
     $this->tradeData->setVsps($vsps);
     $this->assertCount(1, $this->tradeData->getVsps());
     $this->assertEquals($vsps, $this->tradeData->getVsps());
 }
 public function testFindVSPForTradeData()
 {
     $riaRepo = new RiaRepository();
     $ria = $riaRepo->findOneBy(array('email' => '*****@*****.**'));
     $jobRepo = new JobRepository();
     $job = $jobRepo->findOneBy(array('user_id' => $ria->getId()));
     $accountRepo = new AccountRepository();
     $securityRepo = new SecurityRepository();
     $tradeData = new TradeData();
     $tradeData->setJobId($job->getId());
     $tradeData->setAccountId($accountRepo->findOneByAccountNumber('916985328')->getId());
     $tradeData->setSecurityId($securityRepo->findOneBySymbol('RWX')->getId());
     $vsps = $this->repository->findVSPForTradeData($tradeData);
     $vspsExpected = array(array('purchase' => 'VSP', 'purchase_date' => '02132013', 'quantity' => 36), array('purchase' => 'VSP', 'purchase_date' => '02162013', 'quantity' => 20));
     $this->assertEquals($vspsExpected, $vsps);
 }