1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Merge pull request #8771 from turbo124/v5-develop

Update release branch, merge Laravel 10 branch
This commit is contained in:
David Bomba 2023-09-03 09:14:37 +10:00 committed by GitHub
commit fbbdf802c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
96 changed files with 1351 additions and 2478 deletions

View File

@ -32,9 +32,9 @@ jobs:
- name: Prepare Laravel Application
run: |
cp .env.example .env
php artisan key:generate
php artisan key:generate --force
php artisan optimize
php artisan storage:link
php artisan storage:link --force
sudo php artisan cache:clear
sudo find ./vendor/bin/ -type f -exec chmod +x {} \;
sudo find ./ -type d -exec chmod 755 {} \;

View File

@ -1 +1 @@
5.7.5
5.7.6

View File

@ -564,7 +564,7 @@ class CheckData extends Command
GROUP BY clients.id
HAVING payments_applied != client_paid_to_date
ORDER BY clients.id;
"));
")->getValue(DB::connection()->getQueryGrammar()));
return $results;
}
@ -583,7 +583,7 @@ class CheckData extends Command
AND paymentables.amount > 0
AND payments.is_deleted = 0
AND payments.client_id = ?;
"), [App\Models\Credit::class, $client->id]);
")->getValue(DB::connection()->getQueryGrammar()), [App\Models\Credit::class, $client->id]);
return $results;
}
@ -636,7 +636,7 @@ class CheckData extends Command
->where('clients.updated_at', '>', now()->subDays(2))
->groupBy('clients.id')
->havingRaw('clients.paid_to_date != sum(coalesce(payments.amount - payments.refunded, 0))')
->get(['clients.id', 'clients.paid_to_date', DB::raw('sum(coalesce(payments.amount - payments.refunded, 0)) as amount')]);
->get(['clients.id', 'clients.paid_to_date', DB::raw('sum(coalesce(payments.amount - payments.refunded, 0)) as amount')->getValue(DB::connection()->getQueryGrammar())]);
/* Due to accounting differences we need to perform a second loop here to ensure there actually is an issue */
$clients->each(function ($client_record) use ($credit_total_applied) {
@ -656,8 +656,8 @@ class CheckData extends Command
$p = Payment::where('client_id', $client->id)
->where('is_deleted', 0)
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
->sum(DB::Raw('amount - applied'));
// ->sum(DB::Raw('amount - applied')->getValue(DB::connection()->getQueryGrammar()));
->selectRaw('SUM(payments.amount - payments.applied) as amount')->first()->amount ?? 0;
$total_invoice_payments += $p;
// 10/02/21
@ -736,7 +736,7 @@ class CheckData extends Command
GROUP BY clients.id
HAVING invoice_balance != clients.balance
ORDER BY clients.id;
"));
")->getValue(DB::connection()->getQueryGrammar()));
return $results;
}
@ -827,7 +827,7 @@ class CheckData extends Command
GROUP BY clients.id
HAVING(invoices_balance != clients.balance)
ORDER BY clients.id;
"));
")->getValue(DB::connection()->getQueryGrammar()));
return $results;
}
@ -961,7 +961,7 @@ class CheckData extends Command
}
$records = DB::table($table)
->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id")
->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id"))
->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id")->getValue(DB::connection()->getQueryGrammar()))
->get(["{$table}.id"]);
if ($records->count()) {

View File

@ -1065,7 +1065,7 @@ class BaseController extends Controller
$data = $this->first_load;
}
} else {
$included = request()->input('include');
$included = request()->input('include', '');
$included = explode(',', $included);
foreach ($included as $include) {

View File

@ -195,7 +195,7 @@ class UserController extends BaseController
public function destroy(DestroyUserRequest $request, User $user)
{
if ($user->isOwner()) {
return response()->json(['message', 'Cannot detach owner.'], 400);
return response()->json(['message', 'Cannot detach owner.'], 401);
}
/* If the user passes the company user we archive the company user */

View File

@ -128,7 +128,7 @@ class Kernel extends HttpKernel
*
* @var array
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'bindings' => SubstituteBindings::class,

View File

@ -20,7 +20,7 @@ class Request extends FormRequest
use MakesHash;
use RuntimeFormRequest;
protected $file_validation = 'sometimes|file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx,webp,xml|max:20000';
protected $file_validation = 'sometimes|file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx,webp,xml,zip|max:100000';
/**
* Get the validation rules that apply to the request.
*
@ -63,14 +63,20 @@ class Request extends FormRequest
private function invoice_id($rules)
{
$rules['invoice_id'] = 'bail|nullable|sometimes|exists:invoices,id,company_id,'.auth()->user()->company()->id.',client_id,'.$this['client_id'];
/** @var \App\Models\User $user */
$user = auth()->user();
$rules['invoice_id'] = 'bail|nullable|sometimes|exists:invoices,id,company_id,'.$user->company()->id.',client_id,'.$this['client_id'];
return $rules;
}
private function vendor_id($rules)
{
$rules['vendor_id'] = 'bail|nullable|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id;
/** @var \App\Models\User $user */
$user = auth()->user();
$rules['vendor_id'] = 'bail|nullable|sometimes|exists:vendors,id,company_id,'.$user->company()->id;
return $rules;
}

View File

@ -23,6 +23,9 @@ class DestroyUserRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->isOwner();
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isOwner();
}
}

View File

@ -23,7 +23,9 @@ class ShowUserRequest extends Request
*/
public function authorize() : bool
{
//return auth()->user()->can('view', $this->user);
return auth()->user()->isAdmin();
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
}
}

View File

@ -57,9 +57,10 @@ class ValidRefundableRequest implements Rule
$request_invoices = request()->has('invoices') ? $this->input['invoices'] : [];
if ($payment->invoices()->exists()) {
foreach ($payment->invoices as $paymentable_invoice) {
$this->checkInvoice($paymentable_invoice, $request_invoices);
}
$this->checkInvoice($payment->invoices, $request_invoices);
// foreach ($payment->invoices as $paymentable_invoice) {
// $this->checkInvoice($paymentable_invoice, $request_invoices);
// }
}
foreach ($request_invoices as $request_invoice) {
@ -99,42 +100,25 @@ class ValidRefundableRequest implements Rule
}
}
// private function checkCreditIsPaymentable($credit, $payment)
// {
// /** @var \App\Models\Credit $credit */
// $credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first();
// if ($payment->credits()->exists()) {
// $paymentable_credit = $payment->credits->where('id', $credit->id)->first();
// if (! $paymentable_credit) {
// $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
// return false;
// }
// } else {
// $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
// return false;
// }
// }
private function checkInvoice($paymentable, $request_invoices)
private function checkInvoice($paymentables, $request_invoices)
{
$record_found = false;
foreach ($request_invoices as $request_invoice) {
if ($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id) {
$record_found = true;
foreach($paymentables as $paymentable) {
foreach ($request_invoices as $request_invoice) {
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
if ($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id) {
$record_found = true;
if ($request_invoice['amount'] > $refundable_amount) {
$invoice = $paymentable;
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
$this->error_msg = ctrans('texts.max_refundable_invoice', ['invoice' => $invoice->hashed_id, 'amount' => $refundable_amount]);
if ($request_invoice['amount'] > $refundable_amount) {
$invoice = $paymentable;
return false;
$this->error_msg = ctrans('texts.max_refundable_invoice', ['invoice' => $invoice->hashed_id, 'amount' => $refundable_amount]);
return false;
}
}
}
}
@ -146,33 +130,6 @@ class ValidRefundableRequest implements Rule
}
}
// private function checkCredit($paymentable, $request_credits)
// {
// $record_found = null;
// foreach ($request_credits as $request_credit) {
// if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) {
// $record_found = true;
// $refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
// if ($request_credit['amount'] > $refundable_amount) {
// $credit = $paymentable;
// $this->error_msg = ctrans('texts.max_refundable_credit', ['credit' => $credit->hashed_id, 'amount' => $refundable_amount]);
// return false;
// }
// }
// }
// if (! $record_found) {
// $this->error_msg = ctrans('texts.refund_without_credits');
// return false;
// }
// }
/**
* @return string
*/

View File

@ -732,9 +732,23 @@ class BaseImport
protected function findUser($user_hash)
{
$user = false;
if(is_numeric($user_hash)) {
$user = User::query()
->where('account_id', $this->company->account->id)
->where('id', $user_hash)
->first();
}
if($user)
return $user->id;
$user = User::where('account_id', $this->company->account->id)
->where(
\DB::raw('CONCAT_WS(" ", first_name, last_name)'),
\DB::raw('CONCAT_WS(" ", first_name, last_name)')->getValue(\DB::connection()->getQueryGrammar()),
'like',
'%'.$user_hash.'%'
)

View File

@ -238,14 +238,15 @@ class BaseTransformer
*/
public function hasClient($name)
{
return Client::query()->where('company_id', $this->company->id)
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
->whereRaw("LOWER(REPLACE(`name`, ' ' , '')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
->exists();
}
public function hasClientIdNumber($id_number)
{
return Client::query()->where('company_id', $this->company->id)

View File

@ -158,17 +158,6 @@ class CheckCompanyData implements ShouldQueue
$total_invoice_payments += ($total_amount - $total_refund);
}
//10/02/21
// foreach ($client->payments as $payment) {
// $credit_total_applied += $payment->paymentables->where('paymentable_type', App\Models\Credit::class)->sum(DB::raw('amount'));
// }
// if ($credit_total_applied < 0) {
// $total_invoice_payments += $credit_total_applied;
// } //todo this is contentious
// nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
$wrong_paid_to_dates++;
@ -287,7 +276,7 @@ class CheckCompanyData implements ShouldQueue
// $clients->where('clients.id', '=', $this->option('client_id'));
// }
$clients = $clients->get(['clients.id', DB::raw('count(client_contacts.id)')]);
$clients = $clients->get(['clients.id', DB::raw('count(client_contacts.id)')->getValue(DB::connection()->getQueryGrammar())]);
$this->company_data[] = $clients->count().' clients without a single primary contact';
if ($clients->count() > 0) {
@ -326,7 +315,7 @@ class CheckCompanyData implements ShouldQueue
}
$records = DB::table($table)
->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id")
->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id"))
->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id")->getValue(DB::connection()->getQueryGrammar()))
->get(["{$table}.id"]);
if ($records->count()) {

View File

@ -302,7 +302,7 @@ class Import implements ShouldQueue
// 10/02/21
foreach ($client->payments as $payment) {
$credit_total_applied += $payment->paymentables()->where('paymentable_type', \App\Models\Credit::class)->get()->sum(\DB::raw('amount'));
$credit_total_applied += $payment->paymentables()->where('paymentable_type', \App\Models\Credit::class)->get()->sum(\DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
}
if ($credit_total_applied < 0) {

View File

@ -128,23 +128,14 @@ class Account extends BaseModel
'num_users',
];
/**
* @var array
*/
protected $dates = [
'deleted_at',
'promo_expires',
'discount_expires',
// 'trial_started',
// 'plan_expires'
];
protected $casts = [
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
'onboarding' => 'object',
'set_react_as_default_ap' => 'bool'
'set_react_as_default_ap' => 'bool',
'promo_expires' => 'date',
'discount_expires' => 'date',
];
const PLAN_FREE = 'free';

View File

@ -73,9 +73,6 @@ class BankIntegration extends BaseModel
'auto_sync',
];
protected $dates = [
];
public function getEntityType()
{
return self::class;

View File

@ -87,8 +87,6 @@ class BankTransaction extends BaseModel
'amount'
];
protected $dates = [
];
public function getInvoiceIds()
{

View File

@ -87,9 +87,6 @@ class BankTransactionRule extends BaseModel
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
protected $dates = [
];
protected array $search_keys = [
'description' => 'string',

View File

@ -411,7 +411,7 @@ class CompanyGateway extends BaseModel
$fee = 0;
if ($fees_and_limits->adjust_fee_percent) {
if ($fees_and_limits->adjust_fee_percent ?? false) {
$adjusted_fee = 0;
if ($fees_and_limits->fee_amount) {

View File

@ -34,7 +34,7 @@ trait ChartQueries
AND (expenses.date BETWEEN :start_date AND :end_date)
{$user_filter}
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getExpenseChartQuery($start_date, $end_date, $currency_id)
@ -54,7 +54,7 @@ trait ChartQueries
{$user_filter}
GROUP BY expenses.date
HAVING currency_id = :currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,
@ -80,7 +80,7 @@ trait ChartQueries
AND payments.company_id = :company_id
AND (payments.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'company_id' => $this->company->id,
'start_date' => $start_date,
@ -106,7 +106,7 @@ trait ChartQueries
AND (payments.date BETWEEN :start_date AND :end_date)
GROUP BY payments.date
HAVING currency_id = :currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,
@ -139,7 +139,7 @@ trait ChartQueries
AND invoices.balance > 0
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getRevenueQueryX($start_date, $end_date)
@ -161,7 +161,7 @@ trait ChartQueries
AND invoices.status_id IN (3,4)
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getRevenueQuery($start_date, $end_date)
@ -179,7 +179,7 @@ trait ChartQueries
AND payments.status_id IN (1,4,5,6)
AND (payments.date BETWEEN :start_date AND :end_date)
GROUP BY payments.currency_id
"), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getInvoicesQuery($start_date, $end_date)
@ -201,7 +201,7 @@ trait ChartQueries
AND invoices.is_deleted = 0
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getOutstandingChartQuery($start_date, $end_date, $currency_id)
@ -224,7 +224,7 @@ trait ChartQueries
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY invoices.date
HAVING currency_id = :currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => (int) $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,
@ -254,7 +254,7 @@ trait ChartQueries
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY invoices.date
HAVING currency_id = :currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => (int) $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,

View File

@ -23,6 +23,7 @@ trait ChartQueriesLegacy
*/
public function getExpenseQuery($start_date, $end_date)
{
return DB::select(DB::raw('
SELECT sum(expenses.amount) as amount,
IFNULL(expenses.currency_id, :company_currency) as currency_id
@ -31,7 +32,7 @@ trait ChartQueriesLegacy
AND expenses.company_id = :company_id
AND (expenses.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
'), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
')->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getExpenseChartQuery($start_date, $end_date, $currency_id)
@ -47,7 +48,7 @@ trait ChartQueriesLegacy
AND expenses.is_deleted = 0
GROUP BY expenses.date
HAVING currency_id = :currency_id
'), [
')->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,
@ -69,7 +70,7 @@ trait ChartQueriesLegacy
AND payments.company_id = :company_id
AND (payments.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
'), [
')->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'company_id' => $this->company->id,
'start_date' => $start_date,
@ -91,7 +92,7 @@ trait ChartQueriesLegacy
AND payments.is_deleted = 0
GROUP BY payments.date
HAVING currency_id = :currency_id
'), [
')->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,
@ -119,7 +120,7 @@ trait ChartQueriesLegacy
AND invoices.is_deleted = 0
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
")->getValue(DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
}
public function getRevenueQuery($start_date, $end_date)
@ -158,7 +159,7 @@ trait ChartQueriesLegacy
AND invoices.is_deleted = 0
GROUP BY invoices.date
HAVING currency_id = :currency_id
"), [
")->getValue(DB::connection()->getQueryGrammar()), [
'company_currency' => (int) $this->company->settings->currency_id,
'currency_id' => $currency_id,
'company_id' => $this->company->id,

View File

@ -81,7 +81,8 @@ class ClientService
$amount = Payment::query()->where('client_id', $this->client->id)
->where('is_deleted', 0)
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
->sum(DB::Raw('amount - applied'));
->selectRaw('SUM(payments.amount - payments.applied) as amount')->first()->amount ?? 0;
// ->sum(DB::Raw('amount - applied')->getValue(DB::connection()->getQueryGrammar()));
DB::connection(config('database.default'))->transaction(function () use ($amount) {
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();

View File

@ -96,17 +96,17 @@ class HandleRestore extends AbstractService
$this->adjustment_amount += $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$this->adjustment_amount += $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('refunded'));
->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar()));
//14/07/2023 - do not include credits in the payment amount
$this->adjustment_amount -= $payment->paymentables
->where('paymentable_type', '=', 'App\Models\Credit')
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
}
@ -129,16 +129,16 @@ class HandleRestore extends AbstractService
$payment_adjustment = $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$payment_adjustment -= $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('refunded'));
->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar()));
$payment_adjustment -= $payment->paymentables
->where('paymentable_type', '=', 'App\Models\Credit')
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$payment->amount += $payment_adjustment;
$payment->applied += $payment_adjustment;

View File

@ -88,17 +88,17 @@ class MarkInvoiceDeleted extends AbstractService
$payment_adjustment = $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$payment_adjustment -= $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('refunded'));
->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar()));
//14-07-2023 - Do not include credits in the payment adjustment.
$payment_adjustment -= $payment->paymentables
->where('paymentable_type', '=', 'App\Models\Credit')
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$payment->amount -= $payment_adjustment;
$payment->applied -= $payment_adjustment;
@ -121,12 +121,12 @@ class MarkInvoiceDeleted extends AbstractService
$this->adjustment_amount += $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('amount'));
->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar()));
$this->adjustment_amount -= $payment->paymentables
->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id)
->sum(DB::raw('refunded'));
->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar()));
}
$this->total_payments = $this->invoice->payments->sum('amount') - $this->invoice->payments->sum('refunded');

