Beispiel #1
0
 public function testSetIsPreferredBuy()
 {
     $this->security->setIsPreferredBuy(false);
     $this->assertFalse($this->security->getIsPreferredBuy());
 }
 protected function bindSubclassCollection(array $data, SecurityCollection $securityCollection)
 {
     $subclassCollection = new SubclassCollection();
     foreach ($data as $values) {
         $subclass = new Subclass();
         $subclass->loadFromArray($values);
         /** @var Security $security */
         $security = $securityCollection->get($values['security_id']);
         $security->setSubclass($subclass);
         $subclass->setSecurity($security);
         if (isset($values['muni_substitution_id']) && $values['muni_substitution_id']) {
             $sql = "SELECT sp.price FROM " . self::TABLE_SECURITY_PRICE . " sp\n                        WHERE sp.is_current = true AND sp.security_id = :security_id\n                          ORDER BY sp.datetime DESC\n                          LIMIT 1\n                        ";
             $parameters = array('security_id' => $values['muni_substitution_id']);
             $securityPriceData = $this->db->query($sql, $parameters);
             $muni = new Security();
             $muni->setId($values['muni_substitution_id']);
             $muni->setSubclass($subclass);
             $muni->setIsPreferredBuy(true);
             $muni->setName($values['muni_name']);
             $muni->setSymbol($values['muni_symbol']);
             $muni->setPrice($securityPriceData[0]['price']);
             $subclass->setMuniSecurity($muni);
         }
         $subclassCollection->add($subclass);
     }
     return $subclassCollection;
 }