From a4d7d4af5437da722945087ebb6d5971f8708653 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 15 Sep 2022 16:28:18 +1000 Subject: [PATCH] Resolve categories --- app/Jobs/Bank/MatchBankTransactions.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 822a68ad26bd..30e8aada2e26 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -59,6 +59,7 @@ class MatchBankTransactions implements ShouldQueue $this->company_id = $company_id; $this->db = $db; $this->input = $input; + $this->categories = collect(); } @@ -77,7 +78,10 @@ class MatchBankTransactions implements ShouldQueue $yodlee = new Yodlee($this->company->account->bank_integration_account_id); - $this->categories = collect($yodlee->getTransactionCategories()); + $_categories = collect($yodlee->getTransactionCategories()); + + if($_categories) + $this->categories = collect($_categories->transactionCategory); foreach($this->input as $match) { @@ -111,6 +115,9 @@ class MatchBankTransactions implements ShouldQueue private function matchExpense(array $match) :void { //if there is a category id, pull it from Yodlee and insert - or just reuse!! + $this->bt = BankTransaction::find($match['id']); + + $category_id = $this->resolveCategory(); } private function createPayment(int $invoice_id, float $amount) :void @@ -192,6 +199,11 @@ class MatchBankTransactions implements ShouldQueue $this->bt->save(); } + private function resolveCategory() :?int + { + $this->categories->firstWhere('highLevelCategoryId', $this->bt->category_id) + } + private function harvestCurrencyId() :int { $currency = Currency::where('code', $this->bt->currency_code)->first();