mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Minor fixes for scheduler
This commit is contained in:
parent
533bcb951e
commit
7b48da0cff
@ -37,28 +37,6 @@ class TaskSchedulerController extends BaseController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\GET(
|
||||
* path="/api/v1/task_schedulers/",
|
||||
* operationId="getTaskSchedulers",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Task Scheduler Index",
|
||||
* description="Get all schedulers with associated jobs",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function index(SchedulerFilters $filters)
|
||||
{
|
||||
$schedulers = Scheduler::filter($filters);
|
||||
@ -66,44 +44,6 @@ class TaskSchedulerController extends BaseController
|
||||
return $this->listResponse($schedulers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param CreateSchedulerRequest $request The request
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
*
|
||||
* @OA\Get(
|
||||
* path="/api/v1/invoices/task_schedulers",
|
||||
* operationId="getTaskScheduler",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Gets a new blank scheduler object",
|
||||
* description="Returns a blank object with default values",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="A blank scheduler object",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* @OA\JsonContent(ref="#/components/schemas/TaskSchedulerSchema"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
*
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function create(CreateSchedulerRequest $request)
|
||||
{
|
||||
$scheduler = SchedulerFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
||||
@ -111,39 +51,6 @@ class TaskSchedulerController extends BaseController
|
||||
return $this->itemResponse($scheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/task_schedulers/",
|
||||
* operationId="createTaskScheduler",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Create task scheduler with job ",
|
||||
* description="Create task scheduler with a job (action(job) request should be sent via request also. Example: We want client report to be job which will be run
|
||||
* multiple times, we should send the same parameters in the request as we would send if we wanted to get report, see example",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-API-SECRET"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/TaskSchedulerSchema")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function store(StoreSchedulerRequest $request)
|
||||
{
|
||||
$scheduler = $this->scheduler_repository->save($request->all(), SchedulerFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
@ -151,86 +58,12 @@ class TaskSchedulerController extends BaseController
|
||||
return $this->itemResponse($scheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\GET(
|
||||
* path="/api/v1/task_schedulers/{id}",
|
||||
* operationId="showTaskScheduler",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Show given scheduler",
|
||||
* description="Get scheduler with associated job",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(
|
||||
* name="id",
|
||||
* in="path",
|
||||
* description="The Scheduler Hashed ID",
|
||||
* example="D2J234DFA",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* format="string",
|
||||
* ),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
|
||||
public function show(ShowSchedulerRequest $request, Scheduler $scheduler)
|
||||
{
|
||||
return $this->itemResponse($scheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\PUT(
|
||||
* path="/api/v1/task_schedulers/{id}",
|
||||
* operationId="updateTaskScheduler",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Update task scheduler ",
|
||||
* description="Update task scheduler",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-API-SECRET"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(
|
||||
* name="id",
|
||||
* in="path",
|
||||
* description="The Scheduler Hashed ID",
|
||||
* example="D2J234DFA",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* format="string",
|
||||
* ),
|
||||
* ), * @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/TaskSchedulerSchema")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function update(UpdateSchedulerRequest $request, Scheduler $scheduler)
|
||||
{
|
||||
$this->scheduler_repository->save($request->all(), $scheduler);
|
||||
@ -238,39 +71,6 @@ class TaskSchedulerController extends BaseController
|
||||
return $this->itemResponse($scheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\DELETE(
|
||||
* path="/api/v1/task_schedulers/{id}",
|
||||
* operationId="destroyTaskScheduler",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Destroy Task Scheduler",
|
||||
* description="Destroy task scheduler and its associated job",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(
|
||||
* name="id",
|
||||
* in="path",
|
||||
* description="The Scheduler Hashed ID",
|
||||
* example="D2J234DFA",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* format="string",
|
||||
* ),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function destroy(DestroySchedulerRequest $request, Scheduler $scheduler)
|
||||
{
|
||||
$this->scheduler_repository->delete($scheduler);
|
||||
@ -278,57 +78,6 @@ class TaskSchedulerController extends BaseController
|
||||
return $this->itemResponse($scheduler->fresh());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform bulk actions on the list view.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/api/v1/task_schedulers/bulk",
|
||||
* operationId="bulkTaskSchedulerActions",
|
||||
* tags={"task_schedulers"},
|
||||
* summary="Performs bulk actions on an array of task_schedulers",
|
||||
* description="",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(ref="#/components/parameters/index"),
|
||||
* @OA\RequestBody(
|
||||
* description="array of ids",
|
||||
* required=true,
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* type="integer",
|
||||
* description="Array of hashed IDs to be bulk 'actioned",
|
||||
* example="[0,1,2,3]",
|
||||
* ),
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="The TaskSchedule response",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* @OA\JsonContent(ref="#/components/schemas/TaskSchedulerSchema"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function bulk()
|
||||
{
|
||||
$action = request()->input('action');
|
||||
|
@ -60,7 +60,5 @@ class StoreSchedulerRequest extends Request
|
||||
$this->merge(['next_run_client' => $input['next_run']]);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,5 @@ class UpdateSchedulerRequest extends Request
|
||||
$this->merge(['next_run_client' => $input['next_run']]);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace App\Jobs\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Invoice;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
|
||||
class CheckGatewayFee implements ShouldQueue
|
||||
{
|
||||
@ -40,6 +41,8 @@ class CheckGatewayFee implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
nlog("Checking Gateway Fees for Invoice Id = {$this->invoice_id}");
|
||||
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
$i = Invoice::withTrashed()->find($this->invoice_id);
|
||||
@ -52,4 +55,9 @@ class CheckGatewayFee implements ShouldQueue
|
||||
$i->service()->removeUnpaidGatewayFees();
|
||||
}
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [(new WithoutOverlapping($this->invoice_id.$this->db))];
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +250,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
'phone',
|
||||
'number',
|
||||
'routing_id',
|
||||
'is_tax_exempt',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
|
@ -25,10 +25,14 @@ class SchedulerRepository extends BaseRepository
|
||||
*/
|
||||
public function save(array $data, Scheduler $scheduler): Scheduler
|
||||
{
|
||||
|
||||
$scheduler->fill($data);
|
||||
|
||||
$scheduler->save();
|
||||
|
||||
return $scheduler;
|
||||
/** 18-5-2023 set client specific send times. */
|
||||
$scheduler->calculateNextRun();
|
||||
|
||||
return $scheduler->fresh();
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ class SchedulerService
|
||||
use MakesHash;
|
||||
use MakesDates;
|
||||
|
||||
private string $method;
|
||||
|
||||
public function __construct(public Scheduler $scheduler)
|
||||
{
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class AccountTransformer extends EntityTransformer
|
||||
'key' => (string) $account->key,
|
||||
'default_url' => config('ninja.app_url'),
|
||||
'plan' => $account->getPlan(),
|
||||
'plan_term' => (string) $account->plan_terms,
|
||||
'plan_term' => (string) $account->plan_term,
|
||||
'plan_started' => (string) $account->plan_started,
|
||||
'plan_paid' => (string) $account->plan_paid,
|
||||
'plan_expires' => (string) $account->plan_expires,
|
||||
|
@ -27,7 +27,6 @@ class SchedulerTransformer extends EntityTransformer
|
||||
'next_run' => $scheduler->next_run_client->format('Y-m-d'),
|
||||
'template' => (string) $scheduler->template,
|
||||
'is_paused' => (bool) $scheduler->is_paused,
|
||||
'is_deleted' => (bool) $scheduler->is_deleted,
|
||||
'parameters'=> (array) $scheduler->parameters,
|
||||
'is_deleted' => (bool) $scheduler->is_deleted,
|
||||
'updated_at' => (int) $scheduler->updated_at,
|
||||
|
Loading…
x
Reference in New Issue
Block a user