php cs fixer

This commit is contained in:
David Bomba 2024-02-13 15:25:18 +11:00
parent bab55e7aa0
commit c5b6938447
106 changed files with 657 additions and 622 deletions

View File

@ -52,8 +52,9 @@ class EncryptNinja extends Command
*/ */
public function handle() public function handle()
{ {
if($this->option('encrypt')) if($this->option('encrypt')) {
return $this->encryptFiles(); return $this->encryptFiles();
}
if($this->option('decrypt')) { if($this->option('decrypt')) {
return $this->decryptFiles(); return $this->decryptFiles();

View File

@ -451,13 +451,15 @@ class BaseExport
{ {
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') { if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
if(!is_int($this->input['client_id'])) if(!is_int($this->input['client_id'])) {
$this->input['client_id'] = $this->decodePrimaryKey($this->input['client_id']); $this->input['client_id'] = $this->decodePrimaryKey($this->input['client_id']);
}
$client = Client::withTrashed()->find($this->input['client_id']); $client = Client::withTrashed()->find($this->input['client_id']);
if(!$client) if(!$client) {
return $query; return $query;
}
$this->client_description = $client->present()->name; $this->client_description = $client->present()->name;
return $query->where('client_id', $this->input['client_id']); return $query->where('client_id', $this->input['client_id']);
@ -845,16 +847,18 @@ class BaseExport
protected function addClientFilter($query, $clients): Builder protected function addClientFilter($query, $clients): Builder
{ {
if(is_string($clients)) if(is_string($clients)) {
$clients = explode(',', $clients); $clients = explode(',', $clients);
}
$transformed_clients = $this->transformKeys($clients); $transformed_clients = $this->transformKeys($clients);
nlog($clients); nlog($clients);
nlog($transformed_clients); nlog($transformed_clients);
if(count($transformed_clients) > 0) if(count($transformed_clients) > 0) {
$query->whereIn('client_id', $transformed_clients); $query->whereIn('client_id', $transformed_clients);
}
return $query; return $query;
} }
@ -868,8 +872,9 @@ class BaseExport
$transformed_vendors = $this->transformKeys($vendors); $transformed_vendors = $this->transformKeys($vendors);
if(count($transformed_vendors) > 0) if(count($transformed_vendors) > 0) {
$query->whereIn('vendor_id', $transformed_vendors); $query->whereIn('vendor_id', $transformed_vendors);
}
return $query; return $query;
} }
@ -883,8 +888,9 @@ class BaseExport
$transformed_projects = $this->transformKeys($projects); $transformed_projects = $this->transformKeys($projects);
if(count($transformed_projects) > 0) if(count($transformed_projects) > 0) {
$query->whereIn('project_id', $transformed_projects); $query->whereIn('project_id', $transformed_projects);
}
return $query; return $query;
} }
@ -899,8 +905,9 @@ class BaseExport
$transformed_expense_categories = $this->transformKeys($expense_categories); $transformed_expense_categories = $this->transformKeys($expense_categories);
if(count($transformed_expense_categories) > 0) if(count($transformed_expense_categories) > 0) {
$query->whereIn('category_id', $transformed_expense_categories); $query->whereIn('category_id', $transformed_expense_categories);
}
return $query; return $query;
} }
@ -1299,9 +1306,9 @@ class BaseExport
public function queueDocuments(Builder $query) public function queueDocuments(Builder $query)
{ {
nlog("queue docs pls"); nlog("queue docs pls");
if($query->getModel() instanceof Document) if($query->getModel() instanceof Document) {
$documents = $query->pluck('id')->toArray(); $documents = $query->pluck('id')->toArray();
else{ } else {
$documents = $query->cursor() $documents = $query->cursor()
->map(function ($entity) { ->map(function ($entity) {
return $entity->documents()->pluck('id')->toArray(); return $entity->documents()->pluck('id')->toArray();
@ -1315,11 +1322,13 @@ class BaseExport
$user = $this->company->owner(); $user = $this->company->owner();
if(auth()->user() && auth()->user()->account_id == $this->company->account_id) if(auth()->user() && auth()->user()->account_id == $this->company->account_id) {
$user = auth()->user(); $user = auth()->user();
}
if($this->input['user_id'] ?? false) if($this->input['user_id'] ?? false) {
$user = User::where('id', $this->input['user_id'])->where('account_id', $this->company->account_id)->first(); $user = User::where('id', $this->input['user_id'])->where('account_id', $this->company->account_id)->first();
}
ZipDocuments::dispatch($documents, $this->company, $user); ZipDocuments::dispatch($documents, $this->company, $user);
} }

View File

@ -23,7 +23,6 @@ use League\Csv\Writer;
class ExpenseExport extends BaseExport class ExpenseExport extends BaseExport
{ {
private $expense_transformer; private $expense_transformer;
private Decorator $decorator; private Decorator $decorator;
@ -206,14 +205,12 @@ class ExpenseExport extends BaseExport
if($expense->calculate_tax_by_amount) { if($expense->calculate_tax_by_amount) {
$total_tax_amount = round($expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3, $precision); $total_tax_amount = round($expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3, $precision);
} } else {
else {
if($expense->uses_inclusive_taxes) { if($expense->uses_inclusive_taxes) {
$total_tax_amount = ($this->calcInclusiveLineTax($expense->tax_rate1 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate2 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate3 ?? 0, $expense->amount, $precision)); $total_tax_amount = ($this->calcInclusiveLineTax($expense->tax_rate1 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate2 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate3 ?? 0, $expense->amount, $precision));
$entity['expense.net_amount'] = round(($expense->amount - round($total_tax_amount, $precision)), $precision); $entity['expense.net_amount'] = round(($expense->amount - round($total_tax_amount, $precision)), $precision);
} } else {
else{
$total_tax_amount = ($expense->amount * (($expense->tax_rate1 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate2 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate3 ?? 0) / 100)); $total_tax_amount = ($expense->amount * (($expense->tax_rate1 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate2 ?? 0) / 100)) + ($expense->amount * (($expense->tax_rate3 ?? 0) / 100));
$entity['expense.net_amount'] = round(($expense->amount + round($total_tax_amount, $precision)), $precision); $entity['expense.net_amount'] = round(($expense->amount + round($total_tax_amount, $precision)), $precision);
} }

View File

@ -165,8 +165,7 @@ class ClientFilters extends QueryFilters
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc'; $dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
if($sort_col[0] == 'number') if($sort_col[0] == 'number') {
{
return $this->builder->orderByRaw('ABS(number) ' . $dir); return $this->builder->orderByRaw('ABS(number) ' . $dir);
} }

View File

@ -323,8 +323,7 @@ class InvoiceFilters extends QueryFilters
} }
if($sort_col[0] == 'number') if($sort_col[0] == 'number') {
{
return $this->builder->orderByRaw('ABS(number) ' . $dir); return $this->builder->orderByRaw('ABS(number) ' . $dir);
} }

View File

@ -70,8 +70,9 @@ class TransactionTransformer implements BankRevenueInterface
{ {
$data = []; $data = [];
if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"])) if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"])) {
throw new \Exception('invalid dataset'); throw new \Exception('invalid dataset');
}
foreach ($transactionResponse["transactions"]["booked"] as $transaction) { foreach ($transactionResponse["transactions"]["booked"] as $transaction) {
$data[] = $this->transformTransaction($transaction); $data[] = $this->transformTransaction($transaction);
@ -83,11 +84,11 @@ class TransactionTransformer implements BankRevenueInterface
{ {
// depending on institution, the result can be different, so we load the first available unique id // depending on institution, the result can be different, so we load the first available unique id
$transactionId = ''; $transactionId = '';
if (array_key_exists('transactionId', $transaction)) if (array_key_exists('transactionId', $transaction)) {
$transactionId = $transaction["transactionId"]; $transactionId = $transaction["transactionId"];
else if (array_key_exists('internalTransactionId', $transaction)) } elseif (array_key_exists('internalTransactionId', $transaction)) {
$transactionId = $transaction["internalTransactionId"]; $transactionId = $transaction["internalTransactionId"];
else { } else {
nlog(`Invalid Input for nordigen transaction transformer: ` . $transaction); nlog(`Invalid Input for nordigen transaction transformer: ` . $transaction);
throw new \Exception('invalid dataset: missing transactionId - Please report this error to the developer'); throw new \Exception('invalid dataset: missing transactionId - Please report this error to the developer');
} }
@ -96,23 +97,25 @@ class TransactionTransformer implements BankRevenueInterface
// description could be in varios places // description could be in varios places
$description = ''; $description = '';
if (array_key_exists('remittanceInformationStructured', $transaction)) if (array_key_exists('remittanceInformationStructured', $transaction)) {
$description = $transaction["remittanceInformationStructured"]; $description = $transaction["remittanceInformationStructured"];
else if (array_key_exists('remittanceInformationStructuredArray', $transaction)) } elseif (array_key_exists('remittanceInformationStructuredArray', $transaction)) {
$description = implode('\n', $transaction["remittanceInformationStructuredArray"]); $description = implode('\n', $transaction["remittanceInformationStructuredArray"]);
else if (array_key_exists('remittanceInformationUnstructured', $transaction)) } elseif (array_key_exists('remittanceInformationUnstructured', $transaction)) {
$description = $transaction["remittanceInformationUnstructured"]; $description = $transaction["remittanceInformationUnstructured"];
else if (array_key_exists('remittanceInformationUnstructuredArray', $transaction)) } elseif (array_key_exists('remittanceInformationUnstructuredArray', $transaction)) {
$description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]); $description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]);
else } else {
Log::warning("Missing description for the following transaction: " . json_encode($transaction)); Log::warning("Missing description for the following transaction: " . json_encode($transaction));
}
// enrich description with currencyExchange informations // enrich description with currencyExchange informations
if (array_key_exists('currencyExchange', $transaction)) if (array_key_exists('currencyExchange', $transaction)) {
foreach ($transaction["currencyExchange"] as $exchangeRate) { foreach ($transaction["currencyExchange"] as $exchangeRate) {
$targetAmount = round($amount * (float) $exchangeRate["exchangeRate"], 2); $targetAmount = round($amount * (float) $exchangeRate["exchangeRate"], 2);
$description .= '\nexchangeRate: ' . $amount . " " . $exchangeRate["sourceCurrency"] . " = " . $targetAmount . " " . $exchangeRate["targetCurrency"] . " (" . $exchangeRate["quotationDate"] . ")"; $description .= '\nexchangeRate: ' . $amount . " " . $exchangeRate["sourceCurrency"] . " = " . $targetAmount . " " . $exchangeRate["targetCurrency"] . " (" . $exchangeRate["quotationDate"] . ")";
} }
}
// participant data // participant data
$participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ? $participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ?
@ -153,8 +156,9 @@ class TransactionTransformer implements BankRevenueInterface
return $item->code == $code; return $item->code == $code;
})->first(); })->first();
if ($currency) if ($currency) {
return $currency->id; return $currency->id;
}
return 1; return 1;

View File

@ -112,8 +112,9 @@ class BankTransactionController extends BaseController
$this->bank_transaction_repo->convert_matched($bank_transactions); $this->bank_transaction_repo->convert_matched($bank_transactions);
} else { } else {
$bank_transactions->each(function ($bank_transaction, $key) use ($action, $user) { $bank_transactions->each(function ($bank_transaction, $key) use ($action, $user) {
if($user->can('edit', $bank_transaction)) if($user->can('edit', $bank_transaction)) {
$this->bank_transaction_repo->{$action}($bank_transaction); $this->bank_transaction_repo->{$action}($bank_transaction);
}
}); });
} }

View File

@ -74,8 +74,9 @@ class DocumentController extends Controller
$hash = Cache::pull($hash); $hash = Cache::pull($hash);
if(!$hash) if(!$hash) {
abort(404); abort(404);
}
MultiDB::setDb($hash['db']); MultiDB::setDb($hash['db']);

View File

@ -58,4 +58,3 @@ class EmailPreferencesController extends Controller
return back()->with('message', ctrans('texts.updated_settings')); return back()->with('message', ctrans('texts.updated_settings'));
} }
} }

