Merge pull request #7313 from turbo124/master

Fixes for migration + PHPExcel
This commit is contained in:
David Bomba 2022-03-19 15:34:10 +11:00 committed by GitHub
commit fd8d4b835c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 814 additions and 596 deletions

View File

@ -97,20 +97,20 @@ class ForceMigration extends Command
} }
$company = Company::on($this->db) // $company = Company::on($this->db)
->whereNull('plan') // ->whereNull('plan')
->orWhereIn('plan', ['','free']) // ->orWhereIn('plan', ['','free'])
->whereHas('accounts', function ($query){ // ->whereHas('accounts', function ($query){
$query->where('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h'); // $query->where('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
$query->orWhere('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx702'); // $query->orWhere('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx702');
$query->orWhere('account_key', '!=', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT'); // $query->orWhere('account_key', '!=', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT');
}) // })
->with('accounts') // ->with('accounts')
->withCount('accounts') // ->withCount('accounts')
->having('accounts_count', '>=', 1) // ->having('accounts_count', '>=', 1)
->first(); // ->first();
return $company; // return $company;
} }

View File

@ -63,6 +63,6 @@ class Kernel extends HttpKernel
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'lookup' => \App\Http\Middleware\DatabaseLookup::class, 'lookup' => \App\Http\Middleware\DatabaseLookup::class,
'permissions.required' => \App\Http\Middleware\PermissionsRequired::class, 'permissions.required' => \App\Http\Middleware\PermissionsRequired::class,
'migration' => \App\Http\Middleware\EligibleForMigration::class, 'migration_channel' => \App\Http\Middleware\MigrationLookup::class,
]; ];
} }

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
use App\Models\LookupAccount;
use App\Models\LookupContact;
use App\Models\LookupInvitation;
use App\Models\LookupProposalInvitation;
use App\Models\LookupAccountToken;
use App\Models\LookupUser;
use Auth;
use Utils;
class MigrationLookup
{
public function handle(Request $request, Closure $next, $guard = 'user')
{
if (! env('MULTI_DB_ENABLED')) {
return $next($request);
}
if ($guard == 'user') {
}
return $next($request);
}
}

View File

