/**
  * Creates a Planned Transaction.
  * 
  * @param $badgerDb object The DB object.
  * @param $account object The Account object who created this Transaction.
  * @param $data mixed An associative array with the values out of the DB OR the id of the Transaction.
  * @param $repeatUnit string The repeat unit of the Transaction.
  * @param $repeatFrequency string The repeat frequency of the Transaction.
  * @param $beginDate object The Date object with the begin date of the Transaction.
  * @param $endDate object The Date object with the end date of the Transaction.
  * @param $title string The title of the Transaction.
  * @param $amount object The Amount object with the amount of this Transaction.
  * @param $description string The description of the Transaction.
  * @param $transactionPartner string The transaction partner of the Transaction
  * @param $outsideCapital boolean The origin of the Transaction.
  */
 function __construct(&$badgerDb, &$account, $data, $repeatUnit = null, $repeatFrequency = null, $beginDate = null, $endDate = null, $title = null, $amount = null, $description = null, $transactionPartner = null, $category = null, $outsideCapital = null, $type = 'PlannedTransaction', $transferalTransaction = null)
 {
     $CategoryManager = new CategoryManager($badgerDb);
     $this->badgerDb = $badgerDb;
     $this->account = $account;
     if (is_array($data)) {
         $this->id = $data['planned_transaction_id'];
         $this->title = $data['title'];
         $this->description = $data['description'];
         $this->amount = new Amount($data['amount']);
         $this->outsideCapital = $data['outside_capital'];
         $this->transactionPartner = $data['transaction_partner'];
         if ($data['category_id']) {
             $this->category = $CategoryManager->getCategoryById($data['category_id']);
         }
         $this->beginDate = new Date($data['begin_date']);
         if ($data['end_date']) {
             $this->endDate = new Date($data['end_date']);
         }
         $this->repeatUnit = $data['repeat_unit'];
         $this->repeatFrequency = $data['repeat_frequency'];
         $this->transferalSource = $data['transferal_source'];
         if (!$data['transferal_transaction_id']) {
             $this->type = 'FinishedTransaction';
         } else {
             $this->type = 'FinishedTransferalTransaction';
         }
         if ($data['transferal_transaction_id']) {
             if (!is_null($repeatUnit) && $data['transferal_transaction_id'] == $repeatUnit->getId()) {
                 $this->transferalTransaction = $repeatUnit;
             } else {
                 $accountManager = new AccountManager($badgerDb);
                 try {
                     $transferalAccount = $accountManager->getAccountByPlannedTransactionId($data['transferal_transaction_id']);
                     $this->transferalTransaction = $transferalAccount->getPlannedTransactionById($data['transferal_transaction_id'], $this);
                 } catch (BadgerException $ex) {
                     $this->transferalTransaction = null;
                 }
             }
         }
     } else {
         $this->id = $data;
         $this->title = $title;
         $this->description = $description;
         $this->amount = $amount;
         $this->outsideCapital = $outsideCapital;
         $this->transactionPartner = $transactionPartner;
         $this->category = $category;
         $this->beginDate = $beginDate;
         $this->endDate = $endDate;
         $this->repeatUnit = $repeatUnit;
         $this->repeatFrequency = $repeatFrequency;
         $this->type = $type;
         $this->transferalTransaction = $transferalTransaction;
         $this->transferalSource = null;
     }
     $this->updateMode = self::UPDATE_MODE_ALL;
     $this->otherPlannedTransaction = null;
     $this->beginDateLocked = false;
     $this->endDateLocked = false;
     $this->originalTitle = $this->title;
     $this->originalBeginDate = new Date($this->beginDate);
     if (!is_null($this->endDate)) {
         $this->originalEndDate = new Date($this->endDate);
     } else {
         $this->originalEndDate = null;
     }
     $this->originalRepeatUnit = $this->repeatUnit;
     $this->originalRepeatFrequency = $this->repeatFrequency;
 }