mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Apply php-cs-fixer
This commit is contained in:
parent
7764833037
commit
5a8dfd85eb
@ -112,8 +112,8 @@ class InvoiceItemSum
|
||||
{
|
||||
$item_tax = 0;
|
||||
|
||||
// info(print_r($this->item,1));
|
||||
// info(print_r($this->invoice,1));
|
||||
// info(print_r($this->item,1));
|
||||
// info(print_r($this->invoice,1));
|
||||
|
||||
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / 100));
|
||||
$item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount);
|
||||
|
@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class BaseTransformer
|
||||
|
||||
public function getInvoiceTypeId($data, $field)
|
||||
{
|
||||
return (isset($data[$field]) && $data[$field]) ? $data[$field] : '1';
|
||||
return (isset($data[$field]) && $data[$field]) ? $data[$field] : '1';
|
||||
}
|
||||
|
||||
public function getCurrencyByCode($data)
|
||||
@ -60,8 +60,9 @@ 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;
|
||||
@ -69,28 +70,28 @@ class BaseTransformer
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
@ -147,12 +148,12 @@ class BaseTransformer
|
||||
* @return float
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -45,4 +43,4 @@ class InvoiceItemTransformer extends BaseTransformer
|
||||
'type_id' => $this->getInvoiceTypeId($data, 'item.type_id'),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class InvoiceTransformer.
|
||||
*/
|
||||
@ -60,4 +58,4 @@ class InvoiceTransformer extends BaseTransformer
|
||||
'exchange_rate' => $this->getString($data, 'invoice.exchange_rate'),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class PaymentTransformer.
|
||||
*/
|
||||
@ -45,4 +43,4 @@ class PaymentTransformer extends BaseTransformer
|
||||
'method' => $this
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ProductTransformer.
|
||||
*/
|
||||
|
@ -102,8 +102,7 @@ class CSVImport implements ShouldQueue
|
||||
|
||||
info("errors");
|
||||
|
||||
info(print_r($this->error_array,1));
|
||||
|
||||
info(print_r($this->error_array, 1));
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
@ -116,17 +115,17 @@ 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){
|
||||
if (!$invoice_number_key) {
|
||||
info("no invoice number to use as key - returning");
|
||||
return;
|
||||
}
|
||||
@ -134,15 +133,12 @@ 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)
|
||||
{
|
||||
|
||||
$invoices = array_filter($records, function($value) use($invoice_number_key, $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,36 +158,31 @@ 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);
|
||||
|
||||
$validator = Validator::make($invoice, (new StoreInvoiceRequest())->rules());
|
||||
$validator = Validator::make($invoice, (new StoreInvoiceRequest())->rules());
|
||||
|
||||
if ($validator->fails()) {
|
||||
$this->error_array[] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())];
|
||||
} else {
|
||||
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)));
|
||||
|
||||
$invoice = $invoice_repository->save($invoice, InvoiceFactory::create($this->company->id, $this->setUser($record)));
|
||||
$this->maps['invoices'][] = $invoice->id;
|
||||
|
||||
$this->maps['invoices'][] = $invoice->id;
|
||||
|
||||
$this->performInvoiceActions($invoice, $record, $invoice_repository);
|
||||
}
|
||||
$this->performInvoiceActions($invoice, $record, $invoice_repository);
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
@ -215,7 +204,7 @@ class CSVImport implements ShouldQueue
|
||||
break;
|
||||
}
|
||||
|
||||
if($invoice->balance < $invoice->amount && $invoice->status_id <= Invoice::STATUS_SENT){
|
||||
if ($invoice->balance < $invoice->amount && $invoice->status_id <= Invoice::STATUS_SENT) {
|
||||
$invoice->status_id = Invoice::STATUS_PARTIAL;
|
||||
$invoice->save();
|
||||
}
|
||||
@ -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;
|
||||
|
@ -7,7 +7,7 @@ return [
|
||||
'production' => env('NINJA_PROD', false),
|
||||
'license' => env('NINJA_LICENSE', ''),
|
||||
'version_url' => 'https://raw.githubusercontent.com/invoiceninja/invoiceninja/v5-stable/VERSION.txt',
|
||||
'app_name' => env('APP_NAME','Invoice Ninja'),
|
||||
'app_name' => env('APP_NAME', 'Invoice Ninja'),
|
||||
'app_env' => env('APP_ENV', 'selfhosted'),
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
|
@ -30,6 +30,3 @@ class ChangeProductsTableCostResolution extends Migration
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ class CountriesSeeder extends Seeder
|
||||
'sub_region_code' => $country['sub-region-code'],
|
||||
'eea' => (bool) $country['eea'],
|
||||
'thousand_separator' => '',
|
||||
'decimal_separator' => '',
|
||||
'decimal_separator' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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