mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for bank transaction imports
This commit is contained in:
parent
b3e02c8a70
commit
f40360e1fe
@ -46,11 +46,14 @@ use App\Repositories\PaymentRepository;
|
||||
use App\Repositories\ProductRepository;
|
||||
use App\Repositories\QuoteRepository;
|
||||
use App\Repositories\VendorRepository;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
class Csv extends BaseImport implements ImportInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public array $entity_count = [];
|
||||
|
||||
public function import(string $entity)
|
||||
@ -77,24 +80,20 @@ class Csv extends BaseImport implements ImportInterface
|
||||
|
||||
$data = $this->getCsvData($entity_type);
|
||||
|
||||
if (is_array($data)) {
|
||||
if (is_array($data))
|
||||
{
|
||||
|
||||
$data = $this->preTransformCsv($data, $entity_type);
|
||||
|
||||
|
||||
if(array_key_exists('bank_integration_id', $this->request)){
|
||||
|
||||
foreach($data as $key => $value)
|
||||
{
|
||||
$data['bank_integration_id'][$key] = $this->request['bank_integration_id'];
|
||||
}
|
||||
|
||||
foreach($data as $key => $value)
|
||||
{
|
||||
$data[$key]['bank.bank_integration_id'] = $this->decodePrimaryKey($this->request['bank_integration_id']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
$this->entity_count['bank_transactions'] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -102,6 +101,8 @@ class Csv extends BaseImport implements ImportInterface
|
||||
$this->repository_name = BankTransactionRepository::class;
|
||||
$this->factory_name = BankTransactionFactory::class;
|
||||
|
||||
$this->repository = app()->make($this->repository_name);
|
||||
|
||||
$this->transformer = new BankTransformer($this->company);
|
||||
$bank_transaction_count = $this->ingest($data, $entity_type);
|
||||
$this->entity_count['bank_transactions'] = $bank_transaction_count;
|
||||
|
@ -31,17 +31,17 @@ class BankTransformer extends BaseTransformer
|
||||
$now = now();
|
||||
|
||||
$transformed = [
|
||||
// 'bank_integration_id' => $this->bank_integration->id,
|
||||
'bank_integration_id' => $transaction['bank.bank_integration_id'],
|
||||
'transaction_id' => $this->getNumber($transaction,'bank.transaction_id'),
|
||||
'amount' => abs($this->getFloat($transaction, 'bank.amount')),
|
||||
'currency_id' => $this->getCurrencyByCode($transaction, 'bank.currency'),
|
||||
'account_type' => strlen($this->getString($transaction, 'bank.account_type')) > 1 ? $this->getString($transaction, 'bank.account_type') : 'bank',
|
||||
'category_id' => $this->getNumber($transaction, 'bank.category_id') > 0 ? $this->getNumber($transaction, 'bank.category_id') : null,
|
||||
'category_type' => $this->getString($transaction, 'category_type'),
|
||||
'date' => array_key_exists('date', $transaction) ? $this->parseDate($transaction['date'])
|
||||
'category_type' => $this->getString($transaction, 'bank.category_type'),
|
||||
'date' => array_key_exists('bank.date', $transaction) ? $this->parseDate($transaction['bank.date'])
|
||||
: now()->format('Y-m-d'),
|
||||
'bank_account_id' => array_key_exists('bank_account_id', $transaction) ? $transaction['bank_account_id'] : 0,
|
||||
'description' => array_key_exists('description', $transaction)? $transaction['description'] : '',
|
||||
'bank_account_id' => array_key_exists('bank.bank_account_id', $transaction) ? $transaction['bank.bank_account_id'] : 0,
|
||||
'description' => array_key_exists('bank.description', $transaction) ? $transaction['bank.description'] : '',
|
||||
'base_type' => $this->calculateType($transaction),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
@ -56,22 +56,22 @@ class BankTransformer extends BaseTransformer
|
||||
private function calculateType($transaction)
|
||||
{
|
||||
|
||||
if(array_key_exists('base_type', $transaction) && $transaction['base_type'] == 'CREDIT')
|
||||
if(array_key_exists('bank.base_type', $transaction) && $transaction['bank.base_type'] == 'CREDIT')
|
||||
return 'CREDIT';
|
||||
|
||||
if(array_key_exists('base_type', $transaction) && $transaction['base_type'] == 'DEBIT')
|
||||
if(array_key_exists('bank.base_type', $transaction) && $transaction['bank.base_type'] == 'DEBIT')
|
||||
return 'DEBIT';
|
||||
|
||||
if(array_key_exists('category_id',$transaction))
|
||||
if(array_key_exists('bank.category_id', $transaction))
|
||||
return 'DEBIT';
|
||||
|
||||
if(array_key_exists('category_type', $transaction) && $transaction['category_type'] == 'Income')
|
||||
if(array_key_exists('bank.category_type', $transaction) && $transaction['bank.category_type'] == 'Income')
|
||||
return 'CREDIT';
|
||||
|
||||
if(array_key_exists('category_type', $transaction))
|
||||
if(array_key_exists('bank.category_type', $transaction))
|
||||
return 'DEBIT';
|
||||
|
||||
if(array_key_exists('amount', $transaction) && is_numeric($transaction['amount']) && $transaction['amount'] > 0)
|
||||
if(array_key_exists('bank.amount', $transaction) && is_numeric($transaction['bank.amount']) && $transaction['bank.amount'] > 0)
|
||||
return 'CREDIT';
|
||||
|
||||
return 'DEBIT';
|
||||
|
@ -38,9 +38,9 @@ class UserObserver
|
||||
*/
|
||||
public function updated(User $user)
|
||||
{
|
||||
if (Ninja::isHosted() && $user->isDirty('phone')) {
|
||||
VerifyPhone::dispatch($user);
|
||||
}
|
||||
// if (Ninja::isHosted() && $user->isDirty('phone')) {
|
||||
// VerifyPhone::dispatch($user);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user