1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Prevent deleted/archived/completed transactions from being re-converted

This commit is contained in:
David Bomba 2022-11-17 08:43:17 +11:00
parent 2b5285a58a
commit f3fdd1f7fd
2 changed files with 8 additions and 0 deletions

View File

@ -37,6 +37,7 @@ class MatchBankTransactionRequest extends Request
$rules['transactions.*.ninja_category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
$rules['transactions.*.vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
$rules['transactions.*.id'] = 'bail|sometimes|exists:bank_transactions,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
return $rules;

View File

@ -160,6 +160,9 @@ class MatchBankTransactions implements ShouldQueue
{
$this->bt = BankTransaction::find($input['id']);
if(!$this->bt || $this->bt->status_id == BankTransaction::STATUS_CONVERTED)
return $this;
$_invoices = Invoice::withTrashed()->find($this->getInvoices($input['invoice_ids']));
$amount = $this->bt->amount;
@ -180,6 +183,10 @@ class MatchBankTransactions implements ShouldQueue
//if there is a category id, pull it from Yodlee and insert - or just reuse!!
$this->bt = BankTransaction::find($input['id']);
if(!$this->bt || $this->bt->status_id == BankTransaction::STATUS_CONVERTED)
return $this;
$expense = ExpenseFactory::create($this->bt->company_id, $this->bt->user_id);
$expense->category_id = $this->resolveCategory($input);
$expense->amount = $this->bt->amount;