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