mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for migration
This commit is contained in:
parent
388c0e8467
commit
4b1aabbac7
@ -51,7 +51,7 @@ class InvoiceItem
|
|||||||
|
|
||||||
public $custom_value4 = '';
|
public $custom_value4 = '';
|
||||||
|
|
||||||
public $type_id = 1; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee, 5 late fee
|
public $type_id = '1'; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee, 5 late fee
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
'type_id' => 'string',
|
'type_id' => 'string',
|
||||||
|
@ -115,7 +115,7 @@ class MigrationController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge Company but save settings.
|
* Purge Company but save settings.
|
||||||
*
|
*
|
||||||
@ -219,6 +219,7 @@ class MigrationController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function startMigration(Request $request)
|
public function startMigration(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$companies = json_decode($request->companies);
|
$companies = json_decode($request->companies);
|
||||||
|
|
||||||
if (app()->environment() === 'local') {
|
if (app()->environment() === 'local') {
|
||||||
@ -226,21 +227,21 @@ class MigrationController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
$is_valid = $request->file($company->company_key)->isValid();
|
|
||||||
|
$is_valid = $request->file($company->company_index)->isValid();
|
||||||
|
|
||||||
if (!$is_valid) {
|
if (!$is_valid) {
|
||||||
// We might want to send user something's wrong with migration or nope?
|
// We might want to send user something's wrong with migration or nope?
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
// Look for possible existing company (based on company keys).
|
// Look for possible existing company (based on company keys).
|
||||||
$existing_company = Company::where('company_key', $request->company_key)->first();
|
$existing_company = Company::whereRaw('BINARY `company_key` = ?', [$company->company_key])->first();
|
||||||
|
|
||||||
$checks = [
|
$checks = [
|
||||||
'existing_company' => (bool) $existing_company,
|
'existing_company' => $existing_company ? (bool)1 : false,
|
||||||
'force' => property_exists($company, 'force') ? (bool) $company->force : false,
|
'force' => property_exists($company, 'force') ? (bool) $company->force : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -259,6 +260,7 @@ class MigrationController extends BaseController
|
|||||||
|
|
||||||
// If there's existing company and force ** is provided ** - purge the company and migrate again.
|
// If there's existing company and force ** is provided ** - purge the company and migrate again.
|
||||||
if ($checks['existing_company'] == true && $checks['force'] == true) {
|
if ($checks['existing_company'] == true && $checks['force'] == true) {
|
||||||
|
info("purging the existing company here");
|
||||||
$this->purgeCompanyWithForceFlag($existing_company);
|
$this->purgeCompanyWithForceFlag($existing_company);
|
||||||
|
|
||||||
$account = auth()->user()->account;
|
$account = auth()->user()->account;
|
||||||
@ -318,10 +320,10 @@ class MigrationController extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$migration_file = $request->file($company->company_key)
|
$migration_file = $request->file($company->company_index)
|
||||||
->storeAs(
|
->storeAs(
|
||||||
'migrations',
|
'migrations',
|
||||||
$request->file($company->company_key)->getClientOriginalName()
|
$request->file($company->company_index)->getClientOriginalName()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (app()->environment() == 'testing') {
|
if (app()->environment() == 'testing') {
|
||||||
@ -329,7 +331,7 @@ class MigrationController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(60));
|
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
info($e->getMessage());
|
info($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ class PaymentMigrationRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
private function processExchangeRates($data, $payment)
|
private function processExchangeRates($data, $payment)
|
||||||
{
|
{
|
||||||
$client = Client::find($data['client_id'])->withTrashed();
|
$client = Client::where('id', $data['client_id'])->withTrashed()->first();
|
||||||
|
|
||||||
$client_currency = $client->getSetting('currency_id');
|
$client_currency = $client->getSetting('currency_id');
|
||||||
$company_currency = $client->company->settings->currency_id;
|
$company_currency = $client->company->settings->currency_id;
|
||||||
|
@ -29,9 +29,6 @@ trait CleanLineItems
|
|||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
|
|
||||||
if(is_array($item))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$cleaned_items[] = $this->cleanLineItem($item);
|
$cleaned_items[] = $this->cleanLineItem($item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user