|
|
|
@ -395,4 +395,42 @@ trait AutoImports |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param string $csvFile |
|
|
|
* @param string $jsonFile |
|
|
|
*/ |
|
|
|
private function importUpload(string $csvFile, string $jsonFile): void |
|
|
|
{ |
|
|
|
// do JSON check
|
|
|
|
$jsonResult = $this->verifyJSON($jsonFile); |
|
|
|
if (false === $jsonResult) { |
|
|
|
$message = sprintf('The importer can\'t import %s: could not decode the JSON in config file %s.', $csvFile, $jsonFile); |
|
|
|
$this->error($message); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
$configuration = Configuration::fromArray(json_decode(file_get_contents($jsonFile), true)); |
|
|
|
$configuration->updateDateRange(); |
|
|
|
|
|
|
|
|
|
|
|
$this->line(sprintf('Going to convert from file %s using configuration %s and flow "%s".', $csvFile, $jsonFile, $configuration->getFlow())); |
|
|
|
|
|
|
|
// this is it!
|
|
|
|
$this->startConversion($configuration, $csvFile); |
|
|
|
$this->reportConversion(); |
|
|
|
|
|
|
|
$this->line(sprintf('Done converting from file %s using configuration %s.', $csvFile, $jsonFile)); |
|
|
|
$this->startImport($configuration); |
|
|
|
$this->reportImport(); |
|
|
|
|
|
|
|
$this->line('Done!'); |
|
|
|
event(new ImportedTransactions( |
|
|
|
array_merge($this->conversionMessages, $this->importMessages), |
|
|
|
array_merge($this->conversionWarnings, $this->importWarnings), |
|
|
|
array_merge($this->conversionErrors, $this->importErrors) |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |