mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 18:04:35 -04:00
php cs fixer
This commit is contained in:
parent
bab55e7aa0
commit
c5b6938447
@ -52,8 +52,9 @@ class EncryptNinja extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if($this->option('encrypt'))
|
||||
if($this->option('encrypt')) {
|
||||
return $this->encryptFiles();
|
||||
}
|
||||
|
||||
if($this->option('decrypt')) {
|
||||
return $this->decryptFiles();
|
||||
|
@ -451,13 +451,15 @@ class BaseExport
|
||||
{
|
||||
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']);
|
||||
}
|
||||
|
||||
$client = Client::withTrashed()->find($this->input['client_id']);
|
||||
|
||||
if(!$client)
|
||||
if(!$client) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$this->client_description = $client->present()->name;
|
||||
return $query->where('client_id', $this->input['client_id']);
|
||||
@ -845,16 +847,18 @@ class BaseExport
|
||||
|
||||
protected function addClientFilter($query, $clients): Builder
|
||||
{
|
||||
if(is_string($clients))
|
||||
if(is_string($clients)) {
|
||||
$clients = explode(',', $clients);
|
||||
}
|
||||
|
||||
$transformed_clients = $this->transformKeys($clients);
|
||||
|
||||
nlog($clients);
|
||||
nlog($transformed_clients);
|
||||
|
||||
if(count($transformed_clients) > 0)
|
||||
if(count($transformed_clients) > 0) {
|
||||
$query->whereIn('client_id', $transformed_clients);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
@ -868,8 +872,9 @@ class BaseExport
|
||||
|
||||
$transformed_vendors = $this->transformKeys($vendors);
|
||||
|
||||
if(count($transformed_vendors) > 0)
|
||||
if(count($transformed_vendors) > 0) {
|
||||
$query->whereIn('vendor_id', $transformed_vendors);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
@ -883,8 +888,9 @@ class BaseExport
|
||||
|
||||
$transformed_projects = $this->transformKeys($projects);
|
||||
|
||||
if(count($transformed_projects) > 0)
|
||||
if(count($transformed_projects) > 0) {
|
||||
$query->whereIn('project_id', $transformed_projects);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
@ -899,8 +905,9 @@ class BaseExport
|
||||
$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);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
@ -1299,9 +1306,9 @@ class BaseExport
|
||||
public function queueDocuments(Builder $query)
|
||||
{
|
||||
nlog("queue docs pls");
|
||||
if($query->getModel() instanceof Document)
|
||||
if($query->getModel() instanceof Document) {
|
||||
$documents = $query->pluck('id')->toArray();
|
||||
else{
|
||||
} else {
|
||||
$documents = $query->cursor()
|
||||
->map(function ($entity) {
|
||||
return $entity->documents()->pluck('id')->toArray();
|
||||
@ -1315,11 +1322,13 @@ class BaseExport
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
ZipDocuments::dispatch($documents, $this->company, $user);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ use League\Csv\Writer;
|
||||
|
||||
class ExpenseExport extends BaseExport
|
||||
{
|
||||
|
||||
private $expense_transformer;
|
||||
|
||||
private Decorator $decorator;
|
||||
@ -206,14 +205,12 @@ class ExpenseExport extends BaseExport
|
||||
|
||||
if($expense->calculate_tax_by_amount) {
|
||||
$total_tax_amount = round($expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3, $precision);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
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));
|
||||
$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));
|
||||
$entity['expense.net_amount'] = round(($expense->amount + round($total_tax_amount, $precision)), $precision);
|
||||
}
|
||||
|
@ -165,8 +165,7 @@ class ClientFilters extends QueryFilters
|
||||
|
||||
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
|
||||
|
||||
if($sort_col[0] == 'number')
|
||||
{
|
||||
if($sort_col[0] == 'number') {
|
||||
return $this->builder->orderByRaw('ABS(number) ' . $dir);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,9 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
||||
foreach ($transactionResponse["transactions"]["booked"] as $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
|
||||
$transactionId = '';
|
||||
if (array_key_exists('transactionId', $transaction))
|
||||
if (array_key_exists('transactionId', $transaction)) {
|
||||
$transactionId = $transaction["transactionId"];
|
||||
else if (array_key_exists('internalTransactionId', $transaction))
|
||||
} elseif (array_key_exists('internalTransactionId', $transaction)) {
|
||||
$transactionId = $transaction["internalTransactionId"];
|
||||
else {
|
||||
} else {
|
||||
nlog(`Invalid Input for nordigen transaction transformer: ` . $transaction);
|
||||
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 = '';
|
||||
if (array_key_exists('remittanceInformationStructured', $transaction))
|
||||
if (array_key_exists('remittanceInformationStructured', $transaction)) {
|
||||
$description = $transaction["remittanceInformationStructured"];
|
||||
else if (array_key_exists('remittanceInformationStructuredArray', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationStructuredArray', $transaction)) {
|
||||
$description = implode('\n', $transaction["remittanceInformationStructuredArray"]);
|
||||
else if (array_key_exists('remittanceInformationUnstructured', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationUnstructured', $transaction)) {
|
||||
$description = $transaction["remittanceInformationUnstructured"];
|
||||
else if (array_key_exists('remittanceInformationUnstructuredArray', $transaction))
|
||||
} elseif (array_key_exists('remittanceInformationUnstructuredArray', $transaction)) {
|
||||
$description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]);
|
||||
else
|
||||
} else {
|
||||
Log::warning("Missing description for the following transaction: " . json_encode($transaction));
|
||||
}
|
||||
|
||||
// enrich description with currencyExchange informations
|
||||
if (array_key_exists('currencyExchange', $transaction))
|
||||
if (array_key_exists('currencyExchange', $transaction)) {
|
||||
foreach ($transaction["currencyExchange"] as $exchangeRate) {
|
||||
$targetAmount = round($amount * (float) $exchangeRate["exchangeRate"], 2);
|
||||
$description .= '\nexchangeRate: ' . $amount . " " . $exchangeRate["sourceCurrency"] . " = " . $targetAmount . " " . $exchangeRate["targetCurrency"] . " (" . $exchangeRate["quotationDate"] . ")";
|
||||
}
|
||||
}
|
||||
|
||||
// participant data
|
||||
$participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ?
|
||||
@ -153,8 +156,9 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
return $item->code == $code;
|
||||
})->first();
|
||||
|
||||
if ($currency)
|
||||
if ($currency) {
|
||||
return $currency->id;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -112,8 +112,9 @@ class BankTransactionController extends BaseController
|
||||
$this->bank_transaction_repo->convert_matched($bank_transactions);
|
||||
} else {
|
||||
$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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,9 @@ class DocumentController extends Controller
|
||||
|
||||
$hash = Cache::pull($hash);
|
||||
|
||||
if(!$hash)
|
||||
if(!$hash) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
MultiDB::setDb($hash['db']);
|
||||
|
||||
|
@ -58,4 +58,3 @@ class EmailPreferencesController extends Controller
|
||||
return back()->with('message', ctrans('texts.updated_settings'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,9 @@ class InvoiceController extends Controller
|
||||
$settings = auth()->guard('contact')->user()->client->getMergedSettings();
|
||||
$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();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'settings' => $settings,
|
||||
|
@ -29,8 +29,9 @@ class HostedMigrationController extends Controller
|
||||
MultiDB::findAndSetDbByCompanyKey($request->company_key);
|
||||
$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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
@ -22,18 +22,22 @@ class MailgunWebhookController extends BaseController
|
||||
{
|
||||
private $invitation;
|
||||
|
||||
public function __construct() {}
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function webhook(Request $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
if (\abs(\time() - $request['signature']['timestamp']) > 15)
|
||||
if (\abs(\time() - $request['signature']['timestamp']) > 15) {
|
||||
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);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Success.'], 200);
|
||||
}
|
||||
|
@ -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']);
|
||||
}
|
||||
|
||||
if(isset($input['footer']))
|
||||
if(isset($input['footer'])) {
|
||||
$input['footer'] = str_replace("</sc", "<-", $input['footer']);
|
||||
}
|
||||
|
||||
if(isset($input['terms']))
|
||||
if(isset($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']);
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ class PaymentAppliedValidAmount implements Rule
|
||||
|
||||
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';
|
||||
|
||||
return false;
|
||||
|
@ -117,10 +117,8 @@ class Wave extends BaseImport implements ImportInterface
|
||||
|
||||
$this->transformer = new InvoiceTransformer($this->company);
|
||||
|
||||
foreach($data as $key => $invoice)
|
||||
{
|
||||
if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number']))
|
||||
{
|
||||
foreach($data as $key => $invoice) {
|
||||
if(!isset($invoice['Invoice Number']) || empty($invoice['Invoice Number'])) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
$this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name);
|
||||
} elseif(isset($this->nmo->invitation->user)) {
|
||||
$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());
|
||||
}
|
||||
|
||||
@ -286,8 +285,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace App\Jobs\Mail;
|
||||
*/
|
||||
class NinjaMailerObject
|
||||
{
|
||||
|
||||
/* @var Illuminate\Mail\Mailable */
|
||||
public $mailable;
|
||||
|
||||
|
@ -34,7 +34,10 @@ use App\Notifications\Ninja\EmailBounceNotification;
|
||||
|
||||
class ProcessMailgunWebhook implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
@ -89,8 +92,9 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
{
|
||||
nlog($this->request);
|
||||
|
||||
if(!$this->request['event-data']['tags'][0])
|
||||
if(!$this->request['event-data']['tags'][0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($this->request['event-data']['tags'][0]);
|
||||
$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']);
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
$event = [
|
||||
'bounce_id' => '',
|
||||
|
@ -37,8 +37,9 @@ class InvoiceFailedEmailNotification
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
$invoice = $event->invitation->invoice;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
||||
//@deprecated?
|
||||
class EntityNotificationMailer extends Mailable
|
||||
{
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Support\Facades\App;
|
||||
|
||||
class UserLoggedIn extends Mailable
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
|
@ -328,8 +328,9 @@ class BaseModel extends Model
|
||||
*/
|
||||
public function parseHtmlVariables(string $field, array $variables): string
|
||||
{
|
||||
if(!$this->{$field})
|
||||
if(!$this->{$field}) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$section = strtr($this->{$field}, $variables['labels']);
|
||||
|
||||
|
@ -201,7 +201,8 @@ class CompanyUser extends Pivot
|
||||
* @return 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;
|
||||
}
|
||||
|
||||
|
@ -325,8 +325,9 @@ class Payment extends BaseModel
|
||||
return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>';
|
||||
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.payment_status_4').'</span></h6>';
|
||||
case self::STATUS_PARTIALLY_REFUNDED:
|
||||
|
@ -214,8 +214,9 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||
{
|
||||
$this->init();
|
||||
|
||||
if($this->company_gateway->update_details)
|
||||
if($this->company_gateway->update_details) {
|
||||
$this->updateCustomer();
|
||||
}
|
||||
|
||||
$request = new RefundRequest();
|
||||
$request->reference = "{$payment->transaction_reference} ".now();
|
||||
@ -332,8 +333,9 @@ class CheckoutComPaymentDriver extends BaseDriver
|
||||
public function updateCustomer($customer_id = null)
|
||||
{
|
||||
|
||||
if(!$customer_id)
|
||||
if(!$customer_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
@ -272,8 +272,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
//capture
|
||||
$orderID = $response['orderID'];
|
||||
|
||||
if($this->company_gateway->require_shipping_address)
|
||||
{
|
||||
if($this->company_gateway->require_shipping_address) {
|
||||
|
||||
$shipping_data =
|
||||
[[
|
||||
|
@ -26,7 +26,8 @@ use Illuminate\Database\QueryException;
|
||||
|
||||
class ClientService
|
||||
{
|
||||
use MakesDates, GeneratesCounter;
|
||||
use MakesDates;
|
||||
use GeneratesCounter;
|
||||
|
||||
private string $client_start_date;
|
||||
|
||||
@ -153,8 +154,9 @@ class ClientService
|
||||
{
|
||||
$x = 1;
|
||||
|
||||
if(isset($this->client->number))
|
||||
if(isset($this->client->number)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
do {
|
||||
try {
|
||||
|
@ -213,15 +213,13 @@ class EmailDefaults
|
||||
|
||||
if(str_contains($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;
|
||||
}
|
||||
|
||||
if(strlen($this->email->email_object->settings->reply_to_name) > 3) {
|
||||
$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();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ use CleverIt\UBL\Invoice\Price;
|
||||
|
||||
class RoEInvoice extends AbstractService
|
||||
{
|
||||
|
||||
public function __construct(public Invoice $invoice)
|
||||
{
|
||||
}
|
||||
|
@ -18,7 +18,9 @@ use Illuminate\Database\QueryException;
|
||||
|
||||
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.
|
||||
|
@ -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.
|
||||
}
|
||||
|
||||
if($refund > $new_charge)
|
||||
if($refund > $new_charge) {
|
||||
return $this->generateCredit($refund - $new_charge);
|
||||
}
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use App\Repositories\SubscriptionRepository;
|
||||
|
||||
class InvoiceToRecurring extends AbstractService
|
||||
{
|
||||
|
||||
protected \App\Services\Subscription\SubscriptionStatus $status;
|
||||
|
||||
public function __construct(protected int $client_id, public Subscription $subscription, public array $bundle = [])
|
||||
|
@ -19,7 +19,9 @@ use App\Services\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 */
|
||||
public bool $is_trial = false;
|
||||
@ -93,8 +95,9 @@ class SubscriptionStatus extends AbstractService
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if(!$primary_invoice)
|
||||
if(!$primary_invoice) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$subscription_start_date = Carbon::parse($primary_invoice->date)->startOfDay();
|
||||
|
||||
@ -140,8 +143,9 @@ class SubscriptionStatus extends AbstractService
|
||||
private function checkTrial(): self
|
||||
{
|
||||
|
||||
if(!$this->subscription->trial_enabled)
|
||||
if(!$this->subscription->trial_enabled) {
|
||||
return $this->setIsTrial(false);
|
||||
}
|
||||
|
||||
$primary_invoice = Invoice::query()
|
||||
->where('company_id', $this->recurring_invoice->company_id)
|
||||
@ -170,8 +174,9 @@ class SubscriptionStatus extends AbstractService
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
$primary_invoice = $this->recurring_invoice
|
||||
->invoices()
|
||||
|
@ -38,10 +38,11 @@ class UpgradePrice extends AbstractService
|
||||
->subscription
|
||||
->status($this->recurring_invoice);
|
||||
|
||||
if($this->status->is_in_good_standing)
|
||||
if($this->status->is_in_good_standing) {
|
||||
$this->calculateUpgrade();
|
||||
else
|
||||
} else {
|
||||
$this->upgrade_price = $this->subscription->price;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@ -70,8 +71,9 @@ class UpgradePrice extends AbstractService
|
||||
|
||||
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 max(0, round(($invoice->paid_to_date * $ratio), 2));
|
||||
}
|
||||
|
@ -745,8 +745,9 @@ class HtmlEngine
|
||||
if((int)$this->client->country_id !== (int)$this->company->settings->country_id) {
|
||||
$tax_label .= ctrans('texts.intracommunity_tax_info') . "<br>";
|
||||
|
||||
if($this->entity_calc->getTotalTaxes() > 0)
|
||||
if($this->entity_calc->getTotalTaxes() > 0) {
|
||||
$tax_label = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -74,11 +74,13 @@ trait CleanLineItems
|
||||
|
||||
}
|
||||
|
||||
if(isset($item['notes']))
|
||||
if(isset($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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user