Esempio n. 1
0
 public function testIsTaxable()
 {
     $this->assertTrue($this->account->isTaxable());
     $this->account->setType(Account::TYPE_JOINT_INVESTMENT);
     $this->assertTrue($this->account->isTaxable());
     $this->account->setType(Account::TYPE_ROTH_IRA);
     $this->assertFalse($this->account->isTaxable());
 }
Esempio n. 2
0
 /**
  * Check Tax Loss Harvesting
  * 6.C step in spec
  *
  * @param Account $account
  * @param Subclass $subclass
  * @return boolean
  */
 public function checkTlh(Account $account, Subclass $subclass)
 {
     $client = $account->getClient();
     $ria = $client->getRia();
     /** @var LotRepository $lotRepository */
     $lotRepository = $this->getRepository('Lot');
     /** @var ClientRepository $clientRepository */
     $clientRepository = $this->getRepository('Client');
     $clientRepository->loadStopTlhValue($client);
     $date = new \DateTime();
     $clientLossesSum = $lotRepository->getClientLossesSumForYear($client, $date->format('Y'));
     if ($ria->getIsTlhEnabled() && $client->canUseTlh() && $account->isTaxable() && $subclass->hasTlhFund() && abs($clientLossesSum) >= $client->getStopTlhValue()) {
         $lots = $lotRepository->findLotsByAccountAndSecurity($account, $subclass->getSecurity());
         $amount = 0;
         /** @var Lot $lot */
         foreach ($lots as $lot) {
             $loss = $lot->getRealizedGainOrLoss();
             $lossPercent = round(($lot->getAmount() - $lot->getCostBasis()) / $lot->getAmount(), 2);
             if ($loss < 0 && abs($loss) >= $ria->getMinTlh() && abs($lossPercent) >= $ria->getMinTlhPercent()) {
                 $amount += $this->sellLot($lot, $subclass->getSecurity(), $account, $lot->getAmount());
             }
         }
         $this->buySecurity($subclass->getTaxLossHarvesting(), $account, $amount);
     }
 }