mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Expense categories
This commit is contained in:
parent
e0a770c663
commit
d93efb434d
@ -138,7 +138,7 @@ class IncomeTransformer implements BankRevenueInterface
|
|||||||
'amount' => $transaction->amount->amount,
|
'amount' => $transaction->amount->amount,
|
||||||
'currency_code' => $transaction->amount->currency,
|
'currency_code' => $transaction->amount->currency,
|
||||||
'account_type' => $transaction->CONTAINER,
|
'account_type' => $transaction->CONTAINER,
|
||||||
'category_id' => $transaction->categoryId,
|
'category_id' => $transaction->highLevelCategoryId,
|
||||||
'category_type' => $transaction->categoryType,
|
'category_type' => $transaction->categoryType,
|
||||||
'date' => $transaction->date,
|
'date' => $transaction->date,
|
||||||
'bank_account_id' => $transaction->accountId,
|
'bank_account_id' => $transaction->accountId,
|
||||||
|
@ -49,6 +49,7 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
|
|
||||||
private BankTransaction $bt;
|
private BankTransaction $bt;
|
||||||
|
|
||||||
|
private $categories;
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
@ -74,6 +75,10 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
|
|
||||||
$this->company = Company::find($this->company_id);
|
$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)
|
foreach($this->input as $match)
|
||||||
{
|
{
|
||||||
if(array_key_exists('invoice_id', $match) && strlen($match['invoice_id']) > 1)
|
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
|
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
|
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->transaction_reference = $this->bt->transaction_id;
|
||||||
$payment->currency_id = $this->harvestCurrencyId();
|
$payment->currency_id = $this->harvestCurrencyId();
|
||||||
$payment->is_manual = false;
|
$payment->is_manual = false;
|
||||||
|
$payment->date = $this->bt->date ? Carbon::parse($this->bt->date) : now();
|
||||||
|
|
||||||
if ($this->invoice->company->timezone()) {
|
|
||||||
$payment->date = now()->addSeconds($this->invoice->company->timezone()->utc_offset)->format('Y-m-d');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$payment->date = now();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bank Transfer! */
|
/* Bank Transfer! */
|
||||||
$payment_type_id = 1;
|
$payment_type_id = 1;
|
||||||
@ -173,7 +173,6 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($this->payable_balance * -1);
|
->updatePaymentBalance($this->payable_balance * -1);
|
||||||
|
|
||||||
//06-09-2022
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->client
|
->client
|
||||||
->service()
|
->service()
|
||||||
|
@ -79,6 +79,10 @@ return new class extends Migration
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('expense_categories', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('bank_category_id')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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()
|
public function testFunctionalMatching()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -342,12 +360,11 @@ class YodleeApiTest extends TestCase
|
|||||||
|
|
||||||
$transactions = $yodlee->getTransactionCategories();
|
$transactions = $yodlee->getTransactionCategories();
|
||||||
|
|
||||||
// nlog($transactions);
|
|
||||||
|
|
||||||
$this->assertIsArray($transactions->transactionCategory);
|
$this->assertIsArray($transactions->transactionCategory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
[2022-08-05 01:29:45] local.INFO: stdClass Object
|
[2022-08-05 01:29:45] local.INFO: stdClass Object
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user