mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Save transactions by moving them.
This commit is contained in:
parent
e89d613b7e
commit
aa5e313b92
@ -3,6 +3,7 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -57,17 +58,19 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function delete(Account $account)
|
||||
public function delete(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
$typeName = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
|
||||
$typeName = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
|
||||
$accountList = Expandedform::makeSelectList($repository->getAccounts([$account->accountType->type]), true);
|
||||
unset($accountList[$account->id]);
|
||||
|
||||
// put previous url in session
|
||||
Session::put('accounts.delete.url', URL::previous());
|
||||
Session::flash('gaEventCategory', 'accounts');
|
||||
Session::flash('gaEventAction', 'delete-' . $typeName);
|
||||
|
||||
return view('accounts.delete', compact('account', 'subTitle'));
|
||||
return view('accounts.delete', compact('account', 'subTitle', 'accountList'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,12 +81,12 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function destroy(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
|
||||
$type = $account->accountType->type;
|
||||
$typeName = Config::get('firefly.shortNamesByFullName.' . $type);
|
||||
$name = $account->name;
|
||||
$moveTo = Auth::user()->accounts()->find(intval(Input::get('move_account_before_delete')));
|
||||
|
||||
$repository->destroy($account);
|
||||
$repository->destroy($account, $moveTo);
|
||||
|
||||
Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
|
||||
Preferences::mark();
|
||||
|
@ -46,11 +46,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Account $account)
|
||||
public function destroy(Account $account, Account $moveTo = null)
|
||||
{
|
||||
if (!is_null($moveTo)) {
|
||||
// update all transactions:
|
||||
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
||||
}
|
||||
|
||||
$account->delete();
|
||||
|
||||
return true;
|
||||
|
@ -26,10 +26,11 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Account $account);
|
||||
public function destroy(Account $account, Account $moveTo = null);
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
|
@ -204,6 +204,7 @@ return [
|
||||
'accountExtraHelp_expense' => '',
|
||||
'accountExtraHelp_revenue' => '',
|
||||
'account_type' => 'Account type',
|
||||
'save_transactions_by_moving' => 'Save these transaction(s) by moving them to another account:',
|
||||
|
||||
// categories:
|
||||
'new_category' => 'New category',
|
||||
|
@ -206,6 +206,7 @@ return [
|
||||
' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' .
|
||||
' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' .
|
||||
'overmaakt gaat het er bij hen af (negatief).',
|
||||
'save_transactions_by_moving' => 'Bewaar deze transacties door ze aan een andere rekening te koppelen:',
|
||||
|
||||
// categories:
|
||||
'new_category' => 'Nieuwe categorie',
|
||||
|
@ -30,6 +30,12 @@
|
||||
{{ Lang.choice('form.also_delete_piggyBanks', account.piggyBanks|length, {count: account.piggyBanks|length}) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p class="text-success">
|
||||
{{ 'save_transactions_by_moving'|_ }}
|
||||
</p>
|
||||
<p>
|
||||
{{ Form.select('move_account_before_delete', accountList, null, {class: 'form-control'}) }}
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user