Minor fixes for impmort

This commit is contained in:
David Bomba 2021-04-27 20:38:34 +10:00
parent b0f5ca8638
commit d2bb8d6d81
2 changed files with 25 additions and 10 deletions

View File

@ -192,6 +192,15 @@ class Import implements ShouldQueue
$array = json_decode(file_get_contents($this->file_path), 1);
$data = $array['data'];
// disable some functionality here:
// 1. disable update_products
$update_product_state = $this->company->update_products;
$this->company->update_products = false;
$this->company->save();
foreach ($this->available_imports as $import) {
if (! array_key_exists($import, $data)) {
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
@ -211,9 +220,10 @@ class Import implements ShouldQueue
// $this->fixClientBalances();
$check_data = CheckCompanyData::dispatchNow($this->company, md5(time()));
// if($check_data['status'] == 'errors')
// throw new ProcessingMigrationArchiveFailed(implode("\n", $check_data));
//reset functionality here
$this->company->update_products = $update_product_state;
$this->company->save();
try{
Mail::to($this->user->email, $this->user->name())
->send(new MigrationCompleted($this->company, implode("<br>",$check_data)));
@ -224,7 +234,12 @@ class Import implements ShouldQueue
/*After a migration first some basic jobs to ensure the system is up to date*/
VersionCheck::dispatch();
CompanySizeCheck::dispatch();
//company size check
if ($this->company->invoices()->count() > 1000 || $this->company->products()->count() > 1000 || $this->company->clients()->count() > 1000) {
$company->is_large = true;
$company->save();
}
info('Completed🚀🚀🚀🚀🚀 at '.now());

View File

@ -35,12 +35,12 @@ class ProductFactory extends Factory
'cost' => $this->faker->numberBetween(1, 1000),
'price' => $this->faker->numberBetween(1, 1000),
'quantity' => $this->faker->numberBetween(1, 100),
'tax_name1' => 'GST',
'tax_rate1' => 10,
'tax_name2' => 'VAT',
'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5,
// 'tax_name1' => 'GST',
// 'tax_rate1' => 10,
// 'tax_name2' => 'VAT',
// 'tax_rate2' => 17.5,
// 'tax_name3' => 'THIRDTAX',
// 'tax_rate3' => 5,
'custom_value1' => $this->faker->text(20),
'custom_value2' => $this->faker->text(20),
'custom_value3' => $this->faker->text(20),