View File

@ -224,8 +224,9 @@ class InvoiceController extends Controller
$settings = auth()->guard('contact')->user()->client->getMergedSettings(); $settings = auth()->guard('contact')->user()->client->getMergedSettings();
$variables = false; $variables = false;
if(($invitation = $invoices->first()->invitations()->first() ?? false) && $settings->show_accept_invoice_terms) if(($invitation = $invoices->first()->invitations()->first() ?? false) && $settings->show_accept_invoice_terms) {
$variables = (new HtmlEngine($invitation))->generateLabelsAndValues(); $variables = (new HtmlEngine($invitation))->generateLabelsAndValues();
}
$data = [ $data = [
'settings' => $settings, 'settings' => $settings,

View File

@ -29,8 +29,9 @@ class HostedMigrationController extends Controller
MultiDB::findAndSetDbByCompanyKey($request->company_key); MultiDB::findAndSetDbByCompanyKey($request->company_key);
$c = Company::where('company_key', $request->company_key)->first(); $c = Company::where('company_key', $request->company_key)->first();
if(!$c || $c->is_disabled) if(!$c || $c->is_disabled) {
return response()->json(['message' => 'ok'], 200); return response()->json(['message' => 'ok'], 200);
}
// if(\App\Models\Invoice::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2))->first()) // if(\App\Models\Invoice::query()->where('company_id', $c->id)->where('created_at', '>', now()->subMonths(2))->first())
// return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400); // return response()->json(['message' => 'New data exists, are you sure? Please log in here https://app.invoicing.co and delete the company if you really need to migrate again.'], 400);

View File

@ -22,18 +22,22 @@ class MailgunWebhookController extends BaseController
{ {
private $invitation; private $invitation;
public function __construct() {} public function __construct()
{
}
public function webhook(Request $request) public function webhook(Request $request)
{ {
$input = $request->all(); $input = $request->all();
if (\abs(\time() - $request['signature']['timestamp']) > 15) if (\abs(\time() - $request['signature']['timestamp']) > 15) {
return response()->json(['message' => 'Success'], 200); return response()->json(['message' => 'Success'], 200);
}
if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) {
ProcessMailgunWebhook::dispatch($request->all())->delay(10); ProcessMailgunWebhook::dispatch($request->all())->delay(10);
}
return response()->json(['message' => 'Success.'], 200); return response()->json(['message' => 'Success.'], 200);
} }

View File

@ -198,17 +198,21 @@ class Request extends FormRequest
} }
} }
if(isset($input['public_notes'])) if(isset($input['public_notes'])) {
$input['public_notes'] = str_replace("</sc", "<-", $input['public_notes']); $input['public_notes'] = str_replace("</sc", "<-", $input['public_notes']);
}
if(isset($input['footer'])) if(isset($input['footer'])) {
$input['footer'] = str_replace("</sc", "<-", $input['footer']); $input['footer'] = str_replace("</sc", "<-", $input['footer']);
}
if(isset($input['terms'])) if(isset($input['terms'])) {
$input['terms'] = str_replace("</sc", "<-", $input['terms']); $input['terms'] = str_replace("</sc", "<-", $input['terms']);
}
if(isset($input['private_notes'])) if(isset($input['private_notes'])) {
$input['private_notes'] = str_replace("</sc", "<-", $input['private_notes']); $input['private_notes'] = str_replace("</sc", "<-", $input['private_notes']);
}
return $input; return $input;
} }

View File

@ -90,8 +90,7 @@ class PaymentAppliedValidAmount implements Rule
if($inv->status_id == Invoice::STATUS_DRAFT && $inv->amount >= $invoice['amount']) { if($inv->status_id == Invoice::STATUS_DRAFT && $inv->amount >= $invoice['amount']) {
} } elseif ($inv->balance < $invoice['amount']) {
elseif ($inv->balance < $invoice['amount']) {
$this->message = 'Amount cannot be greater than invoice balance'; $this->message = 'Amount cannot be greater than invoice balance';
return false; return false;

View File

@ -117,10 +117,8 @@ class Wave extends BaseImport implements ImportInterface
$this->transformer = new InvoiceTransformer($this->company); $this->transformer = new InvoiceTransformer($this->company);
foreach($data as $key => $invoice) foreach($data as $key => $invoice) {
{ if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number'])) {
if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number']))
{
unset($data[$key]); unset($data[$key]);
} }
} }

View File

@ -101,8 +101,7 @@ class NinjaMailerJob implements ShouldQueue
$this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name); $this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name);
} elseif(isset($this->nmo->invitation->user)) { } elseif(isset($this->nmo->invitation->user)) {
$this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name()); $this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name());
} } else {
else {
$this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name()); $this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name());
} }
@ -286,8 +285,7 @@ class NinjaMailerJob implements ShouldQueue
return $this; return $this;
} }
} } catch(\Exception $e) {
catch(\Exception $e){
nlog($e->getMessage()); nlog($e->getMessage());
} }
} }

