First batch of code for recurring transactions #1469

This commit is contained in:
James Cole
2018-06-10 16:59:03 +02:00
parent 35a5ec78c3
commit 6743d99d9b
29 changed files with 2242 additions and 48 deletions

View File

@@ -23,20 +23,29 @@
declare(strict_types=1);
return [
'html_language' => 'en',
'locale' => 'en, English, en_US, en_US.utf8, en_US.UTF-8',
'month' => '%B %Y',
'month_and_day' => '%B %e, %Y',
'date_time' => '%B %e, %Y, @ %T',
'specific_day' => '%e %B %Y',
'week_in_year' => 'Week %W, %Y',
'year' => '%Y',
'half_year' => '%B %Y',
'month_js' => 'MMMM YYYY',
'month_and_day_js' => 'MMMM Do, YYYY',
'date_time_js' => 'MMMM Do, YYYY, @ HH:mm:ss',
'specific_day_js' => 'D MMMM YYYY',
'week_in_year_js' => '[Week] w, YYYY',
'year_js' => 'YYYY',
'half_year_js' => 'Q YYYY',
'html_language' => 'en',
'locale' => 'en, English, en_US, en_US.utf8, en_US.UTF-8',
'month' => '%B %Y',
'month_and_day' => '%B %e, %Y',
'month_and_date_day' => '%A %B %e, %Y',
'month_and_day_no_year' => '%B %e',
'date_time' => '%B %e, %Y, @ %T',
'specific_day' => '%e %B %Y',
'week_in_year' => 'Week %W, %Y',
'year' => '%Y',
'half_year' => '%B %Y',
'month_js' => 'MMMM YYYY',
'month_and_day_js' => 'MMMM Do, YYYY',
'date_time_js' => 'MMMM Do, YYYY, @ HH:mm:ss',
'specific_day_js' => 'D MMMM YYYY',
'week_in_year_js' => '[Week] w, YYYY',
'year_js' => 'YYYY',
'half_year_js' => 'Q YYYY',
'dow_1' => 'Monday',
'dow_2' => 'Tuesday',
'dow_3' => 'Wednesday',
'dow_4' => 'Thursday',
'dow_5' => 'Friday',
'dow_6' => 'Saturday',
'dow_7' => 'Sunday',
];

View File

