Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop

This commit is contained in:
David Bomba 2021-05-10 09:53:05 +10:00
commit dacd31bb83
16 changed files with 111 additions and 64 deletions

View File

@ -51,11 +51,13 @@ TRUSTED_PROXIES=
NINJA_ENVIRONMENT=selfhost
PHANTOMJS_PDF_GENERATION=true
#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=phantom
PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=secret
UPDATE_SECRET=
UPDATE_SECRET=secret
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5

View File

@ -141,10 +141,10 @@ class ActivityController extends BaseController
return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404);
}
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
$pdf = (new Phantom)->convertHtmlToPdf($backup->html_backup);
}
elseif(config('ninja.invoiceninja_hosted_pdf_generation')){
elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($backup->html_backup);
}
else {

View File

@ -131,11 +131,11 @@ class PreviewController extends BaseController
}
//if phantom js...... inject here..
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
}
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
}

View File

@ -52,12 +52,13 @@ class QueryLogging
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
nlog($request->method().' - '.urldecode($request->fullUrl()).": $count queries - ".$time);
nlog($request->method().' - '.urldecode($request->url()).": $count queries - ".$time);
// nlog($request->method().' - '.urldecode($request->fullUrl()).": $count queries - ".$time);
// if($count > 50)
//nlog($queries);
LightLogs::create(new DbQuery($request->method(), urldecode($request->fullUrl()), $count, $time, request()->ip()))
LightLogs::create(new DbQuery($request->method(), urldecode($request->url()), $count, $time, request()->ip()))
->batch();
}

View File

@ -105,7 +105,7 @@ class CreateEntityPdf implements ShouldQueue
$this->entity->service()->deletePdf();
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->generate($this->invitation);
}
@ -171,7 +171,7 @@ class CreateEntityPdf implements ShouldQueue
try {
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
}
else {

View File

@ -84,8 +84,11 @@ class NinjaMailerJob implements ShouldQueue
}
if (strlen($this->nmo->settings->bcc_email) > 1)
$this->nmo->mailable->bcc($this->nmo->settings->bcc_email, $this->nmo->settings->bcc_email);
if (strlen($this->nmo->settings->bcc_email) > 1) {
nlog('bcc list available');
nlog($this->nmo->settings->bcc_email);
$this->nmo->mailable->bcc(explode(",", $this->nmo->settings->bcc_email), 'Blind Copy');
}
//send email

View File

@ -71,6 +71,7 @@ use App\Repositories\QuoteRepository;
use App\Repositories\UserRepository;
use App\Repositories\VendorContactRepository;
use App\Repositories\VendorRepository;
use App\Utils\Ninja;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver;
use App\Utils\Traits\MakesHash;
@ -1256,6 +1257,11 @@ class Import implements ShouldQueue
$modified['fees_and_limits'] = $this->cleanFeesAndLimits($modified['fees_and_limits']);
}
if(Ninja::isHosted() && $modified['gateway_key'] == 'd14dd26a37cecc30fdd65700bfb55b23'){
$modified['gateway_key'] = 'd14dd26a47cecc30fdd65700bfb67b34';
$modified['fees_and_limits'] = [];
}
$company_gateway = CompanyGateway::create($modified);
$key = "company_gateways_{$resource['id']}";

View File

@ -128,6 +128,11 @@ class Credit extends BaseModel
return $this->hasManyThrough(Backup::class, Activity::class);
}
public function activities()
{
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300);
}
public function company()
{
return $this->belongsTo(Company::class);

View File

@ -204,7 +204,7 @@ class Invoice extends BaseModel
public function activities()
{
return $this->hasMany(Activity::class);
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300);
}
public function history()

View File