View File

@ -16,7 +16,6 @@ namespace App\Jobs\Mail;
*/ */
class NinjaMailerObject class NinjaMailerObject
{ {
/* @var Illuminate\Mail\Mailable */ /* @var Illuminate\Mail\Mailable */
public $mailable; public $mailable;

View File

@ -34,7 +34,10 @@ use App\Notifications\Ninja\EmailBounceNotification;
class ProcessMailgunWebhook implements ShouldQueue class ProcessMailgunWebhook implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public $tries = 1; public $tries = 1;
@ -89,8 +92,9 @@ class ProcessMailgunWebhook implements ShouldQueue
{ {
nlog($this->request); nlog($this->request);
if(!$this->request['event-data']['tags'][0]) if(!$this->request['event-data']['tags'][0]) {
return; return;
}
MultiDB::findAndSetDbByCompanyKey($this->request['event-data']['tags'][0]); MultiDB::findAndSetDbByCompanyKey($this->request['event-data']['tags'][0]);
$company = Company::where('company_key', $this->request['event-data']['tags'][0])->first(); $company = Company::where('company_key', $this->request['event-data']['tags'][0])->first();
@ -180,8 +184,9 @@ class ProcessMailgunWebhook implements ShouldQueue
$sl = $this->getSystemLog($this->request['MessageID']); $sl = $this->getSystemLog($this->request['MessageID']);
/** Prevents Gmail tracking from firing inappropriately */ /** Prevents Gmail tracking from firing inappropriately */
if($this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3) if($this->request['signature']['timestamp'] < $sl->log['signature']['timestamp'] + 3) {
return; return;
}
$event = [ $event = [
'bounce_id' => '', 'bounce_id' => '',

View File

@ -37,8 +37,9 @@ class InvoiceFailedEmailNotification
{ {
MultiDB::setDb($event->company->db); MultiDB::setDb($event->company->db);
if(Cache::has("invoice_failed_email_notification_{$event->invitation->key}")) if(Cache::has("invoice_failed_email_notification_{$event->invitation->key}")) {
return; return;
}
$invoice = $event->invitation->invoice; $invoice = $event->invitation->invoice;

View File

@ -12,6 +12,7 @@
namespace App\Mail\Admin; namespace App\Mail\Admin;
use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailable;
//@deprecated? //@deprecated?
class EntityNotificationMailer extends Mailable class EntityNotificationMailer extends Mailable
{ {

View File

@ -19,7 +19,6 @@ use Illuminate\Support\Facades\App;
class UserLoggedIn extends Mailable class UserLoggedIn extends Mailable
{ {
/** /**
* Create a new message instance. * Create a new message instance.
* *

View File

@ -328,8 +328,9 @@ class BaseModel extends Model
*/ */
public function parseHtmlVariables(string $field, array $variables): string public function parseHtmlVariables(string $field, array $variables): string
{ {
if(!$this->{$field}) if(!$this->{$field}) {
return ''; return '';
}
$section = strtr($this->{$field}, $variables['labels']); $section = strtr($this->{$field}, $variables['labels']);

View File

@ -201,7 +201,8 @@ class CompanyUser extends Pivot
* @return bool * @return bool
*/ */
public function portalType(): bool public function portalType(): bool
{ nlog(isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link); {
nlog(isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link);
return isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link; return isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link;
} }

View File

@ -325,8 +325,9 @@ class Payment extends BaseModel
return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>'; return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>';
case self::STATUS_COMPLETED: case self::STATUS_COMPLETED:
if($this->amount > $this->applied) if($this->amount > $this->applied) {
return '<h6><span class="badge badge-info">' . ctrans('texts.partially_unapplied') . '</span></h6>'; return '<h6><span class="badge badge-info">' . ctrans('texts.partially_unapplied') . '</span></h6>';
}
return '<h6><span class="badge badge-info">'.ctrans('texts.payment_status_4').'</span></h6>'; return '<h6><span class="badge badge-info">'.ctrans('texts.payment_status_4').'</span></h6>';
case self::STATUS_PARTIALLY_REFUNDED: case self::STATUS_PARTIALLY_REFUNDED:

View File

@ -214,8 +214,9 @@ class CheckoutComPaymentDriver extends BaseDriver
{ {
$this->init(); $this->init();
if($this->company_gateway->update_details) if($this->company_gateway->update_details) {
$this->updateCustomer(); $this->updateCustomer();
}
$request = new RefundRequest(); $request = new RefundRequest();
$request->reference = "{$payment->transaction_reference} ".now(); $request->reference = "{$payment->transaction_reference} ".now();
@ -332,8 +333,9 @@ class CheckoutComPaymentDriver extends BaseDriver
public function updateCustomer($customer_id = null) public function updateCustomer($customer_id = null)
{ {
if(!$customer_id) if(!$customer_id) {
return; return;
}
try { try {

View File

@ -272,8 +272,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
//capture //capture
$orderID = $response['orderID']; $orderID = $response['orderID'];
if($this->company_gateway->require_shipping_address) if($this->company_gateway->require_shipping_address) {
{
$shipping_data = $shipping_data =
[[ [[

View File

@ -26,7 +26,8 @@ use Illuminate\Database\QueryException;
class ClientService class ClientService
{ {
use MakesDates, GeneratesCounter; use MakesDates;
use GeneratesCounter;
private string $client_start_date; private string $client_start_date;
@ -153,8 +154,9 @@ class ClientService
{ {
$x = 1; $x = 1;
if(isset($this->client->number)) if(isset($this->client->number)) {
return $this; return $this;
}
do { do {
try { try {

View File

@ -213,15 +213,13 @@ class EmailDefaults
if(str_contains($this->email->email_object->settings->reply_to_email, "@")) { if(str_contains($this->email->email_object->settings->reply_to_email, "@")) {
$reply_to_email = $this->email->email_object->settings->reply_to_email; $reply_to_email = $this->email->email_object->settings->reply_to_email;
} } elseif(isset($this->email->email_object->invitation->user)) {
elseif(isset($this->email->email_object->invitation->user)) {
$reply_to_email = $this->email->email_object->invitation->user->email; $reply_to_email = $this->email->email_object->invitation->user->email;
} }
if(strlen($this->email->email_object->settings->reply_to_name) > 3) { if(strlen($this->email->email_object->settings->reply_to_name) > 3) {
$reply_to_name = $this->email->email_object->settings->reply_to_name; $reply_to_name = $this->email->email_object->settings->reply_to_name;
} } elseif(isset($this->email->email_object->invitation->user)) {
elseif(isset($this->email->email_object->invitation->user)) {
$reply_to_name = $this->email->email_object->invitation->user->present()->name(); $reply_to_name = $this->email->email_object->invitation->user->present()->name();
} }

View File

@ -34,7 +34,6 @@ use CleverIt\UBL\Invoice\Price;
class RoEInvoice extends AbstractService class RoEInvoice extends AbstractService
{ {
public function __construct(public Invoice $invoice) public function __construct(public Invoice $invoice)
{ {
} }

View File

@ -18,7 +18,9 @@ use Illuminate\Database\QueryException;
class SendEmail class SendEmail
{ {
public function __construct(public Payment $payment, public ?ClientContact $contact) {} public function __construct(public Payment $payment, public ?ClientContact $contact)
{
}
/** /**
* Builds the correct template to send. * Builds the correct template to send.

View File

@ -52,8 +52,9 @@ class ChangePlanInvoice extends AbstractService
//generate new recurring invoice at this point as we know the user has succeeded with their upgrade. //generate new recurring invoice at this point as we know the user has succeeded with their upgrade.
} }
if($refund > $new_charge) if($refund > $new_charge) {
return $this->generateCredit($refund - $new_charge); return $this->generateCredit($refund - $new_charge);
}
return $invoice; return $invoice;
} }

View File

@ -21,7 +21,6 @@ use App\Repositories\SubscriptionRepository;
class InvoiceToRecurring extends AbstractService class InvoiceToRecurring extends AbstractService
{ {
protected \App\Services\Subscription\SubscriptionStatus $status; protected \App\Services\Subscription\SubscriptionStatus $status;
public function __construct(protected int $client_id, public Subscription $subscription, public array $bundle = []) public function __construct(protected int $client_id, public Subscription $subscription, public array $bundle = [])

View File

@ -19,7 +19,9 @@ use App\Services\AbstractService;
class SubscriptionStatus extends AbstractService class SubscriptionStatus extends AbstractService
{ {
public function __construct(public Subscription $subscription, protected RecurringInvoice $recurring_invoice) {} public function __construct(public Subscription $subscription, protected RecurringInvoice $recurring_invoice)
{
}
/** @var bool $is_trial */ /** @var bool $is_trial */
public bool $is_trial = false; public bool $is_trial = false;
@ -93,8 +95,9 @@ class SubscriptionStatus extends AbstractService
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->first(); ->first();
if(!$primary_invoice) if(!$primary_invoice) {
return 0; return 0;
}
$subscription_start_date = Carbon::parse($primary_invoice->date)->startOfDay(); $subscription_start_date = Carbon::parse($primary_invoice->date)->startOfDay();
@ -140,8 +143,9 @@ class SubscriptionStatus extends AbstractService
private function checkTrial(): self private function checkTrial(): self
{ {
if(!$this->subscription->trial_enabled) if(!$this->subscription->trial_enabled) {
return $this->setIsTrial(false); return $this->setIsTrial(false);
}
$primary_invoice = Invoice::query() $primary_invoice = Invoice::query()
->where('company_id', $this->recurring_invoice->company_id) ->where('company_id', $this->recurring_invoice->company_id)
@ -170,8 +174,9 @@ class SubscriptionStatus extends AbstractService
*/ */
private function checkRefundable(): self private function checkRefundable(): self
{ {
if(!$this->recurring_invoice->subscription->refund_period || $this->recurring_invoice->subscription->refund_period === 0) if(!$this->recurring_invoice->subscription->refund_period || $this->recurring_invoice->subscription->refund_period === 0) {
return $this->setRefundable(false); return $this->setRefundable(false);
}
$primary_invoice = $this->recurring_invoice $primary_invoice = $this->recurring_invoice
->invoices() ->invoices()

View File

@ -38,10 +38,11 @@ class UpgradePrice extends AbstractService
->subscription ->subscription
->status($this->recurring_invoice); ->status($this->recurring_invoice);
if($this->status->is_in_good_standing) if($this->status->is_in_good_standing) {
$this->calculateUpgrade(); $this->calculateUpgrade();
else } else {
$this->upgrade_price = $this->subscription->price; $this->upgrade_price = $this->subscription->price;
}
return $this; return $this;
@ -70,8 +71,9 @@ class UpgradePrice extends AbstractService
private function getRefundableAmount(?Invoice $invoice, float $ratio): float private function getRefundableAmount(?Invoice $invoice, float $ratio): float
{ {
if (!$invoice || !$invoice->date || $invoice->status_id != Invoice::STATUS_PAID || $ratio == 0) if (!$invoice || !$invoice->date || $invoice->status_id != Invoice::STATUS_PAID || $ratio == 0) {
return 0; return 0;
}
return max(0, round(($invoice->paid_to_date * $ratio), 2)); return max(0, round(($invoice->paid_to_date * $ratio), 2));
} }

View File

@ -745,8 +745,9 @@ class HtmlEngine
if((int)$this->client->country_id !== (int)$this->company->settings->country_id) { if((int)$this->client->country_id !== (int)$this->company->settings->country_id) {
$tax_label .= ctrans('texts.intracommunity_tax_info') . "<br>"; $tax_label .= ctrans('texts.intracommunity_tax_info') . "<br>";
if($this->entity_calc->getTotalTaxes() > 0) if($this->entity_calc->getTotalTaxes() > 0) {
$tax_label = ''; $tax_label = '';
}
} }

View File

@ -74,11 +74,13 @@ trait CleanLineItems
} }
if(isset($item['notes'])) if(isset($item['notes'])) {
$item['notes'] = str_replace("</", "<-", $item['notes']); $item['notes'] = str_replace("</", "<-", $item['notes']);
}
if(isset($item['product_key'])) if(isset($item['product_key'])) {
$item['product_key'] = str_replace("</", "<-", $item['product_key']); $item['product_key'] = str_replace("</", "<-", $item['product_key']);
}
} }