mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 05:44:36 -04:00
Apply php-cs-fixer
This commit is contained in:
parent
7764833037
commit
5a8dfd85eb
@ -12,7 +12,6 @@
|
||||
namespace App\Http\Requests\Invoice;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\Invoice\UniqueInvoiceNumberRule;
|
||||
use App\Http\ValidationRules\Project\ValidProjectForClient;
|
||||
use App\Models\Invoice;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
|
@ -55,4 +55,3 @@ class PaymentMap
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,32 +60,33 @@ class BaseTransformer
|
||||
if ($code) {
|
||||
$currency = $this->maps['currencies']->where('code', $code)->first();
|
||||
|
||||
if($currency_id)
|
||||
if ($currency_id) {
|
||||
return $currency->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->maps['company']->settings->currency_id;
|
||||
}
|
||||
|
||||
public function getClient($client_name, $client_email)
|
||||
{
|
||||
|
||||
$clients = $this->maps['company']->clients;
|
||||
|
||||
$clients = $clients->where('name', $client_name);
|
||||
|
||||
if($clients->count() >= 1)
|
||||
if ($clients->count() >= 1) {
|
||||
return $clients->first()->id;
|
||||
}
|
||||
|
||||
|
||||
$contacts = ClientContact::where('company_id', $this->maps['company']->id)
|
||||
->where('email', $client_email);
|
||||
|
||||
if($contacts->count() >=1)
|
||||
if ($contacts->count() >=1) {
|
||||
return $contacts->first()->client_id;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -148,11 +149,11 @@ class BaseTransformer
|
||||
*/
|
||||
public function getFloat($data, $field)
|
||||
{
|
||||
|
||||
if(array_key_exists($field, $data))
|
||||
if (array_key_exists($field, $data)) {
|
||||
$number = preg_replace('/[^0-9-.]+/', '', $data[$field]);
|
||||
else
|
||||
} else {
|
||||
$number = 0;
|
||||
}
|
||||
|
||||
return Number::parseStringFloat($number);
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class InvoiceItemTransformer.
|
||||
*/
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class InvoiceTransformer.
|
||||
*/
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class PaymentTransformer.
|
||||
*/
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ProductTransformer.
|
||||
*/
|
||||
|
@ -103,7 +103,6 @@ class CSVImport implements ShouldQueue
|
||||
info("errors");
|
||||
|
||||
info(print_r($this->error_array, 1));
|
||||
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
@ -116,15 +115,15 @@ class CSVImport implements ShouldQueue
|
||||
|
||||
private function importInvoice()
|
||||
{
|
||||
|
||||
$invoice_transformer = new InvoiceTransformer($this->maps);
|
||||
|
||||
$records = $this->getCsvData();
|
||||
|
||||
$invoice_number_key = array_search('Invoice Number', reset($records));
|
||||
|
||||
if ($this->skip_header)
|
||||
if ($this->skip_header) {
|
||||
array_shift($records);
|
||||
}
|
||||
|
||||
if (!$invoice_number_key) {
|
||||
info("no invoice number to use as key - returning");
|
||||
@ -134,14 +133,11 @@ class CSVImport implements ShouldQueue
|
||||
$unique_invoices = [];
|
||||
|
||||
//get an array of unique invoice numbers
|
||||
foreach($records as $key => $value)
|
||||
{
|
||||
foreach ($records as $key => $value) {
|
||||
$unique_invoices[] = $value[$invoice_number_key];
|
||||
}
|
||||
|
||||
foreach($unique_invoices as $unique)
|
||||
{
|
||||
|
||||
foreach ($unique_invoices as $unique) {
|
||||
$invoices = array_filter($records, function ($value) use ($invoice_number_key, $unique) {
|
||||
return $value[$invoice_number_key] == $unique;
|
||||
});
|
||||
@ -153,9 +149,7 @@ class CSVImport implements ShouldQueue
|
||||
$invoice = $invoice_transformer->transform($invoice_data);
|
||||
|
||||
$this->processInvoice($invoices, $invoice);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function processInvoice($invoices, $invoice)
|
||||
@ -164,15 +158,12 @@ class CSVImport implements ShouldQueue
|
||||
$item_transformer = new InvoiceItemTransformer($this->maps);
|
||||
$items = [];
|
||||
|
||||
foreach($invoices as $record)
|
||||
{
|
||||
|
||||
foreach ($invoices as $record) {
|
||||
$keys = $this->column_map;
|
||||
$values = array_intersect_key($record, $this->column_map);
|
||||
$invoice_data = array_combine($keys, $values);
|
||||
|
||||
$items[] = $item_transformer->transform($invoice_data);
|
||||
|
||||
}
|
||||
|
||||
$invoice['line_items'] = $this->cleanItems($items);
|
||||
@ -182,7 +173,6 @@ class CSVImport implements ShouldQueue
|
||||
if ($validator->fails()) {
|
||||
$this->error_array[] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())];
|
||||
} else {
|
||||
|
||||
$invoice = $invoice_repository->save($invoice, InvoiceFactory::create($this->company->id, $this->setUser($record)));
|
||||
|
||||
$this->maps['invoices'][] = $invoice->id;
|
||||
@ -193,7 +183,6 @@ class CSVImport implements ShouldQueue
|
||||
|
||||
private function performInvoiceActions($invoice, $record, $invoice_repository)
|
||||
{
|
||||
|
||||
$invoice = $this->actionInvoiceStatus($invoice, $record, $invoice_repository);
|
||||
}
|
||||
|
||||
@ -207,7 +196,7 @@ class CSVImport implements ShouldQueue
|
||||
case 'Sent':
|
||||
$invoice = $invoice->service()->markSent()->save();
|
||||
break;
|
||||
case 'Viewed';
|
||||
case 'Viewed':
|
||||
$invoice = $invoice->service()->markSent()->save();
|
||||
break;
|
||||
default:
|
||||
@ -233,11 +222,11 @@ class CSVImport implements ShouldQueue
|
||||
$client_repository = new ClientRepository($contact_repository);
|
||||
$client_transformer = new ClientTransformer($this->maps);
|
||||
|
||||
if ($this->skip_header)
|
||||
if ($this->skip_header) {
|
||||
array_shift($records);
|
||||
}
|
||||
|
||||
foreach ($records as $record) {
|
||||
|
||||
$keys = $this->column_map;
|
||||
$values = array_intersect_key($record, $this->column_map);
|
||||
|
||||
@ -270,17 +259,16 @@ class CSVImport implements ShouldQueue
|
||||
|
||||
private function importProduct()
|
||||
{
|
||||
|
||||
$product_repository = new ProductRepository();
|
||||
$product_transformer = new ProductTransformer($this->maps);
|
||||
|
||||
$records = $this->getCsvData();
|
||||
|
||||
if ($this->skip_header)
|
||||
if ($this->skip_header) {
|
||||
array_shift($records);
|
||||
}
|
||||
|
||||
foreach ($records as $record)
|
||||
{
|
||||
foreach ($records as $record) {
|
||||
$keys = $this->column_map;
|
||||
$values = array_intersect_key($record, $this->column_map);
|
||||
|
||||
|
@ -16,7 +16,6 @@ use App\Exceptions\PaymentFailed;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Jobs\Mail\PaymentFailureMailer;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
|
@ -29,7 +29,6 @@ use App\PaymentDrivers\Stripe\Utilities;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Exception;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\View\View;
|
||||
use Stripe\Customer;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
use Stripe\PaymentIntent;
|
||||
|
@ -94,8 +94,9 @@ class HandleRestore extends AbstractService
|
||||
|
||||
$new_invoice_number = substr($this->invoice->number, 0, $pos);
|
||||
|
||||
if(strlen($new_invoice_number) == 0)
|
||||
if (strlen($new_invoice_number) == 0) {
|
||||
$new_invoice_number = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->invoice->number = $new_invoice_number;
|
||||
|
@ -30,6 +30,3 @@ class ChangeProductsTableCostResolution extends Migration
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,7 +150,6 @@ class ImportCsvTest extends TestCase
|
||||
CSVImport::dispatchNow($data, $this->company);
|
||||
|
||||
$this->assertGreaterThan($pre_import, Product::count());
|
||||
|
||||
}
|
||||
|
||||
private function getCsvData($csvfile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user