@ -130,6 +130,11 @@ class Quote extends BaseModel
return $this->hasManyThrough(Backup::class, Activity::class);
}
public function activities()
{
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300);
}
public function user()
{
return $this->belongsTo(User::class)->withTrashed();

View File

@ -60,7 +60,7 @@ class GenerateDeliveryNote
$file_path = sprintf('%s%s_delivery_note.pdf', $this->invoice->client->invoice_filepath(), $this->invoice->number);
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->generate($this->invoice->invitations->first());
}
@ -92,7 +92,7 @@ class GenerateDeliveryNote
// Storage::makeDirectory($this->invoice->client->invoice_filepath(), 0775);
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
}
else {

View File

@ -12,6 +12,7 @@
namespace App\Utils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
/**
@ -69,6 +70,28 @@ class Statics
$data = [];
foreach (config('ninja.cached_tables') as $name => $class) {
// if (!Cache::has($name)) {
// // check that the table exists in case the migration is pending
// if (!Schema::hasTable((new $class())->getTable())) {
// continue;
// }
// if ($name == 'payment_terms') {
// $orderBy = 'num_days';
// } elseif ($name == 'fonts') {
// $orderBy = 'sort_order';
// } elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
// $orderBy = 'name';
// } else {
// $orderBy = 'id';
// }
// $tableData = $class::orderBy($orderBy)->get();
// if ($tableData->count()) {
// Cache::forever($name, $tableData);
// }
// }
$data[$name] = Cache::get($name);
}

View File

@ -17,6 +17,7 @@ use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
/**
* Class SystemHealth.
@ -80,6 +81,7 @@ class SystemHealth
'open_basedir' => (bool)self::checkOpenBaseDir(),
'mail_mailer' => (string)self::checkMailMailer(),
'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'),
'jobs_pending' => (int) Queue::size(),
];
}

94
composer.lock generated
View File

@ -103,16 +103,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.180.1",
"version": "3.180.5",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4"
"reference": "948a4defbe2a571cc4460725015b8e98b7060f2d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7801112fd8be227954a6ecfbfd85b01ee4a7cae4",
"reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/948a4defbe2a571cc4460725015b8e98b7060f2d",
"reference": "948a4defbe2a571cc4460725015b8e98b7060f2d",
"shasum": ""
},
"require": {
@ -187,9 +187,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.180.1"
"source": "https://github.com/aws/aws-sdk-php/tree/3.180.5"
},
"time": "2021-05-04T18:14:38+00:00"
"time": "2021-05-07T18:12:43+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -3303,16 +3303,16 @@
},
{
"name": "league/commonmark",
"version": "1.6.0",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "19a9673b833cc37770439097b381d86cd125bfe8"
"reference": "2651c497f005de305c7ba3f232cbd87b8c00ee8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/19a9673b833cc37770439097b381d86cd125bfe8",
"reference": "19a9673b833cc37770439097b381d86cd125bfe8",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2651c497f005de305c7ba3f232cbd87b8c00ee8c",
"reference": "2651c497f005de305c7ba3f232cbd87b8c00ee8c",
"shasum": ""
},
"require": {
@ -3400,7 +3400,7 @@
"type": "tidelift"
}
],
"time": "2021-05-01T19:00:49+00:00"
"time": "2021-05-08T16:08:00+00:00"
},
{
"name": "league/csv",
@ -6811,16 +6811,16 @@
},
{
"name": "sentry/sentry",
"version": "3.2.1",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f"
"reference": "02237728bdc5b82b0a14c37417644e3f3606db9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/02237728bdc5b82b0a14c37417644e3f3606db9b",
"reference": "02237728bdc5b82b0a14c37417644e3f3606db9b",
"shasum": ""
},
"require": {
@ -6899,7 +6899,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/3.2.1"
"source": "https://github.com/getsentry/sentry-php/tree/3.2.2"
},
"funding": [
{
@ -6911,20 +6911,20 @@
"type": "custom"
}
],
"time": "2021-04-06T07:55:41+00:00"
"time": "2021-05-06T10:15:01+00:00"
},
{
"name": "sentry/sentry-laravel",
"version": "2.5.1",
"version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-laravel.git",
"reference": "2af8a531f202f0ac014f5fad532815ed34f730a9"
"reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/2af8a531f202f0ac014f5fad532815ed34f730a9",
"reference": "2af8a531f202f0ac014f5fad532815ed34f730a9",
"url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/368a2701b3bd370a2892f1f67bfbf0cbecbaca17",
"reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17",
"shasum": ""
},
"require": {
@ -6987,7 +6987,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-laravel/issues",
"source": "https://github.com/getsentry/sentry-laravel/tree/2.5.1"
"source": "https://github.com/getsentry/sentry-laravel/tree/2.5.2"
},
"funding": [
{
@ -6999,20 +6999,20 @@
"type": "custom"
}
],
"time": "2021-04-29T11:10:22+00:00"
"time": "2021-05-06T07:49:08+00:00"
},
{
"name": "stripe/stripe-php",
"version": "v7.77.0",
"version": "v7.78.0",
"source": {
"type": "git",
"url": "https://github.com/stripe/stripe-php.git",
"reference": "f6724447481f6fb8c2e714165e092adad9ca470a"
"reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/f6724447481f6fb8c2e714165e092adad9ca470a",
"reference": "f6724447481f6fb8c2e714165e092adad9ca470a",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/6ec33fa8e9de2322be93d28dfd685661c67ca549",
"reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549",
"shasum": ""
},
"require": {
@ -7058,9 +7058,9 @@
],
"support": {
"issues": "https://github.com/stripe/stripe-php/issues",
"source": "https://github.com/stripe/stripe-php/tree/v7.77.0"
"source": "https://github.com/stripe/stripe-php/tree/v7.78.0"
},
"time": "2021-04-12T17:19:16+00:00"
"time": "2021-05-05T23:55:32+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -9809,16 +9809,16 @@
},
{
"name": "turbo124/laravel-gmail",
"version": "v5.0.1",
"version": "v5.0.2",
"source": {
"type": "git",
"url": "https://github.com/turbo124/laravel-gmail.git",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966"
"reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/f8b8806d0b37ab5b2d4c3f402f8094d9021bd342",
"reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342",
"shasum": ""
},
"require": {
@ -9872,9 +9872,9 @@
"laravel"
],
"support": {
"source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.1"
"source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.2"
},
"time": "2021-04-06T00:53:48+00:00"
"time": "2021-05-08T00:17:52+00:00"
},
{
"name": "vlucas/phpdotenv",
@ -10741,21 +10741,21 @@
},
{
"name": "darkaonline/l5-swagger",
"version": "8.0.4",
"version": "8.0.5",
"source": {
"type": "git",
"url": "https://github.com/DarkaOnLine/L5-Swagger.git",
"reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d"
"reference": "238e5d318b3d48a77c76b6950c51146578563853"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/3477e7013daf8b6fc142c45fdcb9fe6c74d7398d",
"reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d",
"url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/238e5d318b3d48a77c76b6950c51146578563853",
"reference": "238e5d318b3d48a77c76b6950c51146578563853",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "^8.0 || ^7.0",
"laravel/framework": ">=8.40.0 || ^7.0",
"php": "^7.2 || ^8.0",
"swagger-api/swagger-ui": "^3.0",
"symfony/yaml": "^5.0",
@ -10808,7 +10808,7 @@
],
"support": {
"issues": "https://github.com/DarkaOnLine/L5-Swagger/issues",
"source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.4"
"source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.5"
},
"funding": [
{
@ -10816,7 +10816,7 @@
"type": "github"
}
],
"time": "2020-12-08T13:29:20+00:00"
"time": "2021-05-07T09:57:00+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
@ -11061,16 +11061,16 @@
},
{
"name": "facade/ignition",
"version": "2.8.4",
"version": "2.9.0",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f"
"reference": "e7db3b601ce742568b92648818ef903904d20164"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"url": "https://api.github.com/repos/facade/ignition/zipball/e7db3b601ce742568b92648818ef903904d20164",
"reference": "e7db3b601ce742568b92648818ef903904d20164",
"shasum": ""
},
"require": {
@ -11134,7 +11134,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2021-04-29T13:55:26+00:00"
"time": "2021-05-05T06:45:12+00:00"
},
{
"name": "facade/ignition-contracts",

View File

@ -18,7 +18,7 @@ return [
'app_tag' => '5.1.61-release',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),
'api_secret' => env('API_SECRET', ''),
'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'),
'google_analytics_url' => env('GOOGLE_ANALYTICS_URL', 'https://www.google-analytics.com/collect'),
'key_length' => 64,
@ -148,4 +148,5 @@ return [
'disable_auto_update' => env('DISABLE_AUTO_UPDATE', false),
'invoiceninja_hosted_pdf_generation' => env('NINJA_HOSTED_PDF', false),
'ninja_stripe_key' => env('NINJA_STRIPE_KEY', null),
'pdf_generator' => env('PDF_GENERATOR', false),
];

View File

@ -52,7 +52,6 @@ class InvitationTest extends TestCase
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/invoices/'.$this->encodePrimaryKey($this->invoice->id), $this->invoice->toArray());
} catch (\Exception $e) {