View File

@ -250,7 +250,7 @@ class ProfitLoss
AND invoices.is_deleted = 0
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
")->getValue(\DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
}
/**
@ -421,7 +421,7 @@ class ProfitLoss
AND invoices.is_deleted = 0
AND (invoices.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
"), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
")->getValue(\DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
}
/**
@ -447,7 +447,7 @@ class ProfitLoss
AND (payments.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
ORDER BY currency_id;
'), ['company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
')->getValue(\DB::connection()->getQueryGrammar()), ['company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
}
private function expenseData()
@ -553,7 +553,7 @@ class ProfitLoss
AND expenses.company_id = :company_id
AND (expenses.date BETWEEN :start_date AND :end_date)
GROUP BY currency_id
'), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
')->getValue(\DB::connection()->getQueryGrammar()), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
}
private function setBillingReportType()

View File

@ -28,7 +28,7 @@ class AccountTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
//'default_company',
//'user',
//'company_users'
@ -37,7 +37,7 @@ class AccountTransformer extends EntityTransformer
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'default_company',
'company_users',
'companies',

View File

@ -34,12 +34,12 @@ class ActivityTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'history',
'user',
'client',

View File

@ -24,7 +24,7 @@ class ArraySerializer extends FractalArraySerializer
*
* @return array
*/
public function collection($resourceKey, array $data)
public function collection(?string $resourceKey, array $data): array
{
return $data;
}
@ -35,7 +35,7 @@ class ArraySerializer extends FractalArraySerializer
*
* @return array
*/
public function item($resourceKey, array $data)
public function item(?string $resourceKey, array $data): array
{
return $data;
}

View File

@ -28,7 +28,7 @@ class BankIntegrationTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
//'default_company',
//'user',
//'company_users'
@ -37,7 +37,7 @@ class BankIntegrationTransformer extends EntityTransformer
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'company',
'account',
'bank_transactions',

View File

@ -29,13 +29,13 @@ class BankTransactionRuleTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'company',
'vendor',
'client',

View File

@ -28,13 +28,13 @@ class BankTransactionTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'company',
// 'expense',
'payment',

View File

@ -29,7 +29,7 @@ class ClientTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'contacts',
'documents',
'gateway_tokens',
@ -38,7 +38,7 @@ class ClientTransformer extends EntityTransformer
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'activities',
'ledger',
'system_logs',

View File

@ -29,13 +29,13 @@ class CompanyGatewayTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'system_logs',
'gateway',
];

View File

@ -24,13 +24,13 @@ class CompanyTokenHashedTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -24,13 +24,13 @@ class CompanyTokenTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -59,14 +59,14 @@ class CompanyTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'documents',
'users',
'designs',

View File

@ -22,14 +22,14 @@ class CompanyUserTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
// 'user',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'user',
'company',
'token',

View File

@ -19,11 +19,11 @@ class InvoiceTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
// 'invoice_items',
];
protected $availableIncludes = [
protected array $availableIncludes = [
];
public function transform(Invoice $invoice)

View File

@ -24,12 +24,12 @@ class CreditTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'activities',
'client',
];

View File

@ -26,13 +26,13 @@ class DesignTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -20,9 +20,9 @@ class DocumentTransformer extends EntityTransformer
protected $serializer;
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
protected $availableIncludes = [];
protected array $availableIncludes = [];
public function __construct($serializer = null)
{

View File

@ -44,7 +44,7 @@ class EntityTransformer extends TransformerAbstract
return $this->item($data, $transformer, $entityType);
}
public function getDefaultIncludes()
public function getDefaultIncludes(): array
{
return $this->defaultIncludes;
}

View File

@ -23,13 +23,13 @@ class ExpenseCategoryTransformer extends EntityTransformer
use MakesHash;
use SoftDeletes;
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -30,14 +30,14 @@ class ExpenseTransformer extends EntityTransformer
use MakesHash;
use SoftDeletes;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'client',
'vendor',
'category',

View File

@ -21,13 +21,13 @@ class GatewayTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -23,14 +23,14 @@ class GroupSettingTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -19,11 +19,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
// 'activity',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'activity',
];

View File

@ -24,12 +24,12 @@ class InvoiceTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'payments',
'client',
'activities',

View File

@ -24,12 +24,12 @@ class PaymentTransformer extends EntityTransformer
protected $serializer;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'paymentables',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'client',
'invoices',
];

View File

@ -21,9 +21,9 @@ class PaymentableTransformer extends EntityTransformer
protected $serializer;
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
protected $availableIncludes = [];
protected array $availableIncludes = [];
public function __construct($serializer = null)
{

View File

@ -22,14 +22,14 @@ class ProductTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'company',
'user',
];

View File

@ -25,14 +25,14 @@ class ProjectTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'client',
'tasks',
];

View File

@ -24,12 +24,12 @@ class PurchaseOrderTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents'
];
protected $availableIncludes = [
protected array $availableIncludes = [
'expense',
'vendor',
'activities',

View File

@ -24,12 +24,12 @@ class QuoteTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'activities',
'client',
];

View File

@ -27,14 +27,14 @@ class RecurringExpenseTransformer extends EntityTransformer
use MakesHash;
use SoftDeletes;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'documents',
'client',
'vendor',

View File

@ -23,12 +23,12 @@ class RecurringInvoiceTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'activities',
'client',
];

View File

