diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index 0d7e068b89..d45a11366c 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -112,6 +112,10 @@ class ExpenseController extends BaseController } } + if ($expense->recurring_expense_id) { + $actions[] = ['url' => URL::to("recurring_expenses/{$expense->recurring_expense->public_id}/edit"), 'label' => trans('texts.view_recurring_expense')]; + } + $actions[] = \DropdownButton::DIVIDER; if (! $expense->trashed()) { $actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_expense')]; diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 4d460b7b12..a76b59cae0 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -142,6 +142,15 @@ class Expense extends EntityModel return $this->belongsTo('App\Models\PaymentType'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function recurring_expense() + { + return $this->belongsTo('App\Models\RecurringExpense'); + } + + /** * @return mixed */ diff --git a/app/Ninja/Repositories/RecurringExpenseRepository.php b/app/Ninja/Repositories/RecurringExpenseRepository.php index fc8e20af3e..9eb121ed2a 100644 --- a/app/Ninja/Repositories/RecurringExpenseRepository.php +++ b/app/Ninja/Repositories/RecurringExpenseRepository.php @@ -183,6 +183,7 @@ class RecurringExpenseRepository extends BaseRepository $expense->expense_date = $account->getDateTime()->format('Y-m-d'); $expense->exchange_rate = 1; $expense->invoice_currency_id = $recurringExpense->expense_currency_id; + $expense->recurring_expense_id = $recurringExpense->id; $expense->save(); $recurringExpense->last_sent_date = $account->getDateTime()->format('Y-m-d'); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index a3a68789d1..1deb2336f8 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2287,6 +2287,7 @@ $LANG = array( 'delete_recurring_expense' => 'Delete Recurring Expense', 'deleted_recurring_expense' => 'Successfully deleted project', 'deleted_recurring_expense' => 'Successfully deleted :count projects', + 'view_recurring_expense' => 'View Recurring Expense', );