Skip to content

Commit

Permalink
Merge branch 'v5-develop' into einvoicing-peppol-form-api
Browse files Browse the repository at this point in the history
Signed-off-by: David Bomba <[email protected]>
  • Loading branch information
turbo124 authored Oct 21, 2024
2 parents 56264b1 + e697790 commit 73364b5
Show file tree
Hide file tree
Showing 150 changed files with 4,881 additions and 837 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.10.34
5.10.42
20 changes: 11 additions & 9 deletions app/Console/Commands/CreateSingleAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,12 @@ private function createSmallAccount()

});


$this->countryClients($company, $user);

$cc = ClientContact::where('company_id', $company->id)->latest()->first();
$cc->email = '[email protected]';
$cc->save();

$this->info("finished");

}
Expand Down Expand Up @@ -472,13 +475,13 @@ private function createClient($company, $user)
'company_id' => $company->id,
]);

ClientContact::factory()->create([
'user_id' => $user->id,
'client_id' => $client->id,
'company_id' => $company->id,
'is_primary' => 1,
'email' => '[email protected]',
]);
// ClientContact::factory()->create([
// 'user_id' => $user->id,
// 'client_id' => $client->id,
// 'company_id' => $company->id,
// 'is_primary' => 1,
// 'email' => '[email protected]',
// ]);

