Expense categories

This commit is contained in:
David Bomba 2022-09-15 16:15:57 +10:00
parent e0a770c663
commit d93efb434d
4 changed files with 32 additions and 12 deletions

View File

@ -138,7 +138,7 @@ class IncomeTransformer implements BankRevenueInterface
'amount' => $transaction->amount->amount,
'currency_code' => $transaction->amount->currency,
'account_type' => $transaction->CONTAINER,
'category_id' => $transaction->categoryId,
'category_id' => $transaction->highLevelCategoryId,
'category_type' => $transaction->categoryType,
'date' => $transaction->date,
'bank_account_id' => $transaction->accountId,

View File

@ -49,6 +49,7 @@ class MatchBankTransactions implements ShouldQueue
private BankTransaction $bt;
private $categories;
/**
* Create a new job instance.
*/
@ -74,6 +75,10 @@ class MatchBankTransactions implements ShouldQueue
$this->company = Company::find($this->company_id);
$yodlee = new Yodlee($this->company->account->bank_integration_account_id);
$this->categories = collect($yodlee->getTransactionCategories());
foreach($this->input as $match)
{
if(array_key_exists('invoice_id', $match) && strlen($match['invoice_id']) > 1)
@ -105,7 +110,7 @@ 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!!
}
private function createPayment(int $invoice_id, float $amount) :void
@ -135,13 +140,8 @@ class MatchBankTransactions implements ShouldQueue
$payment->transaction_reference = $this->bt->transaction_id;
$payment->currency_id = $this->harvestCurrencyId();
$payment->is_manual = false;
if ($this->invoice->company->timezone()) {
$payment->date = now()->addSeconds($this->invoice->company->timezone()->utc_offset)->format('Y-m-d');
}
else {
$payment->date = now();
}
$payment->date = $this->bt->date ? Carbon::parse($this->bt->date) : now();
/* Bank Transfer! */
$payment_type_id = 1;
@ -173,7 +173,6 @@ class MatchBankTransactions implements ShouldQueue
$payment->ledger()
->updatePaymentBalance($this->payable_balance * -1);
//06-09-2022
$this->invoice
->client
->service()

View File

@ -79,6 +79,10 @@ return new class extends Migration
});
Schema::table('expense_categories', function (Blueprint $table) {
$table->unsignedInteger('bank_category_id')->nullable();
});
}
/**

View File

@ -37,6 +37,24 @@ class YodleeApiTest extends TestCase
}
public function testCategoryPropertyExists()
{
$yodlee = new Yodlee('sbMem62e1e69547bfb2');
$transactions = $yodlee->getTransactionCategories();
$this->assertTrue(property_exists($transactions,'transactionCategory'));
$t = collect($transactions->transactionCategory);
$x = $t->firstWhere('highLevelCategoryId', 10000003);
var_dump($x);
$this->assertNotNull($x);
}
public function testFunctionalMatching()
{
@ -342,12 +360,11 @@ class YodleeApiTest extends TestCase
$transactions = $yodlee->getTransactionCategories();
// nlog($transactions);
$this->assertIsArray($transactions->transactionCategory);
}
/**
[2022-08-05 01:29:45] local.INFO: stdClass Object
(