1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00
This commit is contained in:
David Bomba 2024-01-14 15:05:00 +11:00
parent 78aebe6bf7
commit 40086db271
1169 changed files with 63936 additions and 63546 deletions

View File

@ -59,7 +59,7 @@ class BackupUpdate extends Command
if(Ninja::isSelfHost()) {
return;
}
$current_db = config('database.default');
if (! config('ninja.db.multi_db_enabled')) {
@ -91,7 +91,7 @@ class BackupUpdate extends Command
$logo = @file_get_contents($company_logo_path);
$extension = @pathinfo($company->settings->company_logo, PATHINFO_EXTENSION);
if ($logo && $extension) {
$path = "{$company->company_key}/{$company->company_key}.{$extension}";
@ -117,7 +117,7 @@ class BackupUpdate extends Command
$logo = @file_get_contents($company_logo_path);
$extension = @pathinfo($company_logo_path, PATHINFO_EXTENSION);
if ($logo && $extension) {
$path = "{$client->company->company_key}/{$client->client_hash}.{$extension}";
@ -148,7 +148,7 @@ class BackupUpdate extends Command
$logo = @file_get_contents($company_logo_path);
$extension = @pathinfo($company_logo_path, PATHINFO_EXTENSION);
if ($logo && $extension) {
$path = "{$group->company->company_key}/{$group->hashed_id}.{$extension}";

View File

@ -192,7 +192,7 @@ class CheckData extends Command
}
});
}
/**
* checkOauthSanity
*
@ -311,7 +311,7 @@ class CheckData extends Command
if ($this->option('fix') == 'true') {
foreach ($clients as $client) {
$this->logMessage("Fixing missing contacts #{$client->id}");
$new_contact = ClientContactFactory::create($client->company_id, $client->user_id);
$new_contact->client_id = $client->id;
$new_contact->contact_key = Str::random(40);
@ -345,9 +345,9 @@ class CheckData extends Command
]);
}
}
$vendors = Vendor::withTrashed()->doesntHave('contacts');
$this->logMessage($vendors->count().' vendors without any contacts');
if ($vendors->count() > 0) {
@ -359,7 +359,7 @@ class CheckData extends Command
foreach ($vendors as $vendor) {
$this->logMessage("Fixing missing vendor contacts #{$vendor->id}");
$new_contact = VendorContactFactory::create($vendor->company_id, $vendor->user_id);
$new_contact->vendor_id = $vendor->id;
$new_contact->contact_key = Str::random(40);
@ -411,7 +411,7 @@ class CheckData extends Command
private function checkEntityInvitations()
{
RecurringInvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
InvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
QuoteInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
@ -434,7 +434,7 @@ class CheckData extends Command
$ii->viewed_date = null;
$ii->saveQuietly();
});
CreditInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
$ii->sent_date = null;
$ii->saveQuietly();
@ -537,7 +537,7 @@ class CheckData extends Command
HAVING payments_applied != client_paid_to_date
ORDER BY clients.id;
");
return $results;
}
@ -556,7 +556,7 @@ class CheckData extends Command
AND payments.is_deleted = 0
AND payments.client_id = ?;
", [App\Models\Credit::class, $client->id]);
return $results;
}
@ -565,7 +565,7 @@ class CheckData extends Command
$clients_to_check = $this->clientPaidToDateQuery();
$this->wrong_paid_to_dates = 0;
foreach ($clients_to_check as $_client) {
$client = Client::withTrashed()->find($_client->client_id);
@ -610,7 +610,7 @@ class CheckData extends Command
HAVING invoice_balance != clients.balance
ORDER BY clients.id;
");
return $results;
}
@ -623,14 +623,14 @@ class CheckData extends Command
foreach ($clients as $client) {
$client = (array)$client;
if ((string) $client['invoice_balance'] != (string) $client['client_balance']) {
$this->wrong_paid_to_dates++;
$client_object = Client::withTrashed()->find($client['client_id']);
$this->logMessage($client_object->present()->name().' - '.$client_object->id." - calculated client balances do not match Invoice Balances = ". $client['invoice_balance'] ." - Client Balance = ".rtrim($client['client_balance'], '0'));
if ($this->option('client_balance')) {
$this->logMessage("# {$client_object->id} " . $client_object->present()->name().' - '.$client_object->number." Fixing {$client_object->balance} to " . $client['invoice_balance']);
$client_object->balance = $client['invoice_balance'];
@ -658,7 +658,7 @@ class CheckData extends Command
->count();
if ($count == 0) {
$this->isValid = false;
$this->isValid = false;
//factor in over payments to the client balance
$over_payment = Payment::where('client_id', $client->id)
@ -668,7 +668,7 @@ class CheckData extends Command
->pluck('p')
->first();
$over_payment = $over_payment*-1;
$over_payment = $over_payment * -1;
if (floatval($over_payment) == floatval($client->balance)) {
} else {
@ -703,7 +703,7 @@ class CheckData extends Command
HAVING(invoices_balance != clients.balance)
ORDER BY clients.id;
");
return $results;
}
@ -863,14 +863,14 @@ class CheckData extends Command
{
Account::where('plan_expires', '<=', now()->subDays(2))->cursor()->each(function ($account) {
$client = Client::on('db-ninja-01')->where('company_id', config('ninja.ninja_default_company_id'))->where('custom_value2', $account->key)->first();
if ($client) {
$payment = Payment::on('db-ninja-01')
->where('company_id', config('ninja.ninja_default_company_id'))
->where('client_id', $client->id)
->where('date', '>=', now()->subDays(2))
->exists();
if ($payment) {
$this->isValid = false;
@ -913,14 +913,14 @@ class CheckData extends Command
foreach (Invoice::with(['payments'])->where('is_deleted', 0)->where('balance', '>', 0)->whereHas('payments')->where('status_id', 4)->cursor() as $invoice) {
$this->wrong_paid_status++;
$this->logMessage("# {$invoice->id} " . ' - '.$invoice->number." - Marked as paid, but balance = {$invoice->balance}");
if ($this->option('balance_status')) {
$val = $invoice->balance;
$invoice->balance = 0;
$invoice->paid_to_date=$val;
$invoice->paid_to_date = $val;
$invoice->saveQuietly();
$p = $invoice->payments->first();
@ -968,7 +968,7 @@ class CheckData extends Command
if ($c) {
$cc = $c->contacts()->first();
if ($cc) {
$ninja_portal_url = config('ninja.ninja_client_portal')."/client/ninja/{$cc->contact_key}/{$cu->account->key}";
@ -995,7 +995,7 @@ class CheckData extends Command
$bt->save();
$this->logMessage("Fixing - {$bt->id}");
}
});
@ -1023,32 +1023,34 @@ class CheckData extends Command
public function checkSubdomainsSet()
{
if(Ninja::isSelfHost())
if(Ninja::isSelfHost()) {
return;
}
Company::query()
->whereNull('subdomain')
->orWhere('subdomain', '')
->cursor()
->each(function ($c){
->each(function ($c) {
$c->subdomain = MultiDB::randomSubdomainGenerator();
$c->save();
});
}
public function checkPaymentCurrency()
{
$p = Payment::with('company','client')
$p = Payment::with('company', 'client')
->withTrashed()
->where('currency_id', '')
->orWhereNull('currency_id');
$this->logMessage($p->count() . " Payments with No currency set");
if($p->count() != 0)
if($p->count() != 0) {
$this->isValid = false;
}
if ($this->option('fix') == 'true') {

View File

@ -29,7 +29,8 @@ use Illuminate\Support\Str;
class CreateAccount extends Command
{
use MakesHash, GeneratesCounter;
use MakesHash;
use GeneratesCounter;
/**
* @var string
@ -75,10 +76,10 @@ class CreateAccount extends Command
'portal_mode' => 'domain',
'settings' => $settings,
]);
$company->client_registration_fields = ClientRegistrationFields::generate();
$company->save();
$account->default_company_id = $company->id;
$account->set_react_as_default_ap = true;
$account->save();
@ -97,7 +98,7 @@ class CreateAccount extends Command
'phone' => '',
]);
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;

View File

@ -61,10 +61,11 @@ use stdClass;
class CreateSingleAccount extends Command
{
use MakesHash, GeneratesCounter;
use MakesHash;
use GeneratesCounter;
protected $description = 'Create Single Sample Account';
protected $signature = 'ninja:create-single-account {gateway=all} {--database=db-ninja-01}';
protected $invoice_repo;
@ -101,17 +102,17 @@ class CreateSingleAccount extends Command
$this->createSmallAccount();
try {
$pdo = \DB::connection('ronin')->getPdo();
if(class_exists(\Modules\Ronin\app\Models\Admin::class)){
if(class_exists(\Modules\Ronin\app\Models\Admin::class)) {
$this->info('Creating Ronin Account');
$this->createRoninAccount();
}
} catch (\Exception $e) {
}
}
@ -139,7 +140,7 @@ class CreateSingleAccount extends Command
$company = Company::factory()->create([
'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'),
'default_password_timeout' => 30*60000,
'default_password_timeout' => 30 * 60000,
'portal_mode' => 'domain',
'portal_domain' => 'http://ninja.test:8000',
'track_inventory' => true
@ -188,7 +189,7 @@ class CreateSingleAccount extends Command
]);
}
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
@ -377,9 +378,9 @@ class CreateSingleAccount extends Command
$repo->save([], $t);
});
Project::query()->with('client')->whereNotNull('client_id')->cursor()->each(function ($p) {
if($p && $p->client && !isset($p->number)) {
$p->number = $this->getNextProjectNumber($p);
$p->save();
@ -388,7 +389,7 @@ class CreateSingleAccount extends Command
});
$this->info("finished");
}
private function createSubsData($company, $user)
@ -534,7 +535,7 @@ class CreateSingleAccount extends Command
{
$time_log = $this->createTimeLog(rand(1, 20));
$status = TaskStatus::where('company_id', $client->company_id)->get()->random();
return Task::factory()->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id,
@ -581,7 +582,7 @@ class CreateSingleAccount extends Command
'task_rate' => rand(1, 200),
]);
for($x=0; $x < rand(2, 5); $x++) {
for($x = 0; $x < rand(2, 5); $x++) {
$task = $this->createTask($client);
$task->project_id = $project->id;
$task->save();
@ -801,7 +802,7 @@ class CreateSingleAccount extends Command
private function createGateways($company, $user)
{
if (config('ninja.testvars.stripe') && ($this->gateway == 'all' || $this->gateway == 'stripe')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
@ -814,15 +815,15 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.paypal') && ($this->gateway == 'all' || $this->gateway == 'paypal')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e';
@ -835,15 +836,15 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.paypal_rest') && ($this->gateway == 'all' || $this->gateway == 'paypal_rest')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '80af24a6a691230bbec33e930ab40665';
@ -856,8 +857,8 @@ class CreateSingleAccount extends Command
// $gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{3} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{3} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
@ -866,7 +867,7 @@ class CreateSingleAccount extends Command
if (config('ninja.testvars.checkout') && ($this->gateway == 'all' || $this->gateway == 'checkout')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
@ -877,17 +878,17 @@ class CreateSingleAccount extends Command
$cg->config = encrypt(config('ninja.testvars.checkout'));
$cg->save();
$gateway_types = $cg->driver(new Client)->gatewayTypes();
$gateway_types = $cg->driver(new Client())->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.authorize') && ($this->gateway == 'all' || $this->gateway == 'authorizenet')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
@ -898,17 +899,17 @@ class CreateSingleAccount extends Command
$cg->config = encrypt(config('ninja.testvars.authorize'));
$cg->save();
$gateway_types = $cg->driver(new Client)->gatewayTypes();
$gateway_types = $cg->driver(new Client())->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.wepay') && ($this->gateway == 'all' || $this->gateway == 'wepay')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '8fdeed552015b3c7b44ed6c8ebd9e992';
@ -921,15 +922,15 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.braintree') && ($this->gateway == 'all' || $this->gateway == 'braintree')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'f7ec488676d310683fb51802d076d713';
@ -942,8 +943,8 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
@ -951,7 +952,7 @@ class CreateSingleAccount extends Command
if (config('ninja.testvars.paytrace.decrypted') && ($this->gateway == 'all' || $this->gateway == 'paytrace')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'bbd736b3254b0aabed6ad7fda1298c88';
@ -966,15 +967,15 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.mollie') && ($this->gateway == 'all' || $this->gateway == 'mollie')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '1bd651fb213ca0c9d66ae3c336dc77e8';
@ -987,15 +988,15 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.square') && ($this->gateway == 'all' || $this->gateway == 'square')) {
$cg = new CompanyGateway;
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '65faab2ab6e3223dbe848b1686490baz';
@ -1008,8 +1009,8 @@ class CreateSingleAccount extends Command
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();

View File

@ -47,7 +47,8 @@ use Illuminate\Support\Str;
class CreateTestData extends Command
{
use MakesHash, GeneratesCounter;
use MakesHash;
use GeneratesCounter;
/**
* @var string
@ -62,7 +63,7 @@ class CreateTestData extends Command
protected $invoice_repo;
protected $count;
/**
* Execute the console command.
*
@ -115,7 +116,7 @@ class CreateTestData extends Command
]);
}
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
@ -210,7 +211,7 @@ class CreateTestData extends Command
]);
}
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
@ -307,7 +308,7 @@ class CreateTestData extends Command
]);
}
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;

View File

@ -54,7 +54,9 @@ use Illuminate\Support\Str;
class DemoMode extends Command
{
use MakesHash, GeneratesCounter, AppSetup;
use MakesHash;
use GeneratesCounter;
use AppSetup;
protected $signature = 'ninja:demo-mode';
@ -91,7 +93,7 @@ class DemoMode extends Command
Artisan::call('db:seed --force');
$this->buildCache(true);
$this->info('Seeding Random Data');
$this->createSmallAccount();
@ -151,7 +153,7 @@ class DemoMode extends Command
(new CreateCompanyPaymentTerms($company, $user))->handle();
(new CreateCompanyTaskStatuses($company, $user))->handle();
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $user->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;
@ -182,7 +184,7 @@ class DemoMode extends Command
'email_verified_at' => now(),
]);
$company_token = new CompanyToken;
$company_token = new CompanyToken();
$company_token->user_id = $u2->id;
$company_token->company_id = $company->id;
$company_token->account_id = $account->id;

View File

@ -73,7 +73,7 @@ class DesignUpdate extends Command
$invoice_design = new \App\Services\PdfMaker\Design(strtolower($design->name));
$invoice_design->document();
$design_object = new stdClass;
$design_object = new stdClass();
$design_object->includes = $invoice_design->getSectionHTML('style');
$design_object->header = $invoice_design->getSectionHTML('header');
$design_object->body = $invoice_design->getSectionHTML('body');

View File

@ -61,7 +61,7 @@ class MobileLocalization extends Command
private function laravelResources()
{
$resources =(array)$this->getResources();
$resources = (array)$this->getResources();
if(is_iterable($resources)) {
foreach ($resources as $key => $val) {

View File

@ -62,7 +62,7 @@ class OpenApiYaml extends Command
foreach ($directory as $file) {
$this->info($file);
}
Storage::disk('base')->delete('/openapi/api-docs.yaml');
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/info.yaml'));
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/paths.yaml'));
@ -102,7 +102,7 @@ class OpenApiYaml extends Command
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/schemas.yaml'));
//iterate schemas
$directory = new DirectoryIterator($path . '/components/schemas/');
foreach ($directory as $file) {

View File

@ -56,7 +56,7 @@ class ReactBuilder extends Command
$this->error('React files not found');
return;
}
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
if ($file->getExtension() == 'js') {
if (str_contains($file->getFileName(), 'index-')) {

View File

@ -28,7 +28,8 @@ use Illuminate\Support\Facades\App;
//@deprecated 27-11-2022 - only ever should be used for testing
class SendRemindersCron extends Command
{
use MakesReminders, MakesDates;
use MakesReminders;
use MakesDates;
/**
* The name and signature of the console command.
@ -97,7 +98,7 @@ class SendRemindersCron extends Command
});
}
private function calcLateFee($invoice, $template) :Invoice
private function calcLateFee($invoice, $template): Invoice
{
$late_fee_amount = 0;
$late_fee_percent = 0;
@ -137,7 +138,7 @@ class SendRemindersCron extends Command
*
* @return Invoice
*/
private function setLateFee($invoice, $amount, $percent) :Invoice
private function setLateFee($invoice, $amount, $percent): Invoice
{
App::forgetInstance('translator');
$t = app('translator');
@ -158,7 +159,7 @@ class SendRemindersCron extends Command
$fee += round($invoice->balance * $percent / 100, 2);
}
$invoice_item = new InvoiceItem;
$invoice_item = new InvoiceItem();
$invoice_item->type_id = '5';
$invoice_item->product_key = ctrans('texts.fee');
$invoice_item->notes = ctrans('texts.late_fee_added', ['date' => $this->translateDate(now()->startOfDay(), $invoice->client->date_format(), $invoice->client->locale())]);

