1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Resolve categories

This commit is contained in:
David Bomba 2022-09-15 16:28:18 +10:00
parent 84b37d7e94
commit a4d7d4af54

View File

@ -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();