Prevent deleted/archived/completed transactions from being re-converted
This commit is contained in:
parent
2b5285a58a
commit
f3fdd1f7fd
2 changed files with 8 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue