1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Refactor for imports

This commit is contained in:
David Bomba 2022-02-17 14:40:28 +11:00
parent a4a31f35b1
commit 97507871c5
3 changed files with 15 additions and 7 deletions

View File

@ -103,7 +103,7 @@ class ImportController extends Controller {
public function import( ImportRequest $request ) {
$data = $request->all();
nlog($data);
if ( empty( $data['hash'] ) ) {
// Create a reference
$data['hash'] = $hash = Str::random( 32 );

View File

@ -80,6 +80,8 @@ class BaseImport
public function getCsvData($entity_type)
{
nlog("get csv data = entity name = " . $entity_type);
$base64_encoded_csv = Cache::pull($this->hash . '-' . $entity_type);
if (empty($base64_encoded_csv)) {
return null;

View File

@ -71,7 +71,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['clients'] = 0;
@ -98,7 +99,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['products'] = 0;
@ -125,7 +127,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['invoices'] = 0;
@ -152,7 +155,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['payments'] = 0;
@ -179,7 +183,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['vendors'] = 0;
@ -206,7 +211,8 @@ class Csv extends BaseImport implements ImportInterface
$data = $this->getCsvData($entity_type);
$data = $this->preTransformCsv($data, $entity_type);
if(is_array($data))
$data = $this->preTransformCsv($data, $entity_type);
if (empty($data)) {
$this->entity_count['expenses'] = 0;