@ -22,12 +22,12 @@ class RecurringQuoteTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
protected array $availableIncludes = [
'invitations',
'documents',
'activities',

View File

@ -26,13 +26,13 @@ class CompanyShopProfileTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
/**

View File

@ -22,13 +22,13 @@ class SubscriptionTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
];
public function transform(Subscription $subscription): array

View File

@ -9,12 +9,12 @@ class SystemLogTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
/**
* @var array
*/
protected $availableIncludes = [];
protected array $availableIncludes = [];
/**
* @param SystemLog $system_log

View File

@ -28,7 +28,7 @@ class TaskTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'documents',
'project',
];
@ -36,7 +36,7 @@ class TaskTransformer extends EntityTransformer
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'client',
'status',
'project',

View File

@ -25,14 +25,14 @@ class UserTransformer extends EntityTransformer
/**
* @var array
*/
protected $defaultIncludes = [
protected array $defaultIncludes = [
//'company_user'
];
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'companies',
'company_users',
'company_user',

View File

@ -25,7 +25,7 @@ class VendorTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
protected array $defaultIncludes = [
'contacts',
'documents',
];
@ -33,7 +33,7 @@ class VendorTransformer extends EntityTransformer
/**
* @var array
*/
protected $availableIncludes = [
protected array $availableIncludes = [
'activities',
];

View File

@ -9,12 +9,12 @@ class WebhookTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [];
protected array $defaultIncludes = [];
/**
* @var array
*/
protected $availableIncludes = [];
protected array $availableIncludes = [];
/**
* @param Webhook $webhook

View File

@ -43,7 +43,7 @@ class Ninja
public static function getDebugInfo()
{
$mysql_version = DB::select(DB::raw('select version() as version'))[0]->version;
$mysql_version = DB::select(DB::raw('select version() as version')->getValue(DB::connection()->getQueryGrammar()))[0]->version;
$version = request()->input('version', 'No Version Supplied.');

View File

@ -40,9 +40,9 @@
"authorizenet/authorizenet": "^2.0",
"awobaz/compoships": "^2.1",
"bacon/bacon-qr-code": "^2.0",
"beganovich/snappdf": "^3",
"beganovich/snappdf": "^4",
"braintree/braintree_php": "^6.0",
"checkout/checkout-sdk-php": "^2.5",
"checkout/checkout-sdk-php": "^3.0",
"cleverit/ubl_invoice": "^1.3",
"doctrine/dbal": "^3.0",
"eway/eway-rapid-php": "^1.3",
@ -52,21 +52,21 @@
"guzzlehttp/guzzle": "^7.2",
"halaxa/json-machine": "^0.7.0",
"hashids/hashids": "^4.0",
"hedii/laravel-gelf-logger": "^7.0",
"hedii/laravel-gelf-logger": "^8",
"horstoeko/zugferd": "^1",
"imdhemy/laravel-purchases": "^1.7",
"intervention/image": "^2.5",
"invoiceninja/inspector": "^1.0",
"invoiceninja/inspector": "^2.0",
"josemmo/facturae-php": "^1.7",
"laracasts/presenter": "^0.2.1",
"laravel/framework": "^9.3",
"laravel/framework": "^10",
"laravel/slack-notification-channel": "^2.2",
"laravel/socialite": "^5",
"laravel/tinker": "^2.7",
"laravel/ui": "^3.0",
"laravel/ui": "^4.0",
"league/csv": "^9.6",
"league/flysystem-aws-s3-v3": "^3.0",
"league/fractal": "^0.17.0",
"league/fractal": "^0.20.0",
"league/omnipay": "^3.1",
"livewire/livewire": "^2.10",
"microsoft/microsoft-graph": "^1.69",
@ -92,8 +92,8 @@
"symfony/http-client": "^6.0",
"symfony/mailgun-mailer": "^6.1",
"symfony/postmark-mailer": "^6.1",
"turbo124/beacon": "^1.4",
"turbo124/predis": "1.1.11",
"turbo124/beacon": "^1.5",
"predis/predis": "^2",
"twilio/sdk": "^6.40",
"webpatser/laravel-countries": "dev-master#75992ad",
"wepay/php-sdk": "^0.3",
@ -103,19 +103,18 @@
"php": "^8.1",
"barryvdh/laravel-debugbar": "^3.6",
"barryvdh/laravel-ide-helper": "^2.13",
"brianium/paratest": "^6.1",
"brianium/paratest": "^7",
"fakerphp/faker": "^1.14",
"filp/whoops": "^2.7",
"friendsofphp/php-cs-fixer": "^3.14",
"laracasts/cypress": "^3.0",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.0",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0",
"spaze/phpstan-stripe": "^3.0",
"vimeo/psalm": "^4.24"
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0",
"spaze/phpstan-stripe": "^3.0"
},
"autoload": {
"psr-4": {

2346
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION','5.7.5'),
'app_tag' => env('APP_TAG','5.7.5'),
'app_version' => env('APP_VERSION','5.7.6'),
'app_tag' => env('APP_TAG','5.7.6'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -22,8 +22,8 @@ return new class extends Migration {
*/
public function up()
{
DB::raw('SET GLOBAL innodb_file_per_table=1;');
DB::raw('SET GLOBAL innodb_file_format=Barracuda;');
DB::raw('SET GLOBAL innodb_file_per_table=1;')->getValue(DB::connection()->getQueryGrammar());
DB::raw('SET GLOBAL innodb_file_format=Barracuda;')->getValue(DB::connection()->getQueryGrammar());
Schema::create('languages', function ($table) {
$table->increments('id');

View File

@ -12,18 +12,16 @@ return new class extends Migration {
*/
public function up()
{
Schema::table('clients', function (Blueprint $table) {
$table->index([\DB::raw('client_hash(20)')]);
});
\DB::statement('CREATE INDEX client_hash_idx ON clients (client_hash(20));');
\DB::statement('CREATE INDEX client_contact_key_idx ON client_contacts (contact_key(20));');
\DB::statement('CREATE INDEX vendor_contact_key_idx ON vendor_contacts (contact_key(20));');
Schema::table('client_contacts', function (Blueprint $table) {
$table->index([\DB::raw('contact_key(20)')]);
$table->index('email');
});
Schema::table('vendor_contacts', function (Blueprint $table) {
$table->index([\DB::raw('contact_key(20)')]);
$table->index('email');
});
}

View File

@ -296,7 +296,6 @@ class RandomDataSeeder extends Seeder
// $payment->service()->updateInvoicePayment($payment_hash);
// UpdateInvoicePayment::dispatchNow($payment, $payment->company);
}
});

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="true" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="true" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
@ -24,6 +23,7 @@
<env name="MAIL_MAILER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_STRICT" value="FALSE"/>
</php>
<logging/>
</phpunit>

View File

@ -9,7 +9,7 @@
</svg>
</div>
</button>
@if($settings->enable_e_invoice && $entity_type == 'invoice')
@if($entity_type == 'invoice' && $settings->enable_e_invoice)
<button wire:loading.attr="disabled" wire:click="downloadEInvoice" class="bg-primary text-white px-4 py-4 lg:px-2 lg:py-2 rounded" type="button">
<span>{{ ctrans('texts.download_e_invoice') }}</span>
<div wire:loading wire:target="downloadEInvoice">

View File

@ -124,8 +124,8 @@ class CompanyGatewayResolutionTest extends TestCase
$amount = 10;
$this->assertInstanceOf('\\stdClass', $this->cg->fees_and_limits);
$this->assertObjectHasAttribute('min_limit', $this->cg->fees_and_limits->{1});
// $this->assertObjectHasAttribute('min_limit', $this->cg->fees_and_limits->{1});
$this->assertNotNull($this->cg->fees_and_limits->{1}->min_limit);
$payment_methods = $this->client->service()->getPaymentMethods($amount);
$this->assertEquals(2, count($payment_methods));

View File

@ -17,7 +17,6 @@ use App\Models\Invoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
@ -31,7 +30,6 @@ class EntityPaidToDateTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
use WithoutEvents;
protected function setUp() :void
{

View File

@ -11,10 +11,12 @@
namespace Tests\Feature\Export;
use App\Utils\Traits\MakesHash;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\MockAccountData;
use Tests\TestCase;
use Tests\MockAccountData;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Event;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;
/**
* @test
@ -23,7 +25,7 @@ class ReportApiTest extends TestCase
{
use MakesHash;
use MockAccountData;
public $faker;
protected function setUp() :void
@ -36,8 +38,7 @@ class ReportApiTest extends TestCase
ThrottleRequests::class
);
$this->withoutExceptionHandling();
// $this->withoutExceptionHandling();
$this->makeTestData();
}

View File

@ -11,18 +11,21 @@
namespace Tests\Feature\Export;
use App\DataMapper\CompanySettings;
use App\Export\CSV\ProductSalesExport;
use App\Factory\InvoiceItemFactory;
use App\Models\Account;
use Tests\TestCase;
use App\Models\User;
use App\Models\Client;
use App\Models\Account;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\User;
use App\Services\Report\UserSalesReport;
use App\Utils\Traits\AppSetup;
use App\Utils\Traits\MakesHash;
use App\DataMapper\CompanySettings;
use App\Factory\InvoiceItemFactory;
use Illuminate\Support\Facades\Cache;
use App\Export\CSV\ProductSalesExport;
use Illuminate\Support\Facades\Schema;
use App\Services\Report\UserSalesReport;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\TestCase;
/**
* @test
@ -44,6 +47,32 @@ class UserSalesReportTest extends TestCase
);
$this->withoutExceptionHandling();
/* Warm up the cache !*/
$cached_tables = config('ninja.cached_tables');
$this->artisan('db:seed --force');
foreach ($cached_tables as $name => $class) {
// check that the table exists in case the migration is pending
if (! Schema::hasTable((new $class())->getTable())) {
continue;
}
if ($name == 'payment_terms') {
$orderBy = 'num_days';
} elseif ($name == 'fonts') {
$orderBy = 'sort_order';
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
$orderBy = 'name';
} else {
$orderBy = 'id';
}
$tableData = $class::orderBy($orderBy)->get();
if ($tableData->count()) {
Cache::forever($name, $tableData);
}
}
}
public $company;

View File

@ -17,6 +17,7 @@ use Tests\MockAccountData;
use App\Jobs\Entity\EmailEntity;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -153,10 +154,10 @@ class InvoiceEmailTest extends TestCase
public function testTemplateValidation()
{
$data = [
"body" => "hey what's up",
"entity" => 'invoice',
"entity_id"=> $this->invoice->hashed_id,
"subject"=> 'Reminder $number',
"body" => "hey what's up",
"entity" => 'invoice',
"entity_id"=> $this->invoice->hashed_id,
"subject"=> 'Reminder $number',
"template"=> "first_custom"
];
@ -218,15 +219,16 @@ class InvoiceEmailTest extends TestCase
$this->invoice->save();
Bus::fake();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
Bus::assertDispatched(EmailEntity::class);
}
});
$this->assertTrue(true);
}
public function testTemplateThemes()
@ -246,11 +248,15 @@ class InvoiceEmailTest extends TestCase
$this->invoice->save();
Bus::fake();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
Bus::assertDispatched(EmailEntity::class);
}
});
@ -273,12 +279,15 @@ class InvoiceEmailTest extends TestCase
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
Bus::fake();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
Bus::assertDispatched(EmailEntity::class);
}
});
@ -296,12 +305,15 @@ class InvoiceEmailTest extends TestCase
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
Bus::fake();
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
Bus::assertDispatched(EmailEntity::class);
}
});