ClientContact::factory()->count(rand(1, 2))->create([
'user_id' => $user->id,
Expand All @@ -490,7 +493,6 @@ private function createClient($company, $user)

$settings = $client->settings;
$settings->currency_id = "1";
// $settings->use_credits_payment = "always";

$client->settings = $settings;

Expand Down
14 changes: 12 additions & 2 deletions app/Console/Commands/TypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@

namespace App\Console\Commands;

use App\Libraries\MultiDB;
use App\Models\Client;
use App\Models\Company;
use App\Utils\Traits\ClientGroupSettingsSaver;
use App\Models\Invoice;
use App\Libraries\MultiDB;
use Illuminate\Console\Command;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\ClientGroupSettingsSaver;

class TypeCheck extends Command
{
use ClientGroupSettingsSaver;
use CleanLineItems;

/**
* The name and signature of the console command.
Expand Down Expand Up @@ -126,6 +129,13 @@ private function checkAll()
$this->logMessage("Checking company {$company->id}");
$company->saveSettings($company->settings, $company);
});

Invoice::query()->cursor()->each(function ($invoice){
$this->logMessage("Checking invoice {$invoice->id}");
$invoice->line_items = $this->cleanItems($invoice->line_items);
$invoice->saveQuietly();
});

}

private function logMessage($str)
Expand Down
2 changes: 1 addition & 1 deletion app/DataMapper/Tax/TaxModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(public mixed $model = null)
$this->regions = $this->init();
} else {

if(is_null($model->seller_subregion)) {
if(is_null($model->seller_subregion)) {//@phpstan-ignore-line
$this->seller_subregion = '';
}

Expand Down
13 changes: 12 additions & 1 deletion app/Events/Credit/CreditWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@

namespace App\Events\Credit;

use App\Models\BaseModel;
use App\Models\Company;
use App\Models\Credit;
use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class CreditWasCreated
class CreditWasCreated implements ShouldBroadcast
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
use DefaultResourceBroadcast;

public $credit;

Expand All @@ -41,5 +45,12 @@ public function __construct(Credit $credit, Company $company, array $event_vars)
$this->credit = $credit;
$this->company = $company;
$this->event_vars = $event_vars;

$this->dontBroadcastToCurrentUser();
}

public function broadcastModel(): BaseModel
{
return $this->credit;
}
}
13 changes: 12 additions & 1 deletion app/Events/Credit/CreditWasUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@

namespace App\Events\Credit;

use App\Models\BaseModel;
use App\Models\Company;
use App\Models\Credit;
use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class CreditWasUpdated
class CreditWasUpdated implements ShouldBroadcast
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
use DefaultResourceBroadcast;

public $credit;

Expand All @@ -41,5 +45,12 @@ public function __construct(Credit $credit, Company $company, array $event_vars)
$this->credit = $credit;
$this->company = $company;
$this->event_vars = $event_vars;

$this->dontBroadcastToCurrentUser();
}

public function broadcastModel(): BaseModel
{
return $this->credit;
}
}
10 changes: 8 additions & 2 deletions app/Events/Invoice/InvoiceWasPaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

namespace App\Events\Invoice;

use App\Models\BaseModel;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\Payment;
use App\Utils\Traits\Invoice\Broadcasting\DefaultInvoiceBroadcast;
use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
Expand All @@ -25,7 +26,7 @@
*/
class InvoiceWasPaid implements ShouldBroadcast
{
use SerializesModels, DefaultInvoiceBroadcast, InteractsWithSockets;
use SerializesModels, DefaultResourceBroadcast, InteractsWithSockets;

/**
* Create a new event instance.
Expand All @@ -39,4 +40,9 @@ public function __construct(public Invoice $invoice, public Payment $payment, pu
{
$this->dontBroadcastToCurrentUser();
}

public function broadcastModel(): BaseModel
{
return $this->invoice;
}
}
23 changes: 21 additions & 2 deletions app/Events/Invoice/InvoiceWasViewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@

namespace App\Events\Invoice;

use App\Models\BaseModel;
use App\Models\Company;
use App\Models\InvoiceInvitation;
use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
use League\Fractal\Manager;

/**
* Class InvoiceWasViewed.
*/
class InvoiceWasViewed
class InvoiceWasViewed implements ShouldBroadcast
{
use SerializesModels;

use InteractsWithSockets;
use DefaultResourceBroadcast;

/**
* Create a new event instance.
Expand All @@ -32,5 +38,18 @@ class InvoiceWasViewed
*/
public function __construct(public InvoiceInvitation $invitation, public Company $company, public array $event_vars)
{
//
}

public function broadcastModel(): BaseModel
{
return $this->invitation->invoice;
}

public function broadcastManager(Manager $manager): Manager
{
$manager->parseIncludes('client');

return $manager;
}
}
15 changes: 13 additions & 2 deletions app/Events/Payment/PaymentWasUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@

namespace App\Events\Payment;

use App\Models\BaseModel;
use App\Models\Company;
use App\Models\Payment;
use App\Utils\Traits\Invoice\Broadcasting\DefaultResourceBroadcast;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;

/**
* Class PaymentWasUpdated.
*/
class PaymentWasUpdated
class PaymentWasUpdated implements ShouldBroadcast
{
use SerializesModels;
use SerializesModels, InteractsWithSockets, DefaultResourceBroadcast;

/**
* @var Payment
Expand All @@ -43,5 +47,12 @@ public function __construct(Payment $payment, Company $company, array $event_var
$this->payment = $payment;
$this->company = $company;
$this->event_vars = $event_vars;

$this->dontBroadcastToCurrentUser();
}

public function broadcastModel(): BaseModel
{
return $this->payment;
}
}
22 changes: 14 additions & 8 deletions app/Export/CSV/TaskExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ public function init(): Builder

if (count($this->input['report_keys']) == 0) {
$this->input['report_keys'] = array_values($this->task_report_keys);
$this->input['report_keys'] = array_merge($this->input['report_keys'], array_diff($this->forced_client_fields, $this->input['report_keys']));
}

$this->input['report_keys'] = array_merge($this->input['report_keys'], array_diff($this->forced_client_fields, $this->input['report_keys']));

$query = Task::query()
->withTrashed()
->where('company_id', $this->company->id);
Expand Down Expand Up @@ -207,15 +206,23 @@ private function iterateLogs(Task $task, array $entity)
$entity['task.end_time'] = ctrans('texts.is_running');
}

$seconds = $task->calcDuration();
$time_log_entry = (isset($item[1]) && $item[1] != 0) ? $item[1] - $item[0] : ctrans('texts.is_running');

if (in_array('task.duration', $this->input['report_keys']) || in_array('duration', $this->input['report_keys'])) {
$seconds = $task->calcDuration();
$entity['task.duration'] = $seconds;
$entity['task.duration_words'] = $seconds > 86400 ? CarbonInterval::seconds($seconds)->locale($this->company->locale())->cascade()->forHumans() : now()->startOfDay()->addSeconds($seconds)->format('H:i:s');
}

$time_log_entry = (isset($item[1]) && $item[1] != 0) ? $item[1] - $item[0] : ctrans('texts.is_running');
if (in_array('task.time_log', $this->input['report_keys']) || in_array('time_log', $this->input['report_keys'])) {
$entity['task.time_log'] = $time_log_entry;
$entity['task.time_log_duration_words'] = is_int($time_log_entry) && $time_log_entry > 86400 ? CarbonInterval::seconds($time_log_entry)->locale($this->company->locale())->cascade()->forHumans() : $time_log_entry;
}

if (in_array('task.time_log_duration_words', $this->input['report_keys']) || in_array('time_log_duration_words', $this->input['report_keys'])) {
$entity['task.time_log_duration_words'] = is_int($time_log_entry) ? CarbonInterval::seconds($time_log_entry)->locale($this->company->locale())->cascade()->forHumans() : $time_log_entry;
}

if (in_array('task.duration_words', $this->input['report_keys']) || in_array('duration_words', $this->input['report_keys'])) {
$entity['task.duration_words'] = $seconds > 86400 ? CarbonInterval::seconds($seconds)->locale($this->company->locale())->cascade()->forHumans() : now()->startOfDay()->addSeconds($seconds)->format('H:i:s');
}

if (in_array('task.billable', $this->input['report_keys']) || in_array('billable', $this->input['report_keys'])) {
Expand All @@ -227,7 +234,6 @@ private function iterateLogs(Task $task, array $entity)
}



$this->storage_array[] = $entity;

$entity['task.start_date'] = '';
Expand All @@ -237,7 +243,7 @@ private function iterateLogs(Task $task, array $entity)
$entity['task.duration'] = '';
$entity['task.duration_words'] = '';
$entity['task.time_log'] = '';
$entity['task.time_log_duration_words'];
$entity['task.time_log_duration_words'] = '';
$entity['task.billable'] = '';
$entity['task.item_notes'] = '';

Expand Down
9 changes: 9 additions & 0 deletions app/Filters/ExpenseFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ public function categories(string $categories = ''): Builder
return $this->builder->whereIn('category_id', $categories_keys);
}

public function amount(string $amount = ''): Builder
{
if (strlen($amount) == 0) {
return $this->builder;
}

return $this->builder->where('amount', $amount);
}

public function number(string $number = ''): Builder
{
if (strlen($number) == 0) {
Expand Down
5 changes: 1 addition & 4 deletions app/Filters/InvoiceFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function sort(string $sort = ''): Builder
{
$sort_col = explode('|', $sort);

if (!is_array($sort_col) || count($sort_col) != 2 || in_array($sort_col[0], ['documents'])) {
if (!is_array($sort_col) || count($sort_col) != 2 || !in_array($sort_col[0], \Illuminate\Support\Facades\Schema::getColumnListing($this->builder->getModel()->getTable()))) {
return $this->builder;
}

Expand All @@ -290,9 +290,6 @@ public function sort(string $sort = ''): Builder
}

if($sort_col[0] == 'number') {
// return $this->builder->orderByRaw('CAST(number AS UNSIGNED), number ' . $dir);
// return $this->builder->orderByRaw("number REGEXP '^[A-Za-z]+$',CAST(number as SIGNED INTEGER),CAST(REPLACE(number,'-','')AS SIGNED INTEGER) ,number");
// return $this->builder->orderByRaw('ABS(number) ' . $dir);
return $this->builder->orderByRaw("REGEXP_REPLACE(invoices.number,'[^0-9]+','')+0 " . $dir);
}

Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/ClientPortal/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function index(ShowInvoicesRequest $request)
public function show(ShowInvoiceRequest $request, Invoice $invoice, ?string $hash = null)
{
set_time_limit(0);

$invitation = $invoice->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first();

// @phpstan-ignore-next-line
Expand Down Expand Up @@ -91,7 +91,6 @@ public function show(ShowInvoiceRequest $request, Invoice $invoice, ?string $has

return auth()->guard('contact')->user()->client->getSetting('payment_flow') == 'default' ? $this->render('invoices.show', $data) : $this->render('invoices.show_smooth', $data);

// return $this->render('invoices.show_smooth', $data);
}

public function showBlob($hash)
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/CreditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,6 @@ private function performAction(Credit $credit, $action, $bulk = false)
EmailEntity::dispatch($invitation, $credit->company, 'credit');
});

// $credit->sendEvent(Webhook::EVENT_SENT_CREDIT, "client");

if (! $bulk) {
return response()->json(['message' => 'email sent'], 200);
}
Expand Down
Loading

0 comments on commit 73364b5

Please sign in to comment.