mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
commit
29be582020
@ -72,7 +72,7 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
public $translations;
|
||||
|
||||
public $counter_number_applied = 'when_saved';// when_saved , when_sent , when_paid
|
||||
public $counter_number_applied = 'when_saved';// when_saved , when_sent
|
||||
public $quote_number_applied = 'when_saved';// when_saved , when_sent
|
||||
|
||||
/* Counters */
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests\Credit;
|
||||
|
||||
use App\Http\ValidationRules\Credit\UniqueCreditNumberRule;
|
||||
use App\Models\Credit;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -42,6 +43,8 @@ class StoreCreditRequest extends FormRequest
|
||||
}
|
||||
|
||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
|
||||
$rules['number'] = new UniqueCreditNumberRule($this->all());
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
70
app/Http/Requests/Credit/UniqueCreditNumberRule.php
Normal file
70
app/Http/Requests/Credit/UniqueCreditNumberRule.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Credit Ninja (https://creditninja.com)
|
||||
*
|
||||
* @link https://github.com/creditninja/creditninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Credit Ninja LLC (https://creditninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\ValidationRules\Credit;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Credit;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Class UniqueCreditNumberRule
|
||||
* @package App\Http\ValidationRules
|
||||
*/
|
||||
class UniqueCreditNumberRule implements Rule
|
||||
{
|
||||
public $input;
|
||||
|
||||
public function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return $this->checkIfCreditNumberUnique(); //if it exists, return false!
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Credit number already taken";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
*
|
||||
* //off,when_sent,when_paid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIfCreditNumberUnique() : bool
|
||||
{
|
||||
|
||||
$credit = Credit::where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
||||
if($credit)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -42,6 +42,9 @@ class UpdateCreditRequest extends FormRequest
|
||||
$rules['documents'] = 'file|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||
}
|
||||
|
||||
if($this->input('number'))
|
||||
$rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->invoice->company_id;
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,8 @@ class StorePaymentRequest extends Request
|
||||
'credits.*.credit_id' => new ValidCreditsRules($this->all()),
|
||||
'credits.*.amount' => 'required',
|
||||
'invoices' => new ValidPayableInvoicesRule(),
|
||||
'number' => 'nullable',
|
||||
'number' => 'nullable|unique:payments,number,' . $this->id . ',id,company_id,' . $this->company_id,
|
||||
//'number' => 'nullable',
|
||||
];
|
||||
|
||||
|
||||
|
@ -40,6 +40,7 @@ class UpdatePaymentRequest extends Request
|
||||
'invoices' => ['array',new PaymentAppliedValidAmount,new ValidCreditsPresentRule],
|
||||
'invoices.*.invoice_id' => 'distinct',
|
||||
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||
'number' => 'nullable|unique:payments,number,' . $this->id . ',id,company_id,' . $this->company_id,
|
||||
];
|
||||
|
||||
if ($this->input('documents') && is_array($this->input('documents'))) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Requests\Quote;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\Quote\UniqueQuoteNumberRule;
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -93,6 +94,8 @@ class StoreQuoteRequest extends Request
|
||||
$rules['documents'] = 'file|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||
}
|
||||
|
||||
$rules['number'] = new UniqueQuoteNumberRule($this->all());
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
70
app/Http/Requests/Quote/UniqueQuoteNumberRule.php
Normal file
70
app/Http/Requests/Quote/UniqueQuoteNumberRule.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Quote Ninja (https://quoteninja.com)
|
||||
*
|
||||
* @link https://github.com/quoteninja/quoteninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Quote Ninja LLC (https://quoteninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\ValidationRules\Quote;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Quote;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Class UniqueQuoteNumberRule
|
||||
* @package App\Http\ValidationRules
|
||||
*/
|
||||
class UniqueQuoteNumberRule implements Rule
|
||||
{
|
||||
public $input;
|
||||
|
||||
public function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return $this->checkIfQuoteNumberUnique(); //if it exists, return false!
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Quote number already taken";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
*
|
||||
* //off,when_sent,when_paid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIfQuoteNumberUnique() : bool
|
||||
{
|
||||
|
||||
$quote = Quote::where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
||||
if($quote)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -49,6 +49,10 @@ class UpdateQuoteRequest extends Request
|
||||
} elseif ($this->input('documents')) {
|
||||
$rules['documents'] = 'file|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||
}
|
||||
|
||||
if($this->input('number'))
|
||||
$rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->invoice->company_id;
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class ClientGatewayTokenTransformer extends EntityTransformer
|
||||
'gateway_type_id' => (string)$cgt->gateway_type_id ?: '',
|
||||
'company_gateway_id' => (string)$this->encodePrimaryKey($cgt->company_gateway_id) ?: '',
|
||||
'is_default' => (bool) $cgt->is_default,
|
||||
'meta' => $cgt->meta,
|
||||
'created_at' => (int)$cgt->created_at,
|
||||
'updated_at' => (int)$cgt->updated_at,
|
||||
'archived_at' => (int)$cgt->deleted_at,
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Design;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RemovePhotoDesign extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$design = Design::find(10);
|
||||
|
||||
if($design)
|
||||
$design->forceDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ class DesignSeeder extends Seeder
|
||||
['id' => 7, 'name' => 'Elegant', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
|
||||
['id' => 8, 'name' => 'Hipster', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
|
||||
['id' => 9, 'name' => 'Playful', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
|
||||
['id' => 10, 'name' => 'Photo', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
|
||||
];
|
||||
|
||||
foreach ($designs as $design) {
|
||||
|
Loading…
Reference in New Issue
Block a user