1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Remove requirement for names for schedules

This commit is contained in:
David Bomba 2023-03-22 07:30:37 +11:00
parent cd741efa2a
commit 4f9db0124e
5 changed files with 78 additions and 2 deletions

View File

@ -32,7 +32,7 @@ class StoreSchedulerRequest extends Request
public function rules() public function rules()
{ {
$rules = [ $rules = [
'name' => ['bail', 'required', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)], 'name' => 'bail|sometimes|nullable|string',
'is_paused' => 'bail|sometimes|boolean', 'is_paused' => 'bail|sometimes|boolean',
'frequency_id' => 'bail|sometimes|integer|digits_between:1,12', 'frequency_id' => 'bail|sometimes|integer|digits_between:1,12',
'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today', 'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today',

View File

@ -29,7 +29,7 @@ class UpdateSchedulerRequest extends Request
public function rules(): array public function rules(): array
{ {
$rules = [ $rules = [
'name' => ['bail', 'sometimes', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)->ignore($this->task_scheduler->id)], 'name' => 'bail|sometimes|nullable|string',
'is_paused' => 'bail|sometimes|boolean', 'is_paused' => 'bail|sometimes|boolean',
'frequency_id' => 'bail|sometimes|integer|digits_between:1,12', 'frequency_id' => 'bail|sometimes|integer|digits_between:1,12',
'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today', 'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today',

View File

@ -557,6 +557,11 @@ class Company extends BaseModel
return $this->calculate_taxes && in_array($this->getSetting('country_id'), $this->tax_coverage_countries); return $this->calculate_taxes && in_array($this->getSetting('country_id'), $this->tax_coverage_countries);
} }
public function refreshTaxData()
{
}
public function documents() public function documents()
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');

View File

@ -0,0 +1,59 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Tax\Providers;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
class ZipTax
{
private string $endpoint = 'https://api.zip-tax.com/request/v40';
public function __construct(protected string $api_key, protected string $address, protected ?string $postal_code)
{
}
public function run()
{
$response = $this->callApi(['key' => $this->api_key, 'address' => $this->address]);
if($response->successful())
return $response->json();
if($this->postal_code) {
$response = $this->callApi(['key' => $this->api_key, 'address' => $this->postal_code]);
if($response->successful())
return $response->json();
}
$response->throw();
}
/**
* callApi
*
* @param array $parameters
* @return Response
*/
private function callApi(array $parameters): Response
{
$response = Http::retry(3, 1000)->withHeaders([])->get($this->endpoint, $parameters);
return $response;
}
}

View File

@ -31,6 +31,18 @@ return new class extends Migration
$table->boolean('tax_data'); $table->boolean('tax_data');
}); });
Schema::table('schedulers', function (Blueprint $table){
$table->dropUnique('schedulers_company_id_name_unique');
});
Schema::table('schedulers', function (Blueprint $table) {
$table->string('name', 191)->nullable()->change();
});
} }
/** /**