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)
->whereNull('plan')
->orWhereIn('plan', ['','free'])
->whereHas('accounts', function ($query){
$query->where('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
$query->orWhere('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx702');
$query->orWhere('account_key', '!=', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT');
})
->with('accounts')
->withCount('accounts')
->having('accounts_count', '>=', 1)
->first();
// $company = Company::on($this->db)
// ->whereNull('plan')
// ->orWhereIn('plan', ['','free'])
// ->whereHas('accounts', function ($query){
// $query->where('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
// $query->orWhere('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx702');
// $query->orWhere('account_key', '!=', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT');
// })
// ->with('accounts')
// ->withCount('accounts')
// ->having('accounts_count', '>=', 1)
// ->first();
return $company;
// return $company;
}

View File

@ -63,6 +63,6 @@ class Kernel extends HttpKernel
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'lookup' => \App\Http\Middleware\DatabaseLookup::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_taxes2' => $this->account->custom_invoice_taxes2,
'subdomain' => $this->account->subdomain,
'portal_mode' => 'subdomain',
'size_id' => $this->account->size_id,
'enable_modules' => $this->account->enabled_modules,
'custom_fields' => $this->account->custom_fields,
@ -148,6 +149,8 @@ trait GenerateMigrationResources
$timezone_id = (string)($timezone_id - 1);
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),
'payment_terms' => $this->account->payment_terms ? (string) $this->account->payment_terms : '',
'timezone_id' => $timezone_id,
@ -552,13 +555,14 @@ trait GenerateMigrationResources
{
$credits = [];
$export_credits = collect([]);
$export_credits = Invoice::where('account_id', $this->account->id)
->where('balance', '<', '0')
->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD)
->where('is_public', true)
->withTrashed()
->get();
// $export_credits = Invoice::where('account_id', $this->account->id)
// ->where('balance', '<', '0')
// ->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD)
// ->where('is_public', true)
// ->withTrashed()
// ->get();
info("get credit notes => " . $export_credits->count());
@ -613,7 +617,7 @@ trait GenerateMigrationResources
$invoices = [];
$export_invoices = Invoice::where('account_id', $this->account->id)
->where('amount', '>=', 0)
// ->where('amount', '>=', 0)
->where('invoice_type_id', INVOICE_TYPE_STANDARD)
->where('is_recurring', false)
->withTrashed()
@ -810,13 +814,13 @@ trait GenerateMigrationResources
private function calcAutoBillEnabled($invoice)
{
if($invoice->auto_bill == 1)
if($invoice->auto_bill === 1)
return 'off';
elseif($invoice->auto_bill == 2)
elseif($invoice->auto_bill === 2)
return 'optin';
elseif($invoice->auto_bill == 3)
elseif($invoice->auto_bill === 3)
return 'optout';
elseif($invoice->auto_bill == 4)
elseif($invoice->auto_bill === 4)
return 'always';
else
return 'off';
@ -1326,6 +1330,7 @@ trait GenerateMigrationResources
'refunded' => $payment->refunded ?: 0,
'date' => $payment->payment_date,
'transaction_reference' => $payment->transaction_reference ?: '',
'private_notes' => $payment->private_notes ?: '',
'payer_id' => $payment->payer_id,
'is_deleted' => (bool)$payment->is_deleted,
'exchange_rate' => $payment->exchange_rate ? number_format((float) $payment->exchange_rate, 6) : null,
@ -1365,10 +1370,26 @@ trait GenerateMigrationResources
const SEPA = 29;
const GOCARDLESS = 30;
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)
{
switch ($payment_type_id) {
case 4:
return 42;
case PAYMENT_TYPE_CREDIT:
return 32;
case PAYMENT_TYPE_ACH:

View File

@ -67,7 +67,7 @@
"league/flysystem-rackspace": "~1.0",
"league/fractal": "0.13.*",
"lokielse/omnipay-alipay": "~1.4",
"maatwebsite/excel": "dev-carbon#8b17952",
"maatwebsite/excel": "dev-php-fix",
"meebio/omnipay-creditcall": "dev-master",
"meebio/omnipay-secure-trading": "dev-master",
"mfauveau/omnipay-pacnet": "~2.0",
@ -207,7 +207,7 @@
},
{
"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',
'quote_approval_confirmation_label' => 'Are you sure you want to approve this quote?',
'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',
'stay_logged_in' => 'Stay Logged In',
'session_about_to_expire' => 'Warning: Your session is about to expire',

View File

@ -295,7 +295,7 @@
</div>
@endif
<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>
</form>

View File

@ -253,6 +253,12 @@
@include('partials/white_label_expired')
@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'))
<div class="row">
<div class="col-md-4">