View File

@ -26,7 +26,6 @@ use App\Models\Payment;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
@ -42,7 +41,6 @@ class PaymentTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
use WithoutEvents;
protected function setUp() :void
{

View File

@ -23,7 +23,6 @@ use App\Factory\InvoiceItemFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -36,7 +35,6 @@ class PaymentV2Test extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
use WithoutEvents;
public $faker;

View File

@ -20,7 +20,6 @@ use App\Models\Payment;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
@ -35,7 +34,6 @@ class CreditPaymentTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockUnitData;
use WithoutEvents;
protected function setUp() :void
{

View File

@ -14,7 +14,6 @@ namespace Tests\Feature\Payments;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
@ -29,7 +28,6 @@ class StorePaymentValidationTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
use WithoutEvents;
protected function setUp() :void
{

View File

@ -17,7 +17,6 @@ use App\Models\Invoice;
use App\Models\Payment;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Validation\ValidationException;
use Tests\MockUnitData;
@ -31,8 +30,7 @@ class UnappliedPaymentDeleteTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockUnitData;
use WithoutEvents;
protected function setUp() :void
{
parent::setUp();

View File

@ -14,7 +14,6 @@ namespace Tests\Feature\Payments;
use App\Models\Payment;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Validation\ValidationException;
use Tests\MockUnitData;
@ -28,7 +27,6 @@ class UnappliedPaymentRefundTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockUnitData;
use WithoutEvents;
protected function setUp() :void
{

View File

@ -467,7 +467,6 @@ class ReminderTest extends TestCase
$this->assertEquals(Carbon::parse($this->invoice->next_send_date)->format('Y-m-d'), Carbon::now()->addDays(7)->format('Y-m-d'));
// ReminderJob::dispatchNow();
}
public function testReminderHitsScenarioH1()
@ -492,7 +491,6 @@ class ReminderTest extends TestCase
$this->assertEquals(Carbon::parse($this->invoice->next_send_date)->format('Y-m-d'), Carbon::now()->addDays(30)->subDays(2)->format('Y-m-d'));
// ReminderJob::dispatchNow();
}
/* Cant set a reminder in the past so need to skip reminder 2 and go straigh to reminder 3*/

View File

@ -21,11 +21,6 @@ use App\Models\RecurringInvoice;
use App\Factory\SchedulerFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;
use App\DataMapper\Schedule\EmailStatement;
use App\Services\Scheduler\SchedulerService;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\WithoutEvents;
use App\Services\Scheduler\EmailStatementService;
use Illuminate\Routing\Middleware\ThrottleRequests;
/**
@ -36,7 +31,6 @@ class ScheduleEntityTest extends TestCase
{
use MakesHash;
use MockAccountData;
use WithoutEvents;
protected function setUp(): void
{

View File

@ -24,7 +24,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;
use App\DataMapper\Schedule\EmailStatement;
use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\WithoutEvents;
use App\Services\Scheduler\EmailStatementService;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -37,7 +36,6 @@ class SchedulerTest extends TestCase
{
use MakesHash;
use MockAccountData;
use WithoutEvents;
use DatabaseTransactions;
protected $faker;

View File

@ -33,7 +33,6 @@ class UpdatePaymentTest extends TestCase
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
use WithoutEvents;
public $faker;

View File

@ -15,6 +15,7 @@ use Tests\TestCase;
use App\Utils\Ninja;
use Tests\MockAccountData;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Event;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;
use App\Events\Vendor\VendorContactLoggedIn;
@ -62,9 +63,11 @@ class VendorApiTest extends TestCase
$this->assertNull($v->last_login);
$this->assertNull($vc->last_login);
Event::fake();
event(new VendorContactLoggedIn($vc, $this->company, Ninja::eventVars()));
$this->expectsEvents([VendorContactLoggedIn::class]);
Event::assertDispatched(VendorContactLoggedIn::class);
// $vc->fresh();
// $v->fresh();

View File

@ -8,79 +8,82 @@
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Integration;
use App\Events\Client\ClientWasArchived;
use App\Events\Client\ClientWasCreated;
use App\Events\Client\ClientWasDeleted;
use App\Events\Client\ClientWasRestored;
use App\Events\Client\ClientWasUpdated;
use App\Events\Credit\CreditWasArchived;
use App\Events\Credit\CreditWasCreated;
use App\Events\Credit\CreditWasDeleted;
use App\Events\Credit\CreditWasRestored;
use App\Events\Credit\CreditWasUpdated;
use App\Events\Expense\ExpenseWasArchived;
use App\Events\Expense\ExpenseWasCreated;
use App\Events\Expense\ExpenseWasDeleted;
use App\Events\Expense\ExpenseWasRestored;
use App\Events\Expense\ExpenseWasUpdated;
use App\Events\Invoice\InvoiceWasArchived;
use App\Events\Invoice\InvoiceWasCreated;
use App\Events\Invoice\InvoiceWasDeleted;
use App\Events\Invoice\InvoiceWasRestored;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Events\Payment\PaymentWasArchived;
use App\Events\Payment\PaymentWasCreated;
use App\Events\Payment\PaymentWasDeleted;
use App\Events\Payment\PaymentWasRestored;
use App\Events\Payment\PaymentWasUpdated;
use App\Events\PurchaseOrder\PurchaseOrderWasArchived;
use App\Events\PurchaseOrder\PurchaseOrderWasCreated;
use App\Events\PurchaseOrder\PurchaseOrderWasDeleted;
use App\Events\PurchaseOrder\PurchaseOrderWasRestored;
use App\Events\PurchaseOrder\PurchaseOrderWasUpdated;
use App\Events\Quote\QuoteWasApproved;
use App\Events\Quote\QuoteWasArchived;
use App\Events\Quote\QuoteWasCreated;
use App\Events\Quote\QuoteWasDeleted;
use App\Events\Quote\QuoteWasRestored;
use App\Events\Quote\QuoteWasUpdated;
use App\Events\RecurringInvoice\RecurringInvoiceWasArchived;
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted;
use App\Events\RecurringInvoice\RecurringInvoiceWasRestored;
use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
use App\Events\Subscription\SubscriptionWasArchived;
use App\Events\Subscription\SubscriptionWasCreated;
use App\Events\Subscription\SubscriptionWasDeleted;
use App\Events\Subscription\SubscriptionWasRestored;
use App\Events\Subscription\SubscriptionWasUpdated;
use App\Events\Task\TaskWasArchived;
use Tests\TestCase;
use App\Models\Quote;
use App\Models\Invoice;
use Tests\MockAccountData;
use App\Models\PurchaseOrder;
use App\Utils\Traits\MakesHash;
use App\Events\Task\TaskWasCreated;
use App\Events\Task\TaskWasDeleted;
use App\Events\Task\TaskWasRestored;
use App\Events\Task\TaskWasUpdated;
use App\Events\User\UserWasArchived;
use App\Events\User\UserWasCreated;
use App\Events\User\UserWasDeleted;
use App\Events\User\UserWasRestored;
use App\Events\User\UserWasUpdated;
use App\Events\Vendor\VendorWasArchived;
use App\Events\Task\TaskWasArchived;
use App\Events\Task\TaskWasRestored;
use App\Events\User\UserWasArchived;
use App\Events\User\UserWasRestored;
use App\Events\Quote\QuoteWasCreated;
use App\Events\Quote\QuoteWasDeleted;
use App\Events\Quote\QuoteWasUpdated;
use Illuminate\Support\Facades\Event;
use App\Events\Quote\QuoteWasApproved;
use App\Events\Quote\QuoteWasArchived;
use App\Events\Quote\QuoteWasRestored;
use App\Events\Client\ClientWasCreated;
use App\Events\Client\ClientWasDeleted;
use App\Events\Client\ClientWasUpdated;
use App\Events\Credit\CreditWasCreated;
use App\Events\Credit\CreditWasDeleted;
use App\Events\Credit\CreditWasUpdated;
use App\Events\Vendor\VendorWasCreated;
use App\Events\Vendor\VendorWasDeleted;
use App\Events\Vendor\VendorWasRestored;
use App\Events\Vendor\VendorWasUpdated;
use App\Http\Middleware\PasswordProtection;
use App\Models\Invoice;
use App\Models\Quote;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests;
use App\Events\Client\ClientWasArchived;
use App\Events\Client\ClientWasRestored;
use App\Events\Credit\CreditWasArchived;
use App\Events\Credit\CreditWasRestored;
use App\Events\Vendor\VendorWasArchived;
use App\Events\Vendor\VendorWasRestored;
use App\Events\Expense\ExpenseWasCreated;
use App\Events\Expense\ExpenseWasDeleted;
use App\Events\Expense\ExpenseWasUpdated;
use App\Events\Invoice\InvoiceWasCreated;
use App\Events\Invoice\InvoiceWasDeleted;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Events\Payment\PaymentWasCreated;
use App\Events\Payment\PaymentWasDeleted;
use App\Events\Payment\PaymentWasUpdated;
use App\Events\Expense\ExpenseWasArchived;
use App\Events\Expense\ExpenseWasRestored;
use App\Events\Invoice\InvoiceWasArchived;
use App\Events\Invoice\InvoiceWasRestored;
use App\Events\Payment\PaymentWasArchived;
use App\Events\Payment\PaymentWasRestored;
use App\Http\Middleware\PasswordProtection;
use Illuminate\Validation\ValidationException;
use Tests\MockAccountData;
use Tests\TestCase;
use App\Events\Subscription\SubscriptionWasCreated;
use App\Events\Subscription\SubscriptionWasDeleted;
use App\Events\Subscription\SubscriptionWasUpdated;
use Illuminate\Routing\Middleware\ThrottleRequests;
use App\Events\Subscription\SubscriptionWasArchived;
use App\Events\Subscription\SubscriptionWasRestored;
use App\Events\PurchaseOrder\PurchaseOrderWasCreated;
use App\Events\PurchaseOrder\PurchaseOrderWasDeleted;
use App\Events\PurchaseOrder\PurchaseOrderWasUpdated;
use App\Events\PurchaseOrder\PurchaseOrderWasArchived;
use App\Events\PurchaseOrder\PurchaseOrderWasRestored;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted;
use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
use App\Events\RecurringInvoice\RecurringInvoiceWasArchived;
use App\Events\RecurringInvoice\RecurringInvoiceWasRestored;
/**
* @test
@ -91,7 +94,9 @@ class EventTest extends TestCase
use MakesHash;
use DatabaseTransactions;
public function setUp() :void
public $faker;
public function setUp(): void
{
parent::setUp();
@ -109,13 +114,7 @@ class EventTest extends TestCase
public function testExpenseEvents()
{
$this->expectsEvents([
ExpenseWasCreated::class,
ExpenseWasUpdated::class,
ExpenseWasArchived::class,
ExpenseWasRestored::class,
ExpenseWasDeleted::class,
]);
Event::fake();
$data = [
'public_notes' => $this->faker->firstName,
@ -162,18 +161,21 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/expenses/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(ExpenseWasCreated::class);
Event::assertDispatched(ExpenseWasUpdated::class);
Event::assertDispatched(ExpenseWasArchived::class);
Event::assertDispatched(ExpenseWasRestored::class);
Event::assertDispatched(ExpenseWasDeleted::class);
}
public function testVendorEvents()
{
$this->expectsEvents([
VendorWasCreated::class,
VendorWasUpdated::class,
VendorWasArchived::class,
VendorWasRestored::class,
VendorWasDeleted::class,
]);
Event::fake();
$data = [
'name' => $this->faker->firstName,
@ -221,6 +223,14 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/vendors/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(VendorWasCreated::class);
Event::assertDispatched(VendorWasUpdated::class);
Event::assertDispatched(VendorWasArchived::class);
Event::assertDispatched(VendorWasRestored::class);
Event::assertDispatched(VendorWasDeleted::class);
}
@ -232,13 +242,8 @@ class EventTest extends TestCase
'description' => 'dude',
];
$this->expectsEvents([
TaskWasCreated::class,
TaskWasUpdated::class,
TaskWasArchived::class,
TaskWasRestored::class,
TaskWasDeleted::class,
]);
Event::fake();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -282,6 +287,14 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/tasks/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(TaskWasCreated::class);
Event::assertDispatched(TaskWasUpdated::class);
Event::assertDispatched(TaskWasArchived::class);
Event::assertDispatched(TaskWasRestored::class);
Event::assertDispatched(TaskWasDeleted::class);
}
public function testCreditEvents()
@ -292,13 +305,7 @@ class EventTest extends TestCase
'number' => 'dude',
];
$this->expectsEvents([
CreditWasCreated::class,
CreditWasUpdated::class,
CreditWasArchived::class,
CreditWasRestored::class,
CreditWasDeleted::class,
]);
Event::fake();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -342,8 +349,17 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/credits/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(CreditWasCreated::class);
Event::assertDispatched(CreditWasUpdated::class);
Event::assertDispatched(CreditWasArchived::class);
Event::assertDispatched(CreditWasRestored::class);
Event::assertDispatched(CreditWasDeleted::class);
}
public function testQuoteEvents()
{
/* Test fire new invoice */
@ -352,14 +368,8 @@ class EventTest extends TestCase
'number' => 'dude',
];
$this->expectsEvents([
QuoteWasCreated::class,
QuoteWasUpdated::class,
QuoteWasArchived::class,
QuoteWasRestored::class,
QuoteWasDeleted::class,
QuoteWasApproved::class,
]);
Event::fake();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -413,6 +423,15 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/quotes/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(QuoteWasCreated::class);
Event::assertDispatched(QuoteWasUpdated::class);
Event::assertDispatched(QuoteWasArchived::class);
Event::assertDispatched(QuoteWasRestored::class);
Event::assertDispatched(QuoteWasDeleted::class);
Event::assertDispatched(QuoteWasApproved::class);
}
@ -421,13 +440,8 @@ class EventTest extends TestCase
public function testPaymentEvents()
{
$this->expectsEvents([
PaymentWasCreated::class,
PaymentWasUpdated::class,
PaymentWasArchived::class,
PaymentWasRestored::class,
PaymentWasDeleted::class,
]);
Event::fake();
$data = [
'amount' => $this->invoice->amount,
@ -481,6 +495,14 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/payments/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(PaymentWasCreated::class);
Event::assertDispatched(PaymentWasUpdated::class);
Event::assertDispatched(PaymentWasArchived::class);
Event::assertDispatched(PaymentWasRestored::class);
Event::assertDispatched(PaymentWasDeleted::class);
}
@ -492,13 +514,8 @@ class EventTest extends TestCase
'number' => 'dude',
];
$this->expectsEvents([
InvoiceWasCreated::class,
InvoiceWasUpdated::class,
InvoiceWasArchived::class,
InvoiceWasRestored::class,
InvoiceWasDeleted::class,
]);
Event::fake();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -542,6 +559,14 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/invoices/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(InvoiceWasCreated::class);
Event::assertDispatched(InvoiceWasUpdated::class);
Event::assertDispatched(InvoiceWasArchived::class);
Event::assertDispatched(InvoiceWasRestored::class);
Event::assertDispatched(InvoiceWasDeleted::class);
}
@ -555,13 +580,8 @@ class EventTest extends TestCase
'frequency_id' => 1,
];
$this->expectsEvents([
RecurringInvoiceWasCreated::class,
RecurringInvoiceWasUpdated::class,
RecurringInvoiceWasArchived::class,
RecurringInvoiceWasRestored::class,
RecurringInvoiceWasDeleted::class,
]);
Event::fake();
try {
$response = $this->withHeaders([
@ -569,7 +589,7 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/recurring_invoices/', $data);
} catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
// $message = json_decode($e->validator->getMessageBag(), 1);
}
$response->assertStatus(200);
@ -611,19 +631,21 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/recurring_invoices/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(RecurringInvoiceWasCreated::class);
Event::assertDispatched(RecurringInvoiceWasUpdated::class);
Event::assertDispatched(RecurringInvoiceWasArchived::class);
Event::assertDispatched(RecurringInvoiceWasRestored::class);
Event::assertDispatched(RecurringInvoiceWasDeleted::class);
}
public function testClientEvents()
{
$this->expectsEvents([
ClientWasCreated::class,
ClientWasUpdated::class,
ClientWasArchived::class,
ClientWasRestored::class,
ClientWasDeleted::class,
]);
Event::fake();
$data = [
'name' => $this->faker->firstName,
@ -669,6 +691,14 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/clients/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(ClientWasCreated::class);
Event::assertDispatched(ClientWasUpdated::class);
Event::assertDispatched(ClientWasArchived::class);
Event::assertDispatched(ClientWasRestored::class);
Event::assertDispatched(ClientWasDeleted::class);
}
@ -676,13 +706,7 @@ class EventTest extends TestCase
{
$this->withoutMiddleware(PasswordProtection::class);
$this->expectsEvents([
UserWasCreated::class,
UserWasUpdated::class,
UserWasArchived::class,
UserWasRestored::class,
UserWasDeleted::class,
]);
Event::fake();
$data = [
'first_name' => 'hey',
@ -701,7 +725,7 @@ class EventTest extends TestCase
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
])->postJson('/api/v1/users?include=company_user', $data)
->assertStatus(200);
$arr = $response->json();
$data = [
@ -747,17 +771,27 @@ class EventTest extends TestCase
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
])->postJson('/api/v1/users/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(UserWasCreated::class);
Event::assertDispatched(UserWasUpdated::class);
Event::assertDispatched(UserWasArchived::class);
Event::assertDispatched(UserWasRestored::class);
Event::assertDispatched(UserWasDeleted::class);
}
public function testSubscriptionEvents()
{
$this->expectsEvents([
SubscriptionWasCreated::class,
SubscriptionWasUpdated::class,
SubscriptionWasArchived::class,
SubscriptionWasRestored::class,
SubscriptionWasDeleted::class,
]);
Event::fake();
$data = [
'name' => $this->faker->firstName,
@ -804,76 +838,85 @@ class EventTest extends TestCase
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/subscriptions/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(SubscriptionWasCreated::class);
Event::assertDispatched(SubscriptionWasUpdated::class);
Event::assertDispatched(SubscriptionWasArchived::class);
Event::assertDispatched(SubscriptionWasRestored::class);
Event::assertDispatched(SubscriptionWasDeleted::class);
}
public function PurchaseOrderEvents()
{
/* Test fire new invoice */
$data = [
'client_id' => $this->vendor->hashed_id,
'number' => 'dude',
];
public function testPurchaseOrderEvents()
{
/* Test fire new invoice */
$data = [
'vendor_id' => $this->vendor->hashed_id,
'number' => 'dude',
];
$this->expectsEvents([
PurchaseOrderWasCreated::class,
PurchaseOrderWasUpdated::class,
PurchaseOrderWasArchived::class,
PurchaseOrderWasRestored::class,
PurchaseOrderWasDeleted::class,
]);
Event::fake();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/', $data)
->assertStatus(200);
$arr = $response->json();
$arr = $response->json();
$data = [
'client_id' => $this->vendor->hashed_id,
'number' => 'dude2',
];
$data = [
'vendor_id' => $this->vendor->hashed_id,
'number' => 'dude2',
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/purchase_orders/' . $arr['data']['id'], $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/purchase_orders/' . $arr['data']['id'], $data)
->assertStatus(200);
$data = [
'ids' => [$arr['data']['id']],
];
$data = [
'ids' => [$arr['data']['id']],
];
$quote = PurchaseOrder::find($this->decodePrimaryKey($arr['data']['id']));
$quote->status_id = PurchaseOrder::STATUS_SENT;
$quote->save();
$quote = PurchaseOrder::find($this->decodePrimaryKey($arr['data']['id']));
$quote->status_id = PurchaseOrder::STATUS_SENT;
$quote->save();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=archive', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=archive', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=restore', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=restore', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=approve', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=mark_sent', $data)
->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=delete', $data)
->assertStatus(200);
}
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/purchase_orders/bulk?action=delete', $data)
->assertStatus(200);
Event::assertDispatched(PurchaseOrderWasCreated::class);
Event::assertDispatched(PurchaseOrderWasUpdated::class);
Event::assertDispatched(PurchaseOrderWasArchived::class);
Event::assertDispatched(PurchaseOrderWasRestored::class);
Event::assertDispatched(PurchaseOrderWasDeleted::class);
}
}

