Refactor the expandedform methods. First commit to see how Scrutinizer likes this. This commit will break most views.

This commit is contained in:
James Cole
2019-08-10 15:09:44 +02:00
parent 0097c66522
commit 6e2978231b
15 changed files with 970 additions and 1290 deletions

View File

@@ -38,7 +38,7 @@
{{ ExpandedForm.checkbox('has_headers',1,importJob.configuration['has-headers'],{helpText: trans('import.job_config_uc_header_help')}) }}
{{ ExpandedForm.text('date_format',importJob.configuration['date-format'],{helpText: trans('import.job_config_uc_date_help', {dateExample: phpdate('Ymd')}) }) }}
{{ ExpandedForm.select('csv_delimiter', data.delimiters, importJob.configuration['delimiter'], {helpText: trans('import.job_config_uc_delimiter_help') } ) }}
{{ ExpandedForm.activeAssetAccountList('csv_import_account', importJob.configuration['import-account'], {helpText: trans('import.job_config_uc_account_help')}) }}
{{ AccountForm.activeAssetAccountList('csv_import_account', importJob.configuration['import-account'], {helpText: trans('import.job_config_uc_account_help')}) }}
<h4>{{ 'optionalFields'|_ }}</h4>
<div class="form-group">

View File

@@ -18,7 +18,7 @@
<div class="box-body">
{{ ExpandedForm.text('name') }}
{{ ExpandedForm.activeAssetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
{{ AccountForm.activeAssetAccountList('account_id', null, {label: 'saveOnAccount'|_ }) }}
{{ ExpandedForm.amountNoCurrency('targetamount') }}
</div>

View File

@@ -90,16 +90,13 @@
{{ ExpandedForm.amountNoCurrency('amount', []) }}
{# source account if withdrawal, or if transfer: #}
{{ ExpandedForm.activeLongAccountList('source_id', null, {label: trans('form.asset_source_account')}) }}
{# source account name for deposits: #}
{#{{ ExpandedForm.text('source_name', null, {label: trans('form.revenue_account')}) }}#}
{{ AccountForm.activeLongAccountList('source_id', null, {label: trans('form.asset_source_account')}) }}
{# for deposits, a drop down with revenue accounts, loan debt cash and mortgage #}
{{ ExpandedForm.activeDepositDestinations('deposit_source_id', null, {label: trans('form.deposit_source_id')}) }}
{# destination if deposit or transfer: #}
{{ ExpandedForm.activeLongAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }}
{{ AccountForm.activeLongAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }}
{# destination account name for withdrawals #}
{#{{ ExpandedForm.text('destination_name', null, {label: trans('form.expense_account')}) }} #}

View File

@@ -314,168 +314,6 @@
{{ ExpandedForm.staticText('destination_account_asset', '<a href="'~route('accounts.show',[destinationAccount.id])~'">'~destinationAccount.name|escape~'</a>') }}
{% endif %}
#}
{# ONE #}
{#
{% if journalType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
ONE
{% endif %}
{% if journalType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
<p><em>
{{ trans('firefly.convert_explanation_withdrawal_deposit',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em>
</p>
<p><em>
{{ 'convert_please_set_revenue_source'|_ }}
</em>
</p>
{% if destinationAccount.accountType.type == "Cash account" %}
{{ ExpandedForm.text('source_account_revenue', '') }}
{% else %}
{{ ExpandedForm.text('source_account_revenue', destinationAccount.name|escape) }}
{% endif %}
{% endif %}
#}
{# TWO #}
{#
{% if journalType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
<p><em>
{{ trans('firefly.convert_explanation_withdrawal_transfer',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em></p>
<p>
<em>
{{ 'convert_please_set_asset_destination'|_ }}
</em>
</p>
{{ ExpandedForm.activeLongAccountList('destination_account_asset', null) }}
{% endif %}
#}
{# THREE #}
{#
{% if journalType.type == 'Deposit' and destinationType.type == 'Withdrawal' %}
<p>
<em>
{{ trans('firefly.convert_explanation_deposit_withdrawal',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em>
</p>
<p>
<em>
{{ 'convert_please_set_expense_destination'|_ }}
</em>
</p>
{% if sourceAccount.accountType.type == "Cash account" %}
{{ ExpandedForm.text('destination_account_expense', '') }}
{% else %}
{{ ExpandedForm.text('destination_account_expense', destinationAccount.name|escape) }}
{% endif %}
{% endif %}
#}
{# FOUR #}
{#
{% if journalType.type == 'Deposit' and destinationType.type == 'Transfer' %}
<p>
<em>
{{ trans('firefly.convert_explanation_deposit_transfer',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em>
</p>
<p>
<em>
{{ 'convert_please_set_asset_source'|_ }}
</em>
</p>
{{ ExpandedForm.activeLongAccountList('source_account_asset', null) }}
{% endif %}
#}
{# FIVE #}
{#
{% if journalType.type == 'Transfer' and destinationType.type == 'Withdrawal' %}
<p>
<em>
{{ trans('firefly.convert_explanation_transfer_withdrawal',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em>
</p>
<p>
<em>
{{ 'convert_please_set_expense_destination'|_ }}
</em>
</p>
{{ ExpandedForm.text('destination_account_expense', destinationAccount.name|escape) }}
{% endif %}
#}
{# SIX #}
{#
{% if journalType.type == 'Transfer' and destinationType.type == 'Deposit' %}
<p>
<em>
{{ trans('firefly.convert_explanation_transfer_deposit',
{
amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name|escape,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name|escape,
})|raw }}
</em>
</p>
<p>
<em>
{{ 'convert_please_set_revenue_source'|_ }}
</em>
</p>
{{ ExpandedForm.text('source_account_revenue', sourceAccount.name|escape) }}
{% endif %}
#}
</div>
<div class="box-footer">
<a href="{{ route('transactions.show', group.id) }}" class="btn btn-danger">{{ 'cancel'|_ }}</a>

View File

@@ -1,337 +0,0 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, journal) }}
{% endblock %}
{% block content %}
<form method="POST" action="{{ route('transactions.split.update',journal.id) }}" accept-charset="UTF-8" class="form-horizontal" id="update"
enctype="multipart/form-data">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<input type="hidden" name="id" value="{{ journal.id }}"/>
<input type="hidden" name="what" value="{{ preFilled.what }}"/>
<input type="hidden" name="journal_currency_id" value="{{ journal.transaction_currency_id }}"/>
{% if errors.all()|length > 0 %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">{{ 'errors'|_ }}</h3>
</div>
<div class="box-body">
<ul>
{% for key, err in errors.all() %}
<li class="text-danger">{{ err }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_data'|_ }}</h3>
</div>
<div class="box-body">
{# DESCRIPTION IS ALWAYS AVAILABLE #}
{{ ExpandedForm.text('journal_description', journal.description) }}
{# show source if withdrawal or transfer #}
{% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %}
{{ ExpandedForm.activeLongAccountList('journal_source_id', preFilled.journal_source_id) }}
{% endif %}
{# show destination account id, if deposit (is asset): #}
{% if preFilled.what == 'deposit' or preFilled.what == 'transfer' %}
{{ ExpandedForm.activeLongAccountList('journal_destination_id', preFilled.journal_destination_id) }}
{% endif %}
{# show amount and some helper text when making splits: #}
{# amount #}
<div id="journal_amount_holder" class="form-group">
<label for="ffInput_journal_amount" class="col-sm-4 control-label">{{ trans('form.amount') }}</label>
<div class="col-sm-8">
<p id="ffInput_journal_amount" class="form-control-static">
{{ formatAmountBySymbol(preFilled.journal_amount|default("0"), preFilled.transactions[0].currency_symbol|default("x"), preFilled.transactions[0].currency_decimal_places) }}
</p>
</div>
</div>
{# foreign amount, if not zero. #}
{% if preFilled.journal_foreign_amount != 0 %}
<div id="journal_foreign_amount_holder" class="form-group">
<label for="ffInput_foreign_journal_amount" class="col-sm-4 control-label">{{ trans('form.foreign_amount') }}</label>
<div class="col-sm-8">
<p id="ffInput_foreign_journal_amount" class="form-control-static">
{{ formatAmountBySymbol(preFilled.journal_foreign_amount, preFilled.transactions[0].foreign_currency_symbol, preFilled.transactions[0].foreign_currency_decimal_places) }}
</p>
</div>
</div>
{% endif %}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
{# DATE #}
{{ ExpandedForm.date('date', journal.date) }}
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_field_meta_data'|_ }}</h3>
</div>
<div class="box-body">
{# ALWAYS TAGS #}
{{ ExpandedForm.text('tags', preFilled.tags) }}
</div>
</div>
{# EXPLANATION IF NECESSARY: #}
{% if
not optionalFields.interest_date or
not optionalFields.book_date or
not optionalFields.process_date or
not optionalFields.due_date or
not optionalFields.payment_date or
not optionalFields.invoice_date or
not optionalFields.internal_reference or
not optionalFields.notes or
not optionalFields.attachments %}
<p class="text-center text-success"><i class="fa fa-info-circle"></i>
<em>{{ trans('firefly.hidden_fields_preferences', {link: route('preferences.index')})|raw }}</em></p>
{% endif %}
{# BOX FOR DATES #}
{% if
optionalFields.interest_date or optionalFields.book_date or optionalFields.process_date
or optionalFields.due_date or optionalFields.payment_date
or optionalFields.invoice_date %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_field_meta_dates'|_ }}</h3>
</div>
<div class="box-body">
{# INTEREST DATE #}
{% if optionalFields.interest_date or journal.interest_date %}
{{ ExpandedForm.date('interest_date', journal.interest_date) }}
{% endif %}
{# BOOK DATE #}
{% if optionalFields.book_date or journal.book_date %}
{{ ExpandedForm.date('book_date', journal.book_date) }}
{% endif %}
{# PROCESSING DATE #}
{% if optionalFields.process_date or journal.process_date %}
{{ ExpandedForm.date('process_date', journal.process_date) }}
{% endif %}
{# DUE DATE #}
{% if optionalFields.due_date or journal.due_date %}
{{ ExpandedForm.date('due_date', journal.due_date) }}
{% endif %}
{# PAYMENT DATE #}
{% if optionalFields.payment_date or journal.payment_date %}
{{ ExpandedForm.date('payment_date', journal.payment_date) }}
{% endif %}
{# INVOICE DATE #}
{% if optionalFields.invoice_date or journal.invoice_date %}
{{ ExpandedForm.date('invoice_date', journal.invoice_date) }}
{% endif %}
</div>
</div>
{% endif %}
{# BOX FOR BUSINESS FIELDS #}
{% if optionalFields.internal_reference or optionalFields.notes %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_field_meta_business'|_ }}</h3>
</div>
<div class="box-body">
{# INTERNAL REFERENCE #}
{% if optionalFields.internal_reference or journal.internal_reference %}
{{ ExpandedForm.text('internal_reference', journal.internal_reference) }}
{% endif %}
{# NOTES #}
{% if optionalFields.notes or journal.notes %}
{{ ExpandedForm.textarea('notes',preFilled.notes) }}
{% endif %}
</div>
</div>
{% endif %}
{# BOX FOR ATTACHMENTS #}
{% if optionalFields.attachments %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_field_attachments'|_ }}</h3>
</div>
<div class="box-body">
{# ATTACHMENTS #}
{% if optionalFields.attachments %}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'splits'|_ }}</h3>
</div>
<div class="box-body">
<div class="container-fluid split_row_holder">
<div class="row bg-gray-light" style="padding-bottom:3px;">
{# HEADER #}
<div class="col-lg-1 col-md-1 col-sm-6 col-xs-6"><strong>{{ trans('list.split_number') }}</strong></div>
<div class="col-lg-3 col-md-5 col-sm-12 col-xs-12"><strong>{{ trans('list.description') }}</strong></div>
{# withdrawal and deposit have a destination. #}
{% if preFilled.what == 'withdrawal' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12"><strong>{{ trans('list.destination') }}</strong></div>
{% endif %}
{# Deposit has a source #}
{% if preFilled.what == 'deposit' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12"><strong>{{ trans('list.source') }}</strong></div>
{% endif %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12"><strong>{{ trans('list.amount') }}</strong></div>
{# only withdrawal has budget #}
{% if preFilled.what == 'withdrawal' %}
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12"><strong>{{ trans('list.budget') }}</strong></div>
{% endif %}
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12"><strong>{{ trans('list.category') }}</strong></div>
</div>
{# ROWS #}
{% for index, transaction in preFilled.transactions %}
<div class="row {% if loop.index0 % 2 == 1 %}bg-gray-light{% endif %} split_row" data-split="{{ loop.index0 }}">
{# button #}
<div class="col-lg-1 col-md-1 col-sm-6 col-xs-6">
<a href="#" class="btn btn-xs btn-danger remove-current-split" data-split="{{ loop.index0 }}">
<i class="fa fa-trash" data-split="{{ loop.index0 }}"></i><span> #{{ loop.index }}</span></a>
</div>
{# description #}
<div class="col-lg-3 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][transaction_description]"
value="{{ transaction.transaction_description }}"
class="form-control"/>
</div>
{# destination for withdrawals: #}
{% if preFilled.what == 'withdrawal' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][destination_name]"
value="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}"
class="form-control"/>
</div>
{% endif %}
{# source for deposits #}
{% if preFilled.what == 'deposit' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][source_name]"
value="{{ transaction.source_name }}" class="form-control"/>
</div>
{% endif %}
{# amount#}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
{{ transaction.currency_symbol }}&nbsp;<input class="split_amount_input" type="number"
name="transactions[{{ loop.index0 }}][amount]"
value="{{ transaction.amount }}"
autocomplete="off" step="any">
{% if transaction.foreign_amount != null %}
{{ transaction.foreign_currency_symbol }}&nbsp;<input class="split_amount_input" type="number"
name="transactions[{{ loop.index0 }}][foreign_amount]"
value="{{ transaction.foreign_amount }}" autocomplete="off"
step="any">
<input type="hidden" name="transactions[{{ loop.index0 }}][foreign_currency_id]"
value="{{ transaction.foreign_currency_id }}">
{% endif %}
<input type="hidden" name="transactions[{{ loop.index0 }}][currency_id]"
value="{{ transaction.currency_id }}">
</div>
{# budget #}
{% if preFilled.what == 'withdrawal' %}
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
<select class="form-control" name="transactions[{{ loop.index0 }}][budget_id]">
{% for key, budget in budgets %}
<option label="{{ budget }}" value="{{ key }}"
{% if transaction.budget_id == key %} selected="selected"{% endif %}>{{ budget }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{# category #}
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][category_name]"
value="{{ transaction.category_name }}"
class="form-control"/>
</div>
</div>
{% endfor %}
</div>
<p>
<br/>
<a href="#" class="btn btn-default btn-do-split"><i class="fa fa-plus-circle"></i> {{ 'add_another_split'|_ }}</a>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
{# panel for options #}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'options'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.optionsList('update','split-transaction') }}
</div>
<div class="box-footer">
<button type="submit" class="pull-right btn btn-success">{{ ('update_' ~ preFilled.what)|_ }}</button>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block styles %}
<link href="v1/css/bootstrap-tagsinput.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="{{ route('javascript.currencies') }}?ext=.js&amp;v={{ FF_VERSION }}"></script>
<script type="text/javascript">
var currencySymbol = "{{ preFilled.transactions[0].currency_symbol }}";
var foreignCurrencySymbol = "{{ preFilled.transactions[0].foreign_currency_symbol }}";
var originalSum = {{ preFilled.journal_amount }};
var originalForeignSum = {{ preFilled.journal_foreign_amount }};
var what = "{{ preFilled.what }}";
</script>
<script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/ff/common/autocomplete.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/bootstrap-tagsinput.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/ff/transactions/split/edit.js?v={{ FF_VERSION }}"></script>
{% endblock %}