Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop

This commit is contained in:
David Bomba 2022-11-04 12:55:22 +11:00
commit f6ab1c0f0f
190 changed files with 51 additions and 45 deletions

View File

@ -33,9 +33,9 @@ class MatchBankTransactionRequest extends Request
'transactions' => 'bail|array', 'transactions' => 'bail|array',
'transactions.*.id' => 'bail|required', 'transactions.*.id' => 'bail|required',
'transactions.*.invoice_ids' => 'nullable|string|sometimes', 'transactions.*.invoice_ids' => 'nullable|string|sometimes',
'transactions.*.ninja_category_id' => 'nullable|string|sometimes'
]; ];
$rules['transactions.*.ninja_category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
$rules['transactions.*.vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; $rules['transactions.*.vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
return $rules; return $rules;

View File

@ -47,11 +47,11 @@ class HasValidPhoneNumber implements Rule
if(!$sid) if(!$sid)
return true; return true;
$twilio = new Twilio\Rest\Client($sid, $token); $twilio = new \Twilio\Rest\Client($sid, $token);
$country = auth()->user()->account?->companies()?->first()?->country(); $country = auth()->user()->account?->companies()?->first()?->country();
if(!$country || strlen($user->phone) < 2) if(!$country || strlen(auth()->user()->phone) < 2)
return true; return true;
$countryCode = $country->iso_3166_2; $countryCode = $country->iso_3166_2;
@ -62,7 +62,9 @@ class HasValidPhoneNumber implements Rule
->fetch(["countryCode" => $countryCode]); ->fetch(["countryCode" => $countryCode]);
$user = auth()->user(); $user = auth()->user();
$user->phone = $phone_number->phoneNumber;
request()->merge(['validated_phone' => $phone_number->phoneNumber ]);
$user->verified_phone_number = true; $user->verified_phone_number = true;
$user->save(); $user->save();

View File

@ -46,11 +46,14 @@ use App\Repositories\PaymentRepository;
use App\Repositories\ProductRepository; use App\Repositories\ProductRepository;
use App\Repositories\QuoteRepository; use App\Repositories\QuoteRepository;
use App\Repositories\VendorRepository; use App\Repositories\VendorRepository;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
class Csv extends BaseImport implements ImportInterface class Csv extends BaseImport implements ImportInterface
{ {
use MakesHash;
public array $entity_count = []; public array $entity_count = [];
public function import(string $entity) public function import(string $entity)
@ -77,24 +80,20 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type); $data = $this->getCsvData($entity_type);
if (is_array($data)) { if (is_array($data))
{
$data = $this->preTransformCsv($data, $entity_type); $data = $this->preTransformCsv($data, $entity_type);
foreach($data as $key => $value)
if(array_key_exists('bank_integration_id', $this->request)){ {
$data[$key]['bank.bank_integration_id'] = $this->decodePrimaryKey($this->request['bank_integration_id']);
foreach($data as $key => $value)
{
$data['bank_integration_id'][$key] = $this->request['bank_integration_id'];
}
} }
} }
if (empty($data)) { if (empty($data)) {
$this->entity_count['bank_transactions'] = 0; $this->entity_count['bank_transactions'] = 0;
return; return;
} }
@ -102,6 +101,8 @@ class Csv extends BaseImport implements ImportInterface
$this->repository_name = BankTransactionRepository::class; $this->repository_name = BankTransactionRepository::class;
$this->factory_name = BankTransactionFactory::class; $this->factory_name = BankTransactionFactory::class;
$this->repository = app()->make($this->repository_name);
$this->transformer = new BankTransformer($this->company); $this->transformer = new BankTransformer($this->company);
$bank_transaction_count = $this->ingest($data, $entity_type); $bank_transaction_count = $this->ingest($data, $entity_type);
$this->entity_count['bank_transactions'] = $bank_transaction_count; $this->entity_count['bank_transactions'] = $bank_transaction_count;

View File

@ -68,6 +68,11 @@ class BaseTransformer
} }
public function getNumber($data, $field)
{
return (isset($data->$field) && $data->$field) ? (int)$data->$field : 0;
}
public function getString($data, $field) public function getString($data, $field)
{ {
return isset($data[$field]) && $data[$field] ? trim($data[$field]) : ''; return isset($data[$field]) && $data[$field] ? trim($data[$field]) : '';

View File

@ -12,7 +12,7 @@
namespace App\Import\Transformers\Bank; namespace App\Import\Transformers\Bank;
use App\Import\ImportException; use App\Import\ImportException;
use App\Import\Transformers\BaseTransformer; use App\Import\Transformer\BaseTransformer;
use App\Models\BankTransaction; use App\Models\BankTransaction;
use App\Utils\Number; use App\Utils\Number;
@ -31,17 +31,17 @@ class BankTransformer extends BaseTransformer
$now = now(); $now = now();
$transformed = [ $transformed = [
// 'bank_integration_id' => $this->bank_integration->id, 'bank_integration_id' => $transaction['bank.bank_integration_id'],
'transaction_id' => $this->getNumber($transaction,'bank.transaction_id'), 'transaction_id' => $this->getNumber($transaction,'bank.transaction_id'),
'amount' => abs($this->getFloat($transaction, 'bank.amount')), 'amount' => abs($this->getFloat($transaction, 'bank.amount')),
'currency_id' => $this->getCurrencyByCode($transaction, 'bank.currency'), 'currency_id' => $this->getCurrencyByCode($transaction, 'bank.currency'),
'account_type' => strlen($this->getString($transaction, 'bank.account_type')) > 1 ? $this->getString($transaction, 'bank.account_type') : 'bank', '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_id' => $this->getNumber($transaction, 'bank.category_id') > 0 ? $this->getNumber($transaction, 'bank.category_id') : null,
'category_type' => $this->getString($transaction, 'category_type'), 'category_type' => $this->getString($transaction, 'bank.category_type'),
'date' => array_key_exists('date', $transaction) ? date('Y-m-d', strtotime(str_replace("/","-",$transaction['date']))) 'date' => array_key_exists('bank.date', $transaction) ? $this->parseDate($transaction['bank.date'])
: now()->format('Y-m-d'), : now()->format('Y-m-d'),
'bank_account_id' => array_key_exists('bank_account_id', $transaction) ? $transaction['bank_account_id'] : 0, 'bank_account_id' => array_key_exists('bank.bank_account_id', $transaction) ? $transaction['bank.bank_account_id'] : 0,
'description' => array_key_exists('description', $transaction)? $transaction['description'] : '', 'description' => array_key_exists('bank.description', $transaction) ? $transaction['bank.description'] : '',
'base_type' => $this->calculateType($transaction), 'base_type' => $this->calculateType($transaction),
'created_at' => $now, 'created_at' => $now,
'updated_at' => $now, 'updated_at' => $now,
@ -56,22 +56,22 @@ class BankTransformer extends BaseTransformer
private function calculateType($transaction) 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'; 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'; return 'DEBIT';
if(array_key_exists('category_id',$transaction)) if(array_key_exists('bank.category_id', $transaction))
return 'DEBIT'; 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'; return 'CREDIT';
if(array_key_exists('category_type', $transaction)) if(array_key_exists('bank.category_type', $transaction))
return 'DEBIT'; 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 'CREDIT';
return 'DEBIT'; return 'DEBIT';

View File

@ -53,7 +53,7 @@ class VerifyPhone implements ShouldQueue
if(!$sid) if(!$sid)
return; // no twilio api credentials provided, bail. return; // no twilio api credentials provided, bail.
$twilio = new Twilio\Rest\Client($sid, $token); $twilio = new \Twilio\Rest\Client($sid, $token);
$country = $this->user->account?->companies()?->first()?->country(); $country = $this->user->account?->companies()?->first()?->country();

View File

@ -38,9 +38,9 @@ class UserObserver
*/ */
public function updated(User $user) public function updated(User $user)
{ {
if (Ninja::isHosted() && $user->isDirty('phone')) { // if (Ninja::isHosted() && $user->isDirty('phone')) {
VerifyPhone::dispatch($user); // VerifyPhone::dispatch($user);
} // }
} }
/** /**

View File

@ -56,15 +56,12 @@ class UserRepository extends BaseRepository
$company = auth()->user()->company(); $company = auth()->user()->company();
$account = $company->account; $account = $company->account;
/* If hosted and Enterprise we need to increment the num_users field on the accounts table*/
// 05-08-2022 This is an error, the num_users should _never_ increment
// if (! $user->id && $account->isEnterpriseClient()) {
// $account->num_users++;
// $account->save();
// }
if(array_key_exists('oauth_provider_id', $details)) if(array_key_exists('oauth_provider_id', $details))
unset($details['oauth_provider_id']); unset($details['oauth_provider_id']);
if (request()->has('validated_phone'))
$details['phone'] = request()->input('validated_phone');
$user->fill($details); $user->fill($details);
//allow users to change only their passwords - not others! //allow users to change only their passwords - not others!
@ -140,7 +137,7 @@ class UserRepository extends BaseRepository
$cu->forceDelete(); $cu->forceDelete();
} }
event(new UserWasDeleted($user, $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new UserWasDeleted($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
$user->delete(); $user->delete();

0
artisan Executable file → Normal file
View File

0
bootstrap/app.php Executable file → Normal file
View File

0
bootstrap/cache/.gitignore vendored Executable file → Normal file
View File

0
dusk.sh Executable file → Normal file
View File

0
public/.htaccess Executable file → Normal file
View File

0
public/assets/AssetManifest.json Executable file → Normal file
View File

0
public/assets/FontManifest.json Executable file → Normal file
View File

0
public/assets/LICENSE Executable file → Normal file
View File

0
public/assets/NOTICES Executable file → Normal file
View File

0
public/assets/assets/images/google-icon.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

0
public/assets/assets/images/logo.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
public/assets/assets/images/payment_types/ach.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

0
public/assets/assets/images/payment_types/amex.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

0
public/assets/assets/images/payment_types/discover.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

0
public/assets/assets/images/payment_types/jcb.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

0
public/assets/assets/images/payment_types/laser.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

0
public/assets/assets/images/payment_types/maestro.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

0
public/assets/assets/images/payment_types/other.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

0
public/assets/assets/images/payment_types/paypal.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
public/assets/assets/images/payment_types/solo.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

0
public/assets/assets/images/payment_types/switch.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 938 B

0
public/assets/assets/images/payment_types/unionpay.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
public/assets/assets/images/payment_types/visa.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

0
public/assets/fonts/MaterialIcons-Regular.otf Executable file → Normal file
View File

0
public/assets/fonts/MaterialIcons-Regular.ttf Executable file → Normal file
View File

0
public/assets/fonts/Roboto-Regular.ttf Executable file → Normal file
View File

View File

View File

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 881 B

After

Width:  |  Height:  |  Size: 881 B

View File

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

0
public/assets/web/assets/fonts/Roboto-Regular.ttf Executable file → Normal file
View File

0
public/css/app.css vendored Executable file → Normal file
View File

0
public/css/ninja.css vendored Executable file → Normal file
View File

0
public/css/ninja.min.css vendored Executable file → Normal file
View File

0
public/favicon.ico Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
public/favicon.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

0
public/flutter_service_worker.js vendored Executable file → Normal file
View File

0
public/icons/Icon-192.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

0
public/icons/Icon-512.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

0
public/images/american-express.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

0
public/images/created-by-invoiceninja-new.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

0
public/images/created-by-invoiceninja.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
public/images/diners-club.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

0
public/images/discover.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
public/images/invoiceninja-black-logo-2.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
public/images/invoiceninja-white-logo.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

0
public/images/logo.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

0
public/images/mastercard.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
public/images/paypal.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
public/images/svg/activity.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 277 B

0
public/images/svg/align-left.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 388 B

After

Width:  |  Height:  |  Size: 388 B

0
public/images/svg/clock.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 299 B

0
public/images/svg/credit-card.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 324 B

0
public/images/svg/dark/activity.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 278 B

0
public/images/svg/dark/align-left.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 391 B

After

Width:  |  Height:  |  Size: 391 B

0
public/images/svg/dark/clock.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 299 B

0
public/images/svg/dark/credit-card.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 324 B

0
public/images/svg/dark/download.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

0
public/images/svg/dark/file-text.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

0
public/images/svg/dark/file.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 332 B

0
public/images/svg/dark/shield.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

0
public/images/svg/dark/user.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

0
public/images/svg/download.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

0
public/images/svg/file-text.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

0
public/images/svg/file.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 332 B

0
public/images/svg/shield.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

0
public/images/svg/user.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

0
public/images/visa.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
public/index.php Executable file → Normal file
View File

0
public/js/app.js vendored Executable file → Normal file
View File

0
public/js/client_create.js vendored Executable file → Normal file
View File

0
public/js/client_create.min.js vendored Executable file → Normal file
View File

0
public/js/client_edit.js vendored Executable file → Normal file
View File

0
public/js/client_edit.min.js vendored Executable file → Normal file
View File

0
public/js/client_list.js vendored Executable file → Normal file
View File

0
public/js/client_list.min.js vendored Executable file → Normal file
View File

0
public/js/client_settings.js vendored Executable file → Normal file
View File

0
public/js/client_settings.min.js vendored Executable file → Normal file
View File

0
public/js/client_show.js vendored Executable file → Normal file
View File

0
public/js/client_show.min.js vendored Executable file → Normal file
View File

0
public/js/clients/invoices/action-selectors.js vendored Executable file → Normal file
View File

View File

Some files were not shown because too many files have changed in this diff Show More