mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 01:37:30 -04:00 
			
		
		
		
	Merge pull request #8430 from turbo124/v5-develop
Fixes for linking expenses
This commit is contained in:
		
						commit
						bde1f8865e
					
				| @ -39,7 +39,7 @@ class MatchBankTransactionRequest extends Request | ||||
|         $rules['transactions.*.vendor_id'] = 'bail|nullable|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; | ||||
|         $rules['transactions.*.id'] = 'bail|required|exists:bank_transactions,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; | ||||
|         $rules['transactions.*.payment_id'] = 'bail|sometimes|nullable|exists:payments,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; | ||||
|         $rules['transactions.*.expense_id'] = 'bail|sometimes|nullable|exists:expenses,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; | ||||
|         // $rules['transactions.*.expense_id'] = 'bail|sometimes|nullable|exists:expenses,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
 | ||||
| 
 | ||||
|         return $rules; | ||||
|     } | ||||
| @ -72,14 +72,14 @@ class MatchBankTransactionRequest extends Request | ||||
|             } | ||||
| 
 | ||||
|             if (array_key_exists('expense_id', $inputs['transactions'][$key]) && strlen($inputs['transactions'][$key]['expense_id']) >= 1) { | ||||
|                 $inputs['transactions'][$key]['expense_id'] = $this->decodePrimaryKey($inputs['transactions'][$key]['expense_id']); | ||||
|                 // $inputs['transactions'][$key]['expense_id'] = $this->decodePrimaryKey($inputs['transactions'][$key]['expense_id']);
 | ||||
| 
 | ||||
|                 $e = Expense::withTrashed()->where('company_id', auth()->user()->company()->id)->where('id', $inputs['transactions'][$key]['expense_id'])->first(); | ||||
|                 // $e = Expense::withTrashed()->where('company_id', auth()->user()->company()->id)->where('id', $inputs['transactions'][$key]['expense_id'])->first();
 | ||||
| 
 | ||||
|                 /*Ensure we don't relink an existing expense*/ | ||||
|                 if (!$e || is_numeric($e->transaction_id)) { | ||||
|                     unset($inputs['transactions'][$key]['expense_id']); | ||||
|                 } | ||||
|                 // if (!$e || is_numeric($e->transaction_id)) {
 | ||||
|                 //     unset($inputs['transactions'][$key]['expense_id']);
 | ||||
|                 // }
 | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -156,19 +156,27 @@ class MatchBankTransactions implements ShouldQueue | ||||
|             return $this; | ||||
|         } | ||||
| 
 | ||||
|         $expense = Expense::withTrashed()->find($input['expense_id']); | ||||
|         $_expenses = explode(",", $input['expense_id']); | ||||
| 
 | ||||
|         if ($expense && !$expense->transaction_id) { | ||||
|             $expense->transaction_id = $this->bt->id; | ||||
|             $expense->save(); | ||||
|         foreach($_expenses as $_expense) { | ||||
|                      | ||||
|             $this->bt->expense_id = $this->coalesceExpenses($expense->hashed_id); | ||||
|             $this->bt->status_id = BankTransaction::STATUS_CONVERTED; | ||||
|             $this->bt->vendor_id = $expense->vendor_id; | ||||
|             $this->bt->ninja_category_id = $expense->category_id; | ||||
|             $this->bt->save(); | ||||
|             $expense = Expense::withTrashed() | ||||
|                              ->where('id',  $this->decodePrimaryKey($_expense)) | ||||
|                              ->where('company_id', $this->bt->company_id) | ||||
|                              ->first(); | ||||
| 
 | ||||
|             $this->bts->push($this->bt->id); | ||||
|             if ($expense && !$expense->transaction_id) { | ||||
|                 $expense->transaction_id = $this->bt->id; | ||||
|                 $expense->save(); | ||||
| 
 | ||||
|                 $this->bt->expense_id = $this->coalesceExpenses($expense->hashed_id); | ||||
|                 $this->bt->status_id = BankTransaction::STATUS_CONVERTED; | ||||
|                 $this->bt->vendor_id = $expense->vendor_id; | ||||
|                 $this->bt->ninja_category_id = $expense->category_id; | ||||
|                 $this->bt->save(); | ||||
| 
 | ||||
|                 $this->bts->push($this->bt->id); | ||||
|             } | ||||
|         } | ||||
|      | ||||
|         return $this; | ||||
|  | ||||
| @ -97,7 +97,7 @@ class SumTaxTest extends TestCase | ||||
|         $tax_data->seller_region = 'US'; | ||||
|         $tax_data->seller_subregion = 'CA'; | ||||
|         $tax_data->regions->US->has_sales_above_threshold = true; | ||||
|         $tax_data->regions->US->tax_all = true; | ||||
|         $tax_data->regions->US->tax_all_subregions = true; | ||||
| 
 | ||||
|         $this->company->calculate_taxes = false; | ||||
|         $this->company->tax_data = $tax_data; | ||||
| @ -148,7 +148,7 @@ class SumTaxTest extends TestCase | ||||
|         $tax_data->seller_region = 'US'; | ||||
|         $tax_data->seller_subregion = 'CA'; | ||||
|         $tax_data->regions->US->has_sales_above_threshold = true; | ||||
|         $tax_data->regions->US->tax_all = true; | ||||
|         $tax_data->regions->US->tax_all_subregions = true; | ||||
| 
 | ||||
|         $this->company->calculate_taxes = true; | ||||
|         $this->company->tax_data = $tax_data; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user