mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8869 from turbo124/v5-develop
Fixes for RandomDataSeeder
This commit is contained in:
commit
799332409a
@ -32,7 +32,7 @@ class EmailHistoryController extends BaseController
|
||||
->orderBy('id', 'DESC')
|
||||
->cursor()
|
||||
->map(function ($system_log) {
|
||||
if($system_log->log['history'] ?? false) {
|
||||
if(($system_log->log['history'] && $system_log->log['history']['events'] && count($system_log->log['history']['events']) >=1) ?? false) {
|
||||
return $system_log->log['history'];
|
||||
}
|
||||
});
|
||||
@ -57,7 +57,7 @@ class EmailHistoryController extends BaseController
|
||||
->orderBy('id', 'DESC')
|
||||
->cursor()
|
||||
->map(function ($system_log) {
|
||||
if($system_log->log['history'] ?? false) {
|
||||
if(($system_log->log['history'] && $system_log->log['history']['events'] && count($system_log->log['history']['events']) >=1) ?? false) {
|
||||
return $system_log->log['history'];
|
||||
}
|
||||
});
|
||||
|
@ -44,6 +44,19 @@ class ClientService
|
||||
}, 2);
|
||||
} catch (\Throwable $throwable) {
|
||||
nlog("DB ERROR " . $throwable->getMessage());
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
|
||||
} catch(\Exception $exception){
|
||||
nlog("DB ERROR " . $exception->getMessage());
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -60,6 +73,17 @@ class ClientService
|
||||
}, 2);
|
||||
} catch (\Throwable $throwable) {
|
||||
nlog("DB ERROR " . $throwable->getMessage());
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
|
||||
} catch(\Exception $exception){
|
||||
nlog("DB ERROR " . $exception->getMessage());
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -67,11 +91,27 @@ class ClientService
|
||||
|
||||
public function updatePaidToDate(float $amount)
|
||||
{
|
||||
try {
|
||||
DB::connection(config('database.default'))->transaction(function () use ($amount) {
|
||||
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
||||
$this->client->paid_to_date += $amount;
|
||||
$this->client->saveQuietly();
|
||||
}, 2);
|
||||
}
|
||||
catch (\Throwable $throwable) {
|
||||
nlog("DB ERROR " . $throwable->getMessage());
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
|
||||
} catch(\Exception $exception){
|
||||
nlog("DB ERROR " . $exception->getMessage());
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -47,11 +47,12 @@ use App\Repositories\InvoiceRepository;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Events\Payment\PaymentWasCreated;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
|
||||
class RandomDataSeeder extends Seeder
|
||||
{
|
||||
use \App\Utils\Traits\MakesHash;
|
||||
|
||||
use AppSetup;
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
@ -59,30 +60,8 @@ class RandomDataSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
/* Warm up the cache !*/
|
||||
$cached_tables = config('ninja.cached_tables');
|
||||
|
||||
foreach ($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->buildCache(true);
|
||||
|
||||
$this->command->info('Running RandomDataSeeder');
|
||||
|
||||
|
@ -5179,6 +5179,7 @@ $LANG = array(
|
||||
'stock_quantity_number' => 'Stock :quantity',
|
||||
'upcoming' => 'Upcoming',
|
||||
'client_contact' => 'Client Contact',
|
||||
'uncategorized' => 'Uncategorized',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
Loading…
x
Reference in New Issue
Block a user