mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2026-03-03 02:47:02 +00:00
Adjustments for Nordigen, requisition email notifications changed to once per account, not company
This commit is contained in:
@@ -297,10 +297,10 @@ class Nordigen
|
||||
* getTransactions
|
||||
*
|
||||
* @param string $accountId
|
||||
* @param string $dateFrom
|
||||
* @param ?string $dateFrom
|
||||
* @return array
|
||||
*/
|
||||
public function getTransactions(Company $company, string $accountId, string $dateFrom = null): array
|
||||
public function getTransactions(Company $company, string $accountId, ?string $dateFrom = null): array
|
||||
{
|
||||
$transactionResponse = $this->client->account($accountId)->getAccountTransactions($dateFrom);
|
||||
|
||||
@@ -310,7 +310,7 @@ class Nordigen
|
||||
|
||||
public function disabledAccountEmail(BankIntegration $bank_integration): void
|
||||
{
|
||||
$cache_key = "email_quota:{$bank_integration->company->company_key}:{$bank_integration->id}";
|
||||
$cache_key = "email_quota:{$bank_integration->account->key}:bank_integration_notified";
|
||||
|
||||
if (Cache::has($cache_key)) {
|
||||
return;
|
||||
|
||||
@@ -286,7 +286,7 @@ class BankIntegrationController extends BaseController
|
||||
$bank_integration->bank_account_status = "429 Rate limit reached, check back later....";
|
||||
$bank_integration->save();
|
||||
return;
|
||||
} elseif (is_array($account) && isset($account['account_status']) && !in_array($account['account_status'], ['READY', 'PROCESSING','DISCOVERED'])) {
|
||||
} elseif (is_array($account) && isset($account['account_status']) && !in_array($account['account_status'], ['READY', 'PROCESSING', 'DISCOVERED'])) {
|
||||
$bank_integration->disabled_upstream = true;
|
||||
$bank_integration->save();
|
||||
|
||||
|
||||
@@ -98,6 +98,10 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
// UPDATE TRANSACTIONS
|
||||
try {
|
||||
$this->processTransactions();
|
||||
|
||||
// Perform Matching
|
||||
BankMatchingService::dispatch($this->company->id, $this->company->db);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
nlog("Nordigen: {$this->bank_integration->nordigen_account_id} - exited abnormally => " . $e->getMessage());
|
||||
|
||||
@@ -109,11 +113,9 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
|
||||
$this->bank_integration->company->notification(new GenericNinjaAdminNotification($content))->ninja();
|
||||
|
||||
throw $e;
|
||||
// throw $e;
|
||||
}
|
||||
|
||||
// Perform Matching
|
||||
BankMatchingService::dispatch($this->company->id, $this->company->db);
|
||||
}
|
||||
|
||||
// const DISCOVERED = 'DISCOVERED'; // Account was discovered but not yet processed
|
||||
@@ -163,8 +165,10 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
private function processTransactions()
|
||||
{
|
||||
//Get transaction count object
|
||||
$transactions = [];
|
||||
|
||||
$transactions = $this->nordigen->getTransactions($this->company, $this->bank_integration->nordigen_account_id, $this->from_date);
|
||||
|
||||
|
||||
//if no transactions, update the from_date and move on
|
||||
if (count($transactions) == 0) {
|
||||
|
||||
@@ -189,7 +193,12 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
if (BankTransaction::where('nordigen_transaction_id', $transaction['nordigen_transaction_id'])->where('company_id', $this->company->id)->where('bank_integration_id', $this->bank_integration->id)->where('is_deleted', 0)->withTrashed()->exists()) {
|
||||
if (BankTransaction::where('nordigen_transaction_id', $transaction['nordigen_transaction_id'])
|
||||
->where('company_id', $this->company->id)
|
||||
->where('bank_integration_id', $this->bank_integration->id)
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user