From 39749aa11392dac4b900921b96a263b9740ca218 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 29 Oct 2016 15:14:33 +0200 Subject: [PATCH] First code set for #330 --- .../Transaction/ConvertController.php | 108 ++++++++++ app/Http/breadcrumbs.php | 16 +- app/Models/TransactionType.php | 20 ++ config/firefly.php | 1 + resources/lang/en_US/firefly.php | 16 ++ resources/lang/en_US/form.php | 184 ++++++++++-------- resources/views/transactions/convert.twig | 176 +++++++++++++++++ resources/views/transactions/show.twig | 38 +++- routes/web.php | 6 +- 9 files changed, 473 insertions(+), 92 deletions(-) create mode 100644 app/Http/Controllers/Transaction/ConvertController.php create mode 100644 resources/views/transactions/convert.twig diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php new file mode 100644 index 0000000000..4b47b22714 --- /dev/null +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -0,0 +1,108 @@ +middleware( + function ($request, $next) { + $this->accounts = app(AccountRepositoryInterface::class); + + View::share('title', trans('firefly.transactions')); + View::share('mainTitleIcon', 'fa-exchange'); + + return $next($request); + } + ); + } + + /** + * @param TransactionType $destinationType + * @param TransactionJournal $journal + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View + */ + public function convert(TransactionType $destinationType, TransactionJournal $journal) + { + $positiveAmount = TransactionJournal::amountPositive($journal); + $assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); + $sourceType = $journal->transactionType; + + $subTitle = trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]); + $subTitleIcon = 'fa-exchange'; + + if ($sourceType->type === $destinationType->type) { + Session::flash('info', trans('firefly.convert_is_already_type_' . $destinationType->type)); + + return redirect(route('transactions.show', [$journal->id])); + } + if ($journal->transactions()->count() > 2) { + Session::flash('error', trans('firefly.cannot_convert_split_journl')); + + return redirect(route('transactions.show', [$journal->id])); + } + $sourceAccount = TransactionJournal::sourceAccountList($journal)->first(); + $destinationAccount = TransactionJournal::destinationAccountList($journal)->first(); + + return view( + 'transactions.convert', compact( + 'sourceType', 'destinationType', 'journal', 'assetAccounts', + 'positiveAmount', 'sourceAccount', 'destinationAccount', 'sourceType', + 'subTitle', 'subTitleIcon' + + ) + ); + + + // convert withdrawal to deposit requires a new source account () + // or to transfer requires + } + + public function submit(Request $request) + { + echo '
';
+
+        var_dump($request->all());
+
+
+        exit;
+    }
+
+}
\ No newline at end of file
diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php
index 44c4fc707e..9de3b720ac 100644
--- a/app/Http/breadcrumbs.php
+++ b/app/Http/breadcrumbs.php
@@ -25,6 +25,7 @@ use FireflyIII\Models\RuleGroup;
 use FireflyIII\Models\Tag;
 use FireflyIII\Models\TransactionCurrency;
 use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Models\TransactionType;
 use FireflyIII\User;
 
 /**
@@ -595,13 +596,24 @@ Breadcrumbs::register(
 Breadcrumbs::register(
     'transactions.show', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
 
-    $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
+    $what = strtolower($journal->transactionType->type);
     $breadcrumbs->parent('transactions.index', $what);
     $breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
-
 }
 );
 
+Breadcrumbs::register(
+    'transactions.convert', function (BreadCrumbGenerator $breadcrumbs, TransactionType $destinationType, TransactionJournal $journal) {
+
+    $breadcrumbs->parent('transactions.show', $journal);
+    $breadcrumbs->push(
+        trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]),
+        route('transactions.convert', [strtolower($destinationType->type), $journal->id])
+    );
+}
+);
+
+
 /**
  * SPLIT
  */
diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php
index 84a1da7ccf..51a912ca12 100644
--- a/app/Models/TransactionType.php
+++ b/app/Models/TransactionType.php
@@ -15,6 +15,7 @@ namespace FireflyIII\Models;
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
 /**
  * FireflyIII\Models\TransactionType
@@ -43,6 +44,25 @@ class TransactionType extends Model
 
     protected $dates = ['created_at', 'updated_at', 'deleted_at'];
 
+    /**
+     * @param string $type
+     *
+     * @return Model|null|static
+     */
+    public static function routeBinder(string $type)
+    {
+        if (!auth()->check()) {
+            throw new NotFoundHttpException;
+        }
+        $transactionType = self::where('type', $type)->first();
+        if (!is_null($transactionType)) {
+            return $transactionType;
+        }
+        throw new NotFoundHttpException;
+
+    }
+
+
     /**
      * @return bool
      */
