This commit is contained in:
David Bomba 2020-11-25 21:30:00 +11:00
parent 7f2f9d6faa
commit 137231c95e
187 changed files with 898 additions and 1148 deletions

View File

@ -332,16 +332,16 @@ class CheckData extends Command
$total_amount = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.amount'); $total_amount = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.amount');
$total_refund = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.refunded'); $total_refund = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.refunded');
$total_invoice_payments += ($total_amount - $total_refund); $total_invoice_payments += ($total_amount - $total_refund);
} }
foreach($client->payments as $payment) foreach ($client->payments as $payment) {
{ $credit_total_applied += $payment->paymentables->where('paymentable_type', App\Models\Credit::class)->sum(DB::raw('amount'));
$credit_total_applied += $payment->paymentables->where('paymentable_type', App\Models\Credit::class)->sum(DB::raw('amount'));
} }
if($credit_total_applied < 0) if ($credit_total_applied < 0) {
$total_invoice_payments += $credit_total_applied; //todo this is contentious $total_invoice_payments += $credit_total_applied;
} //todo this is contentious
info("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}"); info("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");

View File

@ -100,7 +100,6 @@ class CreateSingleAccount extends Command
$this->warmCache(); $this->warmCache();
$this->createSmallAccount(); $this->createSmallAccount();
} }
private function createSmallAccount() private function createSmallAccount()
@ -205,7 +204,6 @@ class CreateSingleAccount extends Command
$this->info('creating credit for client #'.$client->id); $this->info('creating credit for client #'.$client->id);
$this->createCredit($client); $this->createCredit($client);
} }
$this->createGateways($company, $user); $this->createGateways($company, $user);
@ -299,7 +297,6 @@ class CreateSingleAccount extends Command
private function createInvoice($client) private function createInvoice($client)
{ {
$faker = Factory::create(); $faker = Factory::create();
$invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id $invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id
@ -369,7 +366,6 @@ class CreateSingleAccount extends Command
private function createQuote($client) private function createQuote($client)
{ {
$faker = Factory::create(); $faker = Factory::create();
$quote = Quote::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $quote = Quote::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
@ -414,21 +410,21 @@ class CreateSingleAccount extends Command
{ {
$line_items = []; $line_items = [];
$item = InvoiceItemFactory::create(); $item = InvoiceItemFactory::create();
$item->quantity = 1; $item->quantity = 1;
$item->cost = 1000; $item->cost = 1000;
$product = Product::all()->random(); $product = Product::all()->random();
$item->cost = (float) $product->cost; $item->cost = (float) $product->cost;
$item->product_key = $product->product_key; $item->product_key = $product->product_key;
$item->notes = $product->notes; $item->notes = $product->notes;
$item->custom_value1 = $product->custom_value1; $item->custom_value1 = $product->custom_value1;
$item->custom_value2 = $product->custom_value2; $item->custom_value2 = $product->custom_value2;
$item->custom_value3 = $product->custom_value3; $item->custom_value3 = $product->custom_value3;
$item->custom_value4 = $product->custom_value4; $item->custom_value4 = $product->custom_value4;
$line_items[] = $item; $line_items[] = $item;
return $line_items; return $line_items;
@ -505,7 +501,6 @@ class CreateSingleAccount extends Command
private function createGateways($company, $user) private function createGateways($company, $user)
{ {
if (config('ninja.testvars.stripe') && ($this->gateway == 'all' || $this->gateway == 'stripe')) { if (config('ninja.testvars.stripe') && ($this->gateway == 'all' || $this->gateway == 'stripe')) {
$cg = new CompanyGateway; $cg = new CompanyGateway;
$cg->company_id = $company->id; $cg->company_id = $company->id;

View File

@ -471,7 +471,6 @@ class CreateTestData extends Command
private function createInvoice($client) private function createInvoice($client)
{ {
$faker = Factory::create(); $faker = Factory::create();
$invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id $invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id
@ -522,7 +521,6 @@ class CreateTestData extends Command
private function createCredit($client) private function createCredit($client)
{ {
$faker = Factory::create(); $faker = Factory::create();
$credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
@ -562,7 +560,6 @@ class CreateTestData extends Command
private function createQuote($client) private function createQuote($client)
{ {
$faker = Factory::create(); $faker = Factory::create();
//$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id //$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id

View File

@ -303,7 +303,7 @@ class DemoMode extends Command
'is_primary' => 1, 'is_primary' => 1,
]); ]);
ClientContact::factory()->count(rand(1,5))->create([ ClientContact::factory()->count(rand(1, 5))->create([
'user_id' => $user->id, 'user_id' => $user->id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $company->id, 'company_id' => $company->id,
@ -325,7 +325,7 @@ class DemoMode extends Command
private function createExpense($client) private function createExpense($client)
{ {
Expense::factory()->count(rand(1,5))->create([ Expense::factory()->count(rand(1, 5))->create([
'user_id' => $client->user_id, 'user_id' => $client->user_id,
'client_id' => $client->id, 'client_id' => $client->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
@ -346,7 +346,7 @@ class DemoMode extends Command
'is_primary' => 1, 'is_primary' => 1,
]); ]);
VendorContact::factory()->count(rand(1,5))->create([ VendorContact::factory()->count(rand(1, 5))->create([
'user_id' => $client->user->id, 'user_id' => $client->user->id,
'vendor_id' => $vendor->id, 'vendor_id' => $vendor->id,
'company_id' => $client->company_id, 'company_id' => $client->company_id,
@ -376,7 +376,6 @@ class DemoMode extends Command
private function createInvoice($client, $assigned_user_id = null) private function createInvoice($client, $assigned_user_id = null)
{ {
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id $invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id
@ -441,7 +440,6 @@ class DemoMode extends Command
private function createCredit($client, $assigned_user_id = null) private function createCredit($client, $assigned_user_id = null)
{ {
$faker = \Faker\Factory::create(); $faker = \Faker\Factory::create();
$credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]); $credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);

View File

@ -46,7 +46,6 @@ class PostUpdate extends Command
*/ */
public function handle() public function handle()
{ {
set_time_limit(0); set_time_limit(0);
info('running post update'); info('running post update');
@ -73,6 +72,5 @@ class PostUpdate extends Command
$application->run($input); $application->run($input);
echo "Done."; echo "Done.";
} }
} }

View File

@ -65,10 +65,9 @@ class SendRemindersCron extends Command
->whereDate('due_date', now()->subDays(1)->startOfDay()) ->whereDate('due_date', now()->subDays(1)->startOfDay())
->cursor(); ->cursor();
$invoices->each(function ($invoice){ $invoices->each(function ($invoice) {
WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company); WebHookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company);
}); });
} }
private function webHookExpiredQuotes() private function webHookExpiredQuotes()
@ -78,7 +77,7 @@ class SendRemindersCron extends Command
->whereDate('due_date', now()->subDays(1)->startOfDay()) ->whereDate('due_date', now()->subDays(1)->startOfDay())
->cursor(); ->cursor();
$quotes->each(function ($quote){ $quotes->each(function ($quote) {
WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company); WebHookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company);
}); });
} }

View File

@ -82,7 +82,6 @@ class SendTestEmails extends Command
$user = User::whereEmail('user@example.com')->first(); $user = User::whereEmail('user@example.com')->first();
if (! $user) { if (! $user) {
$account = Account::factory()->create(); $account = Account::factory()->create();
$user = User::factory()->create([ $user = User::factory()->create([

View File

@ -175,13 +175,13 @@ class CompanySettings extends BaseSettings
public $email_template_reminder3 = ''; //@implemented public $email_template_reminder3 = ''; //@implemented
public $email_template_reminder_endless = ''; //@implemented public $email_template_reminder_endless = ''; //@implemented
public $email_signature = ''; //@implemented public $email_signature = ''; //@implemented
public $enable_email_markup = true; //@TODO - public $enable_email_markup = true; //@TODO -
public $email_subject_custom1 = ''; //@TODO public $email_subject_custom1 = ''; //@TODO
public $email_subject_custom2 = ''; //@TODO public $email_subject_custom2 = ''; //@TODO
public $email_subject_custom3 = ''; //@TODO public $email_subject_custom3 = ''; //@TODO
public $email_template_custom1 = ''; //@TODO public $email_template_custom1 = ''; //@TODO
public $email_template_custom2 = ''; //@TODO public $email_template_custom2 = ''; //@TODO
public $email_template_custom3 = ''; //@TODO public $email_template_custom3 = ''; //@TODO
@ -195,7 +195,7 @@ class CompanySettings extends BaseSettings
public $num_days_reminder3 = 0;//@implmemented public $num_days_reminder3 = 0;//@implmemented
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders @TODO public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders @TODO
@ -511,7 +511,7 @@ class CompanySettings extends BaseSettings
/** /**
* Provides class defaults on init. * Provides class defaults on init.
* *
* @return stdClass * @return stdClass
*/ */
public static function defaults(): stdClass public static function defaults(): stdClass
@ -544,7 +544,7 @@ class CompanySettings extends BaseSettings
* set new properties to the object prior to being returned. * set new properties to the object prior to being returned.
* *
* @param $settings * @param $settings
* *
* @return stdClass * @return stdClass
*/ */
public static function setProperties($settings): stdClass public static function setProperties($settings): stdClass
@ -562,7 +562,7 @@ class CompanySettings extends BaseSettings
/** /**
* Stubs the notification defaults * Stubs the notification defaults
* *
* @return stdClass * @return stdClass
*/ */
public static function notificationDefaults() :stdClass public static function notificationDefaults() :stdClass
@ -575,7 +575,7 @@ class CompanySettings extends BaseSettings
/** /**
* Defines entity variables for PDF generation * Defines entity variables for PDF generation
* *
* @return stdClass The stdClass of PDF variables * @return stdClass The stdClass of PDF variables
*/ */
private static function getEntityVariableDefaults() :stdClass private static function getEntityVariableDefaults() :stdClass

View File

@ -148,11 +148,9 @@ class EmailTemplateDefaults
public static function emailPaymentTemplate() public static function emailPaymentTemplate()
{ {
$payment_message = '<p>'.self::transformText('payment_message').'</p><br><br><p>$view_link</p>'; $payment_message = '<p>'.self::transformText('payment_message').'</p><br><br><p>$view_link</p>';
return $payment_message; return $payment_message;
} }
public static function emailCreditTemplate() public static function emailCreditTemplate()
@ -164,11 +162,9 @@ class EmailTemplateDefaults
public static function emailPaymentPartialTemplate() public static function emailPaymentPartialTemplate()
{ {
$payment_message = '<p>'.self::transformText('payment_message').'</p><br><br><p>$view_link</p>'; $payment_message = '<p>'.self::transformText('payment_message').'</p><br><br><p>$view_link</p>';
return $payment_message; return $payment_message;
} }
public static function emailPaymentPartialSubject() public static function emailPaymentPartialSubject()

View File

@ -24,9 +24,9 @@ class TaskFactory
$task->company_id = $company_id; $task->company_id = $company_id;
$task->user_id = $user_id; $task->user_id = $user_id;
$task->time_log = '[]'; $task->time_log = '[]';
$task->is_running = false; $task->is_running = false;
$task->is_deleted = false; $task->is_deleted = false;
$task->duration = 0; $task->duration = 0;
return $task; return $task;
} }

View File

@ -51,13 +51,11 @@ class SystemLogFilters extends QueryFilters
*/ */
public function filter(string $filter = '') : Builder public function filter(string $filter = '') : Builder
{ {
if (strlen($filter) == 0) { if (strlen($filter) == 0) {
return $this->builder; return $this->builder;
} }
return $this->builder; return $this->builder;
} }
/** /**

View File

@ -231,7 +231,7 @@ class InvoiceItemSum
} }
//$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)); //$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total));
$amount = ( $this->sub_total > 0 ) ? $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)) : 0; $amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)) : 0;
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount); $item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
@ -264,7 +264,7 @@ class InvoiceItemSum
/** /**
* Sets default casts for the values in the line_items. * Sets default casts for the values in the line_items.
* *
* @return $this * @return $this
*/ */
private function cleanLineItem() private function cleanLineItem()

View File

@ -160,17 +160,21 @@ class InvoiceSum
{ {
$this->total += $this->total_taxes; $this->total += $this->total_taxes;
if(is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) if (is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) {
$this->total += $this->invoice->custom_value1; $this->total += $this->invoice->custom_value1;
}
if(is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) if (is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) {
$this->total += $this->invoice->custom_value2; $this->total += $this->invoice->custom_value2;
}
if(is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) if (is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) {
$this->total += $this->invoice->custom_value3; $this->total += $this->invoice->custom_value3;
}
if(is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) if (is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) {
$this->total += $this->invoice->custom_value4; $this->total += $this->invoice->custom_value4;
}
return $this; return $this;
} }
@ -202,7 +206,6 @@ class InvoiceSum
public function getRecurringInvoice() public function getRecurringInvoice()
{ {
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); $this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
$this->invoice->total_taxes = $this->getTotalTaxes(); $this->invoice->total_taxes = $this->getTotalTaxes();
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); $this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
@ -220,8 +223,7 @@ class InvoiceSum
{ {
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */ /* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
if($this->invoice->status_id != Invoice::STATUS_DRAFT) if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
{
if ($this->invoice->amount != $this->invoice->balance) { if ($this->invoice->amount != $this->invoice->balance) {
$paid_to_date = $this->invoice->amount - $this->invoice->balance; $paid_to_date = $this->invoice->amount - $this->invoice->balance;
@ -318,7 +320,6 @@ class InvoiceSum
public function purgeTaxes() public function purgeTaxes()
{ {
$this->tax_rate1 = 0; $this->tax_rate1 = 0;
$this->tax_name1 = ''; $this->tax_name1 = '';
@ -332,7 +333,7 @@ class InvoiceSum
$line_items = collect($this->invoice->line_items); $line_items = collect($this->invoice->line_items);
$items = $line_items->map(function ($item){ $items = $line_items->map(function ($item) {
$item->tax_rate1 = 0; $item->tax_rate1 = 0;
$item->tax_rate2 = 0; $item->tax_rate2 = 0;
$item->tax_rate3 = 0; $item->tax_rate3 = 0;
@ -350,5 +351,4 @@ class InvoiceSum
return $this; return $this;
} }
} }

View File

@ -66,7 +66,7 @@ class InvoiceSumInclusive
->calculateCustomValues() ->calculateCustomValues()
->calculateInvoiceTaxes() ->calculateInvoiceTaxes()
->setTaxMap() ->setTaxMap()
->calculateTotals() //just don't add the taxes!! ->calculateTotals() //just don't add the taxes!!
->calculateBalance() ->calculateBalance()
->calculatePartial(); ->calculatePartial();
@ -172,24 +172,27 @@ class InvoiceSumInclusive
{ {
//$this->total += $this->total_taxes; //$this->total += $this->total_taxes;
if(is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) if (is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) {
$this->total += $this->invoice->custom_value1; $this->total += $this->invoice->custom_value1;
}
if(is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) if (is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) {
$this->total += $this->invoice->custom_value2; $this->total += $this->invoice->custom_value2;
}
if(is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) if (is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) {
$this->total += $this->invoice->custom_value3; $this->total += $this->invoice->custom_value3;
}
if(is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) if (is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) {
$this->total += $this->invoice->custom_value4; $this->total += $this->invoice->custom_value4;
}
return $this; return $this;
} }
public function getRecurringInvoice() public function getRecurringInvoice()
{ {
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); $this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
$this->invoice->total_taxes = $this->getTotalTaxes(); $this->invoice->total_taxes = $this->getTotalTaxes();
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision); $this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
@ -329,7 +332,6 @@ class InvoiceSumInclusive
public function purgeTaxes() public function purgeTaxes()
{ {
return $this; return $this;
} }
} }

View File

@ -80,5 +80,4 @@ class ContactLoginController extends Controller
return redirect('/client/login'); return redirect('/client/login');
} }
} }

View File

@ -173,8 +173,7 @@ class LoginController extends BaseController
$cu = CompanyUser::query() $cu = CompanyUser::query()
->where('user_id', auth()->user()->id); ->where('user_id', auth()->user()->id);
return $this->listResponse($cu); return $this->listResponse($cu);
} else { } else {
LightLogs::create(new LoginFailure()) LightLogs::create(new LoginFailure())
->increment() ->increment()

View File

@ -207,12 +207,12 @@ class BaseController extends Controller
$updated_at = date('Y-m-d H:i:s', $updated_at); $updated_at = date('Y-m-d H:i:s', $updated_at);
$query->with( $query->with(
[ [
'company' => function ($query) use ($updated_at) { 'company' => function ($query) use ($updated_at) {
$query->whereNotNull('updated_at')->with('documents'); $query->whereNotNull('updated_at')->with('documents');
}, },
'company.clients' => function ($query) use ($updated_at) { 'company.clients' => function ($query) use ($updated_at) {
$query->where('clients.updated_at', '>=', $updated_at)->with('contacts.company', 'gateway_tokens','documents'); $query->where('clients.updated_at', '>=', $updated_at)->with('contacts.company', 'gateway_tokens', 'documents');
}, },
'company.company_gateways' => function ($query) { 'company.company_gateways' => function ($query) {
$query->whereNotNull('updated_at'); $query->whereNotNull('updated_at');
@ -236,7 +236,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents'); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
}, },
'company.payments'=> function ($query) use ($updated_at) { 'company.payments'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('paymentables','documents'); $query->where('updated_at', '>=', $updated_at)->with('paymentables', 'documents');
}, },
'company.payment_terms'=> function ($query) use ($updated_at) { 'company.payment_terms'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
@ -245,7 +245,7 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at)->with('documents'); $query->where('updated_at', '>=', $updated_at)->with('documents');
}, },
'company.projects'=> function ($query) use ($updated_at) { 'company.projects'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('documents' ); $query->where('updated_at', '>=', $updated_at)->with('documents');
}, },
'company.quotes'=> function ($query) use ($updated_at) { 'company.quotes'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents'); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
@ -254,13 +254,13 @@ class BaseController extends Controller
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents'); $query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
}, },
'company.tasks'=> function ($query) use ($updated_at) { 'company.tasks'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('documents' ); $query->where('updated_at', '>=', $updated_at)->with('documents');
}, },
'company.tax_rates' => function ($query) use ($updated_at) { 'company.tax_rates' => function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
}, },
'company.vendors'=> function ($query) use ($updated_at) { 'company.vendors'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at)->with('contacts','documents'); $query->where('updated_at', '>=', $updated_at)->with('contacts', 'documents');
}, },
'company.expense_categories'=> function ($query) use ($updated_at) { 'company.expense_categories'=> function ($query) use ($updated_at) {
$query->where('updated_at', '>=', $updated_at); $query->where('updated_at', '>=', $updated_at);
@ -297,14 +297,17 @@ class BaseController extends Controller
$query->with($includes); $query->with($includes);
if (auth()->user() && ! auth()->user()->hasPermission('view_'.lcfirst(class_basename($this->entity_type)))) if (auth()->user() && ! auth()->user()->hasPermission('view_'.lcfirst(class_basename($this->entity_type)))) {
$query->where('user_id', '=', auth()->user()->id); $query->where('user_id', '=', auth()->user()->id);
}
if (request()->has('updated_at') && request()->input('updated_at') > 0) if (request()->has('updated_at') && request()->input('updated_at') > 0) {
$query->where('updated_at', '>=', date('Y-m-d H:i:s', intval(request()->input('updated_at')))); $query->where('updated_at', '>=', date('Y-m-d H:i:s', intval(request()->input('updated_at'))));
}
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
$this->entity_type = null; $this->entity_type = null;
}
if ($query instanceof Builder) { if ($query instanceof Builder) {
$limit = request()->input('per_page', 20); $limit = request()->input('per_page', 20);
@ -317,7 +320,6 @@ class BaseController extends Controller
} }
return $this->response($this->manager->createData($resource)->toArray()); return $this->response($this->manager->createData($resource)->toArray());
} }
protected function response($response) protected function response($response)
@ -357,13 +359,15 @@ class BaseController extends Controller
$transformer = new $this->entity_transformer(request()->input('serializer')); $transformer = new $this->entity_transformer(request()->input('serializer'));
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
$this->entity_type = null; $this->entity_type = null;
}
$resource = new Item($item, $transformer, $this->entity_type); $resource = new Item($item, $transformer, $this->entity_type);
if (auth()->user() && request()->include_static) if (auth()->user() && request()->include_static) {
$data['static'] = Statics::company(auth()->user()->getCompany()->getLocale()); $data['static'] = Statics::company(auth()->user()->getCompany()->getLocale());
}
return $this->response($this->manager->createData($resource)->toArray()); return $this->response($this->manager->createData($resource)->toArray());
} }
@ -407,7 +411,6 @@ class BaseController extends Controller
public function flutterRoute() public function flutterRoute()
{ {
if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) { if ((bool) $this->checkAppSetup() !== false && $account = Account::first()) {
if (config('ninja.require_https') && ! request()->isSecure()) { if (config('ninja.require_https') && ! request()->isSecure()) {
return redirect()->secure(request()->getRequestUri()); return redirect()->secure(request()->getRequestUri());

View File

@ -25,11 +25,6 @@ class ContactHashLoginController extends Controller
*/ */
public function login(string $contact_key) public function login(string $contact_key)
{ {
return redirect('/client/login'); return redirect('/client/login');
} }
} }

View File

@ -37,7 +37,6 @@ class InvitationController extends Controller
public function router(string $entity, string $invitation_key) public function router(string $entity, string $invitation_key)
{ {
$key = $entity.'_id'; $key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation'; $entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
@ -48,18 +47,15 @@ class InvitationController extends Controller
/* Return early if we have the correct client_hash embedded */ /* Return early if we have the correct client_hash embedded */
if(request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) { if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) {
auth()->guard('contact')->login($invitation->contact, true); auth()->guard('contact')->login($invitation->contact, true);
} } elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
else if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
$this->middleware('auth:contact'); $this->middleware('auth:contact');
} } else {
else {
auth()->guard('contact')->login($invitation->contact, true); auth()->guard('contact')->login($invitation->contact, true);
} }
if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed(); $invitation->markViewed();
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars())); event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));
@ -68,8 +64,6 @@ class InvitationController extends Controller
} }
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]); return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
} }
private function fireEntityViewedEvent($invitation, $entity_string) private function fireEntityViewedEvent($invitation, $entity_string)

View File

@ -77,8 +77,9 @@ class PaymentController extends Controller
$is_credit_payment = false; $is_credit_payment = false;
$token = false; $token = false;
if($request->input('company_gateway_id') == CompanyGateway::GATEWAY_CREDIT) if ($request->input('company_gateway_id') == CompanyGateway::GATEWAY_CREDIT) {
$is_credit_payment = true; $is_credit_payment = true;
}
$gateway = CompanyGateway::find($request->input('company_gateway_id')); $gateway = CompanyGateway::find($request->input('company_gateway_id'));
@ -94,10 +95,8 @@ class PaymentController extends Controller
$invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->get(); $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->get();
/* pop non payable invoice from the $payable_invoices array */ /* pop non payable invoice from the $payable_invoices array */
$payable_invoices = $payable_invoices->filter(function ($payable_invoice) use ($invoices){ $payable_invoices = $payable_invoices->filter(function ($payable_invoice) use ($invoices) {
return $invoices->where('hashed_id', $payable_invoice['invoice_id'])->first()->isPayable(); return $invoices->where('hashed_id', $payable_invoice['invoice_id'])->first()->isPayable();
}); });
/*return early if no invoices*/ /*return early if no invoices*/
@ -110,8 +109,7 @@ class PaymentController extends Controller
$settings = auth()->user()->client->getMergedSettings(); $settings = auth()->user()->client->getMergedSettings();
/*iterate through invoices and add gateway fees and other payment metadata*/ /*iterate through invoices and add gateway fees and other payment metadata*/
$payable_invoices = $payable_invoices->map(function($payable_invoice) use($invoices, $settings){ $payable_invoices = $payable_invoices->map(function ($payable_invoice) use ($invoices, $settings) {
$payable_invoice['amount'] = Number::parseFloat($payable_invoice['amount']); $payable_invoice['amount'] = Number::parseFloat($payable_invoice['amount']);
$invoice = $invoices->first(function ($inv) use ($payable_invoice) { $invoice = $invoices->first(function ($inv) use ($payable_invoice) {
@ -167,7 +165,6 @@ class PaymentController extends Controller
$payable_invoice['additional_info'] = $additional_info; $payable_invoice['additional_info'] = $additional_info;
return $payable_invoice; return $payable_invoice;
}); });
if (request()->has('signature') && !is_null(request()->signature) && !empty(request()->signature)) { if (request()->has('signature') && !is_null(request()->signature) && !empty(request()->signature)) {
@ -182,8 +179,9 @@ class PaymentController extends Controller
$credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'off' ? 0 : $first_invoice->client->service()->getCreditBalance(); $credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'off' ? 0 : $first_invoice->client->service()->getCreditBalance();
$starting_invoice_amount = $first_invoice->amount; $starting_invoice_amount = $first_invoice->amount;
if($gateway) if ($gateway) {
$first_invoice->service()->addGatewayFee($gateway, $payment_method_id, $invoice_totals)->save(); $first_invoice->service()->addGatewayFee($gateway, $payment_method_id, $invoice_totals)->save();
}
/** /**
* Gateway fee is calculated * Gateway fee is calculated
@ -192,8 +190,9 @@ class PaymentController extends Controller
*/ */
$fee_totals = $first_invoice->amount - $starting_invoice_amount; $fee_totals = $first_invoice->amount - $starting_invoice_amount;
if($gateway) if ($gateway) {
$token = auth()->user()->client->gateway_token($gateway->id, $payment_method_id); $token = auth()->user()->client->gateway_token($gateway->id, $payment_method_id);
}
$payment_hash = new PaymentHash; $payment_hash = new PaymentHash;
$payment_hash->hash = Str::random(128); $payment_hash->hash = Str::random(128);
@ -218,7 +217,7 @@ class PaymentController extends Controller
'amount_with_fee' => $invoice_totals + $fee_totals, 'amount_with_fee' => $invoice_totals + $fee_totals,
]; ];
if($is_credit_payment) { if ($is_credit_payment) {
return $this->processCreditPayment($request, $data); return $this->processCreditPayment($request, $data);
} }
@ -252,9 +251,9 @@ class PaymentController extends Controller
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first(); $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
/* Hydrate the $payment */ /* Hydrate the $payment */
if($payment_hash->payment()->exists()) if ($payment_hash->payment()->exists()) {
$payment = $payment_hash->payment; $payment = $payment_hash->payment;
else { } else {
$payment = PaymentFactory::create($payment_hash->fee_invoice->company_id, $payment_hash->fee_invoice->user_id); $payment = PaymentFactory::create($payment_hash->fee_invoice->company_id, $payment_hash->fee_invoice->user_id);
$payment->client_id = $payment_hash->fee_invoice->client_id; $payment->client_id = $payment_hash->fee_invoice->client_id;
$payment->save(); $payment->save();
@ -264,8 +263,7 @@ class PaymentController extends Controller
} }
/* Iterate through the invoices and apply credits to them */ /* Iterate through the invoices and apply credits to them */
collect($payment_hash->invoices())->each(function ($payable_invoice) use ($payment, $payment_hash){ collect($payment_hash->invoices())->each(function ($payable_invoice) use ($payment, $payment_hash) {
$invoice = Invoice::find($this->decodePrimaryKey($payable_invoice->invoice_id)); $invoice = Invoice::find($this->decodePrimaryKey($payable_invoice->invoice_id));
$amount = $payable_invoice->amount; $amount = $payable_invoice->amount;
@ -274,35 +272,31 @@ class PaymentController extends Controller
->service() ->service()
->getCredits(); ->getCredits();
foreach($credits as $credit) foreach ($credits as $credit) {
{ //starting invoice balance
//starting invoice balance $invoice_balance = $invoice->balance;
$invoice_balance = $invoice->balance;
//credit payment applied //credit payment applied
$credit->service()->applyPayment($invoice, $amount, $payment); $credit->service()->applyPayment($invoice, $amount, $payment);
//amount paid from invoice calculated //amount paid from invoice calculated
$remaining_balance = ($invoice_balance - $invoice->fresh()->balance); $remaining_balance = ($invoice_balance - $invoice->fresh()->balance);
//reduce the amount to be paid on the invoice from the NEXT credit //reduce the amount to be paid on the invoice from the NEXT credit
$amount -= $remaining_balance; $amount -= $remaining_balance;
//break if the invoice is no longer PAYABLE OR there is no more amount to be applied //break if the invoice is no longer PAYABLE OR there is no more amount to be applied
if(!$invoice->isPayable() || (int)$amount == 0) if (!$invoice->isPayable() || (int)$amount == 0) {
break; break;
} }
}
}); });
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]);
} }
public function processCreditPayment(Request $request, array $data) public function processCreditPayment(Request $request, array $data)
{ {
return render('gateways.credit.index', $data); return render('gateways.credit.index', $data);
} }
} }

View File

@ -408,9 +408,9 @@ class CompanyController extends BaseController
*/ */
public function update(UpdateCompanyRequest $request, Company $company) public function update(UpdateCompanyRequest $request, Company $company)
{ {
if ($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings')))) {
if($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings'))))
$this->removeLogo($company); $this->removeLogo($company);
}
$company = $this->company_repo->save($request->all(), $company); $company = $this->company_repo->save($request->all(), $company);
@ -490,7 +490,6 @@ class CompanyController extends BaseController
LightLogs::create(new AccountDeleted()) LightLogs::create(new AccountDeleted())
->increment() ->increment()
->batch(); ->batch();
} else { } else {
$company_id = $company->id; $company_id = $company->id;
$company->delete(); $company->delete();

View File

@ -187,7 +187,7 @@ class CreditController extends BaseController
$credit = $this->credit_repository->save($request->all(), CreditFactory::create(auth()->user()->company()->id, auth()->user()->id)); $credit = $this->credit_repository->save($request->all(), CreditFactory::create(auth()->user()->company()->id, auth()->user()->id));
$credit = $credit->service() $credit = $credit->service()
->fillDefaults() ->fillDefaults()
->save(); ->save();

View File

@ -120,18 +120,14 @@ class EmailController extends BaseController
$template = str_replace("email_template_", "", $template); $template = str_replace("email_template_", "", $template);
$entity_obj->invitations->each(function ($invitation) use ($subject, $body, $entity_string, $entity_obj, $template) { $entity_obj->invitations->each(function ($invitation) use ($subject, $body, $entity_string, $entity_obj, $template) {
if ($invitation->contact->send_email && $invitation->contact->email) { if ($invitation->contact->send_email && $invitation->contact->email) {
$data = [ $data = [
'subject' => $subject, 'subject' => $subject,
'body' => $body 'body' => $body
]; ];
EmailEntity::dispatchNow($invitation, $invitation->company, $template, $data); EmailEntity::dispatchNow($invitation, $invitation->company, $template, $data);
} }
}); });
$entity_obj->last_sent_date = now(); $entity_obj->last_sent_date = now();

View File

@ -396,7 +396,7 @@ class InvoiceController extends BaseController
$invoice = $this->invoice_repo->save($request->all(), $invoice); $invoice = $this->invoice_repo->save($request->all(), $invoice);
UnlinkFile::dispatchNow(config('filesystems.default'),$invoice->client->invoice_filepath().$invoice->number.'.pdf'); UnlinkFile::dispatchNow(config('filesystems.default'), $invoice->client->invoice_filepath().$invoice->number.'.pdf');
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));
@ -731,7 +731,6 @@ class InvoiceController extends BaseController
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) { $invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
info("firing email"); info("firing email");
EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template); EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template);
}); });
if (! $bulk) { if (! $bulk) {

View File

@ -219,7 +219,6 @@ class MigrationController extends BaseController
*/ */
public function startMigration(Request $request) public function startMigration(Request $request)
{ {
$companies = json_decode($request->companies); $companies = json_decode($request->companies);
if (app()->environment() === 'local') { if (app()->environment() === 'local') {
@ -227,7 +226,6 @@ class MigrationController extends BaseController
} }
foreach ($companies as $company) { foreach ($companies as $company) {
$is_valid = $request->file($company->company_index)->isValid(); $is_valid = $request->file($company->company_index)->isValid();
if (!$is_valid) { if (!$is_valid) {

View File

@ -27,4 +27,4 @@
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"), * @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"), * @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* ) * )
*/ */

View File

@ -45,7 +45,9 @@ class PingController extends BaseController
return response()->json( return response()->json(
['company_name' => auth()->user()->getCompany()->present()->name(), ['company_name' => auth()->user()->getCompany()->present()->name(),
'user_name' => auth()->user()->present()->name(), 'user_name' => auth()->user()->present()->name(),
], 200); ],
200
);
} }
/** /**

View File

@ -363,7 +363,7 @@ class ProjectController extends BaseController
$project->fill($request->all()); $project->fill($request->all());
$project->save(); $project->save();
if(empty($project->number)){ if (empty($project->number)) {
$project->number = $this->getNextProjectNumber($project); $project->number = $this->getNextProjectNumber($project);
$project->save(); $project->save();
} }

View File

@ -670,22 +670,25 @@ class QuoteController extends BaseController
case 'restore': case 'restore':
$this->quote_repo->restore($quote); $this->quote_repo->restore($quote);
if (!$bulk) if (!$bulk) {
return $this->listResponse($quote); return $this->listResponse($quote);
}
break; break;
case 'archive': case 'archive':
$this->quote_repo->archive($quote); $this->quote_repo->archive($quote);
if (!$bulk) if (!$bulk) {
return $this->listResponse($quote); return $this->listResponse($quote);
}
break; break;
case 'delete': case 'delete':
$this->quote_repo->delete($quote); $this->quote_repo->delete($quote);
if (!$bulk) if (!$bulk) {
return $this->listResponse($quote); return $this->listResponse($quote);
}
break; break;
case 'email': case 'email':
@ -700,7 +703,6 @@ class QuoteController extends BaseController
return $this->itemResponse($quote); return $this->itemResponse($quote);
} }
break; break;
// no break
default: default:
return response()->json(['message' => "The requested action `{$action}` is not available."], 400); return response()->json(['message' => "The requested action `{$action}` is not available."], 400);
break; break;

View File

@ -628,6 +628,5 @@ class RecurringInvoiceController extends BaseController
// code... // code...
break; break;
} }
} }
} }

View File

@ -74,7 +74,6 @@ class SelfUpdateController extends BaseController
try { try {
$res = $repo->pull(); $res = $repo->pull();
} catch (GitException $e) { } catch (GitException $e) {
info($e->getMessage()); info($e->getMessage());
return response()->json(['message'=>$e->getMessage()], 500); return response()->json(['message'=>$e->getMessage()], 500);
} }

View File

@ -63,8 +63,9 @@ class SystemLogController extends BaseController
{ {
$system_logs = SystemLog::filter($filters); $system_logs = SystemLog::filter($filters);
if(auth()->user()->isAdmin()) if (auth()->user()->isAdmin()) {
return $this->listResponse($system_logs); return $this->listResponse($system_logs);
}
return $this->errorResponse('Insufficient permissions', 403); return $this->errorResponse('Insufficient permissions', 403);
} }

View File

@ -65,9 +65,9 @@ class General extends Component
$data = $this->validate($this->rules); $data = $this->validate($this->rules);
if (!empty($this->password)) { if (!empty($this->password)) {
$this->profile->password = Hash::make($this->password); $this->profile->password = Hash::make($this->password);
} }
$this->profile $this->profile
->fill($data) ->fill($data)

View File

@ -27,9 +27,9 @@ class ApiSecretCheck
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (! config('ninja.api_secret')) {
if(! config('ninja.api_secret'))
return $next($request); return $next($request);
}
if ($request->header('X-API-SECRET') && ($request->header('X-API-SECRET') == config('ninja.api_secret'))) { if ($request->header('X-API-SECRET') && ($request->header('X-API-SECRET') == config('ninja.api_secret'))) {
return $next($request); return $next($request);

View File

@ -34,47 +34,32 @@ class ContactKeyLogin
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (Auth::guard('contact')->check()) {
if(Auth::guard('contact')->check())
Auth::guard('contact')->logout(); Auth::guard('contact')->logout();
}
if ($request->segment(3) && config('ninja.db.multi_db_enabled')) { if ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) { if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
$client_contact = ClientContact::where('contact_key', $request->segment(3))->first(); $client_contact = ClientContact::where('contact_key', $request->segment(3))->first();
Auth::guard('contact')->login($client_contact, true); Auth::guard('contact')->login($client_contact, true);
return redirect()->to('client/dashboard'); return redirect()->to('client/dashboard');
} }
} elseif ($request->has('contact_key')) {
} if ($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()) {
else if ($request->has('contact_key')) {
if($client_contact = ClientContact::where('contact_key', $request->segment(3))->first()){
Auth::guard('contact')->login($client_contact, true); Auth::guard('contact')->login($client_contact, true);
return redirect()->to('client/dashboard'); return redirect()->to('client/dashboard');
} }
} elseif ($request->has('client_hash') && config('ninja.db.multi_db_enabled')) {
}
else if($request->has('client_hash') && config('ninja.db.multi_db_enabled')){
if (MultiDB::findAndSetDbByClientHash($request->input('client_hash'))) { if (MultiDB::findAndSetDbByClientHash($request->input('client_hash'))) {
$client = Client::where('client_hash', $request->input('client_hash'))->first(); $client = Client::where('client_hash', $request->input('client_hash'))->first();
Auth::guard('contact')->login($client->primary_contact()->first(), true); Auth::guard('contact')->login($client->primary_contact()->first(), true);
return redirect()->to('client/dashboard'); return redirect()->to('client/dashboard');
} }
} elseif ($request->has('client_hash')) {
} if ($client = Client::where('client_hash', $request->input('client_hash'))->first()) {
else if($request->has('client_hash')){
if($client = Client::where('client_hash', $request->input('client_hash'))->first()){
Auth::guard('contact')->login($client->primary_contact()->first(), true); Auth::guard('contact')->login($client->primary_contact()->first(), true);
return redirect()->to('client/dashboard'); return redirect()->to('client/dashboard');
} }
} }
return $next($request); return $next($request);

View File

@ -55,7 +55,7 @@ class ContactTokenAuth
//stateless, don't remember the contact. //stateless, don't remember the contact.
auth()->guard('contact')->login($client_contact, false); auth()->guard('contact')->login($client_contact, false);
event(new ContactLoggedIn($client_contact, $client_contact->company, Ninja::eventVars())); event(new ContactLoggedIn($client_contact, $client_contact->company, Ninja::eventVars()));
} else { } else {
$error = [ $error = [
'message' => 'Invalid token', 'message' => 'Invalid token',

View File

@ -31,7 +31,6 @@ class QueryLogging
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next)
{ {
$timeStart = microtime(true); $timeStart = microtime(true);
// Enable query logging for development // Enable query logging for development
@ -54,7 +53,6 @@ class QueryLogging
// if($count > 50) // if($count > 50)
// Log::info($queries); // Log::info($queries);
} }
} }

View File

@ -38,7 +38,7 @@ class SetEmailDb
if (! MultiDB::userFindAndSetDb($request->input('email'))) { if (! MultiDB::userFindAndSetDb($request->input('email'))) {
return response()->json($error, 400); return response()->json($error, 400);
} }
} }
// else { // else {
// return response()->json($error, 403); // return response()->json($error, 403);
// } // }

View File

@ -69,8 +69,9 @@ class StartupCheck
/*Build template cache*/ /*Build template cache*/
if ($request->has('clear_cache') || ! Cache::has('templates')) if ($request->has('clear_cache') || ! Cache::has('templates')) {
$this->buildTemplates(); $this->buildTemplates();
}
$response = $next($request); $response = $next($request);

View File

@ -36,12 +36,12 @@ class TrustProxies extends Middleware
* *
* @param \Illuminate\Contracts\Config\Repository $config * @param \Illuminate\Contracts\Config\Repository $config
*/ */
public function __construct(Repository $config) { public function __construct(Repository $config)
{
parent::__construct($config); parent::__construct($config);
if (config('ninja.trusted_proxies'))
$this->proxies = config('ninja.trusted_proxies');
if (config('ninja.trusted_proxies')) {
$this->proxies = config('ninja.trusted_proxies');
}
} }
} }

View File

@ -42,8 +42,9 @@ class UpdateExpenseRequest extends Request
//$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; //$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id;
$rules['contacts.*.email'] = 'nullable|distinct'; $rules['contacts.*.email'] = 'nullable|distinct';
if(isset($this->number)) if (isset($this->number)) {
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id); $rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }

View File

@ -13,6 +13,7 @@ namespace App\Http\Requests\ExpenseCategory;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Utils\Traits\ChecksEntityStatus; use App\Utils\Traits\ChecksEntityStatus;
class UpdateExpenseCategoryRequest extends Request class UpdateExpenseCategoryRequest extends Request
{ {
use ChecksEntityStatus; use ChecksEntityStatus;
@ -29,13 +30,12 @@ class UpdateExpenseCategoryRequest extends Request
public function rules() public function rules()
{ {
$rules = []; $rules = [];
if ($this->input('name')) if ($this->input('name')) {
$rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->company_id; $rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->company_id;
}
return $rules; return $rules;
} }
} }

View File

@ -31,7 +31,6 @@ class StoreGroupSettingRequest extends Request
public function rules() public function rules()
{ {
$rules['name'] = 'required|unique:group_settings,name,null,null,company_id,'.auth()->user()->companyId(); $rules['name'] = 'required|unique:group_settings,name,null,null,company_id,'.auth()->user()->companyId();
$rules['settings'] = new ValidClientGroupSettingsRule(); $rules['settings'] = new ValidClientGroupSettingsRule();

View File

@ -39,7 +39,7 @@ class StorePaymentRequest extends Request
{ {
$input = $this->all(); $input = $this->all();
// info(print_r($input,1)); // info(print_r($input,1));
$invoices_total = 0; $invoices_total = 0;
$credits_total = 0; $credits_total = 0;
@ -77,7 +77,7 @@ class StorePaymentRequest extends Request
} }
if (! isset($input['amount']) || $input['amount'] == 0) { if (! isset($input['amount']) || $input['amount'] == 0) {
$input['amount'] = $invoices_total - $credits_total; $input['amount'] = $invoices_total - $credits_total;
} }
$input['is_manual'] = true; $input['is_manual'] = true;

View File

@ -35,8 +35,7 @@ class UpdatePaymentRequest extends Request
public function rules() public function rules()
{ {
$rules = [
$rules = [
'number' => 'nullable|unique:payments,number,'.$this->id.',id,company_id,'.$this->payment->company_id, 'number' => 'nullable|unique:payments,number,'.$this->id.',id,company_id,'.$this->payment->company_id,
'invoices' => ['array', new PaymentAppliedValidAmount, new ValidCreditsPresentRule], 'invoices' => ['array', new PaymentAppliedValidAmount, new ValidCreditsPresentRule],
'invoices.*.invoice_id' => 'distinct', 'invoices.*.invoice_id' => 'distinct',

View File

@ -34,16 +34,16 @@ class StoreProjectRequest extends Request
{ {
$rules = []; $rules = [];
$rules['name'] = 'required'; $rules['name'] = 'required';
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id; $rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
$rules['number'] = 'unique:projects,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id; $rules['number'] = 'unique:projects,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
return $this->globalRules($rules); return $this->globalRules($rules);
} }
protected function prepareForValidation() protected function prepareForValidation()
{ {
$input = $this->decodePrimaryKeys($this->all()); $input = $this->decodePrimaryKeys($this->all());
$this->replace($input); $this->replace($input);
} }

View File

@ -33,18 +33,20 @@ class UpdateProjectRequest extends Request
{ {
$rules = []; $rules = [];
if(isset($this->number)) if (isset($this->number)) {
$rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id); $rules['number'] = Rule::unique('projects')->where('company_id', auth()->user()->company()->id)->ignore($this->project->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }
protected function prepareForValidation() protected function prepareForValidation()
{ {
$input = $this->decodePrimaryKeys($this->all()); $input = $this->decodePrimaryKeys($this->all());
if(isset($input['client_id'])) if (isset($input['client_id'])) {
unset($input['client_id']); unset($input['client_id']);
}
$this->replace($input); $this->replace($input);
} }

View File

@ -100,29 +100,30 @@ class StoreRecurringInvoiceRequest extends Request
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
if(isset($input['auto_bill'])) if (isset($input['auto_bill'])) {
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']); $input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
else{ } else {
if ($client = Client::find($input['client_id'])) {
if($client = Client::find($input['client_id']))
$input['auto_bill'] = $client->getSetting('auto_bill'); $input['auto_bill'] = $client->getSetting('auto_bill');
}
} }
$this->replace($input); $this->replace($input);
} }
private function setAutoBillFlag($auto_bill) private function setAutoBillFlag($auto_bill)
{ {
if($auto_bill == 'always') if ($auto_bill == 'always') {
return true; return true;
}
if($auto_bill == 'off') if ($auto_bill == 'off') {
return false; return false;
}
} }
public function messages() public function messages()
{ {
return []; return [];
} }
} }

View File

@ -36,7 +36,6 @@ class UpdateRecurringInvoiceRequest extends Request
public function rules() public function rules()
{ {
$rules = []; $rules = [];
if ($this->input('documents') && is_array($this->input('documents'))) { if ($this->input('documents') && is_array($this->input('documents'))) {
@ -90,33 +89,32 @@ class UpdateRecurringInvoiceRequest extends Request
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
if(isset($input['auto_bill'])) if (isset($input['auto_bill'])) {
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']); $input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
}
$this->replace($input); $this->replace($input);
} }
/** /**
* if($auto_bill == '') * if($auto_bill == '')
* off / optin / optout will reset the status of this field to off to allow * off / optin / optout will reset the status of this field to off to allow
* the client to choose whether to auto_bill or not. * the client to choose whether to auto_bill or not.
* *
* @param enum $auto_bill off/always/optin/optout * @param enum $auto_bill off/always/optin/optout
* *
* @return bool * @return bool
*/ */
private function setAutoBillFlag($auto_bill) :bool private function setAutoBillFlag($auto_bill) :bool
{ {
if ($auto_bill == 'always') {
if($auto_bill == 'always')
return true; return true;
}
// if($auto_bill == '') // if($auto_bill == '')
// off / optin / optout will reset the status of this field to off to allow // off / optin / optout will reset the status of this field to off to allow
// the client to choose whether to auto_bill or not. // the client to choose whether to auto_bill or not.
return false; return false;
} }
} }

View File

@ -17,7 +17,7 @@ use Illuminate\Foundation\Http\FormRequest;
class Request extends FormRequest class Request extends FormRequest
{ {
use MakesHash; use MakesHash;
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
@ -31,22 +31,22 @@ class Request extends FormRequest
public function globalRules($rules) public function globalRules($rules)
{ {
$merge_rules = []; $merge_rules = [];
foreach($this->all() as $key => $value) foreach ($this->all() as $key => $value) {
{ if (method_exists($this, $key)) {
if(method_exists($this, $key)) $merge_rules = $this->{$key}($rules);
$merge_rules = $this->{$key}($rules); }
} }
return array_merge($merge_rules, $rules); return array_merge($merge_rules, $rules);
} }
private function assigned_user_id($rules) private function assigned_user_id($rules)
{ {
$rules['assigned_user_id'] = [ $rules['assigned_user_id'] = [
'bail' , 'bail' ,
'sometimes', 'sometimes',
'nullable', 'nullable',
new RelatedUserRule($this->all()) new RelatedUserRule($this->all())
]; ];
@ -70,7 +70,6 @@ class Request extends FormRequest
public function decodePrimaryKeys($input) public function decodePrimaryKeys($input)
{ {
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) { if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']); $input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
} }
@ -81,15 +80,15 @@ class Request extends FormRequest
if (array_key_exists('vendor_id', $input) && is_string($input['vendor_id'])) { if (array_key_exists('vendor_id', $input) && is_string($input['vendor_id'])) {
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']); $input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
} }
if (array_key_exists('client_id', $input) && is_string($input['client_id'])) { if (array_key_exists('client_id', $input) && is_string($input['client_id'])) {
$input['client_id'] = $this->decodePrimaryKey($input['client_id']); $input['client_id'] = $this->decodePrimaryKey($input['client_id']);
} }
if (array_key_exists('invoice_id', $input) && is_string($input['invoice_id'])) { if (array_key_exists('invoice_id', $input) && is_string($input['invoice_id'])) {
$input['invoice_id'] = $this->decodePrimaryKey($input['invoice_id']); $input['invoice_id'] = $this->decodePrimaryKey($input['invoice_id']);
} }
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) { if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
$input['design_id'] = $this->decodePrimaryKey($input['design_id']); $input['design_id'] = $this->decodePrimaryKey($input['design_id']);
@ -146,6 +145,6 @@ class Request extends FormRequest
} }
} }
return $input; return $input;
} }
} }

View File

@ -38,17 +38,18 @@ class StoreTaskRequest extends Request
{ {
$rules = []; $rules = [];
if(isset($this->number)) if (isset($this->number)) {
$rules['number'] = Rule::unique('tasks')->where('company_id', auth()->user()->company()->id); $rules['number'] = Rule::unique('tasks')->where('company_id', auth()->user()->company()->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }
protected function prepareForValidation() protected function prepareForValidation()
{ {
$input = $this->all(); $input = $this->all();
$input = $this->decodePrimaryKeys($this->all()); $input = $this->decodePrimaryKeys($this->all());
if (array_key_exists('status_id', $input) && is_string($input['status_id'])) { if (array_key_exists('status_id', $input) && is_string($input['status_id'])) {
$input['status_id'] = $this->decodePrimaryKey($input['status_id']); $input['status_id'] = $this->decodePrimaryKey($input['status_id']);
@ -56,5 +57,4 @@ class StoreTaskRequest extends Request
$this->replace($input); $this->replace($input);
} }
} }

View File

@ -38,15 +38,16 @@ class UpdateTaskRequest extends Request
{ {
$rules = []; $rules = [];
if(isset($this->number)) if (isset($this->number)) {
$rules['number'] = Rule::unique('tasks')->where('company_id', auth()->user()->company()->id)->ignore($this->task->id); $rules['number'] = Rule::unique('tasks')->where('company_id', auth()->user()->company()->id)->ignore($this->task->id);
}
return $this->globalRules($rules); return $this->globalRules($rules);
} }
protected function prepareForValidation() protected function prepareForValidation()
{ {
$input = $this->decodePrimaryKeys($this->all()); $input = $this->decodePrimaryKeys($this->all());
if (array_key_exists('status_id', $input) && is_string($input['status_id'])) { if (array_key_exists('status_id', $input) && is_string($input['status_id'])) {
$input['status_id'] = $this->decodePrimaryKey($input['status_id']); $input['status_id'] = $this->decodePrimaryKey($input['status_id']);

View File

@ -33,10 +33,10 @@ class UpdateTaskStatusRequest extends Request
{ {
$rules = []; $rules = [];
if ($this->input('name')) if ($this->input('name')) {
$rules['name'] = 'unique:task_statuses,name,'.$this->id.',id,company_id,'.$this->task_status->company_id; $rules['name'] = 'unique:task_statuses,name,'.$this->id.',id,company_id,'.$this->task_status->company_id;
}
return $rules; return $rules;
} }
} }

View File

@ -41,12 +41,11 @@ class CreditsSumRule implements Rule
private function checkCreditTotals() private function checkCreditTotals()
{ {
if (array_sum(array_column($this->input['credits'], 'amount')) > array_sum(array_column($this->input['invoices'], 'amount'))) {
if( array_sum(array_column($this->input['credits'],'amount')) > array_sum(array_column($this->input['invoices'], 'amount')))
return false; return false;
}
return true; return true;
} }
/** /**

View File

@ -51,8 +51,9 @@ class UniqueExpenseNumberRule implements Rule
*/ */
private function checkIfExpenseNumberUnique() : bool private function checkIfExpenseNumberUnique() : bool
{ {
if(empty($this->input['number'])) if (empty($this->input['number'])) {
return true; return true;
}
$expense = Expense::query() $expense = Expense::query()
->where('number', $this->input['number']) ->where('number', $this->input['number'])

View File

@ -51,8 +51,9 @@ class UniqueInvoiceNumberRule implements Rule
*/ */
private function checkIfInvoiceNumberUnique() : bool private function checkIfInvoiceNumberUnique() : bool
{ {
if(empty($this->input['number'])) if (empty($this->input['number'])) {
return true; return true;
}
$invoice = Invoice::where('client_id', $this->input['client_id']) $invoice = Invoice::where('client_id', $this->input['client_id'])
->where('number', $this->input['number']) ->where('number', $this->input['number'])

View File

@ -73,8 +73,8 @@ class PaymentAmountsBalanceRule implements Rule
return true; return true;
} // if no invoices are present, then this is an unapplied payment, let this pass validation! } // if no invoices are present, then this is an unapplied payment, let this pass validation!
// info("payment amounts = {$payment_amounts}"); // info("payment amounts = {$payment_amounts}");
// info("invoice amounts = {$invoice_amounts}"); // info("invoice amounts = {$invoice_amounts}");
return $payment_amounts >= $invoice_amounts; return $payment_amounts >= $invoice_amounts;
} }

View File

@ -35,11 +35,13 @@ class ValidProjectForClient implements Rule
*/ */
public function passes($attribute, $value) public function passes($attribute, $value)
{ {
if(empty($this->input['project_id'])) if (empty($this->input['project_id'])) {
return true; return true;
}
if(is_string($this->input['project_id'])) if (is_string($this->input['project_id'])) {
$this->input['project_id'] = $this->decodePrimaryKey($this->input['project_id']); $this->input['project_id'] = $this->decodePrimaryKey($this->input['project_id']);
}
$project = Project::findOrFail($this->input['project_id']); $project = Project::findOrFail($this->input['project_id']);
@ -53,6 +55,4 @@ class ValidProjectForClient implements Rule
{ {
return "Project client does not match entity client"; return "Project client does not match entity client";
} }
} }

View File

@ -52,8 +52,9 @@ class UniqueRecurringInvoiceNumberRule implements Rule
*/ */
private function checkIfInvoiceNumberUnique() : bool private function checkIfInvoiceNumberUnique() : bool
{ {
if(empty($this->input['number'])) if (empty($this->input['number'])) {
return true; return true;
}
$invoice = RecurringInvoice::where('client_id', $this->input['client_id']) $invoice = RecurringInvoice::where('client_id', $this->input['client_id'])
->where('number', $this->input['number']) ->where('number', $this->input['number'])

View File

@ -50,9 +50,9 @@ class RelatedUserRule implements Rule
*/ */
private function checkUserIsRelated($user_id) : bool private function checkUserIsRelated($user_id) : bool
{ {
if (empty($user_id)) {
if(empty($user_id))
return true; return true;
}
return User::query() return User::query()
->where('id', $user_id) ->where('id', $user_id)

View File

@ -60,7 +60,6 @@ class ValidCreditsPresentRule implements Rule
if (request()->input('credits') && is_array(request()->input('credits'))) { if (request()->input('credits') && is_array(request()->input('credits'))) {
$credit_collection = Credit::whereIn('id', $this->transformKeys(array_column(request()->input('credits'), 'credit_id'))) $credit_collection = Credit::whereIn('id', $this->transformKeys(array_column(request()->input('credits'), 'credit_id')))
->where('balance', '>', 0) ->where('balance', '>', 0)
->get(); ->get();

View File

@ -32,8 +32,9 @@ class PortalComposer
{ {
$view->with($this->portalData()); $view->with($this->portalData());
if(auth()->user()) if (auth()->user()) {
Lang::replace(Ninja::transformTranslations(auth()->user()->client->getMergedSettings())); Lang::replace(Ninja::transformTranslations(auth()->user()->client->getMergedSettings()));
}
} }
/** /**
@ -73,7 +74,7 @@ class PortalComposer
$data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download']; $data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
if (auth()->user('contact')->client->getSetting('enable_client_portal_tasks')) { if (auth()->user('contact')->client->getSetting('enable_client_portal_tasks')) {
$data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.dashboard', 'icon' => 'clock']; $data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.dashboard', 'icon' => 'clock'];
// TODO: Update when 'tasks' module is available in client portal. // TODO: Update when 'tasks' module is available in client portal.
} }

View File

@ -22,7 +22,7 @@ use Illuminate\Support\Facades\Log;
class RecurringInvoicesCron class RecurringInvoicesCron
{ {
use Dispatchable; use Dispatchable;
/** /**
* Create a new job instance. * Create a new job instance.
@ -44,27 +44,23 @@ class RecurringInvoicesCron
info("Sending recurring invoices ".Carbon::now()->format('Y-m-d h:i:s')); info("Sending recurring invoices ".Carbon::now()->format('Y-m-d h:i:s'));
if (! config('ninja.db.multi_db_enabled')) { if (! config('ninja.db.multi_db_enabled')) {
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->with('company') ->with('company')
->cursor(); ->cursor();
Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count()); Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count());
$recurring_invoices->each(function ($recurring_invoice, $key) {
$recurring_invoices->each(function ($recurring_invoice, $key) {
info("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date); info("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date);
if(!$recurring_invoice->company->is_disabled) if (!$recurring_invoice->company->is_disabled) {
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db); SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
}
}); });
} else { } else {
//multiDB environment, need to //multiDB environment, need to
foreach (MultiDB::$dbs as $db) { foreach (MultiDB::$dbs as $db) {
MultiDB::setDB($db); MultiDB::setDB($db);
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now()) $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
@ -75,12 +71,11 @@ class RecurringInvoicesCron
Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db); Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);
$recurring_invoices->each(function ($recurring_invoice, $key) { $recurring_invoices->each(function ($recurring_invoice, $key) {
info("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date); info("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date);
if(!$recurring_invoice->company->is_disabled) if (!$recurring_invoice->company->is_disabled) {
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db); SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
}
}); });
} }
} }

View File

@ -72,19 +72,16 @@ class CreateEntityPdf implements ShouldQueue
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
if($invitation instanceof InvoiceInvitation){ if ($invitation instanceof InvoiceInvitation) {
$this->entity = $invitation->invoice; $this->entity = $invitation->invoice;
$this->entity_string = 'invoice'; $this->entity_string = 'invoice';
} } elseif ($invitation instanceof QuoteInvitation) {
elseif($invitation instanceof QuoteInvitation){
$this->entity = $invitation->quote; $this->entity = $invitation->quote;
$this->entity_string = 'quote'; $this->entity_string = 'quote';
} } elseif ($invitation instanceof CreditInvitation) {
elseif($invitation instanceof CreditInvitation){
$this->entity = $invitation->credit; $this->entity = $invitation->credit;
$this->entity_string = 'credit'; $this->entity_string = 'credit';
} } elseif ($invitation instanceof RecurringInvoiceInvitation) {
elseif($invitation instanceof RecurringInvoiceInvitation){
$this->entity = $invitation->recurring_invoice; $this->entity = $invitation->recurring_invoice;
$this->entity_string = 'recurring_invoice'; $this->entity_string = 'recurring_invoice';
} }
@ -98,7 +95,6 @@ class CreateEntityPdf implements ShouldQueue
public function handle() public function handle()
{ {
if (config('ninja.phantomjs_key')) { if (config('ninja.phantomjs_key')) {
return (new Phantom)->generate($this->invitation); return (new Phantom)->generate($this->invitation);
} }
@ -108,15 +104,13 @@ class CreateEntityPdf implements ShouldQueue
$entity_design_id = ''; $entity_design_id = '';
if($this->entity instanceof Invoice){ if ($this->entity instanceof Invoice) {
$path = $this->entity->client->invoice_filepath(); $path = $this->entity->client->invoice_filepath();
$entity_design_id = 'invoice_design_id'; $entity_design_id = 'invoice_design_id';
} } elseif ($this->entity instanceof Quote) {
elseif($this->entity instanceof Quote){
$path = $this->entity->client->quote_filepath(); $path = $this->entity->client->quote_filepath();
$entity_design_id = 'quote_design_id'; $entity_design_id = 'quote_design_id';
} } elseif ($this->entity instanceof Credit) {
elseif($this->entity instanceof Credit){
$path = $this->entity->client->credit_filepath(); $path = $this->entity->client->credit_filepath();
$entity_design_id = 'credit_design_id'; $entity_design_id = 'credit_design_id';
} }
@ -131,12 +125,12 @@ class CreateEntityPdf implements ShouldQueue
$html = new HtmlEngine($this->invitation); $html = new HtmlEngine($this->invitation);
if ($design->is_custom) { if ($design->is_custom) {
$options = [ $options = [
'custom_partials' => json_decode(json_encode($design->design), true) 'custom_partials' => json_decode(json_encode($design->design), true)
]; ];
$template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options); $template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options);
} else { } else {
$template = new PdfMakerDesign(strtolower($design->name)); $template = new PdfMakerDesign(strtolower($design->name));
} }
$state = [ $state = [
@ -165,15 +159,14 @@ class CreateEntityPdf implements ShouldQueue
$pdf = null; $pdf = null;
try { try {
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true)); $pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
} } catch (\Exception $e) {
catch(\Exception $e) { info(print_r($e->getMessage(), 1));
info(print_r($e->getMessage(),1));
} }
if($pdf) if ($pdf) {
$instance = Storage::disk($this->disk)->put($file_path, $pdf); $instance = Storage::disk($this->disk)->put($file_path, $pdf);
}
return $file_path; return $file_path;
} }

View File

@ -88,7 +88,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
$this->template_data = $template_data; $this->template_data = $template_data;
$this->email_entity_builder = $this->resolveEmailBuilder(); $this->email_entity_builder = $this->resolveEmailBuilder();
} }
/** /**
@ -99,8 +98,9 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
if($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
MultiDB::setDB($this->company->db); MultiDB::setDB($this->company->db);
@ -132,14 +132,15 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
private function resolveEntityString() :string private function resolveEntityString() :string
{ {
if($this->invitation instanceof InvoiceInvitation) if ($this->invitation instanceof InvoiceInvitation) {
return 'invoice'; return 'invoice';
elseif($this->invitation instanceof QuoteInvitation) } elseif ($this->invitation instanceof QuoteInvitation) {
return 'quote'; return 'quote';
elseif($this->invitation instanceof CreditInvitation) } elseif ($this->invitation instanceof CreditInvitation) {
return 'credit'; return 'credit';
elseif($this->invitation instanceof RecurringInvoiceInvitation) } elseif ($this->invitation instanceof RecurringInvoiceInvitation) {
return 'recurring_invoice'; return 'recurring_invoice';
}
} }
private function entityEmailFailed($message) private function entityEmailFailed($message)
@ -153,7 +154,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
# code... # code...
break; break;
} }
} }
private function entityEmailSucceeded() private function entityEmailSucceeded()

View File

@ -97,10 +97,8 @@ class ZipInvoices extends BaseMailerJob implements ShouldQueue
try { try {
Mail::to($this->email) Mail::to($this->email)
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company)); ->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
} } catch (\Exception $e) {
catch (\Exception $e) {
$this->failed($e); $this->failed($e);
} }
UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1)); UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1));

View File

@ -104,6 +104,5 @@ class BaseMailerJob implements ShouldQueue
LightLogs::create($job_failure) LightLogs::create($job_failure)
->batch(); ->batch();
} }
} }

View File

@ -72,8 +72,9 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -82,18 +83,15 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
$this->setMailDriver(); $this->setMailDriver();
try { try {
$mail_obj = (new EntityPaidObject($this->payment))->build(); $mail_obj = (new EntityPaidObject($this->payment))->build();
$mail_obj->from = [$this->user->email, $this->user->present()->name()]; $mail_obj->from = [$this->user->email, $this->user->present()->name()];
//send email //send email
Mail::to($this->user->email) Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
} catch (\Exception $e) { } catch (\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->payment->client); $this->logMailError($e->getMessage(), $this->payment->client);
} }
} }
} }

View File

@ -76,8 +76,9 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -91,12 +92,9 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
try { try {
Mail::to($this->user->email) Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
}catch(\Exception $e) { } catch (\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->entity->client); $this->logMailError($e->getMessage(), $this->entity->client);
} }
} }
} }

View File

@ -76,8 +76,9 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -89,15 +90,12 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()]; $mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
//send email //send email
try{ try {
Mail::to($this->user->email) Mail::to($this->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
} } catch (\Exception $e) {
catch (\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->entity->client); $this->logMailError($e->getMessage(), $this->entity->client);
} }
} }
} }

View File

@ -67,8 +67,9 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -79,13 +80,9 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
try { try {
Mail::to($this->to_user->email) Mail::to($this->to_user->email)
->send($this->mailable); ->send($this->mailable);
} } catch (\Exception $e) {
catch (\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->to_user); $this->logMailError($e->getMessage(), $this->to_user);
} }
} }
} }

View File

@ -77,8 +77,9 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
/*If we are migrating data we don't want to fire these notification*/ /*If we are migrating data we don't want to fire these notification*/
if ($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -103,14 +104,10 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
try { try {
Mail::to($company_user->user->email) Mail::to($company_user->user->email)
->send(new EntityNotificationMailer($mail_obj)); ->send(new EntityNotificationMailer($mail_obj));
} } catch (\Exception $e) {
catch(\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->client); $this->logMailError($e->getMessage(), $this->client);
} }
} }
}); });
} }

View File

@ -41,16 +41,19 @@ class RefundCancelledAccount implements ShouldQueue
$plan_details = $this->account->getPlanDetails(); $plan_details = $this->account->getPlanDetails();
if(!$plan_details) if (!$plan_details) {
return; return;
}
/* Trial user cancelling early.... */ /* Trial user cancelling early.... */
if ($plan_details['trial_plan']) if ($plan_details['trial_plan']) {
return; return;
}
/* Is the plan Active? */ /* Is the plan Active? */
if (! $plan_details['active']) if (! $plan_details['active']) {
return; return;
}
/* Refundable client! */ /* Refundable client! */

View File

@ -47,26 +47,18 @@ class SendReminders implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
info("Sending reminders ".Carbon::now()->format('Y-m-d h:i:s')); info("Sending reminders ".Carbon::now()->format('Y-m-d h:i:s'));
if (! config('ninja.db.multi_db_enabled')) { if (! config('ninja.db.multi_db_enabled')) {
$this->sendReminderEmails(); $this->sendReminderEmails();
} else { } else {
//multiDB environment, need to //multiDB environment, need to
foreach (MultiDB::$dbs as $db) foreach (MultiDB::$dbs as $db) {
{
MultiDB::setDB($db); MultiDB::setDB($db);
$this->sendReminderEmails(); $this->sendReminderEmails();
} }
} }
} }
@ -80,21 +72,17 @@ class SendReminders implements ShouldQueue
->cursor(); ->cursor();
//we only need invoices that are payable //we only need invoices that are payable
$invoices->filter(function ($invoice){ $invoices->filter(function ($invoice) {
return $invoice->isPayable(); return $invoice->isPayable();
})->each(function ($invoice) {
$reminder_template = $invoice->calculateTemplate('invoice');
})->each(function ($invoice){ info("hitting a reminder for {$invoice->number} with template {$reminder_template}");
$reminder_template = $invoice->calculateTemplate('invoice');
info("hitting a reminder for {$invoice->number} with template {$reminder_template}");
if(in_array($reminder_template, ['reminder1', 'reminder2', 'reminder3', 'endless_reminder'])) if (in_array($reminder_template, ['reminder1', 'reminder2', 'reminder3', 'endless_reminder'])) {
$this->sendReminder($invoice, $reminder_template); $this->sendReminder($invoice, $reminder_template);
}
}); });
} }
private function checkSendSetting($invoice, $template) private function checkSendSetting($invoice, $template)
@ -111,7 +99,7 @@ class SendReminders implements ShouldQueue
break; break;
case 'endless_reminder': case 'endless_reminder':
return $invoice->client->getSetting('enable_reminder_endless'); return $invoice->client->getSetting('enable_reminder_endless');
break; break;
default: default:
return false; return false;
break; break;
@ -121,9 +109,9 @@ class SendReminders implements ShouldQueue
/** /**
* Create a collection of all possible reminder dates * Create a collection of all possible reminder dates
* and pass back the first one in chronology * and pass back the first one in chronology
* *
* @param Invoice $invoice * @param Invoice $invoice
* @return Carbon $date * @return Carbon $date
*/ */
private function calculateNextSendDate($invoice) private function calculateNextSendDate($invoice)
{ {
@ -135,41 +123,41 @@ class SendReminders implements ShouldQueue
$set_reminder2 = false; $set_reminder2 = false;
$set_reminder3 = false; $set_reminder3 = false;
if((int)$settings->schedule_reminder1 > 0){ if ((int)$settings->schedule_reminder1 > 0) {
$next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder1, (int)$settings->num_days_reminder1); $next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder1, (int)$settings->num_days_reminder1);
if($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date))); if ($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date)));
$dates->push($next_reminder_date); $dates->push($next_reminder_date);
if(!$invoice->reminder1_sent) if (!$invoice->reminder1_sent) {
$set_reminder1 = true; $set_reminder1 = true;
}
} }
if((int)$settings->num_days_reminder2 > 0){ if ((int)$settings->num_days_reminder2 > 0) {
$next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder2, (int)$settings->num_days_reminder2); $next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder2, (int)$settings->num_days_reminder2);
if($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date))); if ($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date)));
$dates->push($next_reminder_date); $dates->push($next_reminder_date);
if(!$invoice->reminder2_sent) if (!$invoice->reminder2_sent) {
$set_reminder3 = true; $set_reminder3 = true;
}
} }
if((int)$settings->num_days_reminder3 > 0){ if ((int)$settings->num_days_reminder3 > 0) {
$next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder3, (int)$settings->num_days_reminder3); $next_reminder_date = $this->calculateScheduledDate($invoice, (int)$settings->schedule_reminder3, (int)$settings->num_days_reminder3);
if($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date))); if ($next_reminder_date->gt(Carbon::parse($invoice->last_sent_date)));
$dates->push($next_reminder_date); $dates->push($next_reminder_date);
if(!$invoice->reminder3_sent) if (!$invoice->reminder3_sent) {
$set_reminder3 = true; $set_reminder3 = true;
}
} }
//If all the available reminders have fired, we then start to fire the endless reminders //If all the available reminders have fired, we then start to fire the endless reminders
if((int)$settings->endless_reminder_frequency_id > 0 && !$set_reminder1 && !$set_reminder2 && !$set_reminder3) { if ((int)$settings->endless_reminder_frequency_id > 0 && !$set_reminder1 && !$set_reminder2 && !$set_reminder3) {
$dates->push($this->addTimeInterval($invoice->last_sent_date, (int)$settings->endless_reminder_frequency_id)); $dates->push($this->addTimeInterval($invoice->last_sent_date, (int)$settings->endless_reminder_frequency_id));
} }
@ -179,10 +167,10 @@ class SendReminders implements ShouldQueue
/** /**
* Helper method which switches values based on the $schedule_reminder * Helper method which switches values based on the $schedule_reminder
* @param Invoice $invoice * @param Invoice $invoice
* @param string $schedule_reminder * @param string $schedule_reminder
* @param int $num_days_reminder * @param int $num_days_reminder
* @return Carbon $date * @return Carbon $date
*/ */
private function calculateScheduledDate($invoice, $schedule_reminder, $num_days_reminder) :?Carbon private function calculateScheduledDate($invoice, $schedule_reminder, $num_days_reminder) :?Carbon
{ {
@ -204,48 +192,46 @@ class SendReminders implements ShouldQueue
/** /**
* Sends the reminder and/or late fee for the invoice. * Sends the reminder and/or late fee for the invoice.
* *
* @param Invoice $invoice * @param Invoice $invoice
* @param string $template * @param string $template
* @return void * @return void
*/ */
private function sendReminder($invoice, $template) :void private function sendReminder($invoice, $template) :void
{ {
$invoice = $this->calcLateFee($invoice, $template); $invoice = $this->calcLateFee($invoice, $template);
$invoice->invitations->each(function ($invitation) use($template, $invoice){ $invoice->invitations->each(function ($invitation) use ($template, $invoice) {
//only send if enable_reminder setting is toggled to yes //only send if enable_reminder setting is toggled to yes
if($this->checkSendSetting($invoice, $template)) { if ($this->checkSendSetting($invoice, $template)) {
info("firing email"); info("firing email");
EmailEntity::dispatchNow($invitation, $invitation->company, $template); EmailEntity::dispatchNow($invitation, $invitation->company, $template);
} }
}); });
if($this->checkSendSetting($invoice, $template)) if ($this->checkSendSetting($invoice, $template)) {
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
}
$invoice->last_sent_date = now(); $invoice->last_sent_date = now();
$invoice->next_send_date = $this->calculateNextSendDate($invoice); $invoice->next_send_date = $this->calculateNextSendDate($invoice);
if(in_array($template, ['reminder1', 'reminder2', 'reminder3'])) if (in_array($template, ['reminder1', 'reminder2', 'reminder3'])) {
$invoice->{$template."_sent"} = now(); $invoice->{$template."_sent"} = now();
}
$invoice->save(); $invoice->save();
} }
/** /**
* Calculates the late if - if any - and rebuilds the invoice * Calculates the late if - if any - and rebuilds the invoice
* *
* @param Invoice $invoice * @param Invoice $invoice
* @param string $template * @param string $template
* @return Invoice * @return Invoice
*/ */
private function calcLateFee($invoice, $template) :Invoice private function calcLateFee($invoice, $template) :Invoice
{ {
@ -268,7 +254,7 @@ class SendReminders implements ShouldQueue
case 'endless_reminder': case 'endless_reminder':
$late_fee_amount = $invoice->client->getSetting('late_fee_endless_amount'); $late_fee_amount = $invoice->client->getSetting('late_fee_endless_amount');
$late_fee_percent = $invoice->client->getSetting('late_fee_endless_percent'); $late_fee_percent = $invoice->client->getSetting('late_fee_endless_percent');
break; break;
default: default:
$late_fee_amount = 0; $late_fee_amount = 0;
$late_fee_percent = 0; $late_fee_percent = 0;
@ -276,31 +262,32 @@ class SendReminders implements ShouldQueue
} }
return $this->setLateFee($invoice, $late_fee_amount, $late_fee_percent); return $this->setLateFee($invoice, $late_fee_amount, $late_fee_percent);
} }
/** /**
* Applies the late fee to the invoice line items * Applies the late fee to the invoice line items
* *
* @param Invoice $invoice * @param Invoice $invoice
* @param float $amount The fee amount * @param float $amount The fee amount
* @param float $percent The fee percentage amount * @param float $percent The fee percentage amount
* *
* @return Invoice * @return Invoice
*/ */
private function setLateFee($invoice, $amount, $percent) :Invoice private function setLateFee($invoice, $amount, $percent) :Invoice
{ {
$temp_invoice_balance = $invoice->balance; $temp_invoice_balance = $invoice->balance;
if ($amount <= 0 && $percent <= 0) if ($amount <= 0 && $percent <= 0) {
return $invoice; return $invoice;
}
$fee = $amount; $fee = $amount;
if ($invoice->partial > 0) if ($invoice->partial > 0) {
$fee += round($invoice->partial * $percent / 100, 2); $fee += round($invoice->partial * $percent / 100, 2);
else } else {
$fee += round($invoice->balance * $percent / 100, 2); $fee += round($invoice->balance * $percent / 100, 2);
}
$invoice_item = new InvoiceItem; $invoice_item = new InvoiceItem;
$invoice_item->type_id = '5'; $invoice_item->type_id = '5';
@ -321,7 +308,5 @@ class SendReminders implements ShouldQueue
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance); $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance);
return $invoice; return $invoice;
} }
}
}

View File

@ -73,37 +73,29 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
if ($this->company->is_disabled) {
if($this->company->is_disabled)
return true; return true;
}
if ($this->contact->email) { if ($this->contact->email) {
MultiDB::setDb($this->company->db);
MultiDB::setDb($this->company->db);
//if we need to set an email driver do it now //if we need to set an email driver do it now
$this->setMailDriver(); $this->setMailDriver();
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build(); $email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
try{ try {
$mail = Mail::to($this->contact->email, $this->contact->present()->name()); $mail = Mail::to($this->contact->email, $this->contact->present()->name());
$mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client)); $mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
} catch (\Exception $e) {
}catch(\Exception $e) {
info("mailing failed with message " . $e->getMessage()); info("mailing failed with message " . $e->getMessage());
event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars())); event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars()));
$this->failed($e); $this->failed($e);
return $this->logMailError($e->getMessage(), $this->payment->client); return $this->logMailError($e->getMessage(), $this->payment->client);
} }
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars())); event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars()));
} }
} }
} }

View File

@ -60,9 +60,7 @@ class UpdateOrCreateProduct implements ShouldQueue
//only update / create products - not tasks or gateway fees //only update / create products - not tasks or gateway fees
$updateable_products = collect($this->products)->filter(function ($item) { $updateable_products = collect($this->products)->filter(function ($item) {
return $item->type_id == 1; return $item->type_id == 1;
}); });
foreach ($updateable_products as $item) { foreach ($updateable_products as $item) {
@ -98,6 +96,6 @@ class UpdateOrCreateProduct implements ShouldQueue
public function failed($exception = null) public function failed($exception = null)
{ {
info("update create failed with = "); info("update create failed with = ");
info(print_r($exception->getMessage(),1)); info(print_r($exception->getMessage(), 1));
} }
} }