@ -102,6 +102,7 @@ trait GenerateMigrationResources
'custom_surcharge_taxes1' => $this->account->custom_invoice_taxes1, 'custom_surcharge_taxes1' => $this->account->custom_invoice_taxes1,
'custom_surcharge_taxes2' => $this->account->custom_invoice_taxes2, 'custom_surcharge_taxes2' => $this->account->custom_invoice_taxes2,
'subdomain' => $this->account->subdomain, 'subdomain' => $this->account->subdomain,
'portal_mode' => 'subdomain',
'size_id' => $this->account->size_id, 'size_id' => $this->account->size_id,
'enable_modules' => $this->account->enabled_modules, 'enable_modules' => $this->account->enabled_modules,
'custom_fields' => $this->account->custom_fields, 'custom_fields' => $this->account->custom_fields,
@ -148,6 +149,8 @@ trait GenerateMigrationResources
$timezone_id = (string)($timezone_id - 1); $timezone_id = (string)($timezone_id - 1);
return [ return [
'entity_send_time' => 6,
'auto_bill_date' => $this->account->auto_bill_on_due_date ? 'on_due_date' : 'on_send_date',
'auto_bill' => $this->transformAutoBill($this->account->token_billing_id), 'auto_bill' => $this->transformAutoBill($this->account->token_billing_id),
'payment_terms' => $this->account->payment_terms ? (string) $this->account->payment_terms : '', 'payment_terms' => $this->account->payment_terms ? (string) $this->account->payment_terms : '',
'timezone_id' => $timezone_id, 'timezone_id' => $timezone_id,
@ -552,13 +555,14 @@ trait GenerateMigrationResources
{ {
$credits = []; $credits = [];
$export_credits = collect([]);
$export_credits = Invoice::where('account_id', $this->account->id) // $export_credits = Invoice::where('account_id', $this->account->id)
->where('balance', '<', '0') // ->where('balance', '<', '0')
->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD) // ->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD)
->where('is_public', true) // ->where('is_public', true)
->withTrashed() // ->withTrashed()
->get(); // ->get();
info("get credit notes => " . $export_credits->count()); info("get credit notes => " . $export_credits->count());
@ -613,7 +617,7 @@ trait GenerateMigrationResources
$invoices = []; $invoices = [];
$export_invoices = Invoice::where('account_id', $this->account->id) $export_invoices = Invoice::where('account_id', $this->account->id)
->where('amount', '>=', 0) // ->where('amount', '>=', 0)
->where('invoice_type_id', INVOICE_TYPE_STANDARD) ->where('invoice_type_id', INVOICE_TYPE_STANDARD)
->where('is_recurring', false) ->where('is_recurring', false)
->withTrashed() ->withTrashed()
@ -810,13 +814,13 @@ trait GenerateMigrationResources
private function calcAutoBillEnabled($invoice) private function calcAutoBillEnabled($invoice)
{ {
if($invoice->auto_bill == 1) if($invoice->auto_bill === 1)
return 'off'; return 'off';
elseif($invoice->auto_bill == 2) elseif($invoice->auto_bill === 2)
return 'optin'; return 'optin';
elseif($invoice->auto_bill == 3) elseif($invoice->auto_bill === 3)
return 'optout'; return 'optout';
elseif($invoice->auto_bill == 4) elseif($invoice->auto_bill === 4)
return 'always'; return 'always';
else else
return 'off'; return 'off';
@ -1326,6 +1330,7 @@ trait GenerateMigrationResources
'refunded' => $payment->refunded ?: 0, 'refunded' => $payment->refunded ?: 0,
'date' => $payment->payment_date, 'date' => $payment->payment_date,
'transaction_reference' => $payment->transaction_reference ?: '', 'transaction_reference' => $payment->transaction_reference ?: '',
'private_notes' => $payment->private_notes ?: '',
'payer_id' => $payment->payer_id, 'payer_id' => $payment->payer_id,
'is_deleted' => (bool)$payment->is_deleted, 'is_deleted' => (bool)$payment->is_deleted,
'exchange_rate' => $payment->exchange_rate ? number_format((float) $payment->exchange_rate, 6) : null, 'exchange_rate' => $payment->exchange_rate ? number_format((float) $payment->exchange_rate, 6) : null,
@ -1365,10 +1370,26 @@ trait GenerateMigrationResources
const SEPA = 29; const SEPA = 29;
const GOCARDLESS = 30; const GOCARDLESS = 30;
const CRYPTO = 31; const CRYPTO = 31;
const MOLLIE_BANK_TRANSFER = 34;
const KBC = 35;
const BANCONTACT = 36;
const IDEAL = 37;
const HOSTED_PAGE = 38;
const GIROPAY = 39;
const PRZELEWY24 = 40;
const EPS = 41;
const DIRECT_DEBIT = 42;
const BECS = 43;
const ACSS = 44;
const INSTANT_BANK_PAY = 45;
const FPX = 46;
*/ */
private function transformPaymentType($payment_type_id) private function transformPaymentType($payment_type_id)
{ {
switch ($payment_type_id) { switch ($payment_type_id) {
case 4:
return 42;
case PAYMENT_TYPE_CREDIT: case PAYMENT_TYPE_CREDIT:
return 32; return 32;
case PAYMENT_TYPE_ACH: case PAYMENT_TYPE_ACH:

View File

@ -67,7 +67,7 @@
"league/flysystem-rackspace": "~1.0", "league/flysystem-rackspace": "~1.0",
"league/fractal": "0.13.*", "league/fractal": "0.13.*",
"lokielse/omnipay-alipay": "~1.4", "lokielse/omnipay-alipay": "~1.4",
"maatwebsite/excel": "dev-carbon#8b17952", "maatwebsite/excel": "dev-php-fix",
"meebio/omnipay-creditcall": "dev-master", "meebio/omnipay-creditcall": "dev-master",
"meebio/omnipay-secure-trading": "dev-master", "meebio/omnipay-secure-trading": "dev-master",
"mfauveau/omnipay-pacnet": "~2.0", "mfauveau/omnipay-pacnet": "~2.0",
@ -207,7 +207,7 @@
}, },
{ {
"type": "vcs", "type": "vcs",
"url": "https://github.com/tainmar/Laravel-Excel" "url": "https://github.com/turbo124/Laravel-Excel"
} }
] ]
} }

1295
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4157,7 +4157,7 @@ $LANG = array(
'group_documents' => 'Group documents', 'group_documents' => 'Group documents',
'quote_approval_confirmation_label' => 'Are you sure you want to approve this quote?', 'quote_approval_confirmation_label' => 'Are you sure you want to approve this quote?',
'migration_select_company_label' => 'Select companies to migrate', 'migration_select_company_label' => 'Select companies to migrate',
'force_migration' => 'Force migration', 'force_migration' => 'Force migration <b>**WARNING** This will overwrite any data you have on v5.</b>',
'require_password_with_social_login' => 'Require Password with Social Login', 'require_password_with_social_login' => 'Require Password with Social Login',
'stay_logged_in' => 'Stay Logged In', 'stay_logged_in' => 'Stay Logged In',
'session_about_to_expire' => 'Warning: Your session is about to expire', 'session_about_to_expire' => 'Warning: Your session is about to expire',

View File

@ -295,7 +295,7 @@
</div> </div>
@endif @endif
<br/> <br/>
<button form="forward-form" class="btn btn-primary btn-lg">{!! trans('texts.submit') !!}</button> <button form="forward-form" class="btn btn-primary btn-lg">Enable Forwarding</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -253,6 +253,12 @@
@include('partials/white_label_expired') @include('partials/white_label_expired')
@endif @endif
@if($account->account_email_settings->forward_url_for_v5)
<div class="alert alert-danger">
Your account is currently forwarding all requests to v5, this installation is now disabled.
</div>
@endif
@if (Auth::user()->hasPermission('admin')) @if (Auth::user()->hasPermission('admin'))
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">