diff --git a/config/firefly.php b/config/firefly.php
index 9d5113793b..69b5e13029 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -137,6 +137,7 @@ return [
         'bill'              => 'FireflyIII\Models\Bill',
         'budget'            => 'FireflyIII\Models\Budget',
         'category'          => 'FireflyIII\Models\Category',
+        'transaction_type'  => 'FireflyIII\Models\TransactionType',
         'currency'          => 'FireflyIII\Models\TransactionCurrency',
         'limitrepetition'   => 'FireflyIII\Models\LimitRepetition',
         'piggyBank'         => 'FireflyIII\Models\PiggyBank',
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index cd3074e301..b1d1d18a1a 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -242,6 +242,7 @@ return [
     'rule_action_set_source_account'             => 'Set source account to :action_value',
     'rule_action_set_destination_account_choice' => 'Set destination account to...',
     'rule_action_set_destination_account'        => 'Set destination account to :action_value',
+
     // tags
     'store_new_tag'                              => 'Store new tag',
     'update_tag'                                 => 'Update tag',
@@ -352,6 +353,21 @@ return [
     'title_transfer'                             => 'Transfers',
     'title_transfers'                            => 'Transfers',
 
+    // convert stuff:
+    'convert_is_already_type_Withdrawal'         => 'This transaction is already a withdrawal',
+    'convert_is_already_type_Deposit'            => 'This transaction is already a deposit',
+    'convert_is_already_type_Transfer'           => 'This transaction is already a transfer',
+    'convert_to_Withdrawal'                      => 'Convert ":description" to a withdrawal',
+    'convert_to_Deposit'                         => 'Convert ":description" to a deposit',
+    'convert_to_Transfer'                        => 'Convert ":description" to a transfer',
+    'convert_options_WithdrawalDeposit'          => 'Convert a withdrawal into a deposit',
+    'convert_options_WithdrawalTransfer'         => 'Convert a withdrawal into a transfer',
+    'convert_options_DepositTransfer'            => 'Convert a deposit into a transfer',
+    'convert_options_DepositWithdrawal'          => 'Convert a deposit into a withdrawal',
+    'convert_options_TransferWithdrawal'         => 'Convert a transfer into a withdrawal',
+    'convert_options_TransferDeposit'            => 'Convert a transfer into a deposit',
+
+
     // create new stuff:
     'create_new_withdrawal'                      => 'Create new withdrawal',
     'create_new_deposit'                         => 'Create new deposit',
diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php
index 5cfd1a3688..cb264972d0 100644
--- a/resources/lang/en_US/form.php
+++ b/resources/lang/en_US/form.php
@@ -31,6 +31,8 @@ return [
     'journal_source_account_id'      => 'Asset account (source)',
     'account_from_id'                => 'From account',
     'account_to_id'                  => 'To account',
+    'source_account'                 => 'Source account',
+    'destination_account'            => 'Destination account',
     'journal_destination_account_id' => 'Asset account (destination)',
     'asset_destination_account'      => 'Asset account (destination)',
     'asset_source_account'           => 'Asset account (source)',
@@ -58,95 +60,107 @@ return [
     'description'                    => 'Description',
     'expense_account'                => 'Expense account',
     'revenue_account'                => 'Revenue account',
-    'amount'                         => 'Amount',
-    'date'                           => 'Date',
-    'interest_date'                  => 'Interest date',
-    'book_date'                      => 'Book date',
-    'process_date'                   => 'Processing date',
-    'category'                       => 'Category',
-    'tags'                           => 'Tags',
-    'deletePermanently'              => 'Delete permanently',
-    'cancel'                         => 'Cancel',
-    'targetdate'                     => 'Target date',
-    'tag'                            => 'Tag',
-    'under'                          => 'Under',
-    'symbol'                         => 'Symbol',
-    'code'                           => 'Code',
-    'iban'                           => 'IBAN',
-    'accountNumber'                  => 'Account number',
-    'has_headers'                    => 'Headers',
-    'date_format'                    => 'Date format',
-    'specifix'                       => 'Bank- or file specific fixes',
-    'attachments[]'                  => 'Attachments',
-    'store_new_withdrawal'           => 'Store new withdrawal',
-    'store_new_deposit'              => 'Store new deposit',
-    'store_new_transfer'             => 'Store new transfer',
-    'add_new_withdrawal'             => 'Add a new withdrawal',
-    'add_new_deposit'                => 'Add a new deposit',
-    'add_new_transfer'               => 'Add a new transfer',
-    'noPiggybank'                    => '(no piggy bank)',
-    'title'                          => 'Title',
-    'notes'                          => 'Notes',
-    'filename'                       => 'File name',
-    'mime'                           => 'Mime type',
-    'size'                           => 'Size',
-    'trigger'                        => 'Trigger',
-    'stop_processing'                => 'Stop processing',
-    'start_date'                     => 'Start of range',
-    'end_date'                       => 'End of range',
-    'export_start_range'             => 'Start of export range',
-    'export_end_range'               => 'End of export range',
-    'export_format'                  => 'File format',
-    'include_attachments'            => 'Include uploaded attachments',
-    'include_old_uploads'            => 'Include imported data',
-    'accounts'                       => 'Export transactions from these accounts',
-    'delete_account'                 => 'Delete account ":name"',
-    'delete_bill'                    => 'Delete bill ":name"',
-    'delete_budget'                  => 'Delete budget ":name"',
-    'delete_category'                => 'Delete category ":name"',
-    'delete_currency'                => 'Delete currency ":name"',
-    'delete_journal'                 => 'Delete transaction with description ":description"',
-    'delete_attachment'              => 'Delete attachment ":name"',
-    'delete_rule'                    => 'Delete rule ":title"',
-    'delete_rule_group'              => 'Delete rule group ":title"',
-    'attachment_areYouSure'          => 'Are you sure you want to delete the attachment named ":name"?',
-    'account_areYouSure'             => 'Are you sure you want to delete the account named ":name"?',
-    'bill_areYouSure'                => 'Are you sure you want to delete the bill named ":name"?',
-    'rule_areYouSure'                => 'Are you sure you want to delete the rule titled ":title"?',
-    'ruleGroup_areYouSure'           => 'Are you sure you want to delete the rule group titled ":title"?',
-    'budget_areYouSure'              => 'Are you sure you want to delete the budget named ":name"?',
-    'category_areYouSure'            => 'Are you sure you want to delete the category named ":name"?',
-    'currency_areYouSure'            => 'Are you sure you want to delete the currency named ":name"?',
-    'piggyBank_areYouSure'           => 'Are you sure you want to delete the piggy bank named ":name"?',
-    'journal_areYouSure'             => 'Are you sure you want to delete the transaction described ":description"?',
-    'mass_journal_are_you_sure'      => 'Are you sure you want to delete these transactions?',
-    'tag_areYouSure'                 => 'Are you sure you want to delete the tag ":tag"?',
-    'permDeleteWarning'              => 'Deleting stuff from Firely is permanent and cannot be undone.',
-    'mass_make_selection'            => 'You can still prevent items from being deleted by removing the checkbox.',
-    'delete_all_permanently'         => 'Delete selected permanently',
-    'update_all_journals'            => 'Update these transactions',
-    'also_delete_transactions'       => 'The only transaction connected to this account will be deleted as well.|All :count transactions connected to this account will be deleted as well.',
-    'also_delete_rules'              => 'The only rule connected to this rule group will be deleted as well.|All :count rules connected to this rule group will be deleted as well.',
-    'also_delete_piggyBanks'         => 'The only piggy bank connected to this account will be deleted as well.|All :count piggy bank connected to this account will be deleted as well.',
-    'bill_keep_transactions'         => 'The only transaction connected to this bill will not be deleted.|All :count transactions connected to this bill will spared deletion.',
-    'budget_keep_transactions'       => 'The only transaction connected to this budget will not be deleted.|All :count transactions connected to this budget will spared deletion.',
-    'category_keep_transactions'     => 'The only transaction connected to this category will not be deleted.|All :count transactions connected to this category will spared deletion.',
-    'tag_keep_transactions'          => 'The only transaction connected to this tag will not be deleted.|All :count transactions connected to this tag will spared deletion.',
+
+    'revenue_account_source'      => 'Revenue account (source)',
+    'source_account_asset'        => 'Source account (asset account)',
+    'destination_account_expense' => 'Destination account (expense account)',
+    'destination_account_asset' => 'Destination account (asset account)',
+    'source_account_revenue'      => 'Source account (revenue account)',
+    'type'                        => 'Type',
+    'convert_Withdrawal'          => 'Convert withdrawal',
+    'convert_Deposit'          => 'Convert deposit',
+    'convert_Transfer'          => 'Convert transfer',
+
+
+    'amount'                     => 'Amount',
+    'date'                       => 'Date',
+    'interest_date'              => 'Interest date',
+    'book_date'                  => 'Book date',
+    'process_date'               => 'Processing date',
+    'category'                   => 'Category',
+    'tags'                       => 'Tags',
+    'deletePermanently'          => 'Delete permanently',
+    'cancel'                     => 'Cancel',
+    'targetdate'                 => 'Target date',
+    'tag'                        => 'Tag',
+    'under'                      => 'Under',
+    'symbol'                     => 'Symbol',
+    'code'                       => 'Code',
+    'iban'                       => 'IBAN',
+    'accountNumber'              => 'Account number',
+    'has_headers'                => 'Headers',
+    'date_format'                => 'Date format',
+    'specifix'                   => 'Bank- or file specific fixes',
+    'attachments[]'              => 'Attachments',
+    'store_new_withdrawal'       => 'Store new withdrawal',
+    'store_new_deposit'          => 'Store new deposit',
+    'store_new_transfer'         => 'Store new transfer',
+    'add_new_withdrawal'         => 'Add a new withdrawal',
+    'add_new_deposit'            => 'Add a new deposit',
+    'add_new_transfer'           => 'Add a new transfer',
+    'noPiggybank'                => '(no piggy bank)',
+    'title'                      => 'Title',
+    'notes'                      => 'Notes',
+    'filename'                   => 'File name',
+    'mime'                       => 'Mime type',
+    'size'                       => 'Size',
+    'trigger'                    => 'Trigger',
+    'stop_processing'            => 'Stop processing',
+    'start_date'                 => 'Start of range',
+    'end_date'                   => 'End of range',
+    'export_start_range'         => 'Start of export range',
+    'export_end_range'           => 'End of export range',
+    'export_format'              => 'File format',
+    'include_attachments'        => 'Include uploaded attachments',
+    'include_old_uploads'        => 'Include imported data',
+    'accounts'                   => 'Export transactions from these accounts',
+    'delete_account'             => 'Delete account ":name"',
+    'delete_bill'                => 'Delete bill ":name"',
+    'delete_budget'              => 'Delete budget ":name"',
+    'delete_category'            => 'Delete category ":name"',
+    'delete_currency'            => 'Delete currency ":name"',
+    'delete_journal'             => 'Delete transaction with description ":description"',
+    'delete_attachment'          => 'Delete attachment ":name"',
+    'delete_rule'                => 'Delete rule ":title"',
+    'delete_rule_group'          => 'Delete rule group ":title"',
+    'attachment_areYouSure'      => 'Are you sure you want to delete the attachment named ":name"?',
+    'account_areYouSure'         => 'Are you sure you want to delete the account named ":name"?',
+    'bill_areYouSure'            => 'Are you sure you want to delete the bill named ":name"?',
+    'rule_areYouSure'            => 'Are you sure you want to delete the rule titled ":title"?',
+    'ruleGroup_areYouSure'       => 'Are you sure you want to delete the rule group titled ":title"?',
+    'budget_areYouSure'          => 'Are you sure you want to delete the budget named ":name"?',
+    'category_areYouSure'        => 'Are you sure you want to delete the category named ":name"?',
+    'currency_areYouSure'        => 'Are you sure you want to delete the currency named ":name"?',
+    'piggyBank_areYouSure'       => 'Are you sure you want to delete the piggy bank named ":name"?',
+    'journal_areYouSure'         => 'Are you sure you want to delete the transaction described ":description"?',
+    'mass_journal_are_you_sure'  => 'Are you sure you want to delete these transactions?',
+    'tag_areYouSure'             => 'Are you sure you want to delete the tag ":tag"?',
+    'permDeleteWarning'          => 'Deleting stuff from Firely is permanent and cannot be undone.',
+    'mass_make_selection'        => 'You can still prevent items from being deleted by removing the checkbox.',
+    'delete_all_permanently'     => 'Delete selected permanently',
+    'update_all_journals'        => 'Update these transactions',
+    'also_delete_transactions'   => 'The only transaction connected to this account will be deleted as well.|All :count transactions connected to this account will be deleted as well.',
+    'also_delete_rules'          => 'The only rule connected to this rule group will be deleted as well.|All :count rules connected to this rule group will be deleted as well.',
+    'also_delete_piggyBanks'     => 'The only piggy bank connected to this account will be deleted as well.|All :count piggy bank connected to this account will be deleted as well.',
+    'bill_keep_transactions'     => 'The only transaction connected to this bill will not be deleted.|All :count transactions connected to this bill will spared deletion.',
+    'budget_keep_transactions'   => 'The only transaction connected to this budget will not be deleted.|All :count transactions connected to this budget will spared deletion.',
+    'category_keep_transactions' => 'The only transaction connected to this category will not be deleted.|All :count transactions connected to this category will spared deletion.',
+    'tag_keep_transactions'      => 'The only transaction connected to this tag will not be deleted.|All :count transactions connected to this tag will spared deletion.',
 
     // admin
-    'domain'                         => 'Domain',
-    'single_user_mode'               => 'Single user mode',
+    'domain'                     => 'Domain',
+    'single_user_mode'           => 'Single user mode',
 
     // import
-    'import_file'                    => 'Import file',
-    'configuration_file'             => 'Configuration file',
-    'import_file_type'               => 'Import file type',
-    'csv_comma'                      => 'A comma (,)',
-    'csv_semicolon'                  => 'A semicolon (;)',
-    'csv_tab'                        => 'A tab (invisible)',
-    'csv_delimiter'                  => 'CSV field delimiter',
-    'csv_import_account'             => 'Default import account',
-    'csv_config'                     => 'CSV import configuration',
+    'import_file'                => 'Import file',
+    'configuration_file'         => 'Configuration file',
+    'import_file_type'           => 'Import file type',
+    'csv_comma'                  => 'A comma (,)',
+    'csv_semicolon'              => 'A semicolon (;)',
+    'csv_tab'                    => 'A tab (invisible)',
+    'csv_delimiter'              => 'CSV field delimiter',
+    'csv_import_account'         => 'Default import account',
+    'csv_config'                 => 'CSV import configuration',
 
 
     'due_date'           => 'Due date',
diff --git a/resources/views/transactions/convert.twig b/resources/views/transactions/convert.twig
new file mode 100644
index 0000000000..c7617480a6
--- /dev/null
+++ b/resources/views/transactions/convert.twig
@@ -0,0 +1,176 @@
+{% extends "./layout/default.twig" %}
+
+{% block breadcrumbs %}
+    {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, destinationType, journal) }}
+{% endblock %}
+
+{% block content %}
+    
+ +
+
+
+
+

{{ ('convert_options_'~sourceType.type~destinationType.type)|_ }}

+
+
+ {{ ExpandedForm.staticText('type', sourceType.type|_) }} + {{ ExpandedForm.staticText('description', ''~journal.description~'') }} + {{ ExpandedForm.staticText('date', journal.date.formatLocalized(monthAndDayFormat)) }} + + {# in case of withdrawal #} + {% if sourceType.type == "Withdrawal" %} + {{ ExpandedForm.staticText('source_account_asset', ''~sourceAccount.name~'') }} + {{ ExpandedForm.staticText('destination_account_expense', ''~destinationAccount.name~'') }} + {% endif %} + + {# in case of deposit #} + {% if sourceType.type == "Deposit" %} + {{ ExpandedForm.staticText('source_account_revenue', ''~sourceAccount.name~'') }} + {{ ExpandedForm.staticText('destination_account_asset', ''~destinationAccount.name~'') }} + {% endif %} + + {# in case of transfer #} + {% if sourceType.type == "Transfer" %} + {{ ExpandedForm.staticText('source_account_asset', ''~sourceAccount.name~'') }} + {{ ExpandedForm.staticText('destination_account_asset', ''~destinationAccount.name~'') }} + {% endif %} + + {# ONE #} + {% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %} +

+ If you convert this withdrawal into a deposit, {{ positiveAmount|formatAmount }} + will be deposited into {{ sourceAccount.name }} + instead of taken from it. + +

+

+ Please pick the revenue account where the money will come from. + +

+ + {{ ExpandedForm.text('source_account_revenue', destinationAccount.name) }} + {% endif %} + + {# TWO #} + {% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %} +

+ If you convert this withdrawal into a transfer, {{ positiveAmount|formatAmount }} + will be transferred from {{ sourceAccount.name }} + to a new asset account, instead of being paid to + {{ destinationAccount.name }}. +

+ +

+ + Please pick the asset account where the money will go to. + +

+ {{ ExpandedForm.select('destination_account_asset', assetAccounts) }} + + + {% endif %} + + {# THREE #} + {% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %} +

+ + If you convert this deposit into a withdrawal, {{ positiveAmount|formatAmount }} + will be removed from {{ destinationAccount.name }} + instead of added to it. + +

+

+ + Please pick the expense account where the money will go to. + +

+ {{ ExpandedForm.text('destination_account_expense', destinationAccount.name) }} + + {% endif %} + + {# FOUR #} + {% if sourceType.type == 'Deposit' and destinationType.type == 'Transfer' %} + +

+ + If you convert this deposit into a transfer, {{ positiveAmount|formatAmount }} will be transferred + from an asset account of your choice into + {{ destinationAccount.name }}. + +

+

+ + Please pick the asset account where the money will come from. + +

+ + {{ ExpandedForm.select('source_account_asset', assetAccounts) }} + {% endif %} + + {# FIVE #} + {% if sourceType.type == 'Transfer' and destinationType.type == 'Withdrawal' %} + +

+ + If you convert this transfer into a withdrawal, {{ positiveAmount|formatAmount }} + will go from {{ sourceAccount.name }} + to a new destination as an expense, instead of to + {{ destinationAccount.name }} + as a transfer. + +

+ +

+ + Please pick the expense account where the money will go to. + +

+ + {{ ExpandedForm.text('destination_account_expense', destinationAccount.name) }} + + {% endif %} + + {# SIX #} + {% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %} + +

+ + If you convert this transfer into a deposit, {{ positiveAmount|formatAmount }} + will be deposited into account {{ destinationAccount.name }} + instead of being transferred there. + +

+ +

+ + Please pick the revenue account where the money will come from. + +

+ + {{ ExpandedForm.text('source_account_revenue', sourceAccount.name) }} + + {% endif %} + +
+ +
+
+
+
+ +{% endblock %} +{% block scripts %} + + +{% endblock %} + +{% block styles %} + +{% endblock %} diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig index 5a7e7f42d3..5a146f26be 100644 --- a/resources/views/transactions/show.twig +++ b/resources/views/transactions/show.twig @@ -169,8 +169,6 @@ - - {% if journal.attachments|length > 0 %}
@@ -210,10 +208,44 @@
{% endif %} + {% if transactions|length == 1 %} +
+
+

{{ 'transaction_journal_convert_options'|_ }}

+
+
+ {% if journal.transactionType.type != "Withdrawal" %} +

+ + + Convert this {{ journal.transactionType.type }} to a withdrawal. + +

+ {% endif %} + {% if journal.transactionType.type != "Deposit" %} +

+ + + Convert this {{ journal.transactionType.type }} to a deposit. + +

+ {% endif %} + + {% if journal.transactionType.type != "Transfer" %} +

+ + + Convert this {{ journal.transactionType.type }} to a transfer. + +

+ {% endif %} + +
+
+ {% endif %} -
diff --git a/routes/web.php b/routes/web.php index e53e81ccde..89284d06cc 100755 --- a/routes/web.php +++ b/routes/web.php @@ -284,10 +284,8 @@ Route::group( Route::post('/piggy-banks/store', ['uses' => 'PiggyBankController@store', 'as' => 'piggy-banks.store']); Route::post('/piggy-banks/update/{piggyBank}', ['uses' => 'PiggyBankController@update', 'as' => 'piggy-banks.update']); Route::post('/piggy-banks/destroy/{piggyBank}', ['uses' => 'PiggyBankController@destroy', 'as' => 'piggy-banks.destroy']); - Route::post('/piggy-banks/add/{piggyBank}', ['uses' => 'PiggyBankController@postAdd', 'as' => 'piggy-banks.add']); Route::post('/piggy-banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@postRemove', 'as' => 'piggy-banks.remove']); - Route::post('/piggy-banks/sort', ['uses' => 'PiggyBankController@order', 'as' => 'piggy-banks.order']); /** @@ -425,6 +423,10 @@ Route::group( Route::get('/transaction/split/edit/{tj}', ['uses' => 'Transaction\SplitController@edit', 'as' => 'transactions.edit-split']); Route::post('/transaction/split/update/{tj}', ['uses' => 'Transaction\SplitController@update', 'as' => 'split.journal.update']); + // convert controller: + Route::get('transactions/convert/{transaction_type}/{tj}', ['uses' => 'Transaction\ConvertController@convert', 'as' => 'transactions.convert']); + Route::post('transactions/convert/{transaction_type}/{tj}', ['uses' => 'Transaction\ConvertController@submit', 'as' => 'transactions.convert.post']); + /** * POPUP Controllers */