1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 17:01:33 +02:00

Fixes for setup screen workflow. (#3763)

* Place checks on quote 'isConvertable()'

* Improvements to quality of test data

* fixes for invoices not generating invoice numbers on payment

* Set due date when invoice is marked as sent

* Adjustments for setup page

* Fixes for setup page flow
This commit is contained in:
David Bomba 2020-05-28 19:42:43 +10:00 committed by GitHub
commit c4ecc58226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 12 deletions

View File

@ -15,15 +15,16 @@ use Exception;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
use Illuminate\Database\Eloquent\RelationNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Schema;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Sentry\State\Scope;
use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\Debug\Exception\FatalThrowableError;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Database\Eloquent\RelationNotFoundException;
use Sentry\State\Scope;
use function Sentry\configureScope; use function Sentry\configureScope;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
@ -55,9 +56,12 @@ class Handler extends ExceptionHandler
*/ */
public function report(Exception $exception) public function report(Exception $exception)
{ {
if(!Schema::hasTable('accounts'))
return;
if (app()->bound('sentry') && $this->shouldReport($exception)) { if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->configureScope(function (Scope $scope): void { app('sentry')->configureScope(function (Scope $scope): void {
if (auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) { if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) {
$scope->setUser([ $scope->setUser([
'id' => auth()->guard('contact')->user()->company->account->key, 'id' => auth()->guard('contact')->user()->company->account->key,
'email' => "anonymous@example.com", 'email' => "anonymous@example.com",

View File

@ -23,6 +23,7 @@ use App\Utils\Traits\AppSetup;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request as Input; use Illuminate\Support\Facades\Request as Input;
use Illuminate\Support\Facades\Schema;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection; use League\Fractal\Resource\Collection;
@ -319,10 +320,10 @@ class BaseController extends Controller
// return redirect()->secure(request()->path()); // return redirect()->secure(request()->path());
// } // }
if ((bool)$this->checkAppSetup() !== false) { if ((bool)$this->checkAppSetup() !== false && Schema::hasTable('accounts') && $account = Account::all()->first()) {
$data = []; $data = [];
if (Ninja::isSelfHost() && $account = Account::all()->first()) { if (Ninja::isSelfHost()) {
$data['report_errors'] = $account->report_errors; $data['report_errors'] = $account->report_errors;
} else { } else {
$data['report_errors'] = true; $data['report_errors'] = true;

View File

@ -62,6 +62,8 @@ class ApplyPayment extends AbstractService
$this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1); $this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1);
} }
$this->invoice->service()->applyNumber()->save();
return $this->invoice; return $this->invoice;
} }
} }

View File

@ -139,8 +139,13 @@ class InvoiceService
/* One liners */ /* One liners */
public function setDueDate() public function setDueDate()
{ {
$this->invoice->due_date = Carbon::now()->addDays($this->invoice->client->getSetting('payment_terms')); if($this->invoice->due_date != '')
return $this;
//$this->invoice->due_date = Carbon::now()->addDays($this->invoice->client->getSetting('payment_terms'));
$this->invoice->due_date = Carbon::parse($this->invoice->date)->addDays($this->invoice->client->getSetting('payment_terms'));
return $this; return $this;
} }

View File

@ -61,6 +61,7 @@ class MarkPaid extends AbstractService
$this->invoice->service() $this->invoice->service()
->updateBalance($payment->amount*-1) ->updateBalance($payment->amount*-1)
->setStatus(Invoice::STATUS_PAID) ->setStatus(Invoice::STATUS_PAID)
->applyNumber()
->save(); ->save();
/* Update Invoice balance */ /* Update Invoice balance */

View File

@ -45,6 +45,7 @@ class MarkSent extends AbstractService
->service() ->service()
->setStatus(Invoice::STATUS_SENT) ->setStatus(Invoice::STATUS_SENT)
->applyNumber() ->applyNumber()
->setDueDate()
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->client->service()->updateBalance($this->invoice->balance)->save();

View File

@ -13,7 +13,7 @@ $factory->define(App\Models\Client::class, function (Faker $faker) {
'paid_to_date' => 0, 'paid_to_date' => 0,
'vat_number' => $faker->text(25), 'vat_number' => $faker->text(25),
'id_number' => '', 'id_number' => '',
'custom_value1' => 'date|'.$faker->date('Y-m-d'), 'custom_value1' => $faker->date('Y-m-d'),
'custom_value2' => '', 'custom_value2' => '',
'custom_value3' => '', 'custom_value3' => '',
'custom_value4' => '', 'custom_value4' => '',

View File

@ -17,7 +17,7 @@
<summary class="cursor-pointer focus:outline-none">Show code</summary> <summary class="cursor-pointer focus:outline-none">Show code</summary>
<pre class="text-sm overflow-y-scroll bg-gray-100 p-4"> <pre class="text-sm overflow-y-scroll bg-gray-100 p-4">
-- Commands to create a MySQL database and user -- Commands to create a MySQL database and user
CREATE SCHEMA `ninja` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE SCHEMA `db-ninja-01` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'ninja'@'localhost' IDENTIFIED BY 'ninja'; CREATE USER 'ninja'@'localhost' IDENTIFIED BY 'ninja';
GRANT ALL PRIVILEGES ON `ninja`.* TO 'ninja'@'localhost'; GRANT ALL PRIVILEGES ON `ninja`.* TO 'ninja'@'localhost';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
@ -38,7 +38,7 @@ FLUSH PRIVILEGES;
{{ ctrans('texts.host') }}* {{ ctrans('texts.host') }}*
</dt> </dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2"> <dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="text" class="input w-full" name="host" required value="{{ old('host') }}"> <input type="text" class="input w-full" name="host" required value="{{ old('host') ?: 'localhost'}}">
</dd> </dd>
</div> </div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center"> <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
@ -46,7 +46,7 @@ FLUSH PRIVILEGES;
{{ ctrans('texts.database') }}* {{ ctrans('texts.database') }}*
</dt> </dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2"> <dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="text" class="input w-full" name="database" required value="{{ old('database') }}"> <input type="text" class="input w-full" name="database" required value="{{ old('database') ?: 'db-ninja-01'}}">
</dd> </dd>
</div> </div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center"> <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
@ -54,7 +54,7 @@ FLUSH PRIVILEGES;
{{ ctrans('texts.username') }}* {{ ctrans('texts.username') }}*
</dt> </dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2"> <dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="text" class="input w-full" name="db_username" required value="{{ old('db_username') }}"> <input type="text" class="input w-full" name="db_username" required value="{{ old('db_username') ?: 'ninja' }}">
</dd> </dd>
</div> </div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center"> <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
@ -62,7 +62,7 @@ FLUSH PRIVILEGES;
{{ ctrans('texts.password') }} {{ ctrans('texts.password') }}
</dt> </dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2"> <dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="password" class="input w-full" name="db_password" value="{{ old('db_password') }}"> <input type="password" class="input w-full" name="db_password" value="{{ old('db_password') ?: 'ninja' }}">
</dd> </dd>
</div> </div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center"> <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">