View File

@ -57,7 +57,6 @@ use App\Models\VendorContact;
use App\Utils\Traits\GeneratesCounter;
use App\Utils\Traits\MakesHash;
use App\Utils\TruthSource;
use Illuminate\Foundation\Testing\WithoutEvents;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
@ -71,7 +70,6 @@ trait MockAccountData
{
use MakesHash;
use GeneratesCounter;
use WithoutEvents;
/**
* @var
@ -726,7 +724,6 @@ trait MockAccountData
$this->invoice->save();
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount);
// UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->invoice->amount, $this->invoice->company);
$user_id = $this->invoice->user_id;

View File

@ -2,6 +2,7 @@
namespace Tests;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase

View File

@ -34,7 +34,6 @@ class GoogleAnalyticsTest extends TestCase
public function testGoogleAnalyticsLogic()
{
$this->withoutEvents();
$analytics_id = 'analytics_id';
$invoice = $this->invoice;

View File

@ -43,7 +43,6 @@ class InvoiceActionsTest extends TestCase
public function testInvoiceIsReversable()
{
$this->withoutEvents();
$this->invoice = $this->invoice->service()->markPaid()->save();
@ -54,7 +53,6 @@ class InvoiceActionsTest extends TestCase
public function testInvoiceIsCancellable()
{
$this->withoutEvents();
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
$payment->amount = 40;
@ -73,7 +71,6 @@ class InvoiceActionsTest extends TestCase
public function testInvoiceUnactionable()
{
$this->withoutEvents();
$this->invoice->delete();

View File

@ -11,26 +11,7 @@
namespace Tests\Unit\Migration;
use App\Exceptions\ResourceDependencyMissing;
use App\Exceptions\ResourceNotAvailableForMigration;
use App\Jobs\Util\Import;
use App\Jobs\Util\StartMigration;
use App\Mail\MigrationFailed;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\ClientGatewayToken;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\Credit;
use App\Models\Document;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Product;
use App\Models\Quote;
use App\Models\TaxRate;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Mail;
use Tests\MockAccountData;
use Tests\TestCase;
@ -59,433 +40,4 @@ class ImportTest extends TestCase
$this->assertTrue($status);
}
// public function testAllImport()
// {
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// $this->user->setCompany($this->company);
// auth()->login($this->user, true);
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertTrue(true);
// }
// public function testExceptionOnUnavailableResource()
// {
// $data['panda_bears'] = [
// 'name' => 'Awesome Panda Bear',
// ];
// try {
// Import::dispatchNow($data, $this->company, $this->user);
// }
// catch (ResourceNotAvailableForMigration $e) {
// $this->assertTrue(true);
// }
// }
// public function testCompanyUpdating()
// {
// $original_company_key = $this->company->company_key;
// $data['company'] = [
// 'company_key' => 0,
// ];
// Import::dispatchNow($data, $this->company, $this->user);
// $this->assertNotEquals($original_company_key, $this->company->company_key);
// }
// public function testInvoicesFailsWithoutClient()
// {
// $data['invoices'] = [
// 0 => [
// 'client_id' => 1,
// 'is_amount_discount' => false,
// ]
// ];
// try {
// Import::dispatchNow($data, $this->company, $this->user);
// } catch(ResourceDependencyMissing $e) {
// $this->assertTrue(true);
// }
// }
// public function testInvoicesImporting()
// {
// $this->makeTestData();
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// $original_count = Invoice::count();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertGreaterThan($original_count, Invoice::count());
// }
// public function testQuotesFailsWithoutClient()
// {
// $data['quotes'] = [
// 0 => [
// 'client_id' => 1,
// 'is_amount_discount' => false,
// ]
// ];
// try {
// Import::dispatchNow($data, $this->company, $this->user);
// } catch(ResourceDependencyMissing $e) {
// $this->assertTrue(true);
// }
// }
// public function testImportFileExists()
// {
// $this->assertGreaterThan(1, count($this->migration_array));
// }
// public function testClientAttributes()
// {
// $original_number = Client::count();
// $random_balance = rand(0, 10);
// $data['clients'] = [
// 0 => [
// 'id' => 1,
// 'name' => 'My awesome unique client',
// 'balance' => $random_balance,
// 'user_id' => 1,
// ]
// ];
// Import::dispatchNow($data, $this->company, $this->user);
// $client = Client::where('name', 'My awesome unique client')
// ->where('balance', $random_balance)
// ->first();
// $this->assertNotNull($client);
// $this->assertGreaterThan($original_number, Client::count());
// $this->assertGreaterThanOrEqual(0, $client->balance);
// }
// // public function testInvoiceAttributes()
// // {
// // $original_number = Invoice::count();
// // $this->invoice->forceDelete();
// // $migration_file = base_path() . '/tests/Unit/Migration/migration.json';
// // $this->migration_array = json_decode(file_get_contents($migration_file), 1);
// // Import::dispatchNow($this->migration_array, $this->company, $this->user);
// // $this->assertGreaterThan($original_number, Invoice::count());
// // $invoice_1 = Invoice::whereNumber('0001')
// // // ->where('discount', '0.00')
// // // ->where('date', '2020-03-18')
// // ->first();
// // $invoice_2 = Invoice::whereNumber('0018')
// // // ->where('discount', '0.00')
// // // ->where('date', '2019-10-15')
// // ->first();
// // $this->assertNotNull($invoice_1);
// // $this->assertNotNull($invoice_2);
// // $this->assertEquals('13.5000', $invoice_1->amount);
// // $this->assertEquals('67.4100', $invoice_2->amount);
// // $this->assertEquals('8.4900', $invoice_1->balance);
// // $this->assertEquals('50.4200', $invoice_2->balance);
// // }
// // public function testQuoteAttributes()
// // {
// // $original_number = Quote::count();
// // $this->invoice->forceDelete();
// // $migration_file = base_path() . '/tests/Unit/Migration/migration.json';
// // $this->migration_array = json_decode(file_get_contents($migration_file), 1);
// // Import::dispatchNow($this->migration_array, $this->company, $this->user);
// // $this->assertGreaterThan($original_number, Invoice::count());
// // $quote = Quote::whereNumber('0021')
// // ->whereDiscount('0.00')
// // ->first();
// // $this->assertNotNull($quote);
// // $this->assertEquals('0.0000', $quote->amount);
// // $this->assertEquals('0.0000', $quote->balance);
// // }
// public function testPaymentsImport()
// {
// $original_count = Payment::count();
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertGreaterThan($original_count, Payment::count());
// }
// public function testPaymentDependsOnClient()
// {
// $data['payments'] = [
// 0 => [
// 'client_id' => 1,
// 'amount' => 1,
// ]
// ];
// try {
// Import::dispatchNow($data, $this->company, $this->user);
// } catch(ResourceDependencyMissing $e) {
// $this->assertTrue(true);
// }
// }
// public function testQuotesImport()
// {
// $original_count = Credit::count();
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertGreaterThan($original_count, Credit::count());
// }
// public function testMigrationFileExists()
// {
// $migration_archive = base_path() . '/tests/Unit/Migration/migration.zip';
// $this->assertTrue(file_exists($migration_archive));
// }
// // public function testMigrationFileBeingExtracted()
// // {
// // $migration_archive = base_path() . '/tests/Unit/Migration/migration.zip';
// // StartMigration::dispatchNow($migration_archive, $this->user, $this->company);
// // $extracted_archive = storage_path("migrations/migration");
// // $migration_file = storage_path("migrations/migration/migration.json");
// // $this->assertTrue(file_exists($extracted_archive));
// // $this->assertTrue(is_dir($extracted_archive));
// // $this->assertTrue(file_exists($migration_file));
// // }
// public function testValidityOfImportedData()
// {
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $differences = [];
// foreach ($this->migration_array['invoices'] as $key => $invoices) {
// $record = Invoice::whereNumber($invoices['number'])
// ->whereAmount($invoices['amount'])
// ->whereBalance($invoices['balance'])
// ->first();
// if (!$record) {
// $differences['invoices']['missing'][] = $invoices['id'];
// }
// }
// foreach ($this->migration_array['users'] as $key => $user) {
// $record = User::whereEmail($user['email'])->first();
// if (!$record) {
// $differences['users']['missing'][] = $user['email'];
// }
// }
// foreach ($this->migration_array['tax_rates'] as $key => $tax_rate) {
// $record = TaxRate::whereName($tax_rate['name'])
// ->where('rate', $tax_rate['rate'])
// ->first();
// if (!$record) {
// $differences['tax_rates']['missing'][] = $tax_rate['name'];
// }
// }
// foreach ($this->migration_array['clients'] as $key => $client) {
// $record = Client::whereName($client['name'])
// ->whereCity($client['city'])
// // ->where('paid_to_date', $client['paid_to_date']) // TODO: Doesn't work. Need debugging.
// ->first();
// if (!$record) {
// $differences['clients']['missing'][] = $client['name'];
// }
// }
// foreach ($this->migration_array['products'] as $key => $product) {
// $record = Product::where('product_key', $product['product_key'])
// ->first();
// if (!$record) {
// $differences['products']['missing'][] = $product['notes'];
// }
// }
// foreach ($this->migration_array['quotes'] as $key => $quote) {
// $record = Quote::whereNumber($quote['number'])
// ->whereIsAmountDiscount($quote['is_amount_discount'])
// ->whereDueDate($quote['due_date'])
// ->first();
// if (!$record) {
// $differences['quotes']['missing'][] = $quote['id'];
// }
// }
// foreach ($this->migration_array['payments'] as $key => $payment) {
// $record = Payment::whereApplied($payment['applied'])
// ->first();
// if (!$record) {
// $differences['payments']['missing'][] = $payment['id'];
// }
// }
// foreach ($this->migration_array['credits'] as $key => $credit) {
// // The Import::processCredits() does insert the credit record with number: 0053,
// // .. however this part of the code doesn't see it at all.
// $record = Credit::whereNumber($credit['number'])
// ->first();
// if (!$record) {
// $differences['credits']['missing'][] = $credit['id'];
// }
// }
// /*
// foreach ($this->migration_array['company_gateways'] as $key => $company_gateway) {
// // The Import::processCredits() does insert the credit record with number: 0053,
// // .. however this part of the code doesn't see it at all.
// $record = CompanyGateway::where('gateway_key' ,$company_gateway['gateway_key'])
// ->first();
// if (!$record) {
// $differences['company_gateways']['missing'][] = $company_gateway['id'];
// }
// }
// foreach ($this->migration_array['client_gateway_tokens'] as $key => $cgt) {
// // The Import::processCredits() does insert the credit record with number: 0053,
// // .. however this part of the code doesn't see it at all.
// $record = ClientGatewayToken::where('token' ,$cgt['token'])
// ->first();
// if (!$record) {
// $differences['client_gateway_tokens']['missing'][] = $cgt['id'];
// }
// }
// */
// //@TODO we can uncomment tests for documents when we have imported expenses.
// // foreach ($this->migration_array['documents'] as $key => $document) {
// // if(!is_null($document['invoice_id'])) {
// // $record = Document::where('hash', $document['hash'])
// // ->first();
// // if (!$record) {
// // $differences['documents']['missing'][] = $document['id'];
// // }
// // }
// // }
// //\Log::error($differences);
// $this->assertCount(0, $differences);
// }
// public function testClientContactsImport()
// {
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// $original = ClientContact::count();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertGreaterThan($original, ClientContact::count());
// }
// public function testClientGatewayTokensImport()
// {
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// $original = ClientGatewayToken::count();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $this->assertTrue(true, 'ClientGatewayTokens importing not completed yet.');
// }
// public function testDocumentsImport()
// {
// $this->invoice->forceDelete();
// $this->quote->forceDelete();
// $original = Document::count();
// Import::dispatchNow($this->migration_array, $this->company, $this->user);
// $document = Document::first();
// $this->assertTrue(true, 'Documents importing not completed yet. Missing expenses.');
// }
// public function testExceptionMailSending()
// {
// Mail::fake();
// $data['panda_bears'] = [
// 'name' => 'Awesome Panda Bear',
// ];
// try {
// Import::dispatchNow($data, $this->company, $this->user);
// }
// catch (ResourceNotAvailableForMigration $e) {
// Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
// $this->assertTrue(true);
// }
// }
}

View File

@ -15,10 +15,13 @@ namespace Tests\Unit;
use App\Models\Account;
use App\Models\Company;
use App\Models\Document;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
class WithTypeHelpersTest extends TestCase
{
use DatabaseMigrations;
public function testIsImageHelper(): void
{
$account = Account::factory()->create();