View File

@ -67,19 +67,18 @@ class SendRecurring implements ShouldQueue
->createInvitations() ->createInvitations()
->save(); ->save();
info("Invoice {$invoice->number} created"); info("Invoice {$invoice->number} created");
$invoice->invitations->each(function ($invitation) use ($invoice) { $invoice->invitations->each(function ($invitation) use ($invoice) {
if ($invitation->contact && strlen($invitation->contact->email) >=1) {
if($invitation->contact && strlen($invitation->contact->email) >=1){
EmailEntity::dispatch($invitation, $invoice->company); EmailEntity::dispatch($invitation, $invoice->company);
info("Firing email for invoice {$invoice->number}"); info("Firing email for invoice {$invoice->number}");
} }
}); });
if($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $this->recurring_invoice->auto_bill_enabled) if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $this->recurring_invoice->auto_bill_enabled) {
$invoice->service()->autoBill()->save(); $invoice->service()->autoBill()->save();
}
info("updating recurring invoice dates"); info("updating recurring invoice dates");
/* Set next date here to prevent a recurring loop forming */ /* Set next date here to prevent a recurring loop forming */
@ -88,8 +87,9 @@ class SendRecurring implements ShouldQueue
$this->recurring_invoice->last_sent_date = date('Y-m-d'); $this->recurring_invoice->last_sent_date = date('Y-m-d');
/* Set completed if we don't have any more cycles remaining*/ /* Set completed if we don't have any more cycles remaining*/
if ($this->recurring_invoice->remaining_cycles == 0) if ($this->recurring_invoice->remaining_cycles == 0) {
$this->recurring_invoice->setCompleted(); $this->recurring_invoice->setCompleted();
}
info("next send date = " . $this->recurring_invoice->next_send_date); info("next send date = " . $this->recurring_invoice->next_send_date);
info("remaining cycles = " . $this->recurring_invoice->remaining_cycles); info("remaining cycles = " . $this->recurring_invoice->remaining_cycles);
@ -100,7 +100,6 @@ class SendRecurring implements ShouldQueue
//this is duplicated!! //this is duplicated!!
// if ($invoice->invitations->count() > 0) // if ($invoice->invitations->count() > 0)
// event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); // event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
} }
public function failed($exception = null) public function failed($exception = null)
@ -116,5 +115,4 @@ class SendRecurring implements ShouldQueue
info(print_r($exception->getMessage(), 1)); info(print_r($exception->getMessage(), 1));
} }
} }

