Merge pull request #7399 from turbo124/v5-stable

v5.3.84
This commit is contained in:
David Bomba 2022-04-27 09:56:36 +10:00 committed by GitHub
commit f7cdba652a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 488661 additions and 486968 deletions

View File

@ -1 +1 @@
5.3.83
5.3.84

View File

@ -271,8 +271,10 @@ class CompanySettings extends BaseSettings
public $use_credits_payment = 'off'; //always, option, off //@implemented
public $hide_empty_columns_on_pdf = false;
public $email_from_name = '';
public $auto_archive_invoice_cancelled = false;
public static $casts = [
'auto_archive_invoice_cancelled' => 'bool',
'email_from_name' => 'string',
'show_all_tasks_client_portal' => 'string',
'entity_send_time' => 'int',

View File

@ -138,6 +138,18 @@ class InvoiceFilters extends QueryFilters
});
}
public function payable(string $client_id)
{
if (strlen($client_id) == 0) {
return $this->builder;
}
return $this->builder->whereIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
->where('balance', '>', 0)
->where('is_deleted', 0)
->where('client_id', $this->decodePrimaryKey($client_id));
}
/**
* Sorts the list based on $sort.
*

View File

@ -107,6 +107,8 @@ class ClientController extends BaseController
*/
public function index(ClientFilters $filters)
{
set_time_limit(45);
$clients = Client::filter($filters);
return $this->listResponse($clients);

View File

@ -119,6 +119,8 @@ class InvoiceController extends BaseController
*/
public function index(InvoiceFilters $filters)
{
set_time_limit(45);
$invoices = Invoice::filter($filters);
return $this->listResponse($invoices);

View File

@ -111,6 +111,7 @@ class SelfUpdateController extends BaseController
}
$this->testWritable();
$this->clearCacheDir();
copy($this->getDownloadUrl(), storage_path('app/invoiceninja.zip'));
@ -158,6 +159,19 @@ class SelfUpdateController extends BaseController
}
}
private function clearCacheDir()
{
$directoryIterator = new \RecursiveDirectoryIterator(base_path('bootstrap/cache'), \RecursiveDirectoryIterator::SKIP_DOTS);
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
unlink(base_path('bootstrap/cache/').$file->getFileName());
}
}
private function testWritable()
{
$directoryIterator = new \RecursiveDirectoryIterator(base_path(), \RecursiveDirectoryIterator::SKIP_DOTS);

View File

@ -158,7 +158,11 @@ class UpdateClientRequest extends Request
unset($settings->{$key});
}
if($key == 'default_task_rate'){
//26-04-2022 - In case settings are returned as array instead of object
if($key == 'default_task_rate' && is_array($settings)){
$settings['default_task_rate'] = floatval($value);
}
elseif($key == 'default_task_rate' && is_object($settings)) {
$settings->default_task_rate = floatval($value);
}
}

View File

@ -181,6 +181,65 @@ class BaseImport
} catch (\Exception $ex) {
if(\DB::connection(config('database.default'))->transactionLevel() > 0)
\DB::connection(config('database.default'))->rollBack();
if ($ex instanceof ImportException) {
$message = $ex->getMessage();
} else {
report($ex);
$message = 'Unknown error';
}
$this->error_array[$entity_type][] = [
$entity_type => $record,
'error' => $message,
];
}
}
return $count;
}
public function ingestProducts($data, $entity_type)
{
$count = 0;
foreach ($data as $key => $record) {
try {
$entity = $this->transformer->transform($record);
$validator = $this->request_name::runFormRequest($entity);
if ($validator->fails()) {
$this->error_array[$entity_type][] = [
$entity_type => $record,
'error' => $validator->errors()->all(),
];
} else {
if($this->transformer->hasProduct($entity['product_key']))
$product = $this->transformer->getProduct($entity['product_key']);
else
$product = $this->factory_name::create($this->company->id,$this->getUserIDForRecord($entity));
$entity = $this->repository->save(
array_diff_key($entity, ['user_id' => false]),
$product
);
$entity->saveQuietly();
$count++;
}
} catch (\Exception $ex) {
if(\DB::connection(config('database.default'))->transactionLevel() > 0)
\DB::connection(config('database.default'))->rollBack();
if ($ex instanceof ImportException) {
$message = $ex->getMessage();
} else {
@ -309,6 +368,10 @@ class BaseImport
);
}
} catch (\Exception $ex) {
if(\DB::connection(config('database.default'))->transactionLevel() > 0)
\DB::connection(config('database.default'))->rollBack();
if ($ex instanceof ImportException) {
$message = $ex->getMessage();
} else {

View File

@ -116,7 +116,7 @@ class Csv extends BaseImport implements ImportInterface
$this->transformer = new ProductTransformer($this->company);
$product_count = $this->ingest($data, $entity_type);
$product_count = $this->ingestProducts($data, $entity_type);
$this->entity_count['products'] = $product_count;
}

View File

@ -199,20 +199,16 @@ class BaseTransformer
*
* @return string
*/
public function getProduct($data, $key, $field, $default = false)
public function getProduct($key)
{
$product = $this->company
->products()
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $data->{$key})),
strtolower(str_replace(' ', '', $key)),
])
->first();
if ($product) {
return $product->{$field} ?: $default;
}
return $default;
return $product;
}
/**

View File

@ -241,7 +241,6 @@ class Import implements ShouldQueue
$this->company->account->companies()->update(['is_large' => true]);
}
$this->company->client_registration_fields = \App\DataMapper\ClientRegistrationFields::generate();
$this->company->save();
@ -948,6 +947,11 @@ class Import implements ShouldQueue
RecurringInvoiceFactory::create($this->company->id, $modified['user_id'])
);
if($invoice->status_id == 4 && $invoice->remaining_cycles == -1){
$invoice->status_id =2;
$invoice->save();
}
$key = "recurring_invoices_{$resource['id']}";
$this->ids['recurring_invoices'][$key] = [

View File

@ -50,7 +50,10 @@ class CompanyDeleted extends Mailable
public function build()
{
App::forgetInstance('translator');
App::setLocale($this->account->default_company->getLocale());
if($this->company)
App::setLocale($this->company->getLocale());
$t = app('translator');
$t->replace(Ninja::transformTranslations($this->settings));

View File

@ -30,7 +30,8 @@ class SupportMessageSent extends Mailable
*/
public function build()
{
$system_info = null;
$system_info = request()->has('version') ? 'Version: '.request()->input('version') : 'Version: No Version Supplied.';
$log_lines = [];
/*

View File

@ -479,7 +479,6 @@ class Company extends BaseModel
public function owner()
{
return $this->company_users()->withTrashed()->where('is_owner', true)->first()->user;
//return $this->company_users->where('is_owner', true)->first()->user;
}
public function resolveRouteBinding($value, $field = null)

View File

@ -159,7 +159,7 @@ class Gateway extends StaticModel
break;
case 52:
return [
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']], // GoCardless
GatewayType::BANK_TRANSFER => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']], // GoCardless
GatewayType::DIRECT_DEBIT => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
GatewayType::SEPA => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
GatewayType::INSTANT_BANK_PAY => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],

View File

@ -176,7 +176,7 @@ class AuthorizePaymentMethod
$billto->setCountry($this->authorize->client->country->name);
}
$billto->setPhoneNumber($this->authorize->client->phone);
$billto->setPhoneNumber(substr($this->authorize->client->phone,0,20));
}
// Create a new Customer Payment Profile object

View File

@ -445,7 +445,7 @@ class StripePaymentDriver extends BaseDriver
if(count($searchResults) == 1){
$customer = $searchResults->data[0];
$this->updateStripeCustomer($customer);
// $this->updateStripeCustomer($customer);
return $customer;
}

View File

@ -186,7 +186,7 @@ class PaymentRepository extends BaseRepository {
TransactionLog::dispatch(TransactionEvent::PAYMENT_MADE, $transaction, $payment->company->db);
return $payment->fresh();
return $payment->refresh();
}
/**

View File

@ -52,6 +52,8 @@ class HandleCancellation extends AbstractService
//adjust client balance
$this->invoice->client->service()->updateBalance($adjustment)->save();
$this->invoice->service()->workFlow()->save();
event(new InvoiceWasCancelled($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
$transaction = [

View File

@ -546,6 +546,19 @@ class InvoiceService
event(new InvoiceWasArchived($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
}
if ($this->invoice->status_id == Invoice::STATUS_CANCELLED && $this->invoice->client->getSetting('auto_archive_invoice_cancelled')) {
/* Throws: Payment amount xxx does not match invoice totals. */
if ($this->invoice->trashed())
return $this;
$this->invoice->delete();
event(new InvoiceWasArchived($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
}
return $this;

View File

@ -105,7 +105,7 @@ class MarkPaid extends AbstractService
/* Get the last record for the client and set the current balance*/
$client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first();
$client->paid_to_date += $payment->amount;
$client->balance += $payment->amount * -1;
$client->balance -= $payment->amount;
$client->save();
}, 1);

View File

@ -51,7 +51,7 @@ class TriggeredActions extends AbstractService
}
if ($this->request->has('approve') && $this->request->input('approve') == 'true' && in_array($this->quote->status_id, [Quote::STATUS_SENT, Quote::STATUS_DRAFT])) {
$this->quote = $this->quote->service()->convert()->save();
$this->quote = $this->quote->service()->approveWithNoCoversion()->save();
}

View File

@ -213,9 +213,9 @@ class HtmlEngine
$data['$gross_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getGrossSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
if($this->entity->uses_inclusive_taxes)
$data['$net_subtotal'] = ['value' => Number::formatMoney(($this->entity_calc->getSubTotal() - $this->entity->total_taxes), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
$data['$net_subtotal'] = ['value' => Number::formatMoney(($this->entity_calc->getSubTotal() - $this->entity->total_taxes - $this->entity_calc->getTotalDiscount()), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
else
$data['$net_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
$data['$net_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal() - $this->entity_calc->getTotalDiscount(), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
$data['$invoice.subtotal'] = &$data['$subtotal'];

View File

@ -48,7 +48,8 @@ class Ninja
'White Label: '.'\\n'. // TODO: Implement white label with hasFeature.
'Server OS: '.php_uname('s').' '.php_uname('r').'\\n'.
'PHP Version: '.phpversion().'\\n'.
'MySQL Version: '.$mysql_version;
'MySQL Version: '.$mysql_version.'\\n'.
'Version: '. request()->has('version') ? request()->input('version') : 'No Version Supplied.';
return $info;
}

View File

@ -81,9 +81,31 @@ class SystemHealth
'pdf_engine' => (string) self::getPdfEngine(),
'queue' => (string) config('queue.default'),
'trailing_slash' => (bool) self::checkUrlState(),
'file_permissions' => (string) self::checkFileSystem()
];
}
public static function checkFileSystem()
{
$directoryIterator = new \RecursiveDirectoryIterator(base_path(), \RecursiveDirectoryIterator::SKIP_DOTS);
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
if(strpos($file->getPathname(), '.git') !== false)
continue;
//nlog($file->getPathname());
if ($file->isFile() && ! $file->isWritable()) {
return "{$file->getFileName()} is not writable";
}
}
return 'Ok';
}
public static function checkUrlState()
{
if (env('APP_URL') && substr(env('APP_URL'), -1) == '/')

View File

@ -301,17 +301,29 @@ trait MakesInvoiceValues
$data[$key][$table_type . ".{$_table_type}2"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}2", $item->custom_value2, $this->client);
$data[$key][$table_type . ".{$_table_type}3"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}3", $item->custom_value3, $this->client);
$data[$key][$table_type . ".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->client);
// 08-02-2022 - fix for regression below
// $data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
$data[$key][$table_type.'.quantity'] = ($item->quantity == 0) ? '' : Number::formatValueNoTrailingZeroes($item->quantity, $this->client->currency());
$data[$key][$table_type.'.unit_cost'] = ($item->cost == 0) ? '' : Number::formatMoneyNoRounding($item->cost, $this->client);
if($item->quantity > 0 || $item->cost > 0){
$data[$key][$table_type.'.cost'] = ($item->cost == 0) ? '' : Number::formatMoney($item->cost, $this->client);
$data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $this->client->currency());
$data[$key][$table_type.'.unit_cost'] = Number::formatMoneyNoRounding($item->cost, $this->client);
$data[$key][$table_type.'.line_total'] = ($item->line_total == 0) ? '' :Number::formatMoney($item->line_total, $this->client);
$data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);
$data[$key][$table_type.'.line_total'] = Number::formatMoney($item->line_total, $this->client);
}
else {
$data[$key][$table_type.'.quantity'] = '';
$data[$key][$table_type.'.unit_cost'] = '';
$data[$key][$table_type.'.cost'] = '';
$data[$key][$table_type.'.line_total'] = '';
}
if(property_exists($item, 'gross_line_total'))
$data[$key][$table_type.'.gross_line_total'] = ($item->gross_line_total == 0) ? '' :Number::formatMoney($item->gross_line_total, $this->client);

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.3.83',
'app_tag' => '5.3.83',
'app_version' => '5.3.84',
'app_tag' => '5.3.84',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -0,0 +1,191 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ConvertCustomFieldsColumnFromVarcharToText extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
set_time_limit(0);
Schema::table('credits', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('client_contacts', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('clients', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('clients', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('documents', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('expenses', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('invoices', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('payments', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('products', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('projects', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('quotes', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('recurring_invoices', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('recurring_quotes', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('recurring_expenses', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('tasks', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('users', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('vendors', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
Schema::table('vendor_contacts', function (Blueprint $table) {
$table->text('custom_value1')->change();
$table->text('custom_value2')->change();
$table->text('custom_value3')->change();
$table->text('custom_value3')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"main.dart.js": "6d052e2fe47482bbfea552235cfc5a18",
"/": "e723e8a61f771fed887c7c05674883e9",
"main.dart.js": "7abb94393ec49f70a4fa58f38a6a4535",
"/": "525081efee69feb38a726fae7d7fc27c",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"assets/fonts/MaterialIcons-Regular.otf": "7e7a6cccddf6d7b20012a548461d5d81",
"assets/AssetManifest.json": "38d9aea341601f3a5c6fa7b5a1216ea5",

240182
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

241684
public/main.foss.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

236204
public/main.html.dart.js vendored

File diff suppressed because one or more lines are too long

241308
public/main.next.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4562,6 +4562,11 @@ $LANG = array(
'approved_quotes' => 'Successfully :value approved quotes',
'client_website' => 'Client Website',
'invalid_time' => 'Invalid Time',
'signed_in_as' => 'Signed in as',
'total_results' => 'Total results',
'restore_company_gateway' => 'Restore payment gateway',
'archive_company_gateway' => 'Archive payment gateway',
'delete_company_gateway' => 'Delete payment gateway',
);
return $LANG;

View File

@ -22,6 +22,7 @@ use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use Tests\MockAccountData;
use Tests\TestCase;
@ -34,12 +35,14 @@ class ZohoTest extends TestCase
{
use MakesHash;
use MockAccountData;
use DatabaseTransactions;
// use DatabaseTransactions;
public function setUp(): void
{
parent::setUp();
Session::start();
$this->withoutMiddleware(ThrottleRequests::class);
config(['database.default' => config('ninja.db.default')]);
@ -120,7 +123,7 @@ class ZohoTest extends TestCase
Cache::put($hash . '-client', base64_encode($csv), 360);
$csv_importer = new Zoho($data, $this->company);
$count = $csv_importer->import('client');
$base_transformer = new BaseTransformer($this->company);