public static function create(DB $db, Amount $denom, Purchase $p) { $prepared = $db->prepare(' INSERT INTO `bills` ( `entered_at`, `denomination`, `purchase_id` ) VALUES ( NOW(), :denomination, :purchase_id ) '); $result = $prepared->execute(array(':denomination' => $denom->get(), ':purchase_id' => $p->getId())); if ($result === false) { throw new Exception("Unable to log bill."); } return self::load($db, $db->lastInsertId()); }
public function modulusBy(Amount $b) { return new Amount(bcmod($this->get(), $b->get(), Amount::SCALE)); }
$chart['chart_data'][0][] = $tmp->getFormatted(); $numberOfGraph = 1; if ($showLowerLimit == 1) { $chart['chart_data'][$numberOfGraph][] = $lowerLimit->get(); $numberOfGraph++; } if ($showUpperLimit == 1) { $chart['chart_data'][$numberOfGraph][] = $upperLimit->get(); $numberOfGraph++; } if ($showPlannedTransactions == 1) { $chart['chart_data'][$numberOfGraph][] = $val->get(); $numberOfGraph++; } //to keep $dailyPocketMoney $dailyPocketMoneyLoop = new Amount($dailyPocketMoney->get()); $val1 = new Amount($val->get()); if ($showSavingTarget == 1) { $chart['chart_data'][$numberOfGraph][] = $val1->sub($dailyPocketMoneyLoop->mul($day))->get(); $numberOfGraph++; } $PocketMoney1Loop = new Amount($pocketMoney1->get()); $val2 = new Amount($val->get()); if ($showPocketMoney1 == 1) { $chart['chart_data'][$numberOfGraph][] = $val2->sub($PocketMoney1Loop->mul($day))->get(); $numberOfGraph++; } $PocketMoney2Loop = new Amount($pocketMoney2->get()); $val3 = new Amount($val->get()); if ($showPocketMoney2 == 1) { $chart['chart_data'][$numberOfGraph][] = $val3->sub($PocketMoney2Loop->mul($day))->get();
$noLowerLimit = NULL; $noUpperLimit = NULL; $noGraphChosen = NULL; $insertChart = NULL; //to avoid a date in the past or the same date as today if ($today->compare($today, $selectedDate) != 1) { $selectedSavingTarget = new Amount($_POST["savingTarget"], true); $savingTarget = $selectedSavingTarget->get(); $endDate = $selectedDate->getDate(); $account = $_POST["selectedAccount"]; //save selected account as standard account $us->setProperty('forecastStandardAccount', $account); $selectedPocketMoney1 = new Amount($_POST["pocketmoney1"], true); $pocketMoney1 = $selectedPocketMoney1->get(); $selectedPocketMoney2 = new Amount($_POST["pocketmoney2"], true); $pocketMoney2 = $selectedPocketMoney2->get(); $dailyPocketMoneyLabel = NULL; $dailyPocketMoneyValue = NULL; $dailyPocketMoneyToolTip = NULL; $balancedEndDate2 = NULL; $balancedEndDateLabel2 = NULL; $printedPocketMoney2EndValue = NULL; $balancedEndDate1 = NULL; $balancedEndDateLabel1 = NULL; $printedPocketMoney1EndValue = NULL; $amTransfer = new AccountManager($badgerDb); $accountTransfer = $amTransfer->getAccountById($account); transferFormerFinishedTransactions($accountTransfer); $am1 = new AccountManager($badgerDb); $currentAccount1 = $am1->getAccountById($account); //if no graph was chosen
} } //show chart if (isset($_POST['sendData'])) { # validate if date is in future $selectedDate = new Date($_POST["endDate"], true); $today = new Date(); $noFutureDates = NULL; $noLowerLimit = NULL; $noUpperLimit = NULL; $noGraphChosen = NULL; $insertChart = NULL; //to avoid a date in the past or the same date as today if ($today->compare($today, $selectedDate) != 1) { $selectedSavingTarget = new Amount($_POST["savingTarget"], true); $savingTarget = $selectedSavingTarget->get(); $endDate = $selectedDate->getDate(); $account = $_POST["selectedAccount"]; //save selected account as standard account $us->setProperty('forecastStandardAccount', $account); $selectedPocketMoney1 = new Amount($_POST["pocketmoney1"], true); $pocketMoney1 = $selectedPocketMoney1->getFormatted(); $selectedPocketMoney2 = new Amount($_POST["pocketmoney2"], true); $pocketMoney2 = $selectedPocketMoney2->getFormatted(); $dailyPocketMoneyLabel = NULL; $dailyPocketMoneyValue = NULL; $dailyPocketMoneyToolTip = NULL; $balancedEndDate2 = NULL; $balancedEndDateLabel2 = NULL; $printedPocketMoney2EndValue = NULL; $balancedEndDate1 = NULL;