View File

@ -54,8 +54,9 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
public function handle() public function handle()
{ {
if($this->company->is_disabled) if ($this->company->is_disabled) {
return true; return true;
}
//Set DB //Set DB
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
@ -74,19 +75,15 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
//Send email via a Mailable class //Send email via a Mailable class
// //
try { try {
Mail::to($this->old_email) Mail::to($this->old_email)
->send(new UserNotificationMailer($mail_obj)); ->send(new UserNotificationMailer($mail_obj));
Mail::to($this->new_email) Mail::to($this->new_email)
->send(new UserNotificationMailer($mail_obj)); ->send(new UserNotificationMailer($mail_obj));
} } catch (\Exception $e) {
catch (\Exception $e) {
$this->failed($e); $this->failed($e);
$this->logMailError($e->getMessage(), $this->company->owner()); $this->logMailError($e->getMessage(), $this->company->owner());
} }
} }
private function getData() private function getData()

View File

@ -156,7 +156,7 @@ class Import implements ShouldQueue
// public $backoff = 86430; // public $backoff = 86430;
// public $maxExceptions = 2; // public $maxExceptions = 2;
/** /**
* Create a new job instance. * Create a new job instance.
* *
@ -178,16 +178,15 @@ class Import implements ShouldQueue
* *
* @return bool * @return bool
*/ */
public function handle() public function handle()
{ {
set_time_limit(0); set_time_limit(0);
// $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data"); // $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data");
$array = json_decode(file_get_contents($this->file_path), 1); $array = json_decode(file_get_contents($this->file_path), 1);
$data = $array['data']; $data = $array['data'];
foreach ($this->available_imports as $import) { foreach ($this->available_imports as $import) {
if (! array_key_exists($import, $data)) { if (! array_key_exists($import, $data)) {
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration."); //throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
info("Resource {$import} is not available for migration."); info("Resource {$import} is not available for migration.");
@ -210,7 +209,6 @@ class Import implements ShouldQueue
CompanySizeCheck::dispatch(); CompanySizeCheck::dispatch();
info('Completed🚀🚀🚀🚀🚀 at '.now()); info('Completed🚀🚀🚀🚀🚀 at '.now());
} }
private function setInitialCompanyLedgerBalances() private function setInitialCompanyLedgerBalances()
@ -268,15 +266,12 @@ class Import implements ShouldQueue
$company_repository = new CompanyRepository(); $company_repository = new CompanyRepository();
$company_repository->save($data, $this->company); $company_repository->save($data, $this->company);
if(isset($data['settings']->company_logo) && strlen($data['settings']->company_logo) > 0) { if (isset($data['settings']->company_logo) && strlen($data['settings']->company_logo) > 0) {
try { try {
$tempImage = tempnam(sys_get_temp_dir(), basename($data['settings']->company_logo)); $tempImage = tempnam(sys_get_temp_dir(), basename($data['settings']->company_logo));
copy($data['settings']->company_logo, $tempImage); copy($data['settings']->company_logo, $tempImage);
$this->uploadLogo($tempImage, $this->company, $this->company); $this->uploadLogo($tempImage, $this->company, $this->company);
} } catch (\Exception $e) {
catch(\Exception $e){
} }
} }
@ -596,7 +591,6 @@ class Import implements ShouldQueue
$invoice_repository = new InvoiceMigrationRepository(); $invoice_repository = new InvoiceMigrationRepository();
foreach ($data as $key => $resource) { foreach ($data as $key => $resource) {
$modified = $resource; $modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
@ -621,7 +615,6 @@ class Import implements ShouldQueue
'old' => $resource['id'], 'old' => $resource['id'],
'new' => $invoice->id, 'new' => $invoice->id,
]; ];
} }
RecurringInvoice::reguard(); RecurringInvoice::reguard();
@ -629,7 +622,6 @@ class Import implements ShouldQueue
/*Improve memory handling by setting everything to null when we have finished*/ /*Improve memory handling by setting everything to null when we have finished*/
$data = null; $data = null;
$invoice_repository = null; $invoice_repository = null;
} }
private function processInvoices(array $data): void private function processInvoices(array $data): void
@ -785,7 +777,6 @@ class Import implements ShouldQueue
private function processPayments(array $data): void private function processPayments(array $data): void
{ {
Payment::reguard(); Payment::reguard();
$rules = [ $rules = [
@ -818,14 +809,12 @@ class Import implements ShouldQueue
if (isset($modified['invoices'])) { if (isset($modified['invoices'])) {
foreach ($modified['invoices'] as $key => $invoice) { foreach ($modified['invoices'] as $key => $invoice) {
if ($this->tryTransformingId('invoices', $invoice['invoice_id'])) {
if($this->tryTransformingId('invoices', $invoice['invoice_id']))
$modified['invoices'][$key]['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']); $modified['invoices'][$key]['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
else{ } else {
$modified['credits'][$key]['credit_id'] = $this->transformId('credits', $invoice['invoice_id']); $modified['credits'][$key]['credit_id'] = $this->transformId('credits', $invoice['invoice_id']);
$modified['credits'][$key]['amount'] = $modified['invoices'][$key]['amount']; $modified['credits'][$key]['amount'] = $modified['invoices'][$key]['amount'];
} }
} }
} }
@ -886,12 +875,12 @@ class Import implements ShouldQueue
$payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED; $payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
$payment->save(); $payment->save();
return $payment; return $payment;
break; break;
case 6: case 6:
$payment->status_id = Payment::STATUS_REFUNDED; $payment->status_id = Payment::STATUS_REFUNDED;
$payment->save(); $payment->save();
return $payment; return $payment;
break; break;
default: default:
return $payment; return $payment;
@ -901,11 +890,10 @@ class Import implements ShouldQueue
private function processDocuments(array $data): void private function processDocuments(array $data): void
{ {
// Document::unguard(); // Document::unguard();
/* No validators since data provided by database is already valid. */ /* No validators since data provided by database is already valid. */
foreach($data as $resource) foreach ($data as $resource) {
{
$modified = $resource; $modified = $resource;
if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && ! array_key_exists('invoices', $this->ids)) { if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && ! array_key_exists('invoices', $this->ids)) {
@ -927,7 +915,6 @@ class Import implements ShouldQueue
} }
$this->saveDocument(file_get_contents($resource['url']), $entity, $is_public = true); $this->saveDocument(file_get_contents($resource['url']), $entity, $is_public = true);
} }
// foreach ($data as $resource) { // foreach ($data as $resource) {
@ -1079,7 +1066,8 @@ class Import implements ShouldQueue
} }
private function processTaskStatuses(array $data) :void private function processTaskStatuses(array $data) :void
{info('in task statuses'); {
info('in task statuses');
TaskStatus::unguard(); TaskStatus::unguard();
foreach ($data as $resource) { foreach ($data as $resource) {
@ -1149,17 +1137,21 @@ class Import implements ShouldQueue
$modified['company_id'] = $this->company->id; $modified['company_id'] = $this->company->id;
$modified['user_id'] = $this->processUserId($resource); $modified['user_id'] = $this->processUserId($resource);
if(isset($modified['client_id'])) if (isset($modified['client_id'])) {
$modified['client_id'] = $this->transformId('clients', $resource['client_id']); $modified['client_id'] = $this->transformId('clients', $resource['client_id']);
}
if(isset($modified['invoice_id'])) if (isset($modified['invoice_id'])) {
$modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']); $modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']);
}
if(isset($modified['project_id'])) if (isset($modified['project_id'])) {
$modified['project_id'] = $this->transformId('projects', $resource['project_id']); $modified['project_id'] = $this->transformId('projects', $resource['project_id']);
}
if(isset($modified['status_id'])) if (isset($modified['status_id'])) {
$modified['status_id'] = $this->transformId('task_statuses', $resource['status_id']); $modified['status_id'] = $this->transformId('task_statuses', $resource['status_id']);
}
$task = Task::Create($modified); $task = Task::Create($modified);
@ -1190,8 +1182,9 @@ class Import implements ShouldQueue
$modified['company_id'] = $this->company->id; $modified['company_id'] = $this->company->id;
$modified['user_id'] = $this->processUserId($resource); $modified['user_id'] = $this->processUserId($resource);
if(isset($modified['client_id'])) if (isset($modified['client_id'])) {
$modified['client_id'] = $this->transformId('clients', $resource['client_id']); $modified['client_id'] = $this->transformId('clients', $resource['client_id']);
}
$project = Project::Create($modified); $project = Project::Create($modified);
@ -1201,7 +1194,6 @@ class Import implements ShouldQueue
'old' => $resource['id'], 'old' => $resource['id'],
'new' => $project->id, 'new' => $project->id,
]; ];
} }
Project::reguard(); Project::reguard();
@ -1211,7 +1203,6 @@ class Import implements ShouldQueue
private function processExpenses(array $data) :void private function processExpenses(array $data) :void
{ {
Expense::unguard(); Expense::unguard();
foreach ($data as $resource) { foreach ($data as $resource) {
@ -1222,20 +1213,25 @@ class Import implements ShouldQueue
$modified['company_id'] = $this->company->id; $modified['company_id'] = $this->company->id;
$modified['user_id'] = $this->processUserId($resource); $modified['user_id'] = $this->processUserId($resource);
if(isset($resource['client_id'])) if (isset($resource['client_id'])) {
$modified['client_id'] = $this->transformId('clients', $resource['client_id']); $modified['client_id'] = $this->transformId('clients', $resource['client_id']);
}
if(isset($resource['category_id'])) if (isset($resource['category_id'])) {
$modified['category_id'] = $this->transformId('expense_categories', $resource['category_id']); $modified['category_id'] = $this->transformId('expense_categories', $resource['category_id']);
}
if(isset($resource['invoice_id'])) if (isset($resource['invoice_id'])) {
$modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']); $modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']);
}
if(isset($resource['project_id'])) if (isset($resource['project_id'])) {
$modified['project_id'] = $this->transformId('projects', $resource['project_id']); $modified['project_id'] = $this->transformId('projects', $resource['project_id']);
}
if(isset($resource['vendor_id'])) if (isset($resource['vendor_id'])) {
$modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']); $modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']);
}
$expense = Expense::Create($modified); $expense = Expense::Create($modified);
@ -1252,7 +1248,6 @@ class Import implements ShouldQueue
Expense::reguard(); Expense::reguard();
$data = null; $data = null;
} }
/** /**
* |-------------------------------------------------------------------------- * |--------------------------------------------------------------------------
@ -1289,7 +1284,7 @@ class Import implements ShouldQueue
public function transformId($resource, string $old): int public function transformId($resource, string $old): int
{ {
if (! array_key_exists($resource, $this->ids)) { if (! array_key_exists($resource, $this->ids)) {
info(print_r($resource,1)); info(print_r($resource, 1));
throw new Exception("Resource {$resource} not available."); throw new Exception("Resource {$resource} not available.");
} }
@ -1345,7 +1340,5 @@ class Import implements ShouldQueue
->batch(); ->batch();
info(print_r($exception->getMessage(), 1)); info(print_r($exception->getMessage(), 1));
} }
} }

View File

@ -55,37 +55,27 @@ class ReminderJob implements ShouldQueue
$this->processReminders($db); $this->processReminders($db);
} }
} }
} }
private function processReminders($db = null) private function processReminders($db = null)
{ {
Invoice::where('next_send_date', Carbon::today()->format('Y-m-d'))->with('invitations')->cursor()->each(function ($invoice) { Invoice::where('next_send_date', Carbon::today()->format('Y-m-d'))->with('invitations')->cursor()->each(function ($invoice) {
if ($invoice->isPayable()) { if ($invoice->isPayable()) {
$reminder_template = $invoice->calculateTemplate('invoice');
$reminder_template = $invoice->calculateTemplate('invoice');
$invoice->service()->touchReminder($this->reminder_template)->save(); $invoice->service()->touchReminder($this->reminder_template)->save();
$invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) { $invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
EmailEntity::dispatch($invitation, $invitation->company, $reminder_template); EmailEntity::dispatch($invitation, $invitation->company, $reminder_template);
info("Firing email for invoice {$invoice->number}"); info("Firing email for invoice {$invoice->number}");
}); });
if ($invoice->invitations->count() > 0) if ($invoice->invitations->count() > 0) {
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars()));
}
} else { } else {
$invoice->next_send_date = null; $invoice->next_send_date = null;
$invoice->save(); $invoice->save();
} }
}); });
} }
} }

View File

@ -55,7 +55,6 @@ class SendFailedEmails implements ShouldQueue
private function processEmails() private function processEmails()
{ {
$email_jobs = SystemLog::where('event_id', SystemLog::EVENT_MAIL_RETRY_QUEUE)->get(); $email_jobs = SystemLog::where('event_id', SystemLog::EVENT_MAIL_RETRY_QUEUE)->get();
$email_jobs->each(function ($job) { $email_jobs->each(function ($job) {
@ -64,7 +63,6 @@ class SendFailedEmails implements ShouldQueue
$invitation = $job_meta_array['entity_name']::where('key', $job_meta_array['invitation_key'])->with('contact')->first(); $invitation = $job_meta_array['entity_name']::where('key', $job_meta_array['invitation_key'])->with('contact')->first();
if ($invitation->invoice) { if ($invitation->invoice) {
if ($invitation->contact->send_email && $invitation->contact->email) { if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatch($invitation, $invitation->company, $job_meta_array['reminder_template']); EmailEntity::dispatch($invitation, $invitation->company, $job_meta_array['reminder_template']);
} }

View File

@ -55,7 +55,7 @@ class StartMigration implements ShouldQueue
public $timeout = 0; public $timeout = 0;
// public $maxExceptions = 2; // public $maxExceptions = 2;
//public $backoff = 86430; //public $backoff = 86430;
@ -111,7 +111,6 @@ class StartMigration implements ShouldQueue
//Import::dispatchNow($data['data'], $this->company, $this->user); //Import::dispatchNow($data['data'], $this->company, $this->user);
Import::dispatchNow($file, $this->company, $this->user); Import::dispatchNow($file, $this->company, $this->user);
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) { } catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage())); Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
if (app()->environment() !== 'production') { if (app()->environment() !== 'production') {
@ -126,6 +125,6 @@ class StartMigration implements ShouldQueue
public function failed($exception = null) public function failed($exception = null)
{ {
info(print_r($exception->getMessage(),1)); info(print_r($exception->getMessage(), 1));
} }
} }

View File

@ -63,21 +63,22 @@ class WebhookHandler implements ShouldQueue
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
if (! $this->company || $this->company->is_disabled) if (! $this->company || $this->company->is_disabled) {
return true; return true;
}
$subscriptions = Webhook::where('company_id', $this->company->id) $subscriptions = Webhook::where('company_id', $this->company->id)
->where('event_id', $this->event_id) ->where('event_id', $this->event_id)
->get(); ->get();
if (! $subscriptions || $subscriptions->count() == 0) if (! $subscriptions || $subscriptions->count() == 0) {
return; return;
}
$subscriptions->each(function ($subscription) { $subscriptions->each(function ($subscription) {
$this->process($subscription); $this->process($subscription);
}); });
} }
private function process($subscription) private function process($subscription)

View File

@ -62,7 +62,6 @@ class InvoiceEmailedNotification implements ShouldQueue
EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company); EntitySentMailer::dispatch($event->invitation, 'invoice', $user, $event->invitation->company);
$first_notification_sent = false; $first_notification_sent = false;
} }
$notification->method = $methods; $notification->method = $methods;

View File

@ -57,9 +57,8 @@ class InvoicePaidActivity implements ShouldQueue
try { try {
$event->invoice->service()->touchPdf(); $event->invoice->service()->touchPdf();
} } catch (\Exception $e) {
catch(\Exception $e){ info(print_r($e->getMessage(), 1));
info(print_r($e->getMessage(),1));
} }
} }
} }

View File

@ -50,8 +50,6 @@ class PaymentEmailFailureActivity implements ShouldQueue
$payment = $event->payment; $payment = $event->payment;
info("i failed emailing {$payment->number}"); info("i failed emailing {$payment->number}");
// info(print_r($event->errors,1)); // info(print_r($event->errors,1));
} }
} }

View File

@ -52,4 +52,3 @@ class PaymentEmailedActivity implements ShouldQueue
info("i succeeded in emailing payment {$payment->number}"); info("i succeeded in emailing payment {$payment->number}");
} }
} }

View File

@ -55,7 +55,6 @@ class PaymentNotification implements ShouldQueue
/*User notifications*/ /*User notifications*/
foreach ($payment->company->company_users as $company_user) { foreach ($payment->company->company_users as $company_user) {
$user = $company_user->user; $user = $company_user->user;
$methods = $this->findUserEntityNotificationType($payment, $company_user, ['all_notifications']); $methods = $this->findUserEntityNotificationType($payment, $company_user, ['all_notifications']);
@ -64,7 +63,6 @@ class PaymentNotification implements ShouldQueue
unset($methods[$key]); unset($methods[$key]);
EntityPaidMailer::dispatch($payment, $payment->company, $user); EntityPaidMailer::dispatch($payment, $payment->company, $user);
} }
$notification = new NewPaymentNotification($payment, $payment->company); $notification = new NewPaymentNotification($payment, $payment->company);

