Skip to content

Firefly III: a personal finances manager

Added invoice date

James Cole629baf9de52b
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index 21f059fd20..cdbbde9253 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -175,6 +175,7 @@ class PreferencesController extends Controller
'process_date' => isset($setOptions['process_date']),
'due_date' => isset($setOptions['due_date']),
'payment_date' => isset($setOptions['payment_date']),
+ 'invoice_date' => isset($setOptions['invoice_date']),
'internal_reference' => isset($setOptions['internal_reference']),
'notes' => isset($setOptions['notes']),
'attachments' => isset($setOptions['attachments']),
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index d4661a42e4..376079afbc 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -177,6 +177,7 @@ class TransactionController extends Controller
// new custom fields:
'due_date' => TransactionJournal::dateAsString($journal, 'due_date'),
'payment_date' => TransactionJournal::dateAsString($journal, 'payment_date'),
+ 'invoice_date' => TransactionJournal::dateAsString($journal, 'invoice_date'),
'interal_reference' => $journal->getMeta('internal_reference'),
'notes' => $journal->getMeta('notes'),
];
diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php
index 88e0895673..6c0e44da66 100644
--- a/app/Http/Requests/JournalFormRequest.php
+++ b/app/Http/Requests/JournalFormRequest.php
@@ -64,6 +64,7 @@ class JournalFormRequest extends Request
// new custom fields here:
'due_date' => $this->get('due_date') ? new Carbon($this->get('due_date')) : null,
'payment_date' => $this->get('payment_date') ? new Carbon($this->get('payment_date')) : null,
+ 'invoice_date' => $this->get('invoice_date') ? new Carbon($this->get('invoice_date')) : null,
'internal_reference' => $this->get('internal_reference'),
'notes' => $this->get('notes'),
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 912e3c0482..b81c09e039 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -237,6 +237,16 @@ class TransactionJournal extends TransactionJournalSupport
return $value;
}
+ /**
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function hasMeta(string $name): bool
+ {
+ return !is_null($this->getMeta($name));
+ }
+
/**
* @return bool
*/
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 189a34e01b..778c91e608 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -42,7 +42,7 @@ class JournalRepository implements JournalRepositoryInterface
private $user;
/** @var array */
- private $validMetaFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'internal_reference', 'notes'];
+ private $validMetaFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date', 'internal_reference', 'notes'];
/**
* JournalRepository constructor.
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 8a9b5f0896..56d965ede9 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -285,6 +285,7 @@ return [
'pref_optional_tj_process_date' => 'Processing date',
'pref_optional_tj_due_date' => 'Due date',
'pref_optional_tj_payment_date' => 'Payment date',
+ 'pref_optional_tj_invoice_date' => 'Invoice date',
'pref_optional_tj_internal_reference' => 'Internal reference',
'pref_optional_tj_notes' => 'Notes',
'pref_optional_tj_attachments' => 'Attachments',
diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php
index a94ffaa9e7..62c4971ac6 100644
--- a/resources/lang/en_US/form.php
+++ b/resources/lang/en_US/form.php
@@ -149,5 +149,6 @@ return [
'due_date' => 'Due date',
'payment_date' => 'Payment date',
+ 'invoice_date' => 'Invoice date',
'internal_reference' => 'Internal reference',
];
diff --git a/resources/lang/en_US/list.php b/resources/lang/en_US/list.php
index 4c4743126f..c150b284b2 100644
--- a/resources/lang/en_US/list.php
+++ b/resources/lang/en_US/list.php
@@ -41,6 +41,8 @@ return [
'process_date' => 'Processing date',
'due_date' => 'Due date',
'payment_date' => 'Payment date',
+ 'invoice_date' => 'Invoice date',
+ 'interal_reference' => 'Internal reference',
'notes' => 'Notes',
'from' => 'From',
'piggy_bank' => 'Piggy bank',
diff --git a/resources/views/preferences/index.twig b/resources/views/preferences/index.twig
index e42f578825..3b5ad89453 100644
--- a/resources/views/preferences/index.twig
+++ b/resources/views/preferences/index.twig
@@ -63,6 +63,7 @@
{{ ExpandedForm.checkbox('tj[process_date]','1', tjOptionalFields.process_date,{ 'label' : 'pref_optional_tj_process_date'|_ }) }}
{{ ExpandedForm.checkbox('tj[due_date]','1', tjOptionalFields.due_date,{ 'label' : 'pref_optional_tj_due_date'|_ }) }}
{{ ExpandedForm.checkbox('tj[payment_date]','1', tjOptionalFields.payment_date,{ 'label' : 'pref_optional_tj_payment_date'|_ }) }}
+ {{ ExpandedForm.checkbox('tj[invoice_date]','1', tjOptionalFields.invoice_date,{ 'label' : 'pref_optional_tj_invoice_date'|_ }) }}
<h4>{{ 'optional_tj_business_fields'|_ }}</h4>
{{ ExpandedForm.checkbox('tj[internal_reference]','1', tjOptionalFields.internal_reference,{ 'label' : 'pref_optional_tj_internal_reference'|_ }) }}
diff --git a/resources/views/transactions/create.twig b/resources/views/transactions/create.twig
index 4c0b8d1321..63cf400f2c 100644
--- a/resources/views/transactions/create.twig
+++ b/resources/views/transactions/create.twig
@@ -90,6 +90,7 @@
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
@@ -97,7 +98,11 @@
<p class="text-center text-success"><i class="fa fa-info-circle" aria-hidden="true"></i> <em>{{ trans('firefly.hidden_fields_preferences', {link: route('preferences')})|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 %}
+ {% 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>
@@ -129,6 +134,11 @@
{{ ExpandedForm.date('payment_date') }}
{% endif %}
+ {% if optionalFields.invoice_date %}
+ <!-- INVOICE DATE -->
+ {{ ExpandedForm.date('invoice_date') }}
+ {% endif %}
+
</div>
</div>
{% endif %}
diff --git a/resources/views/transactions/edit.twig b/resources/views/transactions/edit.twig
index e6a988044f..032bb68e75 100644
--- a/resources/views/transactions/edit.twig
+++ b/resources/views/transactions/edit.twig
@@ -103,6 +103,7 @@
not optionalFields.due_date or
not optionalFields.payment_date or
not optionalFields.internal_reference or
+ not optionalFields.invoice_date or
not optionalFields.notes or
not optionalFields.attachments %}
<p class="text-center text-success"><i class="fa fa-info-circle" aria-hidden="true"></i>
@@ -117,6 +118,7 @@
optionalFields.process_date or
optionalFields.due_date or
optionalFields.payment_date or
+ optionalFields.invoice_date or
data.interest_date or
data.book_date or
data.process_date or
@@ -154,6 +156,11 @@
{{ ExpandedForm.date('payment_date',data['payment_date']) }}
{% endif %}
+ {% if optionalFields.invoice_date or data['invoice_date'] %}
+ <!-- INVOICE DATE -->
+ {{ ExpandedForm.date('invoice_date',data['invoice_date']) }}
+ {% endif %}
+
</div>
</div>
{% endif %}
diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig
index 57d9d785bb..bd78503b9b 100644
--- a/resources/views/transactions/show.twig
+++ b/resources/views/transactions/show.twig
@@ -56,6 +56,13 @@
</tr>
{% endif %}
+ {% if journal.getMeta('invoice_date') %}
+ <tr>
+ <td>{{ trans('list.invoice_date') }}</td>
+ <td>{{ journal.getMeta('invoice_date').formatLocalized(monthAndDayFormat) }}</td>
+ </tr>
+ {% endif %}
+
<tr>
<td>{{ trans('list.type') }}</td>
<td>{{ journal.transactiontype.type|_ }}</td>