mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-21 08:51:34 +02:00
Merge pull request #5649 from turbo124/v5-develop
Fixes for Stripe Connect
This commit is contained in:
commit
81563dc20c
@ -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
|
@ -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 {
|
||||
|
@ -21,6 +21,7 @@ use App\Mail\ExistingMigration;
|
||||
use App\Mail\Migration\MaxCompanies;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
@ -378,14 +379,15 @@ class MigrationController extends BaseController
|
||||
return;
|
||||
}
|
||||
|
||||
// try {
|
||||
// StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5));
|
||||
nlog("starting migration job");
|
||||
nlog($migration_file);
|
||||
StartMigration::dispatch($migration_file, $user, $fresh_company)->onQueue('migration');
|
||||
// } catch (\Exception $e) {
|
||||
// nlog($e->getMessage());
|
||||
// }
|
||||
|
||||
if(Ninja::isHosted())
|
||||
StartMigration::dispatch($migration_file, $user, $fresh_company)->onQueue('migration');
|
||||
else
|
||||
StartMigration::dispatch($migration_file, $user, $fresh_company);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,6 @@ class SelfUpdateController extends BaseController
|
||||
if (file_exists($cacheServices)) { unlink ($cacheServices); }
|
||||
|
||||
Artisan::call('clear-compiled');
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('route:clear');
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('config:clear');
|
||||
|
@ -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 {
|
||||
|
@ -84,6 +84,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
@ -462,6 +463,8 @@ class Import implements ShouldQueue
|
||||
|
||||
private function checkUniqueConstraint($model, $column, $value)
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
$model_query = (new $model())
|
||||
->query()
|
||||
->where($column, $value)
|
||||
@ -504,10 +507,10 @@ class Import implements ShouldQueue
|
||||
);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$client->created_at = $modified['created_at'];
|
||||
$client->created_at = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$client->updated_at = $modified['updated_at'];
|
||||
$client->updated_at = Carbon::parse($modified['updated_at']);
|
||||
|
||||
$client->save(['timestamps' => false]);
|
||||
|
||||
@ -584,6 +587,12 @@ class Import implements ShouldQueue
|
||||
unset($modified['id']);
|
||||
unset($modified['contacts']);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$modified['created_at'] = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||
|
||||
$vendor = $vendor_repository->save(
|
||||
$modified,
|
||||
VendorFactory::create(
|
||||
@ -651,6 +660,12 @@ class Import implements ShouldQueue
|
||||
$modified['company_id'] = $this->company->id;
|
||||
$modified['user_id'] = $this->processUserId($resource);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$modified['created_at'] = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
$product_repository->save(
|
||||
@ -697,6 +712,12 @@ class Import implements ShouldQueue
|
||||
$modified['company_id'] = $this->company->id;
|
||||
$modified['line_items'] = $this->cleanItems($modified['line_items']);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$modified['created_at'] = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
if (array_key_exists('invitations', $resource)) {
|
||||
@ -833,6 +854,12 @@ class Import implements ShouldQueue
|
||||
$modified['user_id'] = $this->processUserId($resource);
|
||||
$modified['company_id'] = $this->company->id;
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$modified['created_at'] = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
$credit = $credit_repository->save(
|
||||
@ -892,6 +919,18 @@ class Import implements ShouldQueue
|
||||
|
||||
$modified['company_id'] = $this->company->id;
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$modified['created_at'] = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||
|
||||
if(array_key_exists('tax_rate1', $modified) && is_null($modified['tax_rate1']))
|
||||
$modified['tax_rate1'] = 0;
|
||||
|
||||
if(array_key_exists('tax_rate2', $modified) && is_null($modified['tax_rate2']))
|
||||
$modified['tax_rate2'] = 0;
|
||||
|
||||
unset($modified['id']);
|
||||
|
||||
|
||||
@ -989,10 +1028,10 @@ class Import implements ShouldQueue
|
||||
);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$payment->created_at = $modified['created_at'];
|
||||
$payment->created_at = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$payment->updated_at = $modified['updated_at'];
|
||||
$payment->updated_at = Carbon::parse($modified['updated_at']);
|
||||
|
||||
$payment->save(['timestamps' => false]);
|
||||
|
||||
@ -1364,10 +1403,12 @@ class Import implements ShouldQueue
|
||||
$task = Task::Create($modified);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$task->created_at = $modified['created_at'];
|
||||
$task->created_at = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$task->updated_at = $modified['updated_at'];
|
||||
$task->updated_at = Carbon::parse($modified['updated_at']);
|
||||
|
||||
|
||||
|
||||
$task->save(['timestamps' => false]);
|
||||
|
||||
@ -1452,10 +1493,12 @@ class Import implements ShouldQueue
|
||||
$expense = Expense::Create($modified);
|
||||
|
||||
if(array_key_exists('created_at', $modified))
|
||||
$expense->created_at = $modified['created_at'];
|
||||
$expense->created_at = Carbon::parse($modified['created_at']);
|
||||
|
||||
if(array_key_exists('updated_at', $modified))
|
||||
$expense->updated_at = $modified['updated_at'];
|
||||
$expense->updated_at = Carbon::parse($modified['updated_at']);
|
||||
|
||||
|
||||
|
||||
$expense->save(['timestamps' => false]);
|
||||
|
||||
|
@ -91,6 +91,21 @@ class StartMigration implements ShouldQueue
|
||||
$archive = $zip->open(public_path("storage/{$this->filepath}"));
|
||||
$filename = pathinfo($this->filepath, PATHINFO_FILENAME);
|
||||
|
||||
if($this->company->id == $this->company->account->default_company_id)
|
||||
{
|
||||
$new_default_company = $this->company->account->companies->first();
|
||||
|
||||
if ($new_default_company) {
|
||||
$this->company->account->default_company_id = $new_default_company->id;
|
||||
$this->company->account->save();
|
||||
}
|
||||
}
|
||||
|
||||
$update_product_flag = $this->company->update_products;
|
||||
|
||||
$this->company->update_products = false;
|
||||
$this->company->save();
|
||||
|
||||
try {
|
||||
if (! $archive) {
|
||||
throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.');
|
||||
@ -113,7 +128,16 @@ class StartMigration implements ShouldQueue
|
||||
|
||||
Storage::deleteDirectory(public_path("storage/migrations/{$filename}"));
|
||||
|
||||
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
|
||||
$this->company->account->default_company_id = $this->company->id;
|
||||
$this->company->account->save();
|
||||
|
||||
$this->company->update_products = $update_product_flag;
|
||||
$this->company->save();
|
||||
|
||||
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing | \Exception $e) {
|
||||
|
||||
$this->company->update_products = $update_product_flag;
|
||||
$this->company->save();
|
||||
|
||||
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
|
||||
|
||||
|
@ -302,11 +302,6 @@ class BaseRepository
|
||||
/* Perform model specific tasks */
|
||||
if ($model instanceof Invoice) {
|
||||
|
||||
nlog("in base");
|
||||
nlog($state['finished_amount']);
|
||||
nlog($state['starting_amount']);
|
||||
nlog($model->status_id);
|
||||
|
||||
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
|
||||
|
||||
$model->service()->updateStatus()->save();
|
||||
|
@ -23,6 +23,7 @@ use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Repositories\BaseRepository;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Support\Carbon;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
@ -59,6 +60,12 @@ class InvoiceMigrationRepository extends BaseRepository
|
||||
|
||||
$tmp_data = $data;
|
||||
|
||||
if(array_key_exists('tax_rate1', $tmp_data) && is_null($tmp_data['tax_rate1']))
|
||||
$tmp_data['tax_rate1'] = 0;
|
||||
|
||||
if(array_key_exists('tax_rate2', $tmp_data) && is_null($tmp_data['tax_rate2']))
|
||||
$tmp_data['tax_rate2'] = 0;
|
||||
|
||||
/* We need to unset some variable as we sometimes unguard the model */
|
||||
|
||||
if (isset($tmp_data['invitations'])) {
|
||||
@ -71,7 +78,15 @@ class InvoiceMigrationRepository extends BaseRepository
|
||||
|
||||
$model->fill($tmp_data);
|
||||
$model->status_id = $tmp_data['status_id'];
|
||||
$model->save();
|
||||
|
||||
if($tmp_data['created_at'])
|
||||
$model->created_at = Carbon::parse($tmp_data['created_at']);
|
||||
|
||||
if($tmp_data['updated_at'])
|
||||
$model->updated_at = Carbon::parse($tmp_data['updated_at']);
|
||||
|
||||
$model->save(['timestamps' => false]);
|
||||
|
||||
|
||||
if (array_key_exists('documents', $data)) {
|
||||
$this->saveDocuments($data['documents'], $model);
|
||||
@ -130,10 +145,6 @@ class InvoiceMigrationRepository extends BaseRepository
|
||||
$model->design_id = $this->decodePrimaryKey($client->getSetting('invoice_design_id'));
|
||||
}
|
||||
|
||||
|
||||
if ($model->company->update_products) {
|
||||
//UpdateOrCreateProduct::dispatchNow($model->line_items, $model, $model->company);
|
||||
}
|
||||
}
|
||||
|
||||
if ($class->name == Credit::class) {
|
||||
|
@ -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 {
|
||||
|
@ -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(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ trait AppSetup
|
||||
$orderBy = 'id';
|
||||
}
|
||||
$tableData = $class::orderBy($orderBy)->get();
|
||||
if ($tableData->count()) {
|
||||
if ($tableData->count() > 1) {
|
||||
Cache::forever($name, $tableData);
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
];
|
||||
|
@ -197,8 +197,8 @@ Route::get('token_hash_router', 'OneTimeTokenController@router');
|
||||
Route::get('webcron', 'WebCronController@index');
|
||||
|
||||
Route::group(['middleware' => ['locale']], function () {
|
||||
Route::get('stripe_connect/{token}', 'StripeConnectController@initialize')->name('stripe_connect.initialization');
|
||||
Route::get('stripe_connect/completed', 'StripeConnectController@completed')->name('stripe_connect.return');
|
||||
Route::get('stripe/signup/{token}', 'StripeConnectController@initialize')->name('stripe_connect.initialization');
|
||||
Route::get('stripe/signup/completed', 'StripeConnectController@completed')->name('stripe_connect.return');
|
||||
});
|
||||
|
||||
Route::fallback('BaseController@notFound');
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user