View File

@ -51,11 +51,8 @@ class SendVerificationNotification implements ShouldQueue
$event->user->notify(new VerifyUser($event->user, $event->company)); $event->user->notify(new VerifyUser($event->user, $event->company));
Ninja::registerNinjaUser($event->user); Ninja::registerNinjaUser($event->user);
} catch (Exception $e) { } catch (Exception $e) {
info("I couldn't send the email " . $e->getMessage()); info("I couldn't send the email " . $e->getMessage());
} }
} }
} }

View File

@ -40,6 +40,5 @@ class DownloadInvoices extends Mailable
'logo' => $this->company->present()->logo, 'logo' => $this->company->present()->logo,
] ]
); );
} }
} }

View File

@ -13,129 +13,132 @@ namespace App\Mail\Engine;
class BaseEmailEngine implements EngineInterface class BaseEmailEngine implements EngineInterface
{ {
public $footer; public $footer;
public $variables; public $variables;
public $contact; public $contact;
public $subject; public $subject;
public $body; public $body;
public $template_style; public $template_style;
public $attachments; public $attachments;
public $link; public $link;
public $text; public $text;
public function setFooter($footer) public function setFooter($footer)
{ {
$this->footer = $footer; $this->footer = $footer;
return $this; return $this;
} }
public function setVariables($variables) public function setVariables($variables)
{ {
$this->variables = $variables; $this->variables = $variables;
return $this; return $this;
} }
public function setContact($contact) public function setContact($contact)
{ {
$this->contact = $contact; $this->contact = $contact;
return $this; return $this;
} }
public function setSubject($subject) public function setSubject($subject)
{ {
if (! empty($this->variables)) if (! empty($this->variables)) {
$subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject); $subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject);
}
$this->subject = $subject; $this->subject = $subject;
return $this; return $this;
} }
public function setBody($body) public function setBody($body)
{ {
if (! empty($this->variables)) if (! empty($this->variables)) {
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body); $body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
}
$this->body = $body; $this->body = $body;
return $this; return $this;
} }
public function setTemplate($template_style) public function setTemplate($template_style)
{ {
$this->template_style = $template_style; $this->template_style = $template_style;
return $this; return $this;
} }
public function setAttachments($attachments) public function setAttachments($attachments)
{ {
$this->attachments = $attachments; $this->attachments = $attachments;
return $this; return $this;
} }
public function setViewLink($link) public function setViewLink($link)
{ {
$this->link = $link; $this->link = $link;
return $this; return $this;
} }
public function setViewText($text) public function setViewText($text)
{ {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
public function getSubject() public function getSubject()
{ {
return $this->subject; return $this->subject;
} }
public function getBody() public function getBody()
{ {
return $this->body; return $this->body;
} }
public function getAttachments() public function getAttachments()
{ {
return $this->attachments; return $this->attachments;
} }
public function getFooter() public function getFooter()
{ {
return $this->footer; return $this->footer;
} }
public function getTemplate() public function getTemplate()
{ {
return $this->template_style; return $this->template_style;
} }
public function getViewLink() public function getViewLink()
{ {
return $this->link; return $this->link;
} }
public function getViewText() public function getViewText()
{ {
return $this->text; return $this->text;
} }
public function build(){} public function build()
{
} }
}

View File

