mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #5374 from turbo124/v5-develop
Suppress optimize on shared hosting
This commit is contained in:
commit
fbec084e9d
@ -236,6 +236,7 @@ class CompanySettings extends BaseSettings
|
||||
public $id_number = ''; //@implemented
|
||||
|
||||
public $page_size = 'A4'; //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
|
||||
public $page_layout = 'portrait';
|
||||
public $font_size = 7; //@implemented
|
||||
public $primary_font = 'Roboto';
|
||||
public $secondary_font = 'Roboto';
|
||||
@ -327,6 +328,7 @@ class CompanySettings extends BaseSettings
|
||||
'signature_on_pdf' => 'bool',
|
||||
'quote_footer' => 'string',
|
||||
'page_size' => 'string',
|
||||
'page_layout' => 'string',
|
||||
'font_size' => 'int',
|
||||
'primary_font' => 'string',
|
||||
'secondary_font' => 'string',
|
||||
|
@ -147,7 +147,9 @@ class SetupController extends Controller
|
||||
DB::purge('db-ninja-01');
|
||||
|
||||
/* Run migrations */
|
||||
Artisan::call('optimize');
|
||||
if(!config('ninja.disable_auto_update'))
|
||||
Artisan::call('optimize');
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
|
||||
|
@ -54,6 +54,7 @@ class Account extends BaseModel
|
||||
'promo_expires',
|
||||
'discount_expires',
|
||||
'trial_started',
|
||||
'plan_expires'
|
||||
];
|
||||
|
||||
const PLAN_FREE = 'free';
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Services\Subscription\SubscriptionService;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -77,4 +78,39 @@ class Subscription extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function nextDateByInterval($date, $frequency_id)
|
||||
{
|
||||
|
||||
switch ($frequency_id) {
|
||||
|
||||
case RecurringInvoice::FREQUENCY_DAILY:
|
||||
return $date->addDay();
|
||||
case RecurringInvoice::FREQUENCY_WEEKLY:
|
||||
return $date->addWeek();
|
||||
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
|
||||
return $date->addWeeks(2);
|
||||
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
|
||||
return $date->addWeeks(4);
|
||||
case RecurringInvoice::FREQUENCY_MONTHLY:
|
||||
return $date->addMonthNoOverflow();
|
||||
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
|
||||
return $date->addMonthsNoOverflow(2);
|
||||
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
|
||||
return $date->addMonthsNoOverflow(3);
|
||||
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
|
||||
return $date->addMonthsNoOverflow(4);
|
||||
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
|
||||
return $date->addMonthsNoOverflow(6);
|
||||
case RecurringInvoice::FREQUENCY_ANNUALLY:
|
||||
return $date->addYear();
|
||||
case RecurringInvoice::FREQUENCY_TWO_YEARS:
|
||||
return $date->addYears(2);
|
||||
case RecurringInvoice::FREQUENCY_THREE_YEARS:
|
||||
return $date->addYears(3);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,13 +10,16 @@
|
||||
*/
|
||||
namespace Tests\Feature\Ninja;
|
||||
|
||||
use App\Factory\SubscriptionFactory;
|
||||
use App\Models\Account;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -72,4 +75,17 @@ class PlanTest extends TestCase
|
||||
$this->assertEquals($filtered_plans->count(), 2);
|
||||
}
|
||||
|
||||
public function testSubscriptionDateIncrement()
|
||||
{
|
||||
$subscription = SubscriptionFactory::create($this->company->id, $this->user->id);
|
||||
$subscription->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
||||
$subscription->save();
|
||||
|
||||
$date = Carbon::parse('2020-01-01')->startOfDay();
|
||||
|
||||
$next_date = $subscription->nextDateByInterval($date, RecurringInvoice::FREQUENCY_MONTHLY);
|
||||
|
||||
$this->assertEquals($date->addMonthNoOverflow()->startOfDay(), $next_date->startOfDay());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user