mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
localized date within transaction-transformer
This commit is contained in:
parent
aa41b4126b
commit
b9095b96ab
@ -19,6 +19,7 @@
|
||||
|
||||
namespace App\Helpers\Bank\Nordigen;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Services\Email\Email;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Services\Email\EmailObject;
|
||||
@ -138,11 +139,11 @@ class Nordigen
|
||||
* @param string $dateFrom
|
||||
* @return array
|
||||
*/
|
||||
public function getTransactions(string $accountId, string $dateFrom = null): array
|
||||
public function getTransactions(Company $company, string $accountId, string $dateFrom = null): array
|
||||
{
|
||||
$transactionResponse = $this->client->account($accountId)->getAccountTransactions($dateFrom);
|
||||
|
||||
$it = new TransactionTransformer();
|
||||
$it = new TransactionTransformer($company);
|
||||
return $it->transform($transactionResponse);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,10 @@
|
||||
namespace App\Helpers\Bank\Nordigen\Transformer;
|
||||
|
||||
use App\Helpers\Bank\BankRevenueInterface;
|
||||
use App\Models\Company;
|
||||
use App\Models\DateFormat;
|
||||
use App\Models\Timezone;
|
||||
use Carbon\Carbon;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Log;
|
||||
@ -65,6 +69,13 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
{
|
||||
use AppSetup;
|
||||
|
||||
private Company $company;
|
||||
|
||||
function __construct(Company $company)
|
||||
{
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
public function transform($transactionResponse)
|
||||
{
|
||||
$data = [];
|
||||
@ -163,4 +174,24 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
|
||||
}
|
||||
|
||||
private function formatDate(string $input)
|
||||
{
|
||||
$timezone = Timezone::find($this->company->settings->timezone_id);
|
||||
$timezone_name = 'US/Eastern';
|
||||
|
||||
if ($timezone) {
|
||||
$timezone_name = $timezone->name;
|
||||
}
|
||||
|
||||
$date_format_default = 'Y-m-d';
|
||||
|
||||
$date_format = DateFormat::find($this->company->settings->date_format_id);
|
||||
|
||||
if ($date_format) {
|
||||
$date_format_default = $date_format->format;
|
||||
}
|
||||
|
||||
return Carbon::createFromTimeStamp($input)->setTimezone($timezone_name)->format($date_format_default);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
|
||||
private function processTransactions()
|
||||
{
|
||||
//Get transaction count object
|
||||
$transactions = $this->nordigen->getTransactions($this->bank_integration->nordigen_account_id, $this->from_date);
|
||||
$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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user