mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for imports
This commit is contained in:
parent
03b76d8479
commit
0c9f982bdf
@ -96,7 +96,7 @@ class Import implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $data; //the file path - using a different JSON parser here.
|
private $file_path; //the file path - using a different JSON parser here.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Company
|
* @var Company
|
||||||
@ -163,9 +163,9 @@ class Import implements ShouldQueue
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param array $resources
|
* @param array $resources
|
||||||
*/
|
*/
|
||||||
public function __construct(string $data, Company $company, User $user, array $resources = [])
|
public function __construct(string $file_path, Company $company, User $user, array $resources = [])
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->file_path = $file_path;
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->resources = $resources;
|
$this->resources = $resources;
|
||||||
@ -180,20 +180,27 @@ class Import implements ShouldQueue
|
|||||||
{
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
$jsonStream = \JsonMachine\JsonMachine::fromFile($this->data, "/data");
|
// $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data");
|
||||||
|
$array = json_decode(file_get_contents($this->file_path), 1);
|
||||||
|
$data = $array['data'];
|
||||||
|
|
||||||
foreach ($jsonStream as $key => $resource) {
|
info(array_keys($data));
|
||||||
if (! in_array($key, $this->available_imports)) {
|
|
||||||
|
foreach ($this->available_imports as $import) {
|
||||||
|
|
||||||
|
info("the key = {$import}");
|
||||||
|
|
||||||
|
if (! array_key_exists($import, $data)) {
|
||||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
info("Resource {$key} is not available for migration.");
|
info("Resource {$import} is not available for migration.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = sprintf('process%s', Str::ucfirst(Str::camel($key)));
|
$method = sprintf('process%s', Str::ucfirst(Str::camel($import)));
|
||||||
|
|
||||||
info("Importing {$key}");
|
info("Importing {$import}");
|
||||||
|
|
||||||
$this->{$method}($resource);
|
$this->{$method}($data[$import]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setInitialCompanyLedgerBalances();
|
$this->setInitialCompanyLedgerBalances();
|
||||||
|
@ -600,7 +600,7 @@ trait GeneratesCounter
|
|||||||
$replace[] = str_replace($format, $date, $matches[1]);
|
$replace[] = str_replace($format, $date, $matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($entity instanceof Client){
|
if($entity instanceof Client || $entity instanceof Vendor){
|
||||||
$search[] = '{$client_custom1}';
|
$search[] = '{$client_custom1}';
|
||||||
$replace[] = $entity->custom_value1;
|
$replace[] = $entity->custom_value1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user