@@ -820,7 +820,7 @@ return [
'language' => 'Language',
'new_savings_account' => ':bank_name savings account',
'cash_wallet' => 'Cash wallet',
'currency_not_present' => 'If the currency you normally use is not listed do not worry. You can create your own currencies under Options > Currencies.',
'currency_not_present' => 'If the currency you normally use is not listed do not worry. You can create your own currencies under Options > Currencies.',
// home page:
'yourAccounts' => 'Your accounts',
@@ -1206,4 +1206,35 @@ return [
'no_bills_intro_default' => 'You have no bills yet. You can create bills to keep track of regular expenses, like your rent or insurance.',
'no_bills_imperative_default' => 'Do you have such regular bills? Create a bill and keep track of your payments:',
'no_bills_create_default' => 'Create a bill',
// recurring transactions
'recurrences' => 'Recurring transactions',
'no_recurring_title_default' => 'Let\'s create a recurring transaction!',
'no_recurring_intro_default' => 'You have no recurring transactions yet. You can use these to make Firefly III automatically create transactions for you.',
'no_recurring_imperative_default' => 'This is a pretty advanced feature but it can be extremely useful. Make sure you read the documentation (?-icon in the top right corner) before you continue.',
'no_recurring_create_default' => 'Create a recurring transaction',
'make_new_recurring' => 'Create a recurring transaction',
'recurring_daily' => 'Every day',
'recurring_weekly' => 'Every week on :weekday',
'recurring_monthly' => 'Every month on the :dayOfMonth(st/nd/rd/th) day',
'recurring_ndom' => 'Every month on the :dayOfMonth(st/nd/rd/th) :weekday',
'recurring_yearly' => 'Every year on :date',
'overview_for_recurrence' => 'Overview for recurring transaction ":title"',
'warning_duplicates_repetitions' => 'In rare instances, dates appear twice in this list. This can happen when multiple repetitions collide. Firefly III will always generate one transaction per day.',
'created_transactions' => 'Related transactions',
'expected_transactions' => 'Expected transactions',
'recurring_meta_field_tags' => 'Tags',
'recurring_meta_field_notes' => 'Notes',
'recurring_meta_field_bill_id' => 'Bill',
'recurring_meta_field_piggy_bank_id' => 'Piggy bank',
'create_new_recurrence' => 'Create new recurring transaction',
'help_first_date' => 'Indicate the first expected recurrence. This must be in the future.',
'mandatory_for_recurring' => 'Mandatory recurrence information',
'mandatory_for_transaction' => 'Mandatory transaction information',
'optional_for_recurring' => 'Optional recurrence information',
'optional_for_transaction' => 'Optional transaction information',
'change_date_other_options' => 'Change the "first date" to see more options.',
'mandatory_fields_for_tranaction' => 'The values here will end up in the transaction(s) being created',
];

View File

@@ -216,11 +216,19 @@ return [
'country_code' => 'Country code',
'provider_code' => 'Bank or data-provider',
'due_date' => 'Due date',
'payment_date' => 'Payment date',
'invoice_date' => 'Invoice date',
'internal_reference' => 'Internal reference',
'inward' => 'Inward description',
'outward' => 'Outward description',
'rule_group_id' => 'Rule group',
'due_date' => 'Due date',
'payment_date' => 'Payment date',
'invoice_date' => 'Invoice date',
'internal_reference' => 'Internal reference',
'inward' => 'Inward description',
'outward' => 'Outward description',
'rule_group_id' => 'Rule group',
'transaction_description' => 'Transaction description',
'first_date' => 'First date',
'transaction_type' => 'Transaction type',
'repeat_until' => 'Repeat until',
'recurring_description' => 'Recurring transaction description',
'repetition_type' => 'Type of repetition',
'foreign_currency_id' => 'Foreign currency',
];

View File

@@ -123,4 +123,9 @@ return [
'spectre_last_use' => 'Last login',
'spectre_status' => 'Status',
'bunq_payment_id' => 'bunq payment ID',
'repetitions' => 'Repetitions',
'title' => 'Title',
'transaction_s' => 'Transaction(s)',
'field' => 'Field',
'value' => 'Value',
];

View File

@@ -35,7 +35,7 @@
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
{{ ExpandedForm.integer('skip',0) }}
{{ ExpandedForm.checkbox('active',1,true) }}
{{ ExpandedForm.checkbox('active',1, true) }}
</div>
</div>

View File

@@ -98,6 +98,10 @@
<a href="{{ route('rules.index') }}">
<i class="fa fa-random fa-fw"></i> {{ 'rules'|_ }}</a>
</li>
<li class="{{ activeRoutePartial('recurring') }}">
<a href="{{ route('recurring.index') }}">
<i class="fa fa-paint-brush fa-fw"></i> {{ 'recurrences'|_ }}</a>
</li>
</ul>
</li>

View File

@@ -0,0 +1,150 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName) }}
{% endblock %}
{% block content %}
<form action="{{ route('recurring.store') }}" method="post" id="store" class="form-horizontal">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'mandatory_for_recurring'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.text('name') }}
{{ ExpandedForm.date('first_date',null, {helpText: trans('firefly.help_first_date')}) }}
{{ ExpandedForm.date('repeat_until',null) }}
{{ ExpandedForm.select('repetition_type', [], null, {helpText: trans('firefly.change_date_other_options')}) }}
{{ ExpandedForm.number('skip', 0) }}
{# three buttons to distinguish type of transaction#}
<div class="form-group" id="name_holder">
<label for="ffInput_type" class="col-sm-4 control-label">
{{ trans('form.transaction_type') }}
</label>
<div class="col-sm-8">
<div class="btn-group btn-group-sm">
<a href="#" class="btn btn-default switch-button" data-value="withdrawal">{{ 'withdrawal'|_ }}</a>
<a href="#" class="btn btn-default switch-button" data-value="deposit">{{ 'deposit'|_ }}</a>
<a href="#" class="btn btn-default switch-button" data-value="transfer">{{ 'transfer'|_ }}</a>
</div>
</div>
</div>
</div>
</div>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'mandatory_for_transaction'|_ }}</h3>
</div>
<div class="box-body">
<p><em>{{ 'mandatory_fields_for_tranaction'|_ }}</em></p>
{{ ExpandedForm.text('transaction_description') }}
{# transaction information (mandatory) #}
{{ ExpandedForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
{{ ExpandedForm.amountNoCurrency('amount', []) }}
{# source account if withdrawal, or if transfer: #}
{{ ExpandedForm.assetAccountList('source_account_id', null, {label: trans('form.asset_source_account')}) }}
{# source account name for deposits: #}
{{ ExpandedForm.text('source_account_name', null, {label: trans('form.revenue_account')}) }}
{# destination if deposit or transfer: #}
{{ ExpandedForm.assetAccountList('destination_account_id', null, {label: trans('form.asset_destination_account')} ) }}
{# destination account name for withdrawals #}
{{ ExpandedForm.text('destination_account_name', null, {label: trans('form.expense_account')}) }}
</div>
</div>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'expected_repetitions'|_ }}</h3>
</div>
<div class="box-body">
Here.
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_for_recurring'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.textarea('recurring_description') }}
{{ ExpandedForm.checkbox('active',1) }}
{{ ExpandedForm.checkbox('apply_rules',1) }}
</div>
</div>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optional_for_transaction'|_ }}</h3>
</div>
<div class="box-body">
{# transaction information (optional) #}
{{ ExpandedForm.currencyList('foreign_currency_id', defaultCurrency.id) }}
{{ ExpandedForm.amountNoCurrency('foreign_amount', []) }}
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
{% if budgets|length > 1 %}
{{ ExpandedForm.select('budget_id', budgets, null) }}
{% else %}
{{ ExpandedForm.select('budget_id', budgets, null, {helpText: trans('firefly.no_budget_pointer')}) }}
{% endif %}
{# CATEGORY ALWAYS #}
{{ ExpandedForm.text('category') }}
{# TAGS #}
{{ ExpandedForm.text('tags') }}
{# RELATE THIS TRANSFER TO A PIGGY BANK #}
{{ ExpandedForm.select('piggy_bank_id', [], '0') }}
</div>
</div>
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'options'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.optionsList('create','recurrence') }}
</div>
<div class="box-footer">
<button type="submit" class="btn pull-right btn-success">
{{ ('store_new_recurrence')|_ }}
</button>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/bootstrap-tagsinput.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript">
var transactionType = "{{ preFilled.transaction_type }}";
var suggestUri = "{{ route('recurring.suggest') }}";
</script>
<script type="text/javascript" src="js/ff/recurring/create.js?v={{ FF_VERSION }}"></script>
{% endblock %}
{% block styles %}
<link href="css/bootstrap-tagsinput.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
{% endblock %}

View File

@@ -0,0 +1,120 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName) }}
{% endblock %}
{% block content %}
<!-- block with list of recurring transaction -->
{% if recurring|length > 0 %}
<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">
{{ 'recurrences'|_ }}
</h3>
<div class="box-tools pull-right">
<div class="btn-group">
<button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{ route('recurring.create') }}"><i class="fa fa-plus fa-fw"></i> {{ ('make_new_recurring')|_ }}</a></li>
</ul>
</div>
</div>
</div>
<div class="box-body table-responsive no-padding">
<div style="padding:8px;">
<a href="{{ route('recurring.create') }}" class="btn btn-success"><i class="fa fa-plus fa-fw"></i> {{ ('make_new_recurring')|_ }}
</a>
</div>
<!-- list of recurring here -->
<div style="padding-left:8px;">
{{ recurring.render|raw }}
</div>
<table class="table table-hover sortable">
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th data-defaultsign="az">{{ trans('list.title') }}</th>
<th data-defaultsign="_19">{{ trans('list.transaction_s') }}</th>
<th data-defaultsort="disabled">{{ trans('list.repetitions') }}</th>
</tr>
</thead>
<tbody>
{% for rt in recurring %}
<tr>
<td class="hidden-sm hidden-xs">
<div class="btn-group btn-group-xs edit_tr_buttons">
<a class="btn btn-default btn-xs" title="{{ 'edit'|_ }}" href="{{ route('recurring.edit',rt.id) }}"><i
class="fa fa-fw fa-pencil"></i></a>
<a class="btn btn-danger btn-xs" title="{{ 'delete'|_ }}" href="{{ route('recurring.delete',rt.id) }}"><i
class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td data-value="{{ rt.title }}">
{{ rt.transaction_type|_ }}:
<a href="{{ route('recurring.show',rt.id) }}">{{ rt.title }}</a>
{% if rt.description|length > 0 %}
<small><br>{{ rt.description }}</small>
{% endif %}
</td>
<td data-value="0">
<ol>
{% for rtt in rt.transactions %}
<li>
{# normal amount + comma#}
{{ formatAmountBySymbol(rtt['amount'],rtt['currency_symbol'],rtt['currency_dp']) }}{% if rtt['foreign_amount'] == null %},{% endif %}
{# foreign amount + comma #}
{% if null != rtt['foreign_amount'] %}
({{ formatAmountBySymbol(rtt['foreign_amount'],rtt['foreign_currency_symbol'],rtt['foreign_currency_dp']) }}),
{% endif %}
<a href="{{ route('accounts.show', rtt['source_account_id']) }}">{{ rtt['source_account_name'] }}</a>
&rarr;
<a href="{{ route('accounts.show', rtt['destination_account_id']) }}">{{ rtt['destination_account_name'] }}</a>
</li>
{% endfor %}
</ol>
</td>
<td>
<ul>
{% for rep in rt.repetitions %}
<li>{{ rep.description }}</li>
{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div style="padding-left:8px;">
{{ recurring.render|raw }}
</div>
</div>
<div class="box-footer">
<a href="{{ route('recurring.create') }}" class="btn btn-success"><i class="fa fa-plus fa-fw"></i> {{ ('make_new_recurring')|_ }}</a>
</div>
</div>
</div>
</div>
{% endif %}
{% if recurring|length == 0 and page == 1 %}
{% include 'partials.empty' with {what: 'default', type: 'recurring',route: route('recurring.create')} %}
{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="css/bootstrap-sortable.css?v={{ FF_VERSION }}" type="text/css" media="all"/>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>
{% endblock %}

View File

@@ -0,0 +1,190 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, recurrence) }}
{% endblock %}
{% block content %}
<div class="row">
<!-- basic info -->
<div class="col-lg-8 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ array.title }}
</h3>
</div>
<div class="box-body">
<p><em>{{ array.description }}</em></p>
<ul>
{% for rep in array.repetitions %}
<li>{{ rep.description }}</li>
{% endfor %}
</ul>
</div>
<div class="box-footer">
<div class="btn-group">
<a href="{{ route('recurring.edit', [array.id]) }}" class="btn btn-sm btn-default"><i class="fa fa-pencil"></i> {{ 'edit'|_ }}</a>
<a href="{{ route('recurring.delete', [array.id]) }}" class="btn btn-sm btn-danger">{{ 'delete'|_ }} <i class="fa fa-trash"></i></a>
</div>
</div>
</div>
</div>
<!-- next and previous repetitions -->
<div class="col-lg-4 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ 'expected_transactions'|_ }}
</h3>
</div>
<div class="box-body">
<ul>
{% for rep in array.repetitions %}
<li>{{ rep.description }}
<ul>
{% for occ in rep.occurrences %}
<li>{{ occ.formatLocalized(trans('config.month_and_date_day')) }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
<div class="box-footer">
<small>
<em>{{ 'warning_duplicates_repetitions'|_ }}</em>
</small>
</div>
</div>
</div>
</div>
<div class="row">
<!-- transactions -->
<div class="col-lg-8 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ 'transaction_data'|_ }}
</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover sortable">
<thead>
<th data-defaultsign="az">{{ trans('list.source') }}</th>
<th data-defaultsign="az">{{ trans('list.destination') }}</th>
<th data-defaultsign="_19">{{ trans('list.amount') }}</th>
<th data-defaultsign="az">{{ trans('list.category') }}</th>
<th data-defaultsign="az">{{ trans('list.budget') }}</th>
</thead>
<tbody>
{% for transaction in array.transactions %}
<tr>
<td data-value="{{ transaction.source_account_name }}">
<a href="{{ route('accounts.show', [transaction.source_account_id]) }}">{{ transaction.source_account_name }}</a>
</td>
<td data-value="{{ transaction.destination_account_name }}">
<a href="{{ route('accounts.show', [transaction.destination_account_id]) }}">{{ transaction.destination_account_name }}</a>
</td>
<td>
{{ formatAmountBySymbol(transaction.amount,transaction.currency_symbol,transaction.currency_dp) }}
{% if null != transaction.foreign_amount %}
({{ formatAmountBySymbol(transaction.foreign_amount,transaction.foreign_currency_symbol,transaction.foreign_currency_dp) }})
{% endif %}
</td>
<td data-value="{% for meta in transaction.meta %}{% if meta.name == 'category_name' %}{{ meta.category_id }}{% endif %}{% endfor %}">
{% for meta in transaction.meta %}
{% if meta.name == 'category_name' %}
<a href="{{ route('categories.show', [meta.category_id]) }}">
{{ meta.category_name }}
</a>
{% endif %}
{% endfor %}
</td>
<td data-value="{% for meta in transaction.meta %}{% if meta.name == 'budget_id' %}{{ meta.budget_id }}{% endif %}{% endfor %}">
{% for meta in transaction.meta %}
{% if meta.name == 'budget_id' %}
<a href="{{ route('budgets.show', [meta.budget_id]) }}">
{{ meta.budget_name }}
</a>
{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- meta data -->
{% if array.meta|length > 0 %}
<div class="col-lg-4 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ 'meta_data'|_ }}
</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover sortable">
<thead>
<th style="width:30%;" data-defaultsign="az">{{ trans('list.field') }}</th>
<th data-defaultsign="az">{{ trans('list.value') }}</th>
</thead>
<tbody>
{% for meta in array.meta %}
<tr>
<td>{{ trans('firefly.recurring_meta_field_'~meta.name) }}</td>
<td>
{% if meta.name == 'tags' %}
{% for tag in meta.tags %}
<span class="label label-info">{{ tag }}</span>
{% endfor %}
{% endif %}
{% if meta.name == 'notes' %}
{{ meta.value|markdown }}
{% endif %}
{% if meta.name == 'bill_id' %}
<a href="{{ route('bills.show', [meta.bill_id]) }}">{{ meta.bill_name }}</a>
{% endif %}
{% if meta.name == 'piggy_bank_id' %}
<a href="{{ route('piggy-banks.show', [meta.piggy_bank_id]) }}">{{ meta.piggy_bank_name }}</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>
<div class="row">
<!-- meta data -->
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ 'transactions'|_ }}
</h3>
</div>
<div class="box-body">
Bla bla
</div>
</div>
</div>
</div>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="css/bootstrap-sortable.css?v={{ FF_VERSION }}" type="text/css" media="all"/>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>
{% endblock %}