Skip to content

Firefly III: a personal finances manager

Fix #2567

James Cole3c8935c0a8f2
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index ff6a517440..6ed962b87d 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -264,6 +264,9 @@ class BillController extends Controller
return redirect(route('bills.show', [$bill->id]));
}
+ // unlink all journals:
+ $this->billRepository->unlinkAll($bill);
+
foreach ($set as $rule) {
// simply fire off all rules?
/** @var TransactionMatcher $matcher */
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 137c219d57..848b6b41f0 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -686,4 +686,12 @@ class BillRepository implements BillRepositoryInterface
return $service->update($bill, $data);
}
+
+ /**
+ * @param Bill $bill
+ */
+ public function unlinkAll(Bill $bill): void
+ {
+ $this->user->transactionJournals()->where('bill_id', $bill->id)->update(['bill_id' => null]);
+ }
}
diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.php
index 310c4addf5..7537fe05cd 100644
--- a/app/Repositories/Bill/BillRepositoryInterface.php
+++ b/app/Repositories/Bill/BillRepositoryInterface.php
@@ -33,6 +33,12 @@ use Illuminate\Support\Collection;
*/
interface BillRepositoryInterface
{
+
+ /**
+ * @param Bill $bill
+ */
+ public function unlinkAll(Bill $bill): void;
+
/**
* @param Bill $bill
*
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 2c5605e20b..b65549a92f 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -723,6 +723,7 @@ return [
// bills:
'match_between_amounts' => 'Bill matches transactions between :low and :high.',
+ 'running_again_loss' => 'Previously linked transactions to this bill may lose their connection, if they (no longer) match the rule(s).',
'bill_related_rules' => 'Rules related to this bill',
'repeats' => 'Repeats',
'connected_journals' => 'Connected transactions',
diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig
index 8b23eecbc7..a78f45ec38 100644
--- a/resources/views/v1/bills/show.twig
+++ b/resources/views/v1/bills/show.twig
@@ -88,7 +88,12 @@
{% endif %}
</div>
<div class="box-footer">
- <a id="billButtons" href="{{ route('bills.rescan',object.data.id) }}" class="btn btn-default">{{ 'rescan_old'|_ }}</a>
+ <p><a id="billButtons" href="{{ route('bills.rescan',object.data.id) }}" class="btn btn-default">{{ 'rescan_old'|_ }}</a></p>
+ <p><small class="text-muted">
+ {{ 'running_again_loss'|_ }}
+ </small>
+
+ </p>
</div>
</div>
{% if object.data.notes %}