mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Put meta data in correct array, make sure edit screen works. #2483
This commit is contained in:
@@ -206,15 +206,45 @@ class RecurrenceTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RecurrenceTransaction $transaction
|
* @param RecurrenceTransaction $transaction
|
||||||
* @param array $array
|
* @param array $array
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
private function getTransactionMeta(RecurrenceTransaction $transaction, array $array): array
|
private function getTransactionMeta(RecurrenceTransaction $transaction, array $array): array
|
||||||
{
|
{
|
||||||
|
$array['tags'] = [];
|
||||||
|
$array['bill_id'] = null;
|
||||||
|
$array['bill_name'] = null;
|
||||||
|
$array['category_id'] = null;
|
||||||
|
$array['category_name'] = null;
|
||||||
|
$array['budget_id'] = null;
|
||||||
|
$array['budget_name'] = null;
|
||||||
|
$array['piggy_bank_id'] = null;
|
||||||
|
$array['piggy_bank_name'] = null;
|
||||||
|
|
||||||
/** @var RecurrenceTransactionMeta $transactionMeta */
|
/** @var RecurrenceTransactionMeta $transactionMeta */
|
||||||
foreach ($transaction->recurrenceTransactionMeta as $transactionMeta) {
|
foreach ($transaction->recurrenceTransactionMeta as $transactionMeta) {
|
||||||
switch ($transactionMeta->name) {
|
switch ($transactionMeta->name) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException(sprintf('Recurrence transformer cant handle field "%s"', $transactionMeta->name));
|
||||||
|
case 'tags':
|
||||||
|
$array['tags'] = explode(',', $transactionMeta->value);
|
||||||
|
break;
|
||||||
|
case 'bill_id':
|
||||||
|
$bill = $this->billRepos->find((int)$transactionMeta->value);
|
||||||
|
if (null !== $bill) {
|
||||||
|
$array['bill_id'] = $bill->id;
|
||||||
|
$array['bill_name'] = $bill->name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'piggy_bank_id':
|
||||||
|
$piggy = $this->piggyRepos->findNull((int)$transactionMeta->value);
|
||||||
|
if (null !== $piggy) {
|
||||||
|
$array['piggy_bank_id'] = $piggy->id;
|
||||||
|
$array['piggy_bank_name'] = $piggy->name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'category_name':
|
case 'category_name':
|
||||||
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
|
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
|
||||||
if (null !== $category) {
|
if (null !== $category) {
|
||||||
|
@@ -20,11 +20,11 @@
|
|||||||
{{ ExpandedForm.text('title') }}
|
{{ ExpandedForm.text('title') }}
|
||||||
{{ ExpandedForm.date('first_date',array.first_date, {helpText: trans('firefly.help_first_date_no_past')}) }}
|
{{ ExpandedForm.date('first_date',array.first_date, {helpText: trans('firefly.help_first_date_no_past')}) }}
|
||||||
{{ ExpandedForm.select('repetition_type', [], null, {helpText: trans('firefly.change_date_other_options')}) }}
|
{{ ExpandedForm.select('repetition_type', [], null, {helpText: trans('firefly.change_date_other_options')}) }}
|
||||||
{{ ExpandedForm.number('skip', array.recurrence_repetitions[0].skip) }}
|
{{ ExpandedForm.number('skip', array.repetitions[0].skip) }}
|
||||||
{{ ExpandedForm.select('weekend', weekendResponses, array.recurrence_repetitions[0].weekend, {helpText: trans('firefly.help_weekend')}) }}
|
{{ ExpandedForm.select('weekend', weekendResponses, array.repetitions[0].weekend, {helpText: trans('firefly.help_weekend')}) }}
|
||||||
{{ ExpandedForm.select('repetition_end', repetitionEnds, repetitionEnd) }}
|
{{ ExpandedForm.select('repetition_end', repetitionEnds, repetitionEnd) }}
|
||||||
{{ ExpandedForm.date('repeat_until',array.repeat_until) }}
|
{{ ExpandedForm.date('repeat_until',array.repeat_until) }}
|
||||||
{{ ExpandedForm.number('repetitions', array.repetitions) }}
|
{{ ExpandedForm.number('repetitions', array.nr_of_repetitions) }}
|
||||||
|
|
||||||
{# calendar in popup #}
|
{# calendar in popup #}
|
||||||
<div class="form-group" id="calendar_holder">
|
<div class="form-group" id="calendar_holder">
|
||||||
@@ -90,18 +90,12 @@
|
|||||||
{# source account if withdrawal, or if transfer: #}
|
{# source account if withdrawal, or if transfer: #}
|
||||||
{{ AccountForm.longAccountList('source_id', array.transactions[0].source_id, {label: trans('form.asset_source_account')}) }}
|
{{ AccountForm.longAccountList('source_id', array.transactions[0].source_id, {label: trans('form.asset_source_account')}) }}
|
||||||
|
|
||||||
{# source account name for deposits: #}
|
|
||||||
{#{{ ExpandedForm.text('source_name', array.transactions[0].source_name, {label: trans('form.revenue_account')}) }}#}
|
|
||||||
|
|
||||||
{# NEW for deposits, a drop down with revenue accounts, loan debt cash and mortgage #}
|
{# NEW for deposits, a drop down with revenue accounts, loan debt cash and mortgage #}
|
||||||
{{ AccountForm.activeDepositDestinations('deposit_source_id', preFilled.deposit_source_id, {label: trans('form.deposit_source_id')}) }}
|
{{ AccountForm.activeDepositDestinations('deposit_source_id', preFilled.deposit_source_id, {label: trans('form.deposit_source_id')}) }}
|
||||||
|
|
||||||
{# destination if deposit or transfer: #}
|
{# destination if deposit or transfer: #}
|
||||||
{{ AccountForm.longAccountList('destination_id', array.transactions[0].destination_id, {label: trans('form.asset_destination_account')} ) }}
|
{{ AccountForm.longAccountList('destination_id', array.transactions[0].destination_id, {label: trans('form.asset_destination_account')} ) }}
|
||||||
|
|
||||||
{# destination account name for withdrawals #}
|
|
||||||
{# {{ ExpandedForm.text('destination_name', array.transactions[0].destination_name, {label: trans('form.expense_account')}) }}#}
|
|
||||||
|
|
||||||
{# NEW for withdrawals, also a drop down with expense accounts, loans, debts, mortgages or (cash). #}
|
{# NEW for withdrawals, also a drop down with expense accounts, loans, debts, mortgages or (cash). #}
|
||||||
{{ AccountForm.activeWithdrawalDestinations('withdrawal_destination_id', preFilled.withdrawal_destination_id, {label: trans('form.withdrawal_destination_id')}) }}
|
{{ AccountForm.activeWithdrawalDestinations('withdrawal_destination_id', preFilled.withdrawal_destination_id, {label: trans('form.withdrawal_destination_id')}) }}
|
||||||
</div>
|
</div>
|
||||||
@@ -120,26 +114,15 @@
|
|||||||
{{ ExpandedForm.amountNoCurrency('foreign_amount', array.transactions[0].foreign_amount) }}
|
{{ ExpandedForm.amountNoCurrency('foreign_amount', array.transactions[0].foreign_amount) }}
|
||||||
|
|
||||||
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
|
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
|
||||||
{% set budgetId = 0 %}
|
|
||||||
{% set categoryName = '' %}
|
|
||||||
{% for metaValue in array.transactions[0].meta %}
|
|
||||||
{% if metaValue.name == 'budget_id' %}
|
|
||||||
{% set budgetId = metaValue.value %}
|
|
||||||
{% endif %}
|
|
||||||
{% if metaValue.name == 'category_name' %}
|
|
||||||
{% set categoryName = metaValue.value %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if budgets|length > 1 %}
|
{% if budgets|length > 1 %}
|
||||||
{{ ExpandedForm.select('budget_id', budgets, budgetId) }} {##}
|
{{ ExpandedForm.select('budget_id', budgets, array.transactions[0].budget_id) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ ExpandedForm.select('budget_id', budgets, budgetId, {helpText: trans('firefly.no_budget_pointer', {link: route('budgets.index')})}) }}
|
{{ ExpandedForm.select('budget_id', budgets, array.transactions[0].budget_id, {helpText: trans('firefly.no_budget_pointer', {link: route('budgets.index')})}) }}
|
||||||
{#budgets#}
|
{#budgets#}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# CATEGORY ALWAYS #}
|
{# CATEGORY ALWAYS #}
|
||||||
{{ ExpandedForm.text('category',categoryName) }}
|
{{ ExpandedForm.text('category',array.transactions[0].category_name) }}
|
||||||
|
|
||||||
{# TAGS #}
|
{# TAGS #}
|
||||||
{% set tags = '' %}
|
{% set tags = '' %}
|
||||||
|
Reference in New Issue
Block a user