View File

@ -53,7 +53,7 @@ class SendTestEmails extends Command
$to_user = User::first();
$nmo = new NinjaMailerObject;
$nmo = new NinjaMailerObject();
$nmo->mailable = new TestMailServer('Email Server Works!', config('mail.from.address'));
$nmo->company = $to_user->account->companies()->first();
$nmo->settings = $to_user->account->companies()->first()->settings;

View File

@ -96,7 +96,7 @@ class TranslationsExport extends Command
*/
public function handle()
{
$type =$this->option('type') ?? 'export';
$type = $this->option('type') ?? 'export';
if ($type == 'import') {
$this->import();

View File

@ -47,58 +47,58 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
/* Check for the latest version of Invoice Ninja */
$schedule->job(new VersionCheck)->daily();
$schedule->job(new VersionCheck())->daily();
/* Returns the number of jobs in the queue */
$schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping()->name('queue-size-job')->onOneServer();
$schedule->job(new QueueSize())->everyFiveMinutes()->withoutOverlapping()->name('queue-size-job')->onOneServer();
/* Send reminders */
$schedule->job(new ReminderJob)->hourly()->withoutOverlapping()->name('reminder-job')->onOneServer();
$schedule->job(new ReminderJob())->hourly()->withoutOverlapping()->name('reminder-job')->onOneServer();
/* Sends recurring invoices*/
$schedule->job(new RecurringInvoicesCron)->hourly()->withoutOverlapping()->name('recurring-invoice-job')->onOneServer();
$schedule->job(new RecurringInvoicesCron())->hourly()->withoutOverlapping()->name('recurring-invoice-job')->onOneServer();
/* Checks for scheduled tasks */
$schedule->job(new TaskScheduler())->hourlyAt(10)->withoutOverlapping()->name('task-scheduler-job')->onOneServer();
/* Stale Invoice Cleanup*/
$schedule->job(new CleanStaleInvoiceOrder)->hourlyAt(30)->withoutOverlapping()->name('stale-invoice-job')->onOneServer();
$schedule->job(new CleanStaleInvoiceOrder())->hourlyAt(30)->withoutOverlapping()->name('stale-invoice-job')->onOneServer();
/* Stale Invoice Cleanup*/
$schedule->job(new UpdateCalculatedFields)->hourlyAt(40)->withoutOverlapping()->name('update-calculated-fields-job')->onOneServer();
$schedule->job(new UpdateCalculatedFields())->hourlyAt(40)->withoutOverlapping()->name('update-calculated-fields-job')->onOneServer();
/* Checks for large companies and marked them as is_large */
$schedule->job(new CompanySizeCheck)->dailyAt('23:20')->withoutOverlapping()->name('company-size-job')->onOneServer();
$schedule->job(new CompanySizeCheck())->dailyAt('23:20')->withoutOverlapping()->name('company-size-job')->onOneServer();
/* Pulls in the latest exchange rates */
$schedule->job(new UpdateExchangeRates)->dailyAt('23:30')->withoutOverlapping()->name('exchange-rate-job')->onOneServer();
$schedule->job(new UpdateExchangeRates())->dailyAt('23:30')->withoutOverlapping()->name('exchange-rate-job')->onOneServer();
/* Runs cleanup code for subscriptions */
$schedule->job(new SubscriptionCron)->dailyAt('00:01')->withoutOverlapping()->name('subscription-job')->onOneServer();
$schedule->job(new SubscriptionCron())->dailyAt('00:01')->withoutOverlapping()->name('subscription-job')->onOneServer();
/* Sends recurring expenses*/
$schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping()->name('recurring-expense-job')->onOneServer();
$schedule->job(new RecurringExpensesCron())->dailyAt('00:10')->withoutOverlapping()->name('recurring-expense-job')->onOneServer();
/* Checks the status of the scheduler */
$schedule->job(new SchedulerCheck)->dailyAt('01:10')->withoutOverlapping();
$schedule->job(new SchedulerCheck())->dailyAt('01:10')->withoutOverlapping();
/* Checks and cleans redundant files */
$schedule->job(new DiskCleanup)->dailyAt('02:10')->withoutOverlapping()->name('disk-cleanup-job')->onOneServer();
$schedule->job(new DiskCleanup())->dailyAt('02:10')->withoutOverlapping()->name('disk-cleanup-job')->onOneServer();
/* Performs system maintenance such as pruning the backup table */
$schedule->job(new SystemMaintenance)->sundays()->at('02:30')->withoutOverlapping()->name('system-maintenance-job')->onOneServer();
$schedule->job(new SystemMaintenance())->sundays()->at('02:30')->withoutOverlapping()->name('system-maintenance-job')->onOneServer();
/* Fires notifications for expired Quotes */
$schedule->job(new QuoteCheckExpired)->dailyAt('05:10')->withoutOverlapping()->name('quote-expired-job')->onOneServer();
$schedule->job(new QuoteCheckExpired())->dailyAt('05:10')->withoutOverlapping()->name('quote-expired-job')->onOneServer();
/* Performs auto billing */
$schedule->job(new AutoBillCron)->dailyAt('06:20')->withoutOverlapping()->name('auto-bill-job')->onOneServer();
$schedule->job(new AutoBillCron())->dailyAt('06:20')->withoutOverlapping()->name('auto-bill-job')->onOneServer();
/* Fires webhooks for overdue Invoice */
$schedule->job(new InvoiceCheckLateWebhook)->dailyAt('07:00')->withoutOverlapping()->name('invoice-overdue-job')->onOneServer();
$schedule->job(new InvoiceCheckLateWebhook())->dailyAt('07:00')->withoutOverlapping()->name('invoice-overdue-job')->onOneServer();
/* Pulls in bank transactions from third party services */
$schedule->job(new BankTransactionSync)->everyFourHours()->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer();
$schedule->job(new BankTransactionSync())->everyFourHours()->withoutOverlapping()->name('bank-trans-sync-job')->onOneServer();
if (Ninja::isSelfHost()) {
$schedule->call(function () {
@ -108,10 +108,10 @@ class Kernel extends ConsoleKernel
/* Run hosted specific jobs */
if (Ninja::isHosted()) {
$schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping();
$schedule->job(new AdjustEmailQuota())->dailyAt('23:30')->withoutOverlapping();
/* Checks ACH verification status and updates state to authorize when verified */
$schedule->job(new CheckACHStatus)->everySixHours()->withoutOverlapping()->name('ach-status-job')->onOneServer();
$schedule->job(new CheckACHStatus())->everySixHours()->withoutOverlapping()->name('ach-status-job')->onOneServer();
$schedule->command('ninja:check-data --database=db-ninja-01')->dailyAt('02:10')->withoutOverlapping()->name('check-data-db-1-job')->onOneServer();

View File

@ -64,7 +64,7 @@ class ClientSettings extends BaseSettings
*
* @return stdClass
*/
public static function defaults() : stdClass
public static function defaults(): stdClass
{
$data = (object) [
'entity' => (string) Client::class,

View File

@ -26,7 +26,7 @@ class CompanySettings extends BaseSettings
public $auto_archive_invoice = false; // @implemented
public $qr_iban = ''; //@implemented
public $besr_id = ''; //@implemented
public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented
@ -444,9 +444,9 @@ class CompanySettings extends BaseSettings
public $postmark_secret = '';
public $custom_sending_email = '';
public $mailgun_secret = '';
public $mailgun_domain = '';
public $mailgun_endpoint = 'api.mailgun.net'; //api.eu.mailgun.net
@ -482,9 +482,9 @@ class CompanySettings extends BaseSettings
public $enable_e_invoice = false;
public $delivery_note_design_id = '';
public $statement_design_id = '';
public $payment_receipt_design_id = '';
public $payment_refund_design_id = '';
@ -546,7 +546,7 @@ class CompanySettings extends BaseSettings
'use_credits_payment' => 'string',
'recurring_invoice_number_pattern' => 'string',
'recurring_invoice_number_counter' => 'int',
'client_portal_under_payment_minimum'=> 'float',
'client_portal_under_payment_minimum' => 'float',
'auto_bill_date' => 'string',
'primary_color' => 'string',
'secondary_color' => 'string',
@ -840,7 +840,7 @@ class CompanySettings extends BaseSettings
public static function setProperties($settings): stdClass
{
$company_settings = (object) get_class_vars(self::class);
foreach ($company_settings as $key => $value) {
if (! property_exists($settings, $key)) {
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});
@ -855,9 +855,9 @@ class CompanySettings extends BaseSettings
*
* @return stdClass
*/
public static function notificationDefaults() :stdClass
public static function notificationDefaults(): stdClass
{
$notification = new stdClass;
$notification = new stdClass();
$notification->email = [];
$notification->email = ['invoice_sent_all'];
@ -871,9 +871,9 @@ class CompanySettings extends BaseSettings
*
* @return stdClass
*/
public static function notificationAdminDefaults() :stdClass
public static function notificationAdminDefaults(): stdClass
{
$notification = new stdClass;
$notification = new stdClass();
$notification->email = [];
$notification->email = ['invoice_sent_all'];
@ -888,7 +888,7 @@ class CompanySettings extends BaseSettings
*
* @return stdClass The stdClass of PDF variables
*/
public static function getEntityVariableDefaults() :stdClass
public static function getEntityVariableDefaults(): stdClass
{
$variables = [
'client_details' => [
@ -975,7 +975,7 @@ class CompanySettings extends BaseSettings
'$product.tax',
'$product.line_total',
],
'task_columns' =>[
'task_columns' => [
'$task.service',
'$task.description',
'$task.rate',

View File

@ -27,7 +27,7 @@ class DefaultSettings extends BaseSettings
/**
* @return stdClass
*/
public static function userSettings() : stdClass
public static function userSettings(): stdClass
{
return (object) [
// class_basename(User::class) => self::userSettingsObject(),

View File

@ -72,43 +72,43 @@ class EmailTemplateDefaults
return self::emailPurchaseOrderSubject();
case 'email_subject_invoice':
return self::emailInvoiceSubject();
case 'email_subject_quote':
return self::emailQuoteSubject();
case 'email_subject_credit':
return self::emailCreditSubject();
case 'email_subject_payment':
return self::emailPaymentSubject();
case 'email_subject_payment_partial':
return self::emailPaymentPartialSubject();
case 'email_subject_statement':
return self::emailStatementSubject();
case 'email_subject_reminder1':
return self::emailReminder1Subject();
case 'email_subject_reminder2':
return self::emailReminder2Subject();
case 'email_subject_reminder3':
return self::emailReminder3Subject();
case 'email_subject_reminder_endless':
return self::emailReminderEndlessSubject();
case 'email_subject_custom1':
return self::emailInvoiceSubject();
case 'email_subject_custom2':
return self::emailInvoiceSubject();
case 'email_subject_custom3':
return self::emailInvoiceSubject();
case 'email_vendor_notification_subject':
return self::emailVendorNotificationSubject();
@ -117,7 +117,7 @@ class EmailTemplateDefaults
default:
return self::emailInvoiceTemplate();
}
}
@ -133,12 +133,12 @@ class EmailTemplateDefaults
public static function emailInvoiceSubject()
{
return ctrans('texts.invoice_subject', ['number'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.invoice_subject', ['number' => '$number', 'account' => '$company.name']);
}
public static function emailCreditSubject()
{
return ctrans('texts.credit_subject', ['number'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.credit_subject', ['number' => '$number', 'account' => '$company.name']);
}
public static function emailInvoiceTemplate()
@ -157,7 +157,7 @@ class EmailTemplateDefaults
public static function emailQuoteSubject()
{
return ctrans('texts.quote_subject', ['number'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.quote_subject', ['number' => '$number', 'account' => '$company.name']);
}
public static function emailQuoteTemplate()
@ -212,7 +212,7 @@ class EmailTemplateDefaults
public static function emailReminder1Subject()
{
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
}
public static function emailReminder1Template()
@ -222,7 +222,7 @@ class EmailTemplateDefaults
public static function emailReminder2Subject()
{
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
}
public static function emailReminder2Template()
@ -232,7 +232,7 @@ class EmailTemplateDefaults
public static function emailReminder3Subject()
{
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
}
public static function emailReminder3Template()
@ -242,7 +242,7 @@ class EmailTemplateDefaults
public static function emailReminderEndlessSubject()
{
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
}
public static function emailReminderEndlessTemplate()

View File

@ -44,7 +44,7 @@ class InvoiceItem
public $line_total = 0;
public $gross_line_total = 0;
public $tax_amount = 0;
public $date = '';

View File

@ -66,7 +66,7 @@ class EmailReport
* @var string
*/
public string $end_date = '';
/******************************* Parameters **********************************/
/** @var string $report_name */

View File

@ -8,11 +8,11 @@
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper\Settings;
class SettingsData
{
public bool $auto_archive_invoice = false; // @implemented
public string $qr_iban = ''; //@implemented
@ -464,7 +464,7 @@ class SettingsData
public bool $enable_e_invoice = false;
public string $classification = '';
private mixed $object;
public function cast(mixed $object)
@ -479,7 +479,7 @@ class SettingsData
try {
settype($object->{$key}, gettype($this->{$key}));
} catch(\Exception | \Error | \Throwable $e) {
if(property_exists($this, $key)) {
$object->{$key} = $this->{$key};
} else {

View File

@ -19,28 +19,28 @@ class Rule extends BaseRule implements RuleInterface
{
/** @var string $seller_region */
public string $seller_region = 'AU';
/** @var bool $consumer_tax_exempt */
public bool $consumer_tax_exempt = false;
/** @var bool $business_tax_exempt */
public bool $business_tax_exempt = false;
/** @var bool $eu_business_tax_exempt */
public bool $eu_business_tax_exempt = true;
/** @var bool $foreign_business_tax_exempt */
public bool $foreign_business_tax_exempt = false;
/** @var bool $foreign_consumer_tax_exempt */
public bool $foreign_consumer_tax_exempt = false;
/** @var float $tax_rate */
public float $tax_rate = 0;
/** @var float $reduced_tax_rate */
public float $reduced_tax_rate = 0;
/**
* Initializes the rules and builds any required data.
*
@ -49,10 +49,10 @@ class Rule extends BaseRule implements RuleInterface
public function init(): self
{
$this->calculateRates();
return $this;
}
/**
* Sets the correct tax rate based on the product type.
*
@ -78,10 +78,10 @@ class Rule extends BaseRule implements RuleInterface
Product::PRODUCT_TYPE_REVERSE_TAX => $this->reverseTax($item),
default => $this->default($item),
};
return $this;
}
/**
* Calculates the tax rate for a reduced tax product
*
@ -107,7 +107,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a zero rated tax product
*
@ -120,7 +120,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a tax exempt product
@ -134,7 +134,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a digital product
*
@ -148,7 +148,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a service product
*
@ -162,7 +162,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a shipping product
*
@ -176,7 +176,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a physical product
*
@ -190,7 +190,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a default product
*
@ -198,13 +198,13 @@ class Rule extends BaseRule implements RuleInterface
*/
public function default($item): self
{
$this->tax_name1 = '';
$this->tax_rate1 = 0;
return $this;
}
/**
* Calculates the tax rate for an override product
*
@ -214,7 +214,7 @@ class Rule extends BaseRule implements RuleInterface
{
return $this;
}
/**
* Calculates the tax rates based on the client's location.
*
@ -223,7 +223,7 @@ class Rule extends BaseRule implements RuleInterface
public function calculateRates(): self
{
if ($this->client->is_tax_exempt) {
$this->tax_rate = 0;
$this->reduced_tax_rate = 0;

View File

@ -94,7 +94,7 @@ class BaseRule implements RuleInterface
'SE' => 'EU', // Sweden
'SI' => 'EU', // Slovenia
'SK' => 'EU', // Slovakia
'US' => 'US', // United States
'AU' => 'AU', // Australia
@ -117,7 +117,7 @@ class BaseRule implements RuleInterface
public ?Response $tax_data;
public mixed $invoice;
private bool $should_calc_tax = true;
public function __construct()
@ -128,7 +128,7 @@ class BaseRule implements RuleInterface
{
return $this;
}
public function shouldCalcTax(): bool
{
return $this->should_calc_tax;
@ -157,7 +157,7 @@ class BaseRule implements RuleInterface
return $this;
}
/**
* Configigures the Tax Data for the entity
*
@ -187,9 +187,9 @@ class BaseRule implements RuleInterface
$tax_data = false;
if($this->seller_region == 'US' && $this->client_region == 'US') {
$company = $this->invoice->company;
/** If no company tax data has been configured, lets do that now. */
/** We should never encounter this scenario */
if(!$company->origin_tax_data) {
@ -203,7 +203,7 @@ class BaseRule implements RuleInterface
$tax_data = $company->origin_tax_data;
} elseif($this->client->tax_data) {
$tax_data = $this->client->tax_data;
}
@ -214,22 +214,22 @@ class BaseRule implements RuleInterface
if($this->invoice instanceof Invoice && $tax_data) {
$this->invoice->tax_data = $tax_data;
if(\DB::transactionLevel() == 0) {
try {
$this->invoice->saveQuietly();
} catch(\Exception $e) {
}
}
}
return $this;
}
/**
* Resolve Regions & Subregions
*
@ -237,7 +237,7 @@ class BaseRule implements RuleInterface
*/
private function resolveRegions(): self
{
$this->client_region = $this->region_codes[$this->client->country->iso_3166_2];
match($this->client_region) {
@ -254,7 +254,7 @@ class BaseRule implements RuleInterface
private function getUSState(): string
{
try {
$states = USStates::$states;
if(isset($states[$this->client->state])) {
@ -278,14 +278,14 @@ class BaseRule implements RuleInterface
{
if($this->client_region == 'US' && isset($this->tax_data?->taxSales)) {
$this->tax_rate1 = $this->tax_data->taxSales * 100;
$this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
return $this;
} elseif($this->client_region == 'AU') { //these are defaults and are only stubbed out for now, for AU we can actually remove these
$this->tax_rate1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_name;
@ -296,15 +296,15 @@ class BaseRule implements RuleInterface
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
}
return $this;
}
public function tax($item = null): self
{
if ($this->client->is_tax_exempt || !property_exists($item, 'tax_id')) {
return $this->taxExempt($item);
} elseif($this->client_region == $this->seller_region && $this->isTaxableRegion()) {
@ -326,7 +326,7 @@ class BaseRule implements RuleInterface
return $this;
}
public function taxByType(mixed $type): self
{
return $this;

View File

@ -19,28 +19,28 @@ class Rule extends BaseRule implements RuleInterface
{
/** @var string $seller_region */
public string $seller_region = 'EU';
/** @var bool $consumer_tax_exempt */
public bool $consumer_tax_exempt = false;
/** @var bool $business_tax_exempt */
public bool $business_tax_exempt = false;
/** @var bool $eu_business_tax_exempt */
public bool $eu_business_tax_exempt = true;
/** @var bool $foreign_business_tax_exempt */
public bool $foreign_business_tax_exempt = false;
/** @var bool $foreign_consumer_tax_exempt */
public bool $foreign_consumer_tax_exempt = false;
/** @var float $tax_rate */
public float $tax_rate = 0;
/** @var float $reduced_tax_rate */
public float $reduced_tax_rate = 0;
public string $tax_name1 = 'MwSt.';
/**
* Initializes the rules and builds any required data.
@ -50,10 +50,10 @@ class Rule extends BaseRule implements RuleInterface
public function init(): self
{
$this->calculateRates();
return $this;
}
/**
* Sets the correct tax rate based on the product type.
*
@ -79,10 +79,10 @@ class Rule extends BaseRule implements RuleInterface
Product::PRODUCT_TYPE_REVERSE_TAX => $this->reverseTax($item),
default => $this->default($item),
};
return $this;
}
/**
* Calculates the tax rate for a reduced tax product
*
@ -103,10 +103,10 @@ class Rule extends BaseRule implements RuleInterface
public function taxReduced($item): self
{
$this->tax_rate1 = $this->reduced_tax_rate;
return $this;
}
/**
* Calculates the tax rate for a zero rated tax product
*
@ -115,10 +115,10 @@ class Rule extends BaseRule implements RuleInterface
public function zeroRated($item): self
{
$this->tax_rate1 = 0;
return $this;
}
/**
* Calculates the tax rate for a tax exempt product
@ -132,7 +132,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a digital product
*
@ -142,10 +142,10 @@ class Rule extends BaseRule implements RuleInterface
{
$this->tax_rate1 = $this->tax_rate;
return $this;
}
/**
* Calculates the tax rate for a service product
*
@ -155,10 +155,10 @@ class Rule extends BaseRule implements RuleInterface
{
$this->tax_rate1 = $this->tax_rate;
return $this;
}
/**
* Calculates the tax rate for a shipping product
*
@ -168,10 +168,10 @@ class Rule extends BaseRule implements RuleInterface
{
$this->tax_rate1 = $this->tax_rate;
return $this;
}
/**
* Calculates the tax rate for a physical product
*
@ -181,10 +181,10 @@ class Rule extends BaseRule implements RuleInterface
{
$this->tax_rate1 = $this->tax_rate;
return $this;
}
/**
* Calculates the tax rate for a default product
*
@ -192,13 +192,13 @@ class Rule extends BaseRule implements RuleInterface
*/
public function default($item): self
{
$this->tax_name1 = '';
$this->tax_rate1 = 0;
return $this;
}
/**
* Calculates the tax rate for an override product
*
@ -208,7 +208,7 @@ class Rule extends BaseRule implements RuleInterface
{
return $this;
}
/**
* Calculates the tax rates based on the client's location.
*

View File

@ -20,7 +20,7 @@ interface RuleInterface
public function taxByType($type);
public function taxExempt($item);
public function taxDigital($item);
public function taxService($item);

View File

@ -21,7 +21,7 @@ use App\DataMapper\Tax\ZipTax\Response;
class TaxData
{
public int $updated_at;
public function __construct(public Response $origin)
{
foreach($origin as $key => $value) {

View File

@ -13,16 +13,15 @@ namespace App\DataMapper\Tax;
class TaxModel
{
/** @var string $seller_subregion */
public string $seller_subregion = 'CA';
/** @var string $version */
public string $version = 'alpha';
/** @var object $regions */
public object $regions;
/**
* __construct
*
@ -31,7 +30,7 @@ class TaxModel
*/
public function __construct(public ?TaxModel $model = null)
{
if(!$this->model) {
$this->regions = $this->init();
} else {
@ -39,7 +38,7 @@ class TaxModel
}
}
/**
* Initializes the rules and builds any required data.
*
@ -58,7 +57,7 @@ class TaxModel
return $this->regions;
}
/**
* Builds the model for Australian Taxes
*
@ -74,7 +73,7 @@ class TaxModel
return $this;
}
/**
* Builds the model for Australian Subregions
*
@ -91,7 +90,7 @@ class TaxModel
return $this;
}
/**
* Builds the model for US Taxes
*
@ -105,7 +104,7 @@ class TaxModel
return $this;
}
/**
* Builds the model for EU Taxes
*
@ -113,7 +112,7 @@ class TaxModel
*/
private function euRegion(): self
{
$this->regions->EU->has_sales_above_threshold = false;
$this->regions->EU->tax_all_subregions = false;
$this->regions->EU->tax_threshold = 10000;
@ -121,7 +120,7 @@ class TaxModel
return $this;
}
/**
* Builds the model for US States
*
@ -333,7 +332,7 @@ class TaxModel
return $this;
}
/**
* Create the EU member countries
*
@ -341,7 +340,7 @@ class TaxModel
*/
private function euSubRegions(): self
{
$this->regions->EU->subregions = new \stdClass();
$this->regions->EU->subregions->AT = new \stdClass();

View File

@ -22,10 +22,9 @@ use App\Models\Product;
*/
class Rule extends BaseRule implements RuleInterface
{
/** @var string $seller_region */
public string $seller_region = 'US';
/**
* Initializes the rules and builds any required data.
*
@ -37,7 +36,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Override tax class, we use this when we do not modify the input taxes
*
@ -46,7 +45,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function override($item): self
{
$this->tax_rate1 = $item->tax_rate1;
$this->tax_name1 = $item->tax_name1;
$this->tax_rate2 = $item->tax_rate2;
@ -57,7 +56,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Sets the correct tax rate based on the product type.
*
@ -78,10 +77,10 @@ class Rule extends BaseRule implements RuleInterface
Product::PRODUCT_TYPE_ZERO_RATED => $this->zeroRated($item),
default => $this->default($item),
};
return $this;
}
/**
* Sets the tax as exempt (0)
* @param mixed $item
@ -95,7 +94,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a digital product
* @param mixed $item
@ -108,7 +107,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a service product
* @param mixed $item
@ -125,7 +124,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for a shipping product
* @param mixed $item
@ -140,10 +139,10 @@ class Rule extends BaseRule implements RuleInterface
$this->tax_rate1 = 0;
$this->tax_name1 = '';
return $this;
}
/**
* Calculates the tax rate for a physical product
* @param mixed $item
@ -156,7 +155,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
/**
* Calculates the tax rate for an undefined product uses the default tax rate for the client county
*
@ -164,7 +163,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function default($item): self
{
if($this->tax_data?->stateSalesTax == 0) {
$this->tax_rate1 = 0;
@ -178,7 +177,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
public function zeroRated($item): self
{

View File

@ -110,7 +110,7 @@ class Response
}
}
}
}

View File

@ -51,7 +51,7 @@ class BaseTransaction implements TransactionInterface
'credit_status',
];
public function transform(array $data) :array
public function transform(array $data): array
{
// $invoice = $data['invoice'];
// $payment = $data['payment'];
@ -66,7 +66,7 @@ class BaseTransaction implements TransactionInterface
$data['client'],
$data['credit'],
['metadata' => $data['metadata']],
['event_id' => $this->event_id, 'timestamp' =>time()],
['event_id' => $this->event_id, 'timestamp' => time()],
);
// return [
// 'event_id' => $this->event_id,

View File

@ -13,5 +13,5 @@ namespace App\DataMapper\Transactions;
interface TransactionInterface
{
public function transform(array $data) :array;
public function transform(array $data): array;
}

File diff suppressed because it is too large Load Diff

View File

@ -33919,7 +33919,7 @@ class USStates
}
return false;
}
public static function getStateFromThreeDigitPrefix($zip): mixed

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class AccountCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $user;

View File

@ -21,7 +21,9 @@ use Illuminate\Queue\SerializesModels;
*/
class StripeConnectFailure
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public Company $company, public string $db)
{

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class ClientWasArchived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Client

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CompanyDocumentsDeleted
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Company

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class ContactLoggedIn
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $client_contact;

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasArchived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $credit;

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $credit;

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasDeleted
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $credit;

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasEmailed
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $invitation;

View File

@ -18,7 +18,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasEmailedAndFailed
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $credit;

View File

@ -19,7 +19,9 @@ use Illuminate\Queue\SerializesModels;
class CreditWasUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $credit;

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class DesignWasArchived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public Design $design, public Company $company, public array $event_vars)
{

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class DocumentWasArchived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Document

View File

@ -24,7 +24,9 @@ use Illuminate\Queue\SerializesModels;
*/
class InvoiceWasCreated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Invoice
@ -58,7 +60,7 @@ class InvoiceWasCreated implements ShouldBroadcast
{
return [];
}
// /**
// * Get the data to broadcast.

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class InvoiceWasUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Invoice

View File

@ -20,7 +20,9 @@ use Illuminate\Queue\SerializesModels;
class MethodDeleted
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var ClientGatewayToken

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class PaymentWasEmailed
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* Create a new event instance.

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class PaymentWasEmailedAndFailed
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Payment

View File

@ -20,7 +20,9 @@ use Illuminate\Queue\SerializesModels;
class QuoteWasApproved
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $contact;

View File

@ -21,7 +21,7 @@ use Illuminate\Queue\SerializesModels;
class RecurringInvoiceWasDeleted
{
use SerializesModels;
public function __construct(public RecurringInvoice $recurring_invoice, public Company $company, public array $event_vars)
{
}

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class RecurringInvoiceWasUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public RecurringInvoice $recurring_invoice, public Company $company, public array $event_vars)
{

View File

@ -22,7 +22,9 @@ use Illuminate\Queue\SerializesModels;
*/
class RecurringQuoteWasUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public RecurringQuote $recurring_quote, public Company $company, public array $event_vars)

View File

@ -10,7 +10,9 @@ use Illuminate\Queue\SerializesModels;
class SubscriptionWasCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* @var Subscription

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserLoggedIn
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public User $user, public Company $company, public array $event_vars)
{

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserWasArchived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public User $user, public User $creating_user, public Company $company, public array $event_vars)
{

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserWasCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(public User $user, public User $creating_user, public Company $company, public array $event_vars, public $is_react = true)
{

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserWasDeleted
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $user;

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserWasRestored
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $user;

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class UserWasUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public $user;

View File

@ -23,7 +23,9 @@ use Illuminate\Queue\SerializesModels;
*/
class VendorContactLoggedIn
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
/**
* Create a new event instance.

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -214,7 +214,7 @@ class Handler extends ExceptionHandler
public function render($request, Throwable $exception)
{
if ($exception instanceof ModelNotFoundException && $request->expectsJson()) {
return response()->json(['message'=>$exception->getMessage()], 400);
return response()->json(['message' => $exception->getMessage()], 400);
} elseif ($exception instanceof InternalPDFFailure && $request->expectsJson()) {
return response()->json(['message' => $exception->getMessage()], 500);
} elseif ($exception instanceof PhantomPDFFailure && $request->expectsJson()) {
@ -222,11 +222,11 @@ class Handler extends ExceptionHandler
} elseif ($exception instanceof FilePermissionsFailure) {
return response()->json(['message' => $exception->getMessage()], 500);
} elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
return response()->json(['message'=>'Too many requests'], 429);
// } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
// return response()->json(['message'=>'Fatal error'], 500); //@deprecated
return response()->json(['message' => 'Too many requests'], 429);
// } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
// return response()->json(['message'=>'Fatal error'], 500); //@deprecated
} elseif ($exception instanceof AuthorizationException && $request->expectsJson()) {
return response()->json(['message'=> $exception->getMessage()], 401);
return response()->json(['message' => $exception->getMessage()], 401);
} elseif ($exception instanceof TokenMismatchException) {
return redirect()
->back()
@ -235,9 +235,9 @@ class Handler extends ExceptionHandler
'message' => ctrans('texts.token_expired'),
'message-type' => 'danger', ]);
} elseif ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
return response()->json(['message'=>'Route does not exist'], 404);
return response()->json(['message' => 'Route does not exist'], 404);
} elseif ($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()) {
return response()->json(['message'=>'Method not supported for this route'], 404);
return response()->json(['message' => 'Method not supported for this route'], 404);
} elseif ($exception instanceof ValidationException && $request->expectsJson()) {
return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422);
} elseif ($exception instanceof RelationNotFoundException && $request->expectsJson()) {

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;

View File

@ -25,7 +25,6 @@ use League\Csv\Writer;
class ActivityExport extends BaseExport
{
private $entity_transformer;
public string $date_key = 'created_at';
@ -57,13 +56,13 @@ class ActivityExport extends BaseExport
return ['identifier' => $key, 'display_value' => $headerdisplay[$value]];
})->toArray();
$report = $query->cursor()
->map(function ($resource) {
$row = $this->buildActivityRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -92,7 +91,7 @@ class ActivityExport extends BaseExport
]),
$activity->ip,
];
}
private function init(): Builder
@ -120,7 +119,7 @@ class ActivityExport extends BaseExport
public function run()
{
$query = $this->init();
//load the CSV document from a string
$this->csv = Writer::createFromString();
@ -138,12 +137,12 @@ class ActivityExport extends BaseExport
private function buildRow(Activity $activity)
{
$this->csv->insertOne($this->buildActivityRow($activity));
}
private function decorateAdvancedFields(Task $task, array $entity) :array
private function decorateAdvancedFields(Task $task, array $entity): array
{
return $entity;
}
@ -153,9 +152,9 @@ class ActivityExport extends BaseExport
{
$clean_row = [];
foreach (array_values($this->input['report_keys']) as $key => $value) {
$clean_row[$key]['entity'] = 'activity';
$clean_row[$key]['id'] = $key;
$clean_row[$key]['hashed_id'] = null;

View File

@ -37,9 +37,9 @@ use League\Fractal\Serializer\ArraySerializer;
class BaseExport
{
use MakesHash;
public Company $company;
public array $input;
public string $date_key = '';
@ -382,7 +382,7 @@ class BaseExport
"custom_value4" => "payment.custom_value4",
"user" => "payment.user_id",
"assigned_user" => "payment.assigned_user_id",
];
protected array $expense_report_keys = [
@ -457,7 +457,7 @@ class BaseExport
return $query;
}
protected function resolveKey($key, $entity, $transformer) :string
protected function resolveKey($key, $entity, $transformer): string
{
$parts = explode(".", $key);
@ -481,7 +481,7 @@ class BaseExport
'task' => $value = $this->resolveTaskKey($parts[1], $entity, $transformer),
default => $value = '',
};
return $value;
}
@ -513,7 +513,7 @@ class BaseExport
private function resolveExpenseKey($column, $entity, $transformer)
{
if($column == 'user' && $entity?->expense?->user) {
return $entity->expense->user->present()->name() ?? ' ';
}
@ -582,9 +582,9 @@ class BaseExport
if($column == 'name') {
return $entity->vendor->present()->name() ?: '';
}
if($column == 'user_id') {
return $entity->vendor->user->present()->name() ?: '';
return $entity->vendor->user->present()->name() ?: '';
}
if($column == 'country_id') {
@ -626,7 +626,7 @@ class BaseExport
if(in_array($column, ['client.name', 'name'])) {
return $transformed_client['display_name'];
}
if(in_array($column, ['client.user_id', 'user_id'])) {
return $entity->client->user ? $entity->client->user->present()->name() : '';
}
@ -638,11 +638,11 @@ class BaseExport
if(in_array($column, ['client.country_id', 'country_id'])) {
return $entity->client->country ? ctrans("texts.country_{$entity->client->country->name}") : '';
}
if(in_array($column, ['client.shipping_country_id', 'shipping_country_id'])) {
return $entity->client->shipping_country ? ctrans("texts.country_{$entity->client->shipping_country->name}") : '';
}
if(in_array($column, ['client.size_id', 'size_id'])) {
return $entity->client->size?->name ?? '';
}
@ -654,11 +654,11 @@ class BaseExport
if (in_array($column, ['client.currency_id', 'currency_id'])) {
return $entity->client->currency() ? $entity->client->currency()->code : $entity->company->currency()->code;
}
if(in_array($column, ['payment_terms', 'client.payment_terms'])) {
return $entity->client->getSetting('payment_terms');
}
if(array_key_exists($column, $transformed_client)) {
return $transformed_client[$column];
@ -679,7 +679,7 @@ class BaseExport
if($column == 'status') {
return $entity->stringStatus($entity->status_id);
}
return '';
}
@ -712,7 +712,7 @@ class BaseExport
if(!isset($transformed_invoices['App\\Models\\Invoice'])) {
return '';
}
$transformed_invoices = $transformed_invoices['App\\Models\\Invoice'];
if(count($transformed_invoices) == 1 && array_key_exists($column, $transformed_invoices[0])) {
@ -739,13 +739,13 @@ class BaseExport
$transformed_invoice = $manager->createData($transformed_invoice)->toArray();
}
if($transformed_invoice && array_key_exists($column, $transformed_invoice)) {
return $transformed_invoice[$column];
} elseif ($transformed_invoice && array_key_exists(str_replace("invoice.", "", $column), $transformed_invoice)) {
return $transformed_invoice[$column];
}
return '';
}
@ -816,7 +816,7 @@ class BaseExport
{
if(isset($this->input['product_key'])) {
$products = explode(",", $this->input['product_key']);
$query->where(function ($q) use ($products) {
@ -826,7 +826,7 @@ class BaseExport
});
}
return $query;
}
@ -834,7 +834,7 @@ class BaseExport
{
$status_parameters = explode(',', $status);
if(in_array('all', $status_parameters)) {
return $query;
@ -864,7 +864,7 @@ class BaseExport
if (count($invoice_filters) > 0) {
$nested->whereIn('status_id', $invoice_filters);
}
if (in_array('overdue', $status_parameters)) {
$nested->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
->where('due_date', '<', Carbon::now())
@ -872,14 +872,14 @@ class BaseExport
}
if(in_array('viewed', $status_parameters)) {
$nested->whereHas('invitations', function ($q) {
$q->whereNotNull('viewed_date')->whereNotNull('deleted_at');
});
}
});
return $query;
@ -971,7 +971,7 @@ class BaseExport
return $query->whereBetween($this->date_key, [now()->startOfYear(), now()])->orderBy($this->date_key, 'ASC');
}
}
/**
* Returns the merged array of
* the entity with the matching
@ -985,17 +985,17 @@ class BaseExport
return array_merge($this->{$entity_report_keys}, $this->item_report_keys);
}
public function buildHeader() :array
public function buildHeader(): array
{
$helper = new Helpers();
$header = [];
// nlog("header");
foreach ($this->input['report_keys'] as $value) {
$key = array_search($value, $this->entity_keys);
$original_key = $key;
// nlog("{$key} => {$value}");
$prefix = '';
@ -1023,7 +1023,7 @@ class BaseExport
$prefix = ctrans('texts.quote')." ";
$key = array_search($value, $this->quote_report_keys);
}
if(!$key) {
$prefix = ctrans('texts.credit')." ";
$key = array_search($value, $this->credit_report_keys);
@ -1037,7 +1037,7 @@ class BaseExport
if(!$key) {
$prefix = ctrans('texts.expense')." ";
$key = array_search($value, $this->expense_report_keys);
if(!$key && $value == 'expense.category') {
$key = 'category';
}
@ -1105,7 +1105,7 @@ class BaseExport
$entity = "contact".substr($parts[1], -1);
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}");
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
} elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice','task'])) {
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1)) : ctrans("texts.{$parts[1]}");
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
@ -1119,7 +1119,7 @@ class BaseExport
}
// nlog($header);
return $header;
}
@ -1144,15 +1144,15 @@ class BaseExport
Vendor::class => $entity = 'vendor',
default => $entity = 'invoice',
};
$clean_row = [];
foreach (array_values($this->input['report_keys']) as $key => $value) {
$report_keys = explode(".", $value);
$column_key = $value;
if($value == 'product_image') {
$column_key = 'image';
$value = 'image';
@ -1195,9 +1195,9 @@ class BaseExport
$clean_row = [];
foreach (array_values($this->input['report_keys']) as $key => $value) {
$report_keys = explode(".", $value);
$column_key = $value;
if($value == 'type_id' || $value == 'item.type_id') {
@ -1207,7 +1207,7 @@ class BaseExport
if($value == 'tax_id' || $value == 'item.tax_id') {
$column_key = 'tax_category';
}
$clean_row[$key]['entity'] = $report_keys[0];
$clean_row[$key]['id'] = $report_keys[1] ?? $report_keys[0];
$clean_row[$key]['hashed_id'] = $report_keys[0] == $entity ? null : $resource->{$report_keys[0]}->hashed_id ?? null;

View File

@ -106,7 +106,7 @@ class ClientExport extends BaseExport
$row = $this->buildRow($client);
return $this->processMetaData($row, $client);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -132,7 +132,7 @@ class ClientExport extends BaseExport
$query = $this->addDateRange($query);
return $query;
}
public function run()
@ -141,7 +141,7 @@ class ClientExport extends BaseExport
//load the CSV document from a string
$this->csv = Writer::createFromString();
//insert the header
$this->csv->insertOne($this->buildHeader());
@ -153,7 +153,7 @@ class ClientExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Client $client) :array
private function buildRow(Client $client): array
{
$transformed_contact = false;
@ -169,7 +169,7 @@ class ClientExport extends BaseExport
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if (is_array($parts) && $parts[0] == 'client' && array_key_exists($parts[1], $transformed_client)) {
$entity[$key] = $transformed_client[$parts[1]];
} elseif (is_array($parts) && $parts[0] == 'contact' && array_key_exists($parts[1], $transformed_contact)) {
@ -190,9 +190,9 @@ class ClientExport extends BaseExport
{
$clean_row = [];
foreach (array_values($this->input['report_keys']) as $key => $value) {
$report_keys = explode(".", $value);
$column_key = $value;
$clean_row[$key]['entity'] = $report_keys[0];
$clean_row[$key]['id'] = $report_keys[1] ?? $report_keys[0];
@ -211,7 +211,7 @@ class ClientExport extends BaseExport
return $clean_row;
}
private function decorateAdvancedFields(Client $client, array $entity) :array
private function decorateAdvancedFields(Client $client, array $entity): array
{
if (in_array('client.user', $this->input['report_keys'])) {
$entity['client.user'] = $client->user->present()->name();

View File

@ -25,13 +25,12 @@ use Illuminate\Database\Eloquent\Builder;
class ContactExport extends BaseExport
{
private ClientTransformer $client_transformer;
private ClientContactTransformer $contact_transformer;
private Decorator $decorator;
public Writer $csv;
public string $date_key = 'created_at';
@ -69,7 +68,7 @@ class ContactExport extends BaseExport
public function run()
{
$query = $this->init();
//load the CSV document from a string
@ -101,12 +100,12 @@ class ContactExport extends BaseExport
$row = $this->buildRow($contact);
return $this->processMetaData($row, $contact);
})->toArray();
return array_merge(['columns' => $header], $report);
}
private function buildRow(ClientContact $contact) :array
private function buildRow(ClientContact $contact): array
{
$transformed_contact = false;
@ -133,7 +132,7 @@ class ContactExport extends BaseExport
return $this->decorateAdvancedFields($contact->client, $entity);
}
private function decorateAdvancedFields(Client $client, array $entity) :array
private function decorateAdvancedFields(Client $client, array $entity): array
{
if (in_array('client.country_id', $this->input['report_keys'])) {
$entity['country'] = $client->country ? ctrans("texts.country_{$client->country->name}") : '';

View File

@ -24,7 +24,6 @@ use League\Csv\Writer;
class CreditExport extends BaseExport
{
private CreditTransformer $credit_transformer;
private Decorator $decorator;
@ -56,7 +55,7 @@ class CreditExport extends BaseExport
$row = $this->buildRow($credit);
return $this->processMetaData($row, $credit);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -64,9 +63,9 @@ class CreditExport extends BaseExport
{
$clean_row = [];
foreach (array_values($this->input['report_keys']) as $key => $value) {
$report_keys = explode(".", $value);
$column_key = $value;
$clean_row[$key]['entity'] = $report_keys[0];
$clean_row[$key]['id'] = $report_keys[1] ?? $report_keys[0];
@ -128,18 +127,18 @@ class CreditExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Credit $credit) :array
private function buildRow(Credit $credit): array
{
$transformed_credit = $this->credit_transformer->transform($credit);
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
$keyval = $key;
$credit_key = str_replace("credit.", "", $key);
$searched_credit_key = array_search(str_replace("credit.", "", $key), $this->credit_report_keys) ?? $key;
if (isset($transformed_credit[$credit_key])) {
$entity[$keyval] = $transformed_credit[$credit_key];
} elseif (isset($transformed_credit[$keyval])) {
@ -159,12 +158,12 @@ class CreditExport extends BaseExport
return $this->decorateAdvancedFields($credit, $entity);
}
private function decorateAdvancedFields(Credit $credit, array $entity) :array
private function decorateAdvancedFields(Credit $credit, array $entity): array
{
// if (in_array('country_id', $this->input['report_keys'])) {
// $entity['country'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : '';
// }
// if (in_array('currency_id', $this->input['report_keys'])) {
// $entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $credit->company->currency()->code;
// }
@ -186,11 +185,11 @@ class CreditExport extends BaseExport
// }
if (in_array('credit.assigned_user_id', $this->input['report_keys'])) {
$entity['credit.assigned_user_id'] = $credit->assigned_user ? $credit->assigned_user->present()->name(): '';
$entity['credit.assigned_user_id'] = $credit->assigned_user ? $credit->assigned_user->present()->name() : '';
}
if (in_array('credit.user_id', $this->input['report_keys'])) {
$entity['credit.user_id'] = $credit->user ? $credit->user->present()->name(): '';
$entity['credit.user_id'] = $credit->user ? $credit->user->present()->name() : '';
}
return $entity;

View File

@ -22,7 +22,6 @@ use League\Csv\Writer;
class DocumentExport extends BaseExport
{
private $entity_transformer;
public string $date_key = 'created_at';
@ -58,7 +57,7 @@ class DocumentExport extends BaseExport
$row = $this->buildRow($document);
return $this->processMetaData($row, $document);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -101,7 +100,7 @@ class DocumentExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Document $document) :array
private function buildRow(Document $document): array
{
$transformed_entity = $this->entity_transformer->transform($document);
@ -120,7 +119,7 @@ class DocumentExport extends BaseExport
return $this->decorateAdvancedFields($document, $entity);
}
private function decorateAdvancedFields(Document $document, array $entity) :array
private function decorateAdvancedFields(Document $document, array $entity): array
{
if (in_array('record_type', $this->input['report_keys'])) {
$entity['record_type'] = class_basename($document->documentable);

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class ExpenseExport extends BaseExport
{
private $expense_transformer;
private Decorator $decorator;
@ -56,7 +55,7 @@ class ExpenseExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -103,11 +102,11 @@ class ExpenseExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Expense $expense) :array
private function buildRow(Expense $expense): array
{
$transformed_expense = $this->expense_transformer->transform($expense);
$transformed_expense['currency_id'] = $expense->currency ? $expense->currency->code : $expense->company->currency()->code;
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
@ -130,7 +129,7 @@ class ExpenseExport extends BaseExport
return $this->decorateAdvancedFields($expense, $entity);
}
private function decorateAdvancedFields(Expense $expense, array $entity) :array
private function decorateAdvancedFields(Expense $expense, array $entity): array
{
// if (in_array('expense.currency_id', $this->input['report_keys'])) {
// $entity['expense.currency_id'] = $expense->currency ? $expense->currency->code : '';

View File

@ -85,7 +85,7 @@ class InvoiceExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -107,7 +107,7 @@ class InvoiceExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Invoice $invoice) :array
private function buildRow(Invoice $invoice): array
{
$transformed_invoice = $this->invoice_transformer->transform($invoice);
@ -127,14 +127,14 @@ class InvoiceExport extends BaseExport
}
}
// return $entity;
return $this->decorateAdvancedFields($invoice, $entity);
}
private function decorateAdvancedFields(Invoice $invoice, array $entity) :array
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
{
// if (in_array('invoice.country_id', $this->input['report_keys'])) {
// $entity['invoice.country_id'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : '';
// }
@ -160,11 +160,11 @@ class InvoiceExport extends BaseExport
}
if (in_array('invoice.assigned_user_id', $this->input['report_keys'])) {
$entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name(): '';
$entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name() : '';
}
if (in_array('invoice.user_id', $this->input['report_keys'])) {
$entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name(): '';
$entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : '';
}

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class InvoiceItemExport extends BaseExport
{
private $invoice_transformer;
public string $date_key = 'date';
@ -96,24 +95,24 @@ class InvoiceItemExport extends BaseExport
$query->cursor()
->each(function ($resource) {
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
$this->storage_array = [];
});
return array_merge(['columns' => $header], $this->storage_item_array);
}
public function run()
{
$query = $this->init();
//load the CSV document from a string
$this->csv = Writer::createFromString();
@ -126,7 +125,7 @@ class InvoiceItemExport extends BaseExport
});
$this->csv->insertAll($this->storage_array);
return $this->csv->toString();
}
@ -140,11 +139,11 @@ class InvoiceItemExport extends BaseExport
$item_array = [];
foreach (array_values(array_intersect($this->input['report_keys'], $this->item_report_keys)) as $key) { //items iterator produces item array
if (str_contains($key, "item.")) {
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
$tmp_key = 'type';
}
@ -160,10 +159,10 @@ class InvoiceItemExport extends BaseExport
}
}
}
$transformed_items = array_merge($transformed_invoice, $item_array);
$entity = $this->decorateAdvancedFields($invoice, $transformed_items);
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
$this->storage_array[] = $entity;
@ -171,14 +170,14 @@ class InvoiceItemExport extends BaseExport
}
}
private function buildRow(Invoice $invoice) :array
private function buildRow(Invoice $invoice): array
{
$transformed_invoice = $this->invoice_transformer->transform($invoice);
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if(is_array($parts) && $parts[0] == 'item') {
@ -200,7 +199,7 @@ class InvoiceItemExport extends BaseExport
return $this->decorateAdvancedFields($invoice, $entity);
}
private function decorateAdvancedFields(Invoice $invoice, array $entity) :array
private function decorateAdvancedFields(Invoice $invoice, array $entity): array
{
// if (in_array('currency_id', $this->input['report_keys'])) {
// $entity['currency'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
@ -235,11 +234,11 @@ class InvoiceItemExport extends BaseExport
// }
if (in_array('invoice.assigned_user_id', $this->input['report_keys'])) {
$entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name(): '';
$entity['invoice.assigned_user_id'] = $invoice->assigned_user ? $invoice->assigned_user->present()->name() : '';
}
if (in_array('invoice.user_id', $this->input['report_keys'])) {
$entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name(): '';
$entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : '';
}
return $entity;

View File

@ -38,7 +38,7 @@ class PaymentExport extends BaseExport
$this->entity_transformer = new PaymentTransformer();
$this->decorator = new Decorator();
}
private function init(): Builder
{
@ -80,7 +80,7 @@ class PaymentExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -102,14 +102,14 @@ class PaymentExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Payment $payment) :array
private function buildRow(Payment $payment): array
{
$transformed_entity = $this->entity_transformer->transform($payment);
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if (is_array($parts) && $parts[0] == 'payment' && array_key_exists($parts[1], $transformed_entity)) {
@ -129,7 +129,7 @@ class PaymentExport extends BaseExport
return $this->decorateAdvancedFields($payment, $entity);
}
private function decorateAdvancedFields(Payment $payment, array $entity) :array
private function decorateAdvancedFields(Payment $payment, array $entity): array
{
// if (in_array('status_id', $this->input['report_keys'])) {
// $entity['status'] = $payment->stringStatus($payment->status_id);

View File

@ -54,7 +54,7 @@ class ProductExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -84,7 +84,7 @@ class ProductExport extends BaseExport
public function run()
{
$query = $this->init();
//load the CSV document from a string
@ -101,7 +101,7 @@ class ProductExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Product $product) :array
private function buildRow(Product $product): array
{
$transformed_entity = $this->entity_transformer->transform($product);
@ -124,7 +124,7 @@ class ProductExport extends BaseExport
// return $this->decorateAdvancedFields($product, $entity);
}
private function decorateAdvancedFields(Product $product, array $entity) :array
private function decorateAdvancedFields(Product $product, array $entity): array
{
if (in_array('vendor_id', $this->input['report_keys'])) {
$entity['vendor'] = $product->vendor()->exists() ? $product->vendor->name : '';

View File

@ -87,7 +87,7 @@ class ProductSalesExport extends BaseExport
$t->replace(Ninja::transformTranslations($this->company->settings));
$this->products = Product::query()->where('company_id', $this->company->id)->withTrashed()->get();
//load the CSV document from a string
$this->csv = Writer::createFromString();
@ -115,7 +115,7 @@ class ProductSalesExport extends BaseExport
}
});
$grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) {
$data = [
'product' => $value,
@ -143,9 +143,9 @@ class ProductSalesExport extends BaseExport
$this->csv->insertOne([ctrans('texts.clients'), ctrans('texts.type'), ctrans('texts.start_date'), ctrans('texts.end_date')]);
$this->csv->insertOne([$this->client_description, ctrans('texts.product_sales'), $this->start_date, $this->end_date]);
$this->csv->insertOne([]);
if ($grouped->count() >=1) {
if ($grouped->count() >= 1) {
$header = [];
foreach ($grouped->first() as $key => $value) {
@ -161,10 +161,10 @@ class ProductSalesExport extends BaseExport
return $this->csv->toString();
}
private function buildRow($invoice, $invoice_item) :array
private function buildRow($invoice, $invoice_item): array
{
$transformed_entity = (array)$invoice_item;
$transformed_entity['price'] = ($invoice_item->product_cost ?? 1 ) * ($invoice->exchange_rate ?? 1) ;
$transformed_entity['price'] = ($invoice_item->product_cost ?? 1) * ($invoice->exchange_rate ?? 1) ;
$entity = [];
@ -180,15 +180,15 @@ class ProductSalesExport extends BaseExport
}
}
$entity = $this->decorateAdvancedFields($invoice, $entity);
$this->sales->push($entity);
return $entity;
}
private function decorateAdvancedFields(Invoice $invoice, $entity) :array
private function decorateAdvancedFields(Invoice $invoice, $entity): array
{
//$product = $this->getProduct($entity['product_key']);
// $entity['cost'] = $product->cost ?? 0;
/** @var float $unit_cost */
@ -204,7 +204,7 @@ class ProductSalesExport extends BaseExport
$entity['net_total'] = $entity['price'] - $entity['discount'];
$entity['profit'] = $entity['price'] - $entity['discount'] - $entity['cost'];
if (strlen($entity['tax_name1']) > 1) {
$entity['tax_name1'] = $entity['tax_name1'] . ' [' . $entity['tax_rate1'] . '%]';
$entity['tax_amount1'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate1']);
@ -218,7 +218,7 @@ class ProductSalesExport extends BaseExport
} else {
$entity['tax_amount2'] = 0;
}
if (strlen($entity['tax_name3']) > 1) {
$entity['tax_name3'] = $entity['tax_name3'] . ' [' . $entity['tax_rate3'] . '%]';
$entity['tax_amount3'] = $this->calculateTax($invoice, $entity['line_total'], $entity['tax_rate3']);
@ -228,7 +228,7 @@ class ProductSalesExport extends BaseExport
return $entity;
}
/**
* calculateTax
*
@ -248,7 +248,7 @@ class ProductSalesExport extends BaseExport
}
}
/**
* calculateDiscount
@ -257,7 +257,7 @@ class ProductSalesExport extends BaseExport
* @param mixed $entity
* @return float
*/
private function calculateDiscount(Invoice $invoice, $entity) :float
private function calculateDiscount(Invoice $invoice, $entity): float
{
if ($entity['discount'] == 0) {
return 0;
@ -271,14 +271,14 @@ class ProductSalesExport extends BaseExport
return 0;
}
/**
* getProduct
*
* @param string $product_key
* @return Product
*/
private function getProduct(string $product_key) :?Product
private function getProduct(string $product_key): ?Product
{
return $this->products->firstWhere('product_key', $product_key);
}

View File

@ -23,7 +23,6 @@ use App\Transformers\PurchaseOrderTransformer;
class PurchaseOrderExport extends BaseExport
{
private $purchase_order_transformer;
public string $date_key = 'date';
@ -128,7 +127,7 @@ class PurchaseOrderExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
@ -151,7 +150,7 @@ class PurchaseOrderExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(PurchaseOrder $purchase_order) :array
private function buildRow(PurchaseOrder $purchase_order): array
{
$transformed_purchase_order = $this->purchase_order_transformer->transform($purchase_order);
@ -171,13 +170,13 @@ class PurchaseOrderExport extends BaseExport
// $entity[$key] = $this->resolveKey($key, $purchase_order, $this->purchase_order_transformer);
}
}
// return $entity;
return $this->decorateAdvancedFields($purchase_order, $entity);
}
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity) :array
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
{
if (in_array('country_id', $this->input['report_keys'])) {
$entity['country'] = $purchase_order->vendor->country ? ctrans("texts.country_{$purchase_order->vendor->country->name}") : '';

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class PurchaseOrderItemExport extends BaseExport
{
private $purchase_order_transformer;
public string $date_key = 'date';
@ -85,15 +84,15 @@ class PurchaseOrderItemExport extends BaseExport
$query->cursor()
->each(function ($resource) {
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
$this->storage_array = [];
});
return array_merge(['columns' => $header], $this->storage_item_array);
}
@ -113,7 +112,7 @@ class PurchaseOrderItemExport extends BaseExport
});
$this->csv->insertAll($this->storage_array);
return $this->csv->toString();
}
@ -128,11 +127,11 @@ class PurchaseOrderItemExport extends BaseExport
$item_array = [];
foreach (array_values(array_intersect($this->input['report_keys'], $this->item_report_keys)) as $key) { //items iterator produces item array
if (str_contains($key, "item.")) {
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
$tmp_key = 'type';
}
@ -157,7 +156,7 @@ class PurchaseOrderItemExport extends BaseExport
}
}
private function buildRow(PurchaseOrder $purchase_order) :array
private function buildRow(PurchaseOrder $purchase_order): array
{
$transformed_purchase_order = $this->purchase_order_transformer->transform($purchase_order);
@ -185,7 +184,7 @@ class PurchaseOrderItemExport extends BaseExport
return $this->decorateAdvancedFields($purchase_order, $entity);
}
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity) :array
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
{
if (in_array('currency_id', $this->input['report_keys'])) {
$entity['currency'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class QuoteExport extends BaseExport
{
private $quote_transformer;
public string $date_key = 'date';
@ -89,7 +88,7 @@ class QuoteExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
@ -113,7 +112,7 @@ class QuoteExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Quote $quote) :array
private function buildRow(Quote $quote): array
{
$transformed_invoice = $this->quote_transformer->transform($quote);
@ -137,7 +136,7 @@ class QuoteExport extends BaseExport
return $this->decorateAdvancedFields($quote, $entity);
}
private function decorateAdvancedFields(Quote $quote, array $entity) :array
private function decorateAdvancedFields(Quote $quote, array $entity): array
{
if (in_array('quote.currency_id', $this->input['report_keys'])) {
$entity['quote.currency'] = $quote->client->currency()->code;
@ -156,11 +155,11 @@ class QuoteExport extends BaseExport
}
if (in_array('quote.assigned_user_id', $this->input['report_keys'])) {
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name(): '';
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name() : '';
}
if (in_array('quote.user_id', $this->input['report_keys'])) {
$entity['quote.user_id'] = $quote->user ? $quote->user->present()->name(): '';
$entity['quote.user_id'] = $quote->user ? $quote->user->present()->name() : '';
}

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class QuoteItemExport extends BaseExport
{
private $quote_transformer;
public string $date_key = 'date';
@ -33,7 +32,7 @@ class QuoteItemExport extends BaseExport
private Decorator $decorator;
private array $storage_array = [];
private array $storage_item_array = [];
private array $decorate_keys = [
@ -46,7 +45,7 @@ class QuoteItemExport extends BaseExport
$this->company = $company;
$this->input = $input;
$this->quote_transformer = new QuoteTransformer();
$this->decorator = new Decorator;
$this->decorator = new Decorator();
}
public function init(): Builder
@ -57,7 +56,7 @@ class QuoteItemExport extends BaseExport
App::setLocale($this->company->locale());
$t = app('translator');
$t->replace(Ninja::transformTranslations($this->company->settings));
if (count($this->input['report_keys']) == 0) {
$this->input['report_keys'] = array_values($this->mergeItemsKeys('quote_report_keys'));
}
@ -74,7 +73,7 @@ class QuoteItemExport extends BaseExport
return $query;
}
public function returnJson()
{
$query = $this->init();
@ -88,15 +87,15 @@ class QuoteItemExport extends BaseExport
$query->cursor()
->each(function ($resource) {
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
$this->storage_array = [];
});
return array_merge(['columns' => $header], $this->storage_item_array);
}
@ -104,7 +103,7 @@ class QuoteItemExport extends BaseExport
public function run()
{
//load the CSV document from a string
$this->csv = Writer::createFromString();
@ -113,14 +112,14 @@ class QuoteItemExport extends BaseExport
//insert the header
$this->csv->insertOne($this->buildHeader());
$query->cursor()
->each(function ($quote) {
$this->iterateItems($quote);
});
$this->csv->insertAll($this->storage_array);
return $this->csv->toString();
}
@ -135,11 +134,11 @@ class QuoteItemExport extends BaseExport
$item_array = [];
foreach (array_values(array_intersect($this->input['report_keys'], $this->item_report_keys)) as $key) { //items iterator produces item array
if (str_contains($key, "item.")) {
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
$tmp_key = 'type';
}
@ -155,7 +154,7 @@ class QuoteItemExport extends BaseExport
}
}
}
$transformed_items = array_merge($transformed_quote, $item_array);
$entity = $this->decorateAdvancedFields($quote, $transformed_items);
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
@ -164,14 +163,14 @@ class QuoteItemExport extends BaseExport
}
}
private function buildRow(Quote $quote) :array
private function buildRow(Quote $quote): array
{
$transformed_quote = $this->quote_transformer->transform($quote);
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if(is_array($parts) && $parts[0] == 'item') {
@ -192,7 +191,7 @@ class QuoteItemExport extends BaseExport
// return $entity;
return $this->decorateAdvancedFields($quote, $entity);
}
private function decorateAdvancedFields(Quote $quote, array $entity) :array
private function decorateAdvancedFields(Quote $quote, array $entity): array
{
// if (in_array('currency_id', $this->input['report_keys'])) {
// $entity['currency'] = $quote->client->currency() ? $quote->client->currency()->code : $quote->company->currency()->code;
@ -205,13 +204,13 @@ class QuoteItemExport extends BaseExport
// if (in_array('status_id', $this->input['report_keys'])) {
// $entity['status'] = $quote->stringStatus($quote->status_id);
// }
if (in_array('quote.assigned_user_id', $this->input['report_keys'])) {
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name(): '';
$entity['quote.assigned_user_id'] = $quote->assigned_user ? $quote->assigned_user->present()->name() : '';
}
if (in_array('quote.user_id', $this->input['report_keys'])) {
$entity['quote.user_id'] = $quote->user ? $quote->user->present()->name(): '';
$entity['quote.user_id'] = $quote->user ? $quote->user->present()->name() : '';
}

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class RecurringInvoiceExport extends BaseExport
{
private $invoice_transformer;
public string $date_key = 'date';
@ -101,12 +100,12 @@ class RecurringInvoiceExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
private function buildRow(RecurringInvoice $invoice) :array
private function buildRow(RecurringInvoice $invoice): array
{
$transformed_invoice = $this->invoice_transformer->transform($invoice);
@ -118,10 +117,9 @@ class RecurringInvoiceExport extends BaseExport
if (is_array($parts) && $parts[0] == 'recurring_invoice' && array_key_exists($parts[1], $transformed_invoice)) {
$entity[$key] = $transformed_invoice[$parts[1]];
} elseif($parts[0] == 'item'){
} elseif($parts[0] == 'item') {
$entity[$key] = '';
}
else {
} else {
// nlog($key);
$entity[$key] = $this->decorator->transform($key, $invoice);
// $entity[$key] = '';
@ -134,7 +132,7 @@ class RecurringInvoiceExport extends BaseExport
return $this->decorateAdvancedFields($invoice, $entity);
}
private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity) :array
private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity): array
{
// if (in_array('country_id', $this->input['report_keys'])) {
// $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : '';

View File

@ -26,7 +26,6 @@ use League\Csv\Writer;
class TaskExport extends BaseExport
{
private $entity_transformer;
public string $date_key = 'created_at';
@ -111,9 +110,9 @@ class TaskExport extends BaseExport
$query->cursor()
->each(function ($resource) {
$this->buildRow($resource);
foreach($this->storage_array as $row) {
$this->storage_item_array[] = $this->processMetaData($row, $resource);
}
@ -158,7 +157,7 @@ class TaskExport extends BaseExport
} else {
$this->iterateLogs($task, $entity);
}
}
private function iterateLogs(Task $task, array $entity)
@ -196,11 +195,11 @@ class TaskExport extends BaseExport
if (in_array('task.duration', $this->input['report_keys']) || in_array('duration', $this->input['report_keys'])) {
$entity['task.duration'] = $task->calcDuration();
}
$entity = $this->decorateAdvancedFields($task, $entity);
$this->storage_array[] = $entity;
unset($entity['task.start_date']);
unset($entity['task.end_date']);
unset($entity['task.duration']);
@ -208,7 +207,7 @@ class TaskExport extends BaseExport
}
private function decorateAdvancedFields(Task $task, array $entity) :array
private function decorateAdvancedFields(Task $task, array $entity): array
{
if (in_array('task.status_id', $this->input['report_keys'])) {
$entity['task.status_id'] = $task->status()->exists() ? $task->status->name : '';
@ -217,7 +216,7 @@ class TaskExport extends BaseExport
if (in_array('task.project_id', $this->input['report_keys'])) {
$entity['task.project_id'] = $task->project()->exists() ? $task->project->name : '';
}
if (in_array('task.user_id', $this->input['report_keys'])) {
$entity['task.user_id'] = $task->user ? $task->user->present()->name() : '';
}

View File

@ -24,7 +24,6 @@ use League\Csv\Writer;
class VendorExport extends BaseExport
{
private $vendor_transformer;
private $contact_transformer;
@ -59,7 +58,7 @@ class VendorExport extends BaseExport
if (count($this->input['report_keys']) == 0) {
$this->input['report_keys'] = array_values($this->vendor_report_keys);
}
$query = Vendor::query()->with('contacts')
->withTrashed()
->where('company_id', $this->company->id)
@ -86,13 +85,13 @@ class VendorExport extends BaseExport
$row = $this->buildRow($resource);
return $this->processMetaData($row, $resource);
})->toArray();
return array_merge(['columns' => $header], $report);
}
public function run()
{
$query = $this->init();
//insert the header
@ -106,7 +105,7 @@ class VendorExport extends BaseExport
return $this->csv->toString();
}
private function buildRow(Vendor $vendor) :array
private function buildRow(Vendor $vendor): array
{
$transformed_contact = false;
@ -136,7 +135,7 @@ class VendorExport extends BaseExport
return $this->decorateAdvancedFields($vendor, $entity);
}
private function decorateAdvancedFields(Vendor $vendor, array $entity) :array
private function decorateAdvancedFields(Vendor $vendor, array $entity): array
{
if (in_array('vendor.country_id', $this->input['report_keys'])) {
$entity['country'] = $vendor->country ? ctrans("texts.country_{$vendor->country->name}") : '';

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