@ -14,15 +14,15 @@ namespace App\Mail\Engine;
use App\Utils\HtmlEngine; use App\Utils\HtmlEngine;
use App\Utils\Number; use App\Utils\Number;
class CreditEmailEngine extends BaseEmailEngine class CreditEmailEngine extends BaseEmailEngine
{ {
public $invitation; public $invitation;
public $client; public $client;
public $credit; public $credit;
public $contact; public $contact;
public $reminder_template; public $reminder_template;
@ -30,7 +30,7 @@ class CreditEmailEngine extends BaseEmailEngine
public function __construct($invitation, $reminder_template, $template_data) public function __construct($invitation, $reminder_template, $template_data)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->reminder_template = $reminder_template; $this->reminder_template = $reminder_template;
$this->client = $invitation->contact->client; $this->client = $invitation->contact->client;
$this->credit = $invitation->credit; $this->credit = $invitation->credit;
@ -40,11 +40,11 @@ class CreditEmailEngine extends BaseEmailEngine
public function build() public function build()
{ {
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0)
$body_template = $this->template_data['body']; $body_template = $this->template_data['body'];
else } else {
$body_template = $this->client->getSetting('email_template_'.$this->reminder_template); $body_template = $this->client->getSetting('email_template_'.$this->reminder_template);
}
/* Use default translations if a custom message has not been set*/ /* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) { if (iconv_strlen($body_template) == 0) {
@ -60,13 +60,13 @@ class CreditEmailEngine extends BaseEmailEngine
); );
} }
if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject']; $subject_template = $this->template_data['subject'];
else } else {
$subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
}
if (iconv_strlen($subject_template) == 0) { if (iconv_strlen($subject_template) == 0) {
$subject_template = trans( $subject_template = trans(
'texts.credit_subject', 'texts.credit_subject',
[ [
@ -76,7 +76,6 @@ class CreditEmailEngine extends BaseEmailEngine
null, null,
$this->client->locale() $this->client->locale()
); );
} }
$this->setTemplate($this->client->getSetting('email_style')) $this->setTemplate($this->client->getSetting('email_style'))
@ -93,8 +92,5 @@ class CreditEmailEngine extends BaseEmailEngine
} }
return $this; return $this;
} }
} }

View File

@ -13,7 +13,6 @@ namespace App\Mail\Engine;
interface EngineInterface interface EngineInterface
{ {
public function setFooter($footer); public function setFooter($footer);
public function setVariables($variables); public function setVariables($variables);
@ -47,5 +46,4 @@ interface EngineInterface
public function getViewText(); public function getViewText();
public function build(); public function build();
}
}

View File

@ -15,15 +15,15 @@ use App\DataMapper\EmailTemplateDefaults;
use App\Utils\HtmlEngine; use App\Utils\HtmlEngine;
use App\Utils\Number; use App\Utils\Number;
class InvoiceEmailEngine extends BaseEmailEngine class InvoiceEmailEngine extends BaseEmailEngine
{ {
public $invitation; public $invitation;
public $client; public $client;
public $invoice; public $invoice;
public $contact; public $contact;
public $reminder_template; public $reminder_template;
@ -31,7 +31,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
public function __construct($invitation, $reminder_template, $template_data) public function __construct($invitation, $reminder_template, $template_data)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->reminder_template = $reminder_template; $this->reminder_template = $reminder_template;
$this->client = $invitation->contact->client; $this->client = $invitation->contact->client;
$this->invoice = $invitation->invoice; $this->invoice = $invitation->invoice;
@ -41,12 +41,11 @@ class InvoiceEmailEngine extends BaseEmailEngine
public function build() public function build()
{ {
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0)
$body_template = $this->template_data['body']; $body_template = $this->template_data['body'];
elseif(strlen($this->client->getSetting('email_template_'.$this->reminder_template)) > 0) } elseif (strlen($this->client->getSetting('email_template_'.$this->reminder_template)) > 0) {
$body_template = $this->client->getSetting('email_template_'.$this->reminder_template); $body_template = $this->client->getSetting('email_template_'.$this->reminder_template);
else{ } else {
$body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_'.$this->reminder_template, $this->client->locale()); $body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_'.$this->reminder_template, $this->client->locale());
} }
@ -64,22 +63,19 @@ class InvoiceEmailEngine extends BaseEmailEngine
); );
} }
if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0){ if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject']; $subject_template = $this->template_data['subject'];
info("subject = template data"); info("subject = template data");
} } elseif (strlen($this->client->getSetting('email_subject_'.$this->reminder_template)) > 0) {
elseif(strlen($this->client->getSetting('email_subject_'.$this->reminder_template)) > 0){
$subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
info("subject = settings var"); info("subject = settings var");
} } else {
else{
info("subject = default template " . 'email_subject_'.$this->reminder_template); info("subject = default template " . 'email_subject_'.$this->reminder_template);
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_'.$this->reminder_template, $this->client->locale()); $subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_'.$this->reminder_template, $this->client->locale());
// $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); // $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
} }
if (iconv_strlen($subject_template) == 0) { if (iconv_strlen($subject_template) == 0) {
$subject_template = trans( $subject_template = trans(
'texts.invoice_subject', 'texts.invoice_subject',
[ [
@ -89,7 +85,6 @@ class InvoiceEmailEngine extends BaseEmailEngine
null, null,
$this->client->locale() $this->client->locale()
); );
} }
$this->setTemplate($this->client->getSetting('email_style')) $this->setTemplate($this->client->getSetting('email_style'))
@ -106,8 +101,5 @@ class InvoiceEmailEngine extends BaseEmailEngine
} }
return $this; return $this;
} }
} }

View File

@ -16,13 +16,13 @@ use App\Utils\HtmlEngine;
use App\Utils\Number; use App\Utils\Number;
use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesDates;
class PaymentEmailEngine extends BaseEmailEngine class PaymentEmailEngine extends BaseEmailEngine
{ {
use MakesDates; use MakesDates;
public $client; public $client;
public $payment; public $payment;
public $template_data; public $template_data;
@ -44,12 +44,11 @@ class PaymentEmailEngine extends BaseEmailEngine
public function build() public function build()
{ {
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0)
$body_template = $this->template_data['body']; $body_template = $this->template_data['body'];
elseif(strlen($this->client->getSetting('email_template_payment')) > 0) } elseif (strlen($this->client->getSetting('email_template_payment')) > 0) {
$body_template = $this->client->getSetting('email_template_payment'); $body_template = $this->client->getSetting('email_template_payment');
else{ } else {
$body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_payment', $this->client->locale()); $body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_payment', $this->client->locale());
} }
@ -63,13 +62,11 @@ class PaymentEmailEngine extends BaseEmailEngine
); );
} }
if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0){ if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject']; $subject_template = $this->template_data['subject'];
} } elseif (strlen($this->client->getSetting('email_subject_payment')) > 0) {
elseif(strlen($this->client->getSetting('email_subject_payment')) > 0){
$subject_template = $this->client->getSetting('email_subject_payment'); $subject_template = $this->client->getSetting('email_subject_payment');
} } else {
else{
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_payment', $this->client->locale()); $subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_payment', $this->client->locale());
} }
@ -92,7 +89,6 @@ class PaymentEmailEngine extends BaseEmailEngine
->setViewText(''); ->setViewText('');
return $this; return $this;
} }
@ -115,7 +111,7 @@ class PaymentEmailEngine extends BaseEmailEngine
$data['$payment2'] = ['value' => $this->formatCustomFieldValue('payment2', $this->payment->custom_value2) ?: '&nbsp;', 'label' => $this->makeCustomField('payment2')]; $data['$payment2'] = ['value' => $this->formatCustomFieldValue('payment2', $this->payment->custom_value2) ?: '&nbsp;', 'label' => $this->makeCustomField('payment2')];
$data['$payment3'] = ['value' => $this->formatCustomFieldValue('payment3', $this->payment->custom_value3) ?: '&nbsp;', 'label' => $this->makeCustomField('payment3')]; $data['$payment3'] = ['value' => $this->formatCustomFieldValue('payment3', $this->payment->custom_value3) ?: '&nbsp;', 'label' => $this->makeCustomField('payment3')];
$data['$payment4'] = ['value' => $this->formatCustomFieldValue('payment4', $this->payment->custom_value4) ?: '&nbsp;', 'label' => $this->makeCustomField('payment4')]; $data['$payment4'] = ['value' => $this->formatCustomFieldValue('payment4', $this->payment->custom_value4) ?: '&nbsp;', 'label' => $this->makeCustomField('payment4')];
// $data['$type'] = ['value' => $this->payment->type->name ?: '', 'label' => ctrans('texts.payment_type')]; // $data['$type'] = ['value' => $this->payment->type->name ?: '', 'label' => ctrans('texts.payment_type')];
$data['$client1'] = ['value' => $this->formatCustomFieldValue('client1', $this->client->custom_value1) ?: '&nbsp;', 'label' => $this->makeCustomField('client1')]; $data['$client1'] = ['value' => $this->formatCustomFieldValue('client1', $this->client->custom_value1) ?: '&nbsp;', 'label' => $this->makeCustomField('client1')];
$data['$client2'] = ['value' => $this->formatCustomFieldValue('client2', $this->client->custom_value2) ?: '&nbsp;', 'label' => $this->makeCustomField('client2')]; $data['$client2'] = ['value' => $this->formatCustomFieldValue('client2', $this->client->custom_value2) ?: '&nbsp;', 'label' => $this->makeCustomField('client2')];
@ -200,8 +196,7 @@ class PaymentEmailEngine extends BaseEmailEngine
{ {
$invoice_list = ''; $invoice_list = '';
foreach($this->payment->invoices as $invoice) foreach ($this->payment->invoices as $invoice) {
{
$invoice_list .= ctrans('texts.invoice_number_short') . " {$invoice->number} - " . Number::formatMoney($invoice->pivot->amount, $this->client) . "<br>"; $invoice_list .= ctrans('texts.invoice_number_short') . " {$invoice->number} - " . Number::formatMoney($invoice->pivot->amount, $this->client) . "<br>";
} }
@ -232,8 +227,9 @@ class PaymentEmailEngine extends BaseEmailEngine
$custom_field = $custom_fields->{$field}; $custom_field = $custom_fields->{$field};
$custom_field_parts = explode('|', $custom_field); $custom_field_parts = explode('|', $custom_field);
if(count($custom_field_parts) >= 2) if (count($custom_field_parts) >= 2) {
$custom_field = $custom_field_parts[1]; $custom_field = $custom_field_parts[1];
}
} }
switch ($custom_field) { switch ($custom_field) {
@ -260,4 +256,3 @@ class PaymentEmailEngine extends BaseEmailEngine
return $data; return $data;
} }
} }

View File

@ -14,23 +14,23 @@ namespace App\Mail\Engine;
use App\Utils\HtmlEngine; use App\Utils\HtmlEngine;
use App\Utils\Number; use App\Utils\Number;
class QuoteEmailEngine extends BaseEmailEngine class QuoteEmailEngine extends BaseEmailEngine
{ {
public $invitation; public $invitation;
public $client; public $client;
public $quote; public $quote;
public $contact; public $contact;
public $reminder_template; public $reminder_template;
public $template_data; public $template_data;
public function __construct($invitation, $reminder_template, $template_data) public function __construct($invitation, $reminder_template, $template_data)
{ {
$this->invitation = $invitation; $this->invitation = $invitation;
$this->reminder_template = $reminder_template; $this->reminder_template = $reminder_template;
$this->client = $invitation->contact->client; $this->client = $invitation->contact->client;
$this->quote = $invitation->quote; $this->quote = $invitation->quote;
@ -40,11 +40,11 @@ class QuoteEmailEngine extends BaseEmailEngine
public function build() public function build()
{ {
if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) {
if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0)
$body_template = $this->template_data['body']; $body_template = $this->template_data['body'];
else } else {
$body_template = $this->client->getSetting('email_template_'.$this->reminder_template); $body_template = $this->client->getSetting('email_template_'.$this->reminder_template);
}
/* Use default translations if a custom message has not been set*/ /* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) { if (iconv_strlen($body_template) == 0) {
@ -60,13 +60,13 @@ class QuoteEmailEngine extends BaseEmailEngine
); );
} }
if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject']; $subject_template = $this->template_data['subject'];
else } else {
$subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
}
if (iconv_strlen($subject_template) == 0) { if (iconv_strlen($subject_template) == 0) {
$subject_template = trans( $subject_template = trans(
'texts.quote_subject', 'texts.quote_subject',
[ [
@ -76,7 +76,6 @@ class QuoteEmailEngine extends BaseEmailEngine
null, null,
$this->client->locale() $this->client->locale()
); );
} }
$this->setTemplate($this->client->getSetting('email_style')) $this->setTemplate($this->client->getSetting('email_style'))
@ -93,8 +92,5 @@ class QuoteEmailEngine extends BaseEmailEngine
} }
return $this; return $this;
} }
} }

View File

@ -47,7 +47,6 @@ class TemplateEmail extends Mailable
*/ */
public function build() public function build()
{ {
$template_name = 'email.template.'.$this->build_email->getTemplate(); $template_name = 'email.template.'.$this->build_email->getTemplate();
$settings = $this->client->getMergedSettings(); $settings = $this->client->getMergedSettings();
@ -56,13 +55,15 @@ class TemplateEmail extends Mailable
$this->from($this->user->email, $this->user->present()->name()); $this->from($this->user->email, $this->user->present()->name());
if(strlen($settings->reply_to_email) > 1) if (strlen($settings->reply_to_email) > 1) {
$this->replyTo($settings->reply_to_email, $settings->reply_to_email); $this->replyTo($settings->reply_to_email, $settings->reply_to_email);
}
if(strlen($settings->bcc_email) > 1) if (strlen($settings->bcc_email) > 1) {
$this->bcc($settings->bcc_email, $settings->bcc_email); $this->bcc($settings->bcc_email, $settings->bcc_email);
}
$this->subject($this->build_email->getSubject()) $this->subject($this->build_email->getSubject())
->text('email.template.plain', [ ->text('email.template.plain', [
'body' => $this->build_email->getBody(), 'body' => $this->build_email->getBody(),
'footer' => $this->build_email->getFooter(), 'footer' => $this->build_email->getFooter(),

View File

@ -157,7 +157,7 @@ class Activity extends StaticModel
return $this->belongsTo(Company::class); return $this->belongsTo(Company::class);
} }
public function resolveRouteBinding($value, $field = NULL) public function resolveRouteBinding($value, $field = null)
{ {
if (is_numeric($value)) { if (is_numeric($value)) {
throw new ModelNotFoundException("Record with value {$value} not found"); throw new ModelNotFoundException("Record with value {$value} not found");

View File

@ -166,7 +166,7 @@ class BaseModel extends Model
* @param null $field * @param null $field
* @return Model|null * @return Model|null
*/ */
public function resolveRouteBinding($value, $field = NULL) public function resolveRouteBinding($value, $field = null)
{ {
if (is_numeric($value)) { if (is_numeric($value)) {
throw new ModelNotFoundException("Record with value {$value} not found"); throw new ModelNotFoundException("Record with value {$value} not found");

View File

@ -243,7 +243,6 @@ class Client extends BaseModel implements HasLocalePreference
return $date_formats->filter(function ($item) { return $date_formats->filter(function ($item) {
return $item->id == $this->getSetting('date_format_id'); return $item->id == $this->getSetting('date_format_id');
})->first()->format; })->first()->format;
} }
public function currency() public function currency()
@ -384,7 +383,7 @@ class Client extends BaseModel implements HasLocalePreference
return array_search($model->id, $transformed_ids); return array_search($model->id, $transformed_ids);
}); });
} else { } else {
$gateways = $this->company->company_gateways; $gateways = $this->company->company_gateways;
} }
foreach ($gateways as $gateway) { foreach ($gateways as $gateway) {
@ -472,7 +471,6 @@ class Client extends BaseModel implements HasLocalePreference
//we need to check for "0" here as we disable a payment gateway for a client with the number "0" //we need to check for "0" here as we disable a payment gateway for a client with the number "0"
if ($company_gateways || $company_gateways == '0') { if ($company_gateways || $company_gateways == '0') {
$transformed_ids = $this->transformKeys(explode(',', $company_gateways)); $transformed_ids = $this->transformKeys(explode(',', $company_gateways));
$gateways = $this->company $gateways = $this->company
->company_gateways ->company_gateways
@ -488,21 +486,13 @@ class Client extends BaseModel implements HasLocalePreference
foreach ($gateways as $gateway) { foreach ($gateways as $gateway) {
foreach ($gateway->driver($this)->gatewayTypes() as $type) { foreach ($gateway->driver($this)->gatewayTypes() as $type) {
if (isset($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) {
if(isset($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $amount)) {
{
if($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $amount))
$payment_methods[] = [$gateway->id => $type]; $payment_methods[] = [$gateway->id => $type];
}
} } else {
else
{
$payment_methods[] = [$gateway->id => $type]; $payment_methods[] = [$gateway->id => $type];
} }
} }
} }
@ -527,8 +517,8 @@ class Client extends BaseModel implements HasLocalePreference
} }
} }
if(($this->getSetting('use_credits_payment') == 'option' || $this->getSetting('use_credits_payment') == 'always') && $this->service()->getCreditBalance() > 0) { if (($this->getSetting('use_credits_payment') == 'option' || $this->getSetting('use_credits_payment') == 'always') && $this->service()->getCreditBalance() > 0) {
$payment_urls[] = [ $payment_urls[] = [
'label' => ctrans('texts.apply_credit'), 'label' => ctrans('texts.apply_credit'),
'company_gateway_id' => CompanyGateway::GATEWAY_CREDIT, 'company_gateway_id' => CompanyGateway::GATEWAY_CREDIT,
'gateway_type_id' => GatewayType::CREDIT, 'gateway_type_id' => GatewayType::CREDIT,
@ -540,21 +530,21 @@ class Client extends BaseModel implements HasLocalePreference
public function validGatewayForAmount($fees_and_limits_for_payment_type, $amount) :bool public function validGatewayForAmount($fees_and_limits_for_payment_type, $amount) :bool
{ {
if (isset($fees_and_limits_for_payment_type)) { if (isset($fees_and_limits_for_payment_type)) {
$fees_and_limits = $fees_and_limits_for_payment_type; $fees_and_limits = $fees_and_limits_for_payment_type;
} else { } else {
return true;
}
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $fees_and_limits->min_limit != -1 && $amount < $fees_and_limits->min_limit) {
return false;
}
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $fees_and_limits->max_limit != -1 && $amount > $fees_and_limits->max_limit) {
return false;
}
return true; return true;
}
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $fees_and_limits->min_limit != -1 && $amount < $fees_and_limits->min_limit) {
return false;
}
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $fees_and_limits->max_limit != -1 && $amount > $fees_and_limits->max_limit) {
return false;
}
return true;
} }
public function preferredLocale() public function preferredLocale()

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