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:02:23 +11:00
parent 62c1b6b2f5
commit a4a31f35b1
11 changed files with 11 additions and 21 deletions

View File

@ -516,12 +516,11 @@ class BaseImport
public function preTransform(array $data, $entity_type)
{
//sort the array by key
$keys = $this->column_map[$entity_type];
ksort($keys);
// $keys = $this->column_map[$entity_type];
$keys = array_shift( $data );
ksort($keys);
return array_map( function ( $values ) use ( $keys ) {
return array_combine( $keys, $values );

View File

@ -83,7 +83,7 @@ class Invoicely extends BaseImport
$data = $this->getCsvData($entity_type);
$data = $this->preTransform($data, $entity_type);
nlog($data);
if (empty($data)) {
$this->entity_count['invoices'] = 0;
return;

View File

@ -218,8 +218,6 @@ class Wave extends BaseImport implements ImportInterface
$expenses = $this->groupExpenses($data);
// nlog($expenses);
// exit;
foreach ($expenses as $raw_expense) {
try {

View File

@ -65,18 +65,16 @@ class BaseTransformer
public function getClient($client_name, $client_email)
{
nlog("client name = {$client_name} - email {$client_email}");
if(!empty($client_name))
{
nlog("client name = {$client_name}");
$client_id_search = $this->company
->clients()
->where('id_number', $client_name);
if ($client_id_search->count() >= 1) {
nlog("found via id number => {$client_id_search->first()->id}");
// nlog("found via id number => {$client_id_search->first()->id}");
return $client_id_search->first()->id;
}
@ -85,7 +83,7 @@ class BaseTransformer
->where('name', $client_name);
if ($client_name_search->count() >= 1) {
nlog("found via name {$client_name_search->first()->id}");
// nlog("found via name {$client_name_search->first()->id}");
return $client_name_search->first()->id;
}
}
@ -96,7 +94,7 @@ class BaseTransformer
)->where('email', $client_email);
if ($contacts->count() >= 1) {
nlog("found via contact {$contacts->first()->client_id}");
// nlog("found via contact {$contacts->first()->client_id}");
return $contacts->first()->client_id;
}
}

View File

@ -73,7 +73,6 @@ class InvoiceTransformer extends BaseTransformer {
'amount' => $transformed['amount'],
]];
}
nlog($transformed);
return $transformed;
}

View File

@ -88,7 +88,6 @@ class InvoiceTransformer extends BaseTransformer {
],
];
}
nlog($transformed);
return $transformed;
}

View File

@ -28,7 +28,6 @@ class ClientTransformer extends BaseTransformer {
if ( isset( $data['Client Name'] ) && $this->hasClient( $data['Client Name'] ) ) {
throw new ImportException('Client already exists');
}
nlog($data);
$transformed = [
'company_id' => $this->company->id,

View File

@ -267,8 +267,8 @@ class BraintreePaymentDriver extends BaseDriver
nlog("braintree webhook");
if($webhookNotification)
nlog($webhookNotification->kind);
// if($webhookNotification)
// nlog($webhookNotification->kind);
// // Example values for webhook notification properties
// $message = $webhookNotification->kind; // "subscription_went_past_due"

View File

@ -57,7 +57,7 @@ class Token
$header['signature'] = $this->payfast->generateTokenSignature(array_merge($body, $header));
nlog($header['signature']);
// nlog($header['signature']);
$result = $this->send($header, $body, $cgt->token);
@ -95,7 +95,7 @@ class Token
$parameter_string = rtrim( $parameter_string, '&' );
}
nlog($parameter_string);
// nlog($parameter_string);
return $parameter_string;

View File

@ -47,7 +47,7 @@ use WePayCommon;
$data = $request->all();
// authorize the credit card
nlog($data);
// nlog($data);
/*
'_token' => '1Fk5CRj34up5ntKPvrFyMIAJhDdUNF3boqT3iIN3',
'company_gateway_id' => '39',

View File

@ -46,8 +46,6 @@ class GetCreditPdf extends AbstractService
$file_path = CreateEntityPdf::dispatchNow($this->invitation);
nlog($file_path);
return $file_path;
// return Storage::disk($disk)->path($file_path);
}
}