1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for type checking for purchase orders

This commit is contained in:
David Bomba 2022-07-01 16:56:36 +10:00
parent 20f2d09326
commit 9ae0474de3
5 changed files with 33 additions and 6 deletions

View File

@ -138,6 +138,14 @@ class InvoiceFilters extends QueryFilters
}); });
} }
public function without_deleted_clients()
{
return $this->builder->whereHas('client', function ($query) {
$query->where('is_deleted',0);
});
}
public function upcoming() public function upcoming()
{ {
return $this->builder return $this->builder

View File

@ -14,12 +14,15 @@ namespace App\Http\Requests\PurchaseOrder;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\PurchaseOrder; use App\Models\PurchaseOrder;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
class StorePurchaseOrderRequest extends Request class StorePurchaseOrderRequest extends Request
{ {
use MakesHash; use MakesHash;
use CleanLineItems;
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
@ -43,8 +46,6 @@ class StorePurchaseOrderRequest extends Request
$rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', auth()->user()->company()->id)]; $rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', auth()->user()->company()->id)];
$rules['discount'] = 'sometimes|numeric'; $rules['discount'] = 'sometimes|numeric';
$rules['is_amount_discount'] = ['boolean']; $rules['is_amount_discount'] = ['boolean'];
$rules['line_items'] = 'array'; $rules['line_items'] = 'array';
return $rules; return $rules;
@ -56,6 +57,12 @@ class StorePurchaseOrderRequest extends Request
$input = $this->decodePrimaryKeys($input); $input = $this->decodePrimaryKeys($input);
if (isset($input['line_items']) && is_array($input['line_items']))
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
$input['amount'] = 0;
$input['balance'] = 0;
$this->replace($input); $this->replace($input);
} }

View File

@ -14,6 +14,7 @@ namespace App\Http\Requests\PurchaseOrder;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Utils\Traits\ChecksEntityStatus; use App\Utils\Traits\ChecksEntityStatus;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
@ -21,6 +22,7 @@ class UpdatePurchaseOrderRequest extends Request
{ {
use ChecksEntityStatus; use ChecksEntityStatus;
use MakesHash; use MakesHash;
use CleanLineItems;
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
@ -57,6 +59,10 @@ class UpdatePurchaseOrderRequest extends Request
$input['id'] = $this->purchase_order->id; $input['id'] = $this->purchase_order->id;
if (isset($input['line_items']) && is_array($input['line_items'])) {
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
}
$this->replace($input); $this->replace($input);
} }
} }

View File

@ -318,13 +318,14 @@ class NinjaMailerJob implements ShouldQueue
return true; return true;
/* GMail users are uncapped */ /* GMail users are uncapped */
if(Ninja::isHosted() && $this->nmo->settings->email_sending_method == 'gmail') if(Ninja::isHosted() && ($this->nmo->settings->email_sending_method == 'gmail' || $this->nmo->settings->email_sending_method == 'office365'))
return false; return false;
/* On the hosted platform, if the user is over the email quotas, we do not send the email. */ /* On the hosted platform, if the user is over the email quotas, we do not send the email. */
if(Ninja::isHosted() && $this->company->account && $this->company->account->emailQuotaExceeded()) if(Ninja::isHosted() && $this->company->account && $this->company->account->emailQuotaExceeded())
return true; return true;
/* To handle spam users we drop all emails from flagged accounts */
if(Ninja::isHosted() && $this->company->account && $this->nmo->company->account->is_flagged) if(Ninja::isHosted() && $this->company->account && $this->nmo->company->account->is_flagged)
return true; return true;
@ -332,6 +333,10 @@ class NinjaMailerJob implements ShouldQueue
if(!str_contains($this->nmo->to_user->email, "@")) if(!str_contains($this->nmo->to_user->email, "@"))
return true; return true;
/* On the hosted platform we actively scan all outbound emails to ensure outbound email quality remains high */
if(Ninja::isHosted())
return (new \Modules\Admin\Jobs\Account\EmailQuality($this->nmo, $this->company))->run();
return false; return false;
} }
@ -373,7 +378,7 @@ class NinjaMailerJob implements ShouldQueue
'form_params' => [ 'form_params' => [
'client_id' => config('ninja.o365.client_id') , 'client_id' => config('ninja.o365.client_id') ,
'client_secret' => config('ninja.o365.client_secret') , 'client_secret' => config('ninja.o365.client_secret') ,
'scope' => 'email Mail.ReadWrite Mail.Send offline_access profile User.Read openid', 'scope' => 'email Mail.Send offline_access profile User.Read openid',
'grant_type' => 'refresh_token', 'grant_type' => 'refresh_token',
'refresh_token' => $user->oauth_user_refresh_token 'refresh_token' => $user->oauth_user_refresh_token
], ],

View File

@ -15,6 +15,7 @@ class AddFlagToAccountsTable extends Migration
{ {
Schema::table('accounts', function (Blueprint $table) { Schema::table('accounts', function (Blueprint $table) {
$table->boolean('is_flagged')->default(0); $table->boolean('is_flagged')->default(0);
$table->boolean('is_verified_account')->default(0);
}); });
} }