mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix #1334
This commit is contained in:
@@ -62,8 +62,8 @@ class PiggyBankEventFactory
|
|||||||
$piggyRepos->setUser($journal->user);
|
$piggyRepos->setUser($journal->user);
|
||||||
|
|
||||||
// repetition exists?
|
// repetition exists?
|
||||||
$repetition = $piggyRepos->getRepetition($piggyBank, $journal->date);
|
$repetition = $piggyRepos->getRepetition($piggyBank);
|
||||||
if (null === $repetition->id) {
|
if (null === $repetition) {
|
||||||
Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d')));
|
Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d')));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@@ -25,13 +25,18 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
use Steam;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +44,14 @@ use View;
|
|||||||
*/
|
*/
|
||||||
class PiggyBankController extends Controller
|
class PiggyBankController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var AccountRepositoryInterface */
|
||||||
|
private $accountRepos;
|
||||||
|
/** @var CurrencyRepositoryInterface */
|
||||||
|
private $currencyRepos;
|
||||||
|
/** @var PiggyBankRepositoryInterface */
|
||||||
|
private $piggyRepos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -51,6 +64,10 @@ class PiggyBankController extends Controller
|
|||||||
app('view')->share('title', trans('firefly.piggyBanks'));
|
app('view')->share('title', trans('firefly.piggyBanks'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-sort-amount-asc');
|
app('view')->share('mainTitleIcon', 'fa-sort-amount-asc');
|
||||||
|
|
||||||
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||||
|
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -59,43 +76,53 @@ class PiggyBankController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Add money to piggy bank.
|
* Add money to piggy bank.
|
||||||
*
|
*
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function add(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
|
public function add(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $date);
|
||||||
$savedSoFar = $repository->getCurrentAmount($piggyBank);
|
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
return view('piggy-banks.add', compact('piggyBank', 'maxAmount'));
|
// get currency:
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('piggy-banks.add', compact('piggyBank', 'maxAmount', 'currency'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add money to piggy bank (for mobile devices).
|
* Add money to piggy bank (for mobile devices).
|
||||||
*
|
*
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function addMobile(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
|
public function addMobile(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $date);
|
||||||
$savedSoFar = $repository->getCurrentAmount($piggyBank);
|
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
return view('piggy-banks.add-mobile', compact('piggyBank', 'maxAmount'));
|
// get currency:
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('piggy-banks.add-mobile', compact('piggyBank', 'maxAmount', 'currency'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,16 +158,15 @@ class PiggyBankController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function destroy(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
Session::flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
Session::flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
$repository->destroy($piggyBank);
|
$this->piggyRepos->destroy($piggyBank);
|
||||||
|
|
||||||
return redirect($this->getPreviousUri('piggy-banks.delete.uri'));
|
return redirect($this->getPreviousUri('piggy-banks.delete.uri'));
|
||||||
}
|
}
|
||||||
@@ -185,53 +211,52 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param PiggyBankRepositoryInterface $piggyRepository
|
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, PiggyBankRepositoryInterface $piggyRepository)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$collection = $piggyRepository->getPiggyBanks();
|
$collection = $this->piggyRepos->getPiggyBanks();
|
||||||
$total = $collection->count();
|
$total = $collection->count();
|
||||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||||
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
|
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
|
||||||
|
$accounts = [];
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
|
|
||||||
$accounts = [];
|
// transform piggies using the transformer:
|
||||||
Log::debug('Looping piggues');
|
$parameters = new ParameterBag;
|
||||||
/** @var PiggyBank $piggyBank */
|
$parameters->set('end', $end);
|
||||||
foreach ($collection as $piggyBank) {
|
$transformed = new Collection;
|
||||||
|
$transformer = new PiggyBankTransformer(new ParameterBag);
|
||||||
|
$accountTransformer = new AccountTransformer($parameters);
|
||||||
|
/** @var PiggyBank $piggy */
|
||||||
|
foreach ($collection as $piggy) {
|
||||||
|
$array = $transformer->transform($piggy);
|
||||||
|
$account = $accountTransformer->transform($piggy->account);
|
||||||
|
$accountId = $account['id'];
|
||||||
|
if (!isset($accounts[$accountId])) {
|
||||||
|
// create new:
|
||||||
|
$accounts[$accountId] = $account;
|
||||||
|
|
||||||
$piggyBank->savedSoFar = $piggyRepository->getCurrentAmount($piggyBank);
|
// add some interesting details:
|
||||||
$piggyBank->percentage = (int)(0 !== bccomp('0', $piggyBank->savedSoFar) ? $piggyBank->savedSoFar / $piggyBank->targetamount * 100 : 0);
|
$accounts[$accountId]['left'] = $accounts[$accountId]['current_balance'];
|
||||||
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, (string)$piggyBank->savedSoFar);
|
$accounts[$accountId]['saved'] = 0;
|
||||||
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
$accounts[$accountId]['target'] = 0;
|
||||||
|
$accounts[$accountId]['to_save'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Fill account information:
|
// calculate new interesting fields:
|
||||||
$account = $piggyBank->account;
|
$accounts[$accountId]['left'] -= $array['current_amount'];
|
||||||
$new = false;
|
$accounts[$accountId]['saved'] += $array['current_amount'];
|
||||||
if (!isset($accounts[$account->id])) {
|
$accounts[$accountId]['target'] += $array['target_amount'];
|
||||||
$new = true;
|
$accounts[$accountId]['to_save'] += ($array['target_amount'] - $array['current_amount']);
|
||||||
$accounts[$account->id] = [
|
$array['account_name'] = $account['name'];
|
||||||
'name' => $account->name,
|
$transformed->push($array);
|
||||||
'balance' => Steam::balanceIgnoreVirtual($account, $end),
|
|
||||||
'leftForPiggyBanks' => $piggyBank->leftOnAccount($end),
|
|
||||||
'sumOfSaved' => (string)$piggyBank->savedSoFar,
|
|
||||||
'sumOfTargets' => $piggyBank->targetamount,
|
|
||||||
'leftToSave' => $piggyBank->leftToSave,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
if (isset($accounts[$account->id]) && false === $new) {
|
|
||||||
$accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], (string)$piggyBank->savedSoFar);
|
|
||||||
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
|
|
||||||
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// paginate piggy banks
|
$transformed = $transformed->slice(($page - 1) * $pageSize, $pageSize);
|
||||||
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
$piggyBanks = new LengthAwarePaginator($transformed, $total, $pageSize, $page);
|
||||||
$piggyBanks = new LengthAwarePaginator($collection, $total, $pageSize, $page);
|
|
||||||
$piggyBanks->setPath(route('piggy-banks.index'));
|
$piggyBanks->setPath(route('piggy-banks.index'));
|
||||||
|
|
||||||
return view('piggy-banks.index', compact('piggyBanks', 'accounts'));
|
return view('piggy-banks.index', compact('piggyBanks', 'accounts'));
|
||||||
@@ -239,20 +264,19 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function order(Request $request, PiggyBankRepositoryInterface $repository)
|
public function order(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->get('order');
|
$data = $request->get('order');
|
||||||
|
|
||||||
// set all users piggy banks to zero:
|
// set all users piggy banks to zero:
|
||||||
$repository->reset();
|
$this->piggyRepos->reset();
|
||||||
|
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
foreach ($data as $order => $id) {
|
foreach ($data as $order => $id) {
|
||||||
$repository->setOrder((int)$id, $order + 1);
|
$this->piggyRepos->setOrder((int)$id, $order + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,17 +285,20 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function postAdd(Request $request, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$amount = $request->get('amount') ?? '0';
|
$amount = $request->get('amount') ?? '0';
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
if ($repository->canAddAmount($piggyBank, $amount)) {
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
$repository->addAmount($piggyBank, $amount);
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
if ($this->piggyRepos->canAddAmount($piggyBank, $amount)) {
|
||||||
|
$this->piggyRepos->addAmount($piggyBank, $amount);
|
||||||
Session::flash(
|
Session::flash(
|
||||||
'success',
|
'success',
|
||||||
(string)trans(
|
(string)trans(
|
||||||
@@ -298,17 +325,20 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function postRemove(Request $request, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$amount = $request->get('amount') ?? '0';
|
$amount = $request->get('amount') ?? '0';
|
||||||
$currency = app('amount')->getDefaultCurrency();
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
if ($repository->canRemoveAmount($piggyBank, $amount)) {
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
$repository->removeAmount($piggyBank, $amount);
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
if ($this->piggyRepos->canRemoveAmount($piggyBank, $amount)) {
|
||||||
|
$this->piggyRepos->removeAmount($piggyBank, $amount);
|
||||||
Session::flash(
|
Session::flash(
|
||||||
'success',
|
'success',
|
||||||
(string)trans(
|
(string)trans(
|
||||||
@@ -341,7 +371,15 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function remove(PiggyBank $piggyBank)
|
public function remove(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
return view('piggy-banks.remove', compact('piggyBank'));
|
$repetition = $this->piggyRepos->getRepetition($piggyBank);
|
||||||
|
// get currency:
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('piggy-banks.remove', compact('piggyBank', 'repetition', 'currency'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,19 +391,27 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function removeMobile(PiggyBank $piggyBank)
|
public function removeMobile(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
return view('piggy-banks.remove-mobile', compact('piggyBank'));
|
$repetition = $this->piggyRepos->getRepetition($piggyBank);
|
||||||
|
// get currency:
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
$currencyId = (int)$this->accountRepos->getMetaValue($piggyBank->account, 'currency_id');
|
||||||
|
if ($currencyId > 0) {
|
||||||
|
$currency = $this->currencyRepos->findNull($currencyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return view('piggy-banks.remove-mobile', compact('piggyBank', 'repetition', 'currency'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
public function show(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$note = $piggyBank->notes()->first();
|
$note = $piggyBank->notes()->first();
|
||||||
$events = $repository->getEvents($piggyBank);
|
$events = $this->piggyRepos->getEvents($piggyBank);
|
||||||
$subTitle = $piggyBank->name;
|
$subTitle = $piggyBank->name;
|
||||||
|
|
||||||
return view('piggy-banks.show', compact('piggyBank', 'events', 'subTitle', 'note'));
|
return view('piggy-banks.show', compact('piggyBank', 'events', 'subTitle', 'note'));
|
||||||
@@ -373,17 +419,16 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBankFormRequest $request
|
* @param PiggyBankFormRequest $request
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
|
public function store(PiggyBankFormRequest $request)
|
||||||
{
|
{
|
||||||
$data = $request->getPiggyBankData();
|
$data = $request->getPiggyBankData();
|
||||||
if (null === $data['startdate']) {
|
if (null === $data['startdate']) {
|
||||||
$data['startdate'] = new Carbon;
|
$data['startdate'] = new Carbon;
|
||||||
}
|
}
|
||||||
$piggyBank = $repository->store($data);
|
$piggyBank = $this->piggyRepos->store($data);
|
||||||
|
|
||||||
Session::flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
Session::flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@@ -400,16 +445,15 @@ class PiggyBankController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
|
||||||
* @param PiggyBankFormRequest $request
|
* @param PiggyBankFormRequest $request
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
|
public function update(PiggyBankFormRequest $request, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$data = $request->getPiggyBankData();
|
$data = $request->getPiggyBankData();
|
||||||
$piggyBank = $repository->update($piggyBank, $data);
|
$piggyBank = $this->piggyRepos->update($piggyBank, $data);
|
||||||
|
|
||||||
Session::flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
|
Session::flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
@@ -65,7 +65,6 @@ class PiggyBankFormRequest extends Request
|
|||||||
'name' => $nameRule,
|
'name' => $nameRule,
|
||||||
'account_id' => 'required|belongsToUser:accounts',
|
'account_id' => 'required|belongsToUser:accounts',
|
||||||
'targetamount' => 'required|numeric|more:0',
|
'targetamount' => 'required|numeric|more:0',
|
||||||
'amount_currency_id_targetamount' => 'required|exists:transaction_currencies,id',
|
|
||||||
'startdate' => 'date',
|
'startdate' => 'date',
|
||||||
'targetdate' => 'date|nullable',
|
'targetdate' => 'date|nullable',
|
||||||
'order' => 'integer|min:1',
|
'order' => 'integer|min:1',
|
||||||
|
@@ -197,8 +197,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getCurrentAmount(PiggyBank $piggyBank): string
|
public function getCurrentAmount(PiggyBank $piggyBank): string
|
||||||
{
|
{
|
||||||
/** @var PiggyBankRepetition $rep */
|
$rep = $this->getRepetition($piggyBank);
|
||||||
$rep = $piggyBank->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
|
||||||
if (null === $rep) {
|
if (null === $rep) {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
@@ -301,19 +300,40 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return PiggyBankRepetition|null
|
||||||
|
*/
|
||||||
|
public function getRepetition(PiggyBank $piggyBank): ?PiggyBankRepetition
|
||||||
|
{
|
||||||
|
return $piggyBank->piggyBankRepetitions()->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get for piggy account what is left to put in piggies.
|
||||||
|
*
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return PiggyBankRepetition
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRepetition(PiggyBank $piggyBank, Carbon $date): PiggyBankRepetition
|
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string
|
||||||
{
|
{
|
||||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($date)->first();
|
|
||||||
if (null === $repetition) {
|
$balance = app('steam')->balanceIgnoreVirtual($piggyBank->account, $date);
|
||||||
return new PiggyBankRepetition;
|
|
||||||
|
/** @var Collection $piggies */
|
||||||
|
$piggies = $piggyBank->account->piggyBanks;
|
||||||
|
|
||||||
|
/** @var PiggyBank $current */
|
||||||
|
foreach ($piggies as $current) {
|
||||||
|
$repetition = $this->getRepetition($current);
|
||||||
|
if(null !== $repetition) {
|
||||||
|
$balance = bcsub($balance, $repetition->currentamount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $repetition;
|
return $balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -162,12 +162,21 @@ interface PiggyBankRepositoryInterface
|
|||||||
public function getPiggyBanksWithAmount(): Collection;
|
public function getPiggyBanksWithAmount(): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return PiggyBankRepetition|null
|
||||||
|
*/
|
||||||
|
public function getRepetition(PiggyBank $piggyBank): ?PiggyBankRepetition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get for piggy account what is left to put in piggies.
|
||||||
|
*
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return PiggyBankRepetition
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRepetition(PiggyBank $piggyBank, Carbon $date): PiggyBankRepetition;
|
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
|
@@ -151,13 +151,15 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
if ($type !== AccountType::ASSET || (string)$role === '') {
|
if ($type !== AccountType::ASSET || (string)$role === '') {
|
||||||
$role = null;
|
$role = null;
|
||||||
}
|
}
|
||||||
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
||||||
$currencyCode = null;
|
$currencyCode = null;
|
||||||
$decimalPlaces = 2;
|
$currencySymbol = null;
|
||||||
|
$decimalPlaces = 2;
|
||||||
if ($currencyId > 0) {
|
if ($currencyId > 0) {
|
||||||
$currency = TransactionCurrency::find($currencyId);
|
$currency = TransactionCurrency::find($currencyId);
|
||||||
$currencyCode = $currency->code;
|
$currencyCode = $currency->code;
|
||||||
$decimalPlaces = $currency->decimal_places;
|
$decimalPlaces = $currency->decimal_places;
|
||||||
|
$currencySymbol = $currency->symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
@@ -196,6 +198,8 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
'type' => $type,
|
'type' => $type,
|
||||||
'currency_id' => $currencyId,
|
'currency_id' => $currencyId,
|
||||||
'currency_code' => $currencyCode,
|
'currency_code' => $currencyCode,
|
||||||
|
'currency_symbol' => $currencySymbol,
|
||||||
|
'currency_dp' => $decimalPlaces,
|
||||||
'current_balance' => round(app('steam')->balance($account, $date), $decimalPlaces),
|
'current_balance' => round(app('steam')->balance($account, $date), $decimalPlaces),
|
||||||
'current_balance_date' => $date->format('Y-m-d'),
|
'current_balance_date' => $date->format('Y-m-d'),
|
||||||
'notes' => $this->repository->getNoteText($account),
|
'notes' => $this->repository->getNoteText($account),
|
||||||
|
@@ -24,8 +24,10 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Transformers;
|
namespace FireflyIII\Transformers;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Note;
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
@@ -116,39 +118,60 @@ class PiggyBankTransformer extends TransformerAbstract
|
|||||||
*/
|
*/
|
||||||
public function transform(PiggyBank $piggyBank): array
|
public function transform(PiggyBank $piggyBank): array
|
||||||
{
|
{
|
||||||
$account = $piggyBank->account;
|
/** @var Account $account */
|
||||||
$currencyId = (int)$account->getMeta('currency_id');
|
$account = $piggyBank->account;
|
||||||
$decimalPlaces = 2;
|
/** @var AccountRepositoryInterface $accountRepos */
|
||||||
|
$accountRepos = app(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->setUser($account->user);
|
||||||
|
$currencyId = (int)$accountRepos->getMetaValue($account, 'currency_id');
|
||||||
|
|
||||||
|
if ($currencyId === 0) {
|
||||||
|
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
|
||||||
|
}
|
||||||
|
|
||||||
if ($currencyId > 0) {
|
if ($currencyId > 0) {
|
||||||
/** @var CurrencyRepositoryInterface $repository */
|
/** @var CurrencyRepositoryInterface $repository */
|
||||||
$repository = app(CurrencyRepositoryInterface::class);
|
$repository = app(CurrencyRepositoryInterface::class);
|
||||||
$repository->setUser($account->user);
|
$repository->setUser($account->user);
|
||||||
$currency = $repository->findNull($currencyId);
|
$currency = $repository->findNull($currencyId);
|
||||||
$decimalPlaces = $currency->decimal_places;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$decimalPlaces = $currency->decimal_places;
|
||||||
|
|
||||||
// get currently saved amount:
|
// get currently saved amount:
|
||||||
/** @var PiggyBankRepositoryInterface $piggyRepos */
|
/** @var PiggyBankRepositoryInterface $piggyRepos */
|
||||||
$piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
$piggyRepos->setUser($account->user);
|
$piggyRepos->setUser($account->user);
|
||||||
$currentAmount = round($piggyRepos->getCurrentAmount($piggyBank), $decimalPlaces);
|
|
||||||
|
|
||||||
|
// current amount in piggy bank:
|
||||||
|
$currentAmountStr = $piggyRepos->getCurrentAmount($piggyBank);
|
||||||
|
$currentAmount = round($currentAmountStr, $decimalPlaces);
|
||||||
|
|
||||||
|
// left to save to target:
|
||||||
|
$leftToSave = bcsub($piggyBank->targetamount, $currentAmountStr);
|
||||||
$startDate = null === $piggyBank->startdate ? null : $piggyBank->startdate->format('Y-m-d');
|
$startDate = null === $piggyBank->startdate ? null : $piggyBank->startdate->format('Y-m-d');
|
||||||
$targetDate = null === $piggyBank->targetdate ? null : $piggyBank->targetdate->format('Y-m-d');
|
$targetDate = null === $piggyBank->targetdate ? null : $piggyBank->targetdate->format('Y-m-d');
|
||||||
$targetAmount = round($piggyBank->targetamount, $decimalPlaces);
|
$targetAmount = round($piggyBank->targetamount, $decimalPlaces);
|
||||||
|
$percentage = (int)(0 !== bccomp('0', $currentAmountStr) ? $currentAmount / $targetAmount * 100 : 0);
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$piggyBank->id,
|
'id' => (int)$piggyBank->id,
|
||||||
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
||||||
'created_at' => $piggyBank->created_at->toAtomString(),
|
'created_at' => $piggyBank->created_at->toAtomString(),
|
||||||
'name' => $piggyBank->name,
|
'name' => $piggyBank->name,
|
||||||
'target_amount' => $targetAmount,
|
'currency_id' => $currency->id,
|
||||||
'current_amount' => $currentAmount,
|
'currency_code' => $currency->code,
|
||||||
'startdate' => $startDate,
|
'currency_symbol' => $currency->symbol,
|
||||||
'targetdate' => $targetDate,
|
'currency_dp' => $currency->decimal_places,
|
||||||
'order' => (int)$piggyBank->order,
|
'target_amount' => $targetAmount,
|
||||||
'active' => (int)$piggyBank->active === 1,
|
'percentage' => $percentage,
|
||||||
'notes' => null,
|
'current_amount' => $currentAmount,
|
||||||
'links' => [
|
'left_to_save' => round($leftToSave, $decimalPlaces),
|
||||||
|
'startdate' => $startDate,
|
||||||
|
'targetdate' => $targetDate,
|
||||||
|
'order' => (int)$piggyBank->order,
|
||||||
|
'active' => (int)$piggyBank->active === 1,
|
||||||
|
'notes' => null,
|
||||||
|
'links' => [
|
||||||
[
|
[
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
'uri' => '/piggy_banks/' . $piggyBank->id,
|
'uri' => '/piggy_banks/' . $piggyBank->id,
|
||||||
|
@@ -13,15 +13,15 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for piggyBank in piggyBanks %}
|
{% for piggy in piggyBanks %}
|
||||||
<tr data-id="{{ piggyBank.id }}">
|
<tr data-id="{{ piggy.id }}">
|
||||||
<td class="visible-xs visible-sm hidden-md hidden-lg">
|
<td class="visible-xs visible-sm hidden-md hidden-lg">
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="visible-xs visible-sm hidden-md hidden-lg">
|
<td class="visible-xs visible-sm hidden-md hidden-lg">
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="{{ route('piggy-banks.remove-money-mobile', piggyBank.id) }}" class="btn btn-default btn-xs"><i class="fa fa-minus"></i></a>
|
<a href="{{ route('piggy-banks.remove-money-mobile', piggy.id) }}" class="btn btn-default btn-xs"><i class="fa fa-minus"></i></a>
|
||||||
<a href="{{ route('piggy-banks.add-money-mobile', piggyBank.id) }}" class="btn btn-default btn-xs"><i class="fa fa-plus"></i></a>
|
<a href="{{ route('piggy-banks.add-money-mobile', piggy.id) }}" class="btn btn-default btn-xs"><i class="fa fa-plus"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:60px;" class="hidden-sm hidden-xs">
|
<td style="width:60px;" class="hidden-sm hidden-xs">
|
||||||
@@ -30,53 +30,53 @@
|
|||||||
</td>
|
</td>
|
||||||
<td style="width:100px;" class="hidden-sm hidden-xs">
|
<td style="width:100px;" class="hidden-sm hidden-xs">
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="{{ route('piggy-banks.edit', piggyBank.id) }}" class="btn btn-default btn-xs"><i class="fa fa-pencil fa-fw"></i></a>
|
<a href="{{ route('piggy-banks.edit', piggy.id) }}" class="btn btn-default btn-xs"><i class="fa fa-pencil fa-fw"></i></a>
|
||||||
<a href="{{ route('piggy-banks.delete', piggyBank.id) }}" class="btn btn-danger btn-xs"><i class="fa fa-trash fa-fw"></i></a>
|
<a href="{{ route('piggy-banks.delete', piggy.id) }}" class="btn btn-danger btn-xs"><i class="fa fa-trash fa-fw"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('piggy-banks.show', piggyBank.id) }}" title="{{ piggyBank.account.name }}">{{ piggyBank.name }}</a>
|
<a href="{{ route('piggy-banks.show', piggy.id) }}" title="{{ piggy.account_name }}">{{ piggy.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: right;" class="piggySaved">
|
<td style="text-align: right;" class="piggySaved">
|
||||||
<span title="Saved so far" style="text-align:right;">{{ piggyBank.savedSoFar|formatAmount }}</span>
|
<span title="Saved so far" style="text-align:right;">{{ formatAmountBySymbol(piggy.current_amount,piggy.currency_symbol,piggy.currency_dp) }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-sm hidden-xs" style="text-align:right;width:40px;">
|
<td class="hidden-sm hidden-xs" style="text-align:right;width:40px;">
|
||||||
{% if piggyBank.savedSoFar > 0 %}
|
{% if piggy.current_amount > 0 %}
|
||||||
<a href="{{ route('piggy-banks.remove-money', piggyBank.id) }}" class="btn btn-default btn-xs removeMoney" data-id="{{ piggyBank.id }}">
|
<a href="{{ route('piggy-banks.remove-money', piggy.id) }}" class="btn btn-default btn-xs removeMoney" data-id="{{ piggy.id }}">
|
||||||
<i data-id="{{ piggyBank.id }}" class="fa fa-minus"></i></a>
|
<i data-id="{{ piggy.id }}" class="fa fa-minus"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="hidden-sm hidden-xs piggyBar">
|
<td class="hidden-sm hidden-xs piggyBar">
|
||||||
<div class="progress progress" style="margin-bottom:0;">
|
<div class="progress progress" style="margin-bottom:0;">
|
||||||
<div
|
<div
|
||||||
{% if piggyBank.percentage == 100 %}
|
{% if piggy.percentage == 100 %}
|
||||||
class="progress-bar progress-bar-success"
|
class="progress-bar progress-bar-success"
|
||||||
{% elseif piggyBank.percentage == 0 %}
|
{% elseif piggy.percentage == 0 %}
|
||||||
class="progress-bar progress-bar-warning"
|
class="progress-bar progress-bar-warning"
|
||||||
{% else %}
|
{% else %}
|
||||||
class="progress-bar progress-bar-info"
|
class="progress-bar progress-bar-info"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
role="progressbar" aria-valuenow="{{ piggyBank.percentage }}" aria-valuemin="0" aria-valuemax="100"
|
role="progressbar" aria-valuenow="{{ piggy.percentage }}" aria-valuemin="0" aria-valuemax="100"
|
||||||
style="min-width: 30px;width: {{ piggyBank.percentage }}%;">
|
style="min-width: 30px;width: {{ piggy.percentage }}%;">
|
||||||
{{ piggyBank.percentage }}%
|
{{ piggy.percentage }}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td class="hidden-sm hidden-xs" style="width:40px;">
|
<td class="hidden-sm hidden-xs" style="width:40px;">
|
||||||
{% if piggyBank.leftToSave > 0 %}
|
{% if piggy.left_to_save > 0 %}
|
||||||
<a href="{{ route('piggy-banks.add-money', piggyBank.id) }}" class="btn btn-default btn-xs addMoney" data-id="{{ piggyBank.id }}">
|
<a href="{{ route('piggy-banks.add-money', piggy.id) }}" class="btn btn-default btn-xs addMoney" data-id="{{ piggy.id }}">
|
||||||
<i data-id="{{ piggyBank.id }}" class="fa fa-plus"></i></a>
|
<i data-id="{{ piggy.id }}" class="fa fa-plus"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-sm hidden-xs" style="width:200px;text-align:right;">
|
<td class="hidden-sm hidden-xs" style="text-align:right;">
|
||||||
<span title="{{ 'target_amount'|_ }}">{{ piggyBank.targetamount|formatAmount }}</span>
|
<span title="{{ 'target_amount'|_ }}">{{ formatAmountBySymbol(piggy.target_amount,piggy.currency_symbol,piggy.currency_dp) }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-sm hidden-xs" style="width:200px;text-align:right;">
|
<td class="hidden-sm hidden-xs" style="text-align:right;">
|
||||||
{% if piggyBank.leftToSave > 0 %}
|
{% if piggy.left_to_save > 0 %}
|
||||||
<span title="{{ 'left_to_save'|_ }}">{{ piggyBank.leftToSave|formatAmount }}</span>
|
<span title="{{ 'left_to_save'|_ }}">{{ formatAmountBySymbol(piggy.left_to_save,piggy.currency_symbol,piggy.currency_dp) }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -16,11 +16,11 @@
|
|||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
{% if maxAmount > 0 %}
|
{% if maxAmount > 0 %}
|
||||||
<p>
|
<p>
|
||||||
{{ 'max_amount_add'|_ }}: {{ maxAmount|formatAmount }}.
|
{{ 'max_amount_add'|_ }}: {{ formatAmountByCurrency(currency,maxAmount) }}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
<div class="input-group-addon">{{ currency.symbol|raw }}</div>
|
||||||
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ maxAmount|round(2) }}"
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ maxAmount|round(2) }}"
|
||||||
type="number"/>
|
type="number"/>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -11,12 +11,12 @@
|
|||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ 'max_amount_add'|_ }}: {{ maxAmount|formatAmount }}.
|
{{ 'max_amount_add'|_ }}: {{ formatAmountByCurrency(currency,maxAmount) }}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
<div class="input-group-addon">{{ currency.symbol|raw }}</div>
|
||||||
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ maxAmount|round(2) }}" type="number"/>
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ maxAmount|round(currency.decimal_places) }}" type="number"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
{{ ExpandedForm.text('name') }}
|
{{ ExpandedForm.text('name') }}
|
||||||
{{ ExpandedForm.assetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
|
{{ ExpandedForm.assetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
|
||||||
{{ ExpandedForm.amount('targetamount') }}
|
{{ ExpandedForm.amountNoCurrency('targetamount') }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
{{ ExpandedForm.text('name') }}
|
{{ ExpandedForm.text('name') }}
|
||||||
{{ ExpandedForm.assetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
|
{{ ExpandedForm.assetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
|
||||||
{{ ExpandedForm.amount('targetamount') }}
|
{{ ExpandedForm.amountNoCurrency('targetamount') }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if piggyBanks.count == 0 %}
|
{% if piggyBanks|length == 0 %}
|
||||||
{% include 'partials.empty' with {what: 'default', type: 'piggies',route: route('piggy-banks.create')} %}
|
{% include 'partials.empty' with {what: 'default', type: 'piggies',route: route('piggy-banks.create')} %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -49,11 +49,21 @@
|
|||||||
{% for id,info in accounts %}
|
{% for id,info in accounts %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ route('accounts.show',id) }}" title="{{ info.name }}">{{ info.name }}</a></td>
|
<td><a href="{{ route('accounts.show',id) }}" title="{{ info.name }}">{{ info.name }}</a></td>
|
||||||
<td style="text-align:right;" class="hidden-sm hidden-xs">{{ info.balance|formatAmount }}</td>
|
<td style="text-align:right;" class="hidden-sm hidden-xs">
|
||||||
<td style="text-align:right;">{{ info.leftForPiggyBanks|formatAmount }}</td>
|
{{ formatAmountBySymbol(info.current_balance,info.currency_symbol,info.currency_dp) }}
|
||||||
<td style="text-align:right;" class="hidden-sm hidden-xs">{{ info.sumOfTargets|formatAmount }}</td>
|
</td>
|
||||||
<td style="text-align:right;" class="hidden-sm hidden-xs">{{ info.sumOfSaved|formatAmount }}</td>
|
<td style="text-align:right;">
|
||||||
<td style="text-align:right;" class="hidden-sm hidden-xs">{{ info.leftToSave|formatAmount }}</td>
|
{{ formatAmountBySymbol(info.left,info.currency_symbol,info.currency_dp) }}
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right;" class="hidden-sm hidden-xs">
|
||||||
|
{{ formatAmountBySymbol(info.target,info.currency_symbol,info.currency_dp) }}
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right;" class="hidden-sm hidden-xs">
|
||||||
|
{{ formatAmountBySymbol(info.saved,info.currency_symbol,info.currency_dp) }}
|
||||||
|
</td>
|
||||||
|
<td style="text-align:right;" class="hidden-sm hidden-xs">
|
||||||
|
{{ formatAmountBySymbol(info.to_save,info.currency_symbol,info.currency_dp) }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -15,12 +15,12 @@
|
|||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ 'max_amount_remove'|_ }}: {{ currentRelevantRepAmount(piggyBank)|formatAmount }}.
|
{{ 'max_amount_remove'|_ }}: {{ formatAmountByCurrency(currency, repetition.currentamount) }}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
<div class="input-group-addon">{{ currency.symbol|raw }}</div>
|
||||||
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ currentRelevantRepAmount(piggyBank) }}"
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ repetition.currentamount }}"
|
||||||
type="number"/>
|
type="number"/>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
|
@@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>
|
<p>
|
||||||
{{ 'max_amount_remove'|_ }}: {{ currentRelevantRepAmount(piggyBank)|formatAmount }}.
|
{{ 'max_amount_remove'|_ }}: {{ formatAmountByCurrency(currency, repetition.currentamount) }}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
<div class="input-group-addon">{{ currency.symbol|raw }}</div>
|
||||||
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ currentRelevantRepAmount(piggyBank)|round(2) }}"
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{ repetition.currentamount }}"
|
||||||
type="number">
|
type="number">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user