mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
php cs fixer
This commit is contained in:
parent
bab55e7aa0
commit
c5b6938447
@ -891,7 +891,7 @@ class CheckData extends Command
|
||||
$this->logMessage("Fixing country for # {$client->id}");
|
||||
});
|
||||
|
||||
Client::query()->whereNull("settings->currency_id")->cursor()->each(function ($client){
|
||||
Client::query()->whereNull("settings->currency_id")->cursor()->each(function ($client) {
|
||||
$settings = $client->settings;
|
||||
$settings->currency_id = (string)$client->company->settings->currency_id;
|
||||
$client->settings = $settings;
|
||||
@ -901,7 +901,7 @@ class CheckData extends Command
|
||||
|
||||
});
|
||||
|
||||
Payment::withTrashed()->where('exchange_rate', 0)->cursor()->each(function ($payment){
|
||||
Payment::withTrashed()->where('exchange_rate', 0)->cursor()->each(function ($payment) {
|
||||
$payment->exchange_rate = 1;
|
||||
$payment->saveQuietly();
|
||||
|
||||
|
@ -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,11 +1306,11 @@ 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){
|
||||
->map(function ($entity) {
|
||||
return $entity->documents()->pluck('id')->toArray();
|
||||
})->flatten()
|
||||
->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,15 +205,13 @@ 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));
|
||||
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{
|
||||
$total_tax_amount = ($expense->amount * (($expense->tax_rate1 ?? 0)/100)) + ($expense->amount * (($expense->tax_rate2 ?? 0)/100)) + ($expense->amount * (($expense->tax_rate3 ?? 0)/100));
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
@ -318,13 +318,12 @@ class InvoiceFilters extends QueryFilters
|
||||
|
||||
if ($sort_col[0] == 'client_id') {
|
||||
|
||||
return $this->builder->orderBy(\App\Models\Client::select ('name')
|
||||
return $this->builder->orderBy(\App\Models\Client::select('name')
|
||||
->whereColumn('clients.id', 'invoices.client_id'), $dir);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -421,10 +421,10 @@ class ClientController extends BaseController
|
||||
|
||||
$documents = Document::query()
|
||||
->company()
|
||||
->whereHasMorph('documentable', [Invoice::class, Quote::class, Credit::class, Expense::class, Payment::class, Task::class], function ($query) use($client) {
|
||||
->whereHasMorph('documentable', [Invoice::class, Quote::class, Credit::class, Expense::class, Payment::class, Task::class], function ($query) use ($client) {
|
||||
$query->where('client_id', $client->id);
|
||||
})
|
||||
->orWhereHasMorph('documentable', [Client::class], function ($query) use ($client){
|
||||
->orWhereHasMorph('documentable', [Client::class], function ($query) use ($client) {
|
||||
$query->where('id', $client->id);
|
||||
});
|
||||
|
||||
|
@ -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']))
|
||||
$input['public_notes'] = str_replace("</sc","<-", $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;
|
||||
}
|
||||
|
@ -88,10 +88,9 @@ class PaymentAppliedValidAmount implements Rule
|
||||
nlog($inv->amount);
|
||||
nlog($invoice['amount']);
|
||||
|
||||
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';
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
$this->file_name = date('Y-m-d') . '_' . str_replace([" ", "/"], ["_",""], $this->company->present()->name() . '_' . $this->company->company_key . '.json');
|
||||
|
||||
$this->writer = new File($this->file_name);
|
||||
$this->writer = new File($this->file_name);
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$this->writer->value('app_version', config('ninja.app_version'));
|
||||
$this->writer->value('storage_url', Storage::url(''));
|
||||
$this->writer->value('app_version', config('ninja.app_version'));
|
||||
$this->writer->value('storage_url', Storage::url(''));
|
||||
|
||||
$this->export_data['activities'] = $this->company->all_activities->map(function ($activity) {
|
||||
$activity = $this->transformArrayOfKeys($activity, [
|
||||
@ -104,9 +104,9 @@ $this->writer->value('storage_url', Storage::url(''));
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('activities');
|
||||
$x->addItems($this->export_data['activities']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('activities');
|
||||
$x->addItems($this->export_data['activities']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['users'] = $this->company->users()->withTrashed()->cursor()->map(function ($user) {
|
||||
@ -116,9 +116,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('users');
|
||||
$x->addItems($this->export_data['users']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('users');
|
||||
$x->addItems($this->export_data['users']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['client_contacts'] = $this->company->client_contacts->map(function ($client_contact) {
|
||||
@ -140,9 +140,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('client_contacts');
|
||||
$x->addItems($this->export_data['client_contacts']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('client_contacts');
|
||||
$x->addItems($this->export_data['client_contacts']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['client_gateway_tokens'] = $this->company->client_gateway_tokens->map(function ($client_gateway_token) {
|
||||
$client_gateway_token = $this->transformArrayOfKeys($client_gateway_token, ['company_id', 'client_id', 'company_gateway_id']);
|
||||
@ -151,9 +151,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('client_gateway_tokens');
|
||||
$x->addItems($this->export_data['client_gateway_tokens']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('client_gateway_tokens');
|
||||
$x->addItems($this->export_data['client_gateway_tokens']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['clients'] = $this->company->clients()->orderBy('number', 'DESC')->cursor()->map(function ($client) {
|
||||
$client = $this->transformArrayOfKeys($client, ['company_id', 'user_id', 'assigned_user_id', 'group_settings_id']);
|
||||
@ -162,18 +162,18 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('clients');
|
||||
$x->addItems($this->export_data['clients']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('clients');
|
||||
$x->addItems($this->export_data['clients']);
|
||||
$this->export_data = null;
|
||||
|
||||
// $this->export_data['company'] = $this->company->toArray();
|
||||
// $this->export_data['company']['company_key'] = $this->createHash();
|
||||
|
||||
$this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
$this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
|
||||
// $x = $this->writer->collection('company');
|
||||
// $x->addItems($this->export_data['company']);
|
||||
// $this->export_data = null;
|
||||
// $x = $this->writer->collection('company');
|
||||
// $x->addItems($this->export_data['company']);
|
||||
// $this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['company_gateways'] = $this->company->company_gateways()->withTrashed()->cursor()->map(function ($company_gateway) {
|
||||
@ -184,9 +184,9 @@ $this->writer->value('company', $this->company->toJson(), encode: false);
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_gateways');
|
||||
$x->addItems($this->export_data['company_gateways']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_gateways');
|
||||
$x->addItems($this->export_data['company_gateways']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
@ -198,9 +198,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_tokens');
|
||||
$x->addItems($this->export_data['company_tokens']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_tokens');
|
||||
$x->addItems($this->export_data['company_tokens']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['company_ledger'] = $this->company->ledger->map(function ($ledger) {
|
||||
@ -210,9 +210,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_ledger');
|
||||
$x->addItems($this->export_data['company_ledger']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_ledger');
|
||||
$x->addItems($this->export_data['company_ledger']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['company_users'] = $this->company->company_users()->without(['user','account'])->cursor()->map(function ($company_user) {
|
||||
@ -221,9 +221,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('company_users');
|
||||
$x->addItems($this->export_data['company_users']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('company_users');
|
||||
$x->addItems($this->export_data['company_users']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['credits'] = $this->company->credits()->orderBy('number', 'DESC')->cursor()->map(function ($credit) {
|
||||
@ -233,9 +233,9 @@ $this->export_data = null;
|
||||
return $credit->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('credits');
|
||||
$x->addItems($this->export_data['credits']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('credits');
|
||||
$x->addItems($this->export_data['credits']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['credit_invitations'] = CreditInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($credit) {
|
||||
@ -245,17 +245,17 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('credit_invitations');
|
||||
$x->addItems($this->export_data['credit_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('credit_invitations');
|
||||
$x->addItems($this->export_data['credit_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['designs'] = $this->company->user_designs->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('designs');
|
||||
$x->addItems($this->export_data['designs']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('designs');
|
||||
$x->addItems($this->export_data['designs']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['documents'] = $this->company->all_documents->map(function ($document) {
|
||||
@ -265,9 +265,9 @@ $this->export_data = null;
|
||||
return $document->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('documents');
|
||||
$x->addItems($this->export_data['documents']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('documents');
|
||||
$x->addItems($this->export_data['documents']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['expense_categories'] = $this->company->expense_categories()->cursor()->map(function ($expense_category) {
|
||||
$expense_category = $this->transformArrayOfKeys($expense_category, ['user_id', 'company_id']);
|
||||
@ -275,9 +275,9 @@ $this->export_data = null;
|
||||
return $expense_category->makeVisible(['id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('expense_categories');
|
||||
$x->addItems($this->export_data['expense_categories']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('expense_categories');
|
||||
$x->addItems($this->export_data['expense_categories']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['expenses'] = $this->company->expenses()->orderBy('number', 'DESC')->cursor()->map(function ($expense) {
|
||||
@ -288,9 +288,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('expenses');
|
||||
$x->addItems($this->export_data['expenses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('expenses');
|
||||
$x->addItems($this->export_data['expenses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['group_settings'] = $this->company->group_settings->map(function ($gs) {
|
||||
@ -300,9 +300,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('group_settings');
|
||||
$x->addItems($this->export_data['group_settings']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('group_settings');
|
||||
$x->addItems($this->export_data['group_settings']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['invoices'] = $this->company->invoices()->orderBy('number', 'DESC')->cursor()->map(function ($invoice) {
|
||||
@ -318,9 +318,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('invoices');
|
||||
$x->addItems($this->export_data['invoices']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('invoices');
|
||||
$x->addItems($this->export_data['invoices']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['invoice_invitations'] = InvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($invoice) {
|
||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'invoice_id']);
|
||||
@ -329,9 +329,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('invoice_invitations');
|
||||
$x->addItems($this->export_data['invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('invoice_invitations');
|
||||
$x->addItems($this->export_data['invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['payment_terms'] = $this->company->user_payment_terms->map(function ($term) {
|
||||
@ -341,9 +341,9 @@ $this->export_data = null;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('payment_terms');
|
||||
$x->addItems($this->export_data['payment_terms']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('payment_terms');
|
||||
$x->addItems($this->export_data['payment_terms']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['payments'] = $this->company->payments()->orderBy('number', 'DESC')->cursor()->map(function ($payment) {
|
||||
@ -357,9 +357,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('payments');
|
||||
$x->addItems($this->export_data['payments']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('payments');
|
||||
$x->addItems($this->export_data['payments']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['products'] = $this->company->products->map(function ($product) {
|
||||
@ -370,9 +370,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('products');
|
||||
$x->addItems($this->export_data['products']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('products');
|
||||
$x->addItems($this->export_data['products']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['projects'] = $this->company->projects()->orderBy('number', 'DESC')->cursor()->map(function ($project) {
|
||||
@ -383,9 +383,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('projects');
|
||||
$x->addItems($this->export_data['projects']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('projects');
|
||||
$x->addItems($this->export_data['projects']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['quotes'] = $this->company->quotes()->orderBy('number', 'DESC')->cursor()->map(function ($quote) {
|
||||
@ -396,9 +396,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('quotes');
|
||||
$x->addItems($this->export_data['quotes']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('quotes');
|
||||
$x->addItems($this->export_data['quotes']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['quote_invitations'] = QuoteInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($quote) {
|
||||
@ -408,9 +408,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('quote_invitations');
|
||||
$x->addItems($this->export_data['quote_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('quote_invitations');
|
||||
$x->addItems($this->export_data['quote_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_expenses'] = $this->company->recurring_expenses()->orderBy('number', 'DESC')->cursor()->map(function ($expense) {
|
||||
@ -422,9 +422,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_expenses');
|
||||
$x->addItems($this->export_data['recurring_expenses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('recurring_expenses');
|
||||
$x->addItems($this->export_data['recurring_expenses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_invoices'] = $this->company->recurring_invoices()->orderBy('number', 'DESC')->cursor()->map(function ($ri) {
|
||||
@ -435,9 +435,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_invoices');
|
||||
$x->addItems($this->export_data['recurring_invoices']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('recurring_invoices');
|
||||
$x->addItems($this->export_data['recurring_invoices']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['recurring_invoice_invitations'] = RecurringInvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($ri) {
|
||||
@ -447,9 +447,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('recurring_invoice_invitations');
|
||||
$x->addItems($this->export_data['recurring_invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('recurring_invoice_invitations');
|
||||
$x->addItems($this->export_data['recurring_invoice_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
@ -467,9 +467,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('subscriptions');
|
||||
$x->addItems($this->export_data['subscriptions']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('subscriptions');
|
||||
$x->addItems($this->export_data['subscriptions']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['system_logs'] = $this->company->system_logs->map(function ($log) {
|
||||
$log->client_id = $this->encodePrimaryKey($log->client_id);
|
||||
@ -479,9 +479,9 @@ $this->export_data = null;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('system_logs');
|
||||
$x->addItems($this->export_data['system_logs']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('system_logs');
|
||||
$x->addItems($this->export_data['system_logs']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['tasks'] = $this->company->tasks()->orderBy('number', 'DESC')->cursor()->map(function ($task) {
|
||||
@ -493,9 +493,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('tasks');
|
||||
$x->addItems($this->export_data['tasks']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('tasks');
|
||||
$x->addItems($this->export_data['tasks']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['task_statuses'] = $this->company->task_statuses->map(function ($status) {
|
||||
@ -508,9 +508,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('task_statuses');
|
||||
$x->addItems($this->export_data['task_statuses']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('task_statuses');
|
||||
$x->addItems($this->export_data['task_statuses']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['tax_rates'] = $this->company->tax_rates->map(function ($rate) {
|
||||
@ -522,9 +522,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('tax_rates');
|
||||
$x->addItems($this->export_data['tax_rates']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('tax_rates');
|
||||
$x->addItems($this->export_data['tax_rates']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['vendors'] = $this->company->vendors()->orderBy('number', 'DESC')->cursor()->map(function ($vendor) {
|
||||
@ -533,9 +533,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('vendors');
|
||||
$x->addItems($this->export_data['vendors']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('vendors');
|
||||
$x->addItems($this->export_data['vendors']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['vendor_contacts'] = VendorContact::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($vendor) {
|
||||
@ -547,9 +547,9 @@ $this->export_data = null;
|
||||
|
||||
|
||||
|
||||
$x = $this->writer->collection('vendor_contacts');
|
||||
$x->addItems($this->export_data['vendor_contacts']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('vendor_contacts');
|
||||
$x->addItems($this->export_data['vendor_contacts']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['webhooks'] = $this->company->webhooks->map(function ($hook) {
|
||||
@ -560,9 +560,9 @@ $this->export_data = null;
|
||||
})->makeHidden(['id'])->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('webhooks');
|
||||
$x->addItems($this->export_data['webhooks']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('webhooks');
|
||||
$x->addItems($this->export_data['webhooks']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
$this->export_data['purchase_orders'] = $this->company->purchase_orders()->orderBy('number', 'DESC')->cursor()->map(function ($purchase_order) {
|
||||
@ -578,9 +578,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('purchase_orders');
|
||||
$x->addItems($this->export_data['purchase_orders']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('purchase_orders');
|
||||
$x->addItems($this->export_data['purchase_orders']);
|
||||
$this->export_data = null;
|
||||
|
||||
|
||||
|
||||
@ -591,9 +591,9 @@ $this->export_data = null;
|
||||
})->all();
|
||||
|
||||
|
||||
$x = $this->writer->collection('purchase_order_invitations');
|
||||
$x->addItems($this->export_data['purchase_order_invitations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('purchase_order_invitations');
|
||||
$x->addItems($this->export_data['purchase_order_invitations']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['bank_integrations'] = $this->company->bank_integrations()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($bank_integration) {
|
||||
$bank_integration = $this->transformArrayOfKeys($bank_integration, ['account_id','company_id', 'user_id']);
|
||||
@ -601,9 +601,9 @@ $this->export_data = null;
|
||||
return $bank_integration->makeVisible(['id','user_id','company_id','account_id','hashed_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('bank_integrations');
|
||||
$x->addItems($this->export_data['bank_integrations']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('bank_integrations');
|
||||
$x->addItems($this->export_data['bank_integrations']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['bank_transactions'] = $this->company->bank_transactions()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($bank_transaction) {
|
||||
$bank_transaction = $this->transformArrayOfKeys($bank_transaction, ['company_id', 'user_id','bank_integration_id','expense_id','ninja_category_id','vendor_id']);
|
||||
@ -611,9 +611,9 @@ $this->export_data = null;
|
||||
return $bank_transaction->makeVisible(['id','user_id','company_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('bank_transactions');
|
||||
$x->addItems($this->export_data['bank_transactions']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('bank_transactions');
|
||||
$x->addItems($this->export_data['bank_transactions']);
|
||||
$this->export_data = null;
|
||||
|
||||
$this->export_data['schedulers'] = $this->company->schedulers()->withTrashed()->orderBy('id', 'ASC')->cursor()->map(function ($scheduler) {
|
||||
$scheduler = $this->transformArrayOfKeys($scheduler, ['company_id', 'user_id']);
|
||||
@ -621,14 +621,14 @@ $this->export_data = null;
|
||||
return $scheduler->makeVisible(['id','user_id','company_id']);
|
||||
})->all();
|
||||
|
||||
$x = $this->writer->collection('schedulers');
|
||||
$x->addItems($this->export_data['schedulers']);
|
||||
$this->export_data = null;
|
||||
$x = $this->writer->collection('schedulers');
|
||||
$x->addItems($this->export_data['schedulers']);
|
||||
$this->export_data = null;
|
||||
|
||||
//write to tmp and email to owner();
|
||||
|
||||
|
||||
$this->writer->end();
|
||||
$this->writer->end();
|
||||
|
||||
|
||||
$this->zipAndSend();
|
||||
@ -680,20 +680,20 @@ $this->writer->end();
|
||||
|
||||
$zip->close();
|
||||
|
||||
Storage::disk(config('filesystems.default'))->put('backups/'.str_replace(".json", ".zip",$this->file_name), file_get_contents($zip_path));
|
||||
Storage::disk(config('filesystems.default'))->put('backups/'.str_replace(".json", ".zip", $this->file_name), file_get_contents($zip_path));
|
||||
|
||||
if(file_exists($zip_path)) {
|
||||
unlink($zip_path);
|
||||
}
|
||||
|
||||
if(file_exists($this->file_name)){
|
||||
if(file_exists($this->file_name)) {
|
||||
unlink($this->file_name);
|
||||
}
|
||||
|
||||
if(Ninja::isSelfHost()) {
|
||||
$storage_path = 'backups/'.str_replace(".json", ".zip",$this->file_name);
|
||||
$storage_path = 'backups/'.str_replace(".json", ".zip", $this->file_name);
|
||||
} else {
|
||||
$storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.str_replace(".json", ".zip",$this->file_name));
|
||||
$storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.str_replace(".json", ".zip", $this->file_name));
|
||||
}
|
||||
|
||||
$url = Cache::get($this->hash);
|
||||
|
@ -99,10 +99,9 @@ class NinjaMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
$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());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name());
|
||||
}
|
||||
|
||||
@ -270,12 +269,12 @@ class NinjaMailerJob implements ShouldQueue
|
||||
if(Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') {
|
||||
//check if outlook.
|
||||
|
||||
try{
|
||||
try {
|
||||
$email = $this->nmo->to_user->email;
|
||||
$domain = explode("@", $email)[1] ?? "";
|
||||
$dns = dns_get_record($domain, DNS_MX);
|
||||
$server = $dns[0]["target"];
|
||||
if(stripos($server, "outlook.com") !== false){
|
||||
if(stripos($server, "outlook.com") !== false) {
|
||||
|
||||
$this->mailer = 'postmark';
|
||||
$this->client_postmark_secret = config('services.postmark-outlook.token');
|
||||
@ -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();
|
||||
@ -128,8 +132,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "7f388cf8096aa0bca1477aee9d91e156c61f8fa8282c7f1c0c",
|
||||
"timestamp": "1705376308",
|
||||
@ -170,8 +174,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
private function processOpen()
|
||||
{
|
||||
$this->invitation->opened_date = now();
|
||||
@ -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' => '',
|
||||
@ -201,8 +206,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "70b91a64ed0f1bdf90fb9c6ea7e3c31d5792a3d0945ffc20fe",
|
||||
"timestamp": "1705376276",
|
||||
@ -262,8 +267,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
private function processDelivery()
|
||||
{
|
||||
$this->invitation->email_status = 'delivered';
|
||||
@ -384,8 +389,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
/*
|
||||
{
|
||||
"signature": {
|
||||
"token": "d7be371deef49c8b187119df295e3eb17fd1974d513a4be2cb",
|
||||
"timestamp": "1705376380",
|
||||
@ -423,8 +428,8 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
"my-var-2": "awesome"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
private function processSpamComplaint()
|
||||
{
|
||||
$this->invitation->email_status = 'spam';
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -134,9 +134,9 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]);
|
||||
}
|
||||
|
||||
// $hash = Str::uuid();
|
||||
// $url = \Illuminate\Support\Facades\URL::temporarySignedRoute('protected_download', now()->addHour(), ['hash' => $hash]);
|
||||
// Cache::put($hash, $url, now()->addHour());
|
||||
// $hash = Str::uuid();
|
||||
// $url = \Illuminate\Support\Facades\URL::temporarySignedRoute('protected_download', now()->addHour(), ['hash' => $hash]);
|
||||
// Cache::put($hash, $url, now()->addHour());
|
||||
|
||||
//attach third party documents
|
||||
if ($this->client->getSetting('document_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||
|
@ -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 =
|
||||
[[
|
||||
|
@ -89,7 +89,7 @@ class ClientContactRepository extends BaseRepository
|
||||
->where('company_id', $client->company_id)
|
||||
->where('client_id', $client->id)
|
||||
->where('email', $update_contact->email)->cursor()
|
||||
->each(function ($saveable_contact) use ($update_contact){
|
||||
->each(function ($saveable_contact) use ($update_contact) {
|
||||
$saveable_contact->password = $update_contact->password;
|
||||
$saveable_contact->save();
|
||||
});
|
||||
|
@ -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 {
|
||||
|
@ -211,17 +211,15 @@ class EmailDefaults
|
||||
$reply_to_email = $this->email->company->owner()->email;
|
||||
$reply_to_name = $this->email->company->owner()->present()->name();
|
||||
|
||||
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;
|
||||
}
|
||||
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)) {
|
||||
$reply_to_name = $this->email->email_object->settings->reply_to_name;
|
||||
} 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.
|
||||
|
@ -46,14 +46,15 @@ class ChangePlanInvoice extends AbstractService
|
||||
|
||||
$invoice = $this->generateInvoice($refund);
|
||||
|
||||
if($refund >= $new_charge){
|
||||
if($refund >= $new_charge) {
|
||||
$invoice = $invoice->markPaid()->save();
|
||||
|
||||
//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;
|
||||
@ -66,7 +68,7 @@ class SubscriptionStatus extends AbstractService
|
||||
|
||||
$this->refundable_invoice = $primary_invoice;
|
||||
|
||||
return $primary_invoice ? max(0, round(($primary_invoice->paid_to_date * $this->getProRataRatio()),2)) : 0;
|
||||
return $primary_invoice ? max(0, round(($primary_invoice->paid_to_date * $this->getProRataRatio()), 2)) : 0;
|
||||
|
||||
}
|
||||
|
||||
@ -76,7 +78,7 @@ class SubscriptionStatus extends AbstractService
|
||||
* The ratio of days used / days in interval
|
||||
* @return float
|
||||
*/
|
||||
public function getProRataRatio():float
|
||||
public function getProRataRatio(): float
|
||||
{
|
||||
|
||||
$subscription_interval_end_date = Carbon::parse($this->recurring_invoice->next_send_date_client);
|
||||
@ -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()
|
||||
@ -183,7 +188,7 @@ class SubscriptionStatus extends AbstractService
|
||||
if($primary_invoice &&
|
||||
$primary_invoice->status_id == Invoice::STATUS_PAID &&
|
||||
Carbon::parse($primary_invoice->date)->addSeconds($this->recurring_invoice->subscription->refund_period)->lte(now()->startOfDay()->addSeconds($primary_invoice->client->timezone_offset()))
|
||||
){
|
||||
) {
|
||||
return $this->setRefundable(true);
|
||||
}
|
||||
|
||||
|
@ -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,10 +71,11 @@ 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));
|
||||
return max(0, round(($invoice->paid_to_date * $ratio), 2));
|
||||
}
|
||||
|
||||
private function getCredits(): float
|
||||
@ -82,7 +84,7 @@ class UpgradePrice extends AbstractService
|
||||
|
||||
$use_credit_setting = $this->recurring_invoice->client->getSetting('use_credits_payment');
|
||||
|
||||
if($use_credit_setting){
|
||||
if($use_credit_setting) {
|
||||
|
||||
$outstanding_credits = Credit::query()
|
||||
->where('client_id', $this->recurring_invoice->client_id)
|
||||
|
@ -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