2019-04-02 08:36:49 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2019-04-02 08:36:49 +02:00
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2021-05-10 10:45:07 +02:00
|
|
|
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
|
|
|
|
use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
|
2019-05-03 00:29:04 +02:00
|
|
|
use App\Factory\RecurringInvoiceFactory;
|
|
|
|
use App\Filters\RecurringInvoiceFilters;
|
|
|
|
use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\EditRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\ShowRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest;
|
|
|
|
use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest;
|
2021-02-15 21:58:19 +01:00
|
|
|
use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest;
|
2021-03-07 22:32:38 +01:00
|
|
|
use App\Models\Account;
|
2019-05-03 00:29:04 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
use App\Repositories\RecurringInvoiceRepository;
|
|
|
|
use App\Transformers\RecurringInvoiceTransformer;
|
2021-05-10 12:20:52 +02:00
|
|
|
use App\Utils\Ninja;
|
2019-05-03 00:29:04 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2021-02-15 21:58:19 +01:00
|
|
|
use App\Utils\Traits\SavesDocuments;
|
2021-06-10 13:25:47 +02:00
|
|
|
use Carbon\Carbon;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Illuminate\Http\Response;
|
2021-07-09 01:49:01 +02:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2019-04-02 08:36:49 +02:00
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class RecurringInvoiceController.
|
2019-05-03 00:29:04 +02:00
|
|
|
*/
|
|
|
|
class RecurringInvoiceController extends BaseController
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
use MakesHash;
|
2021-02-15 21:58:19 +01:00
|
|
|
use SavesDocuments;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
protected $entity_type = RecurringInvoice::class;
|
|
|
|
|
|
|
|
protected $entity_transformer = RecurringInvoiceTransformer::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var RecurringInvoiceRepository
|
|
|
|
*/
|
|
|
|
protected $recurring_invoice_repo;
|
|
|
|
|
|
|
|
protected $base_repo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RecurringInvoiceController constructor.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param RecurringInvoiceRepository $recurring_invoice_repo The RecurringInvoice repo
|
2019-05-03 00:29:04 +02:00
|
|
|
*/
|
|
|
|
public function __construct(RecurringInvoiceRepository $recurring_invoice_repo)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->recurring_invoice_repo = $recurring_invoice_repo;
|
|
|
|
}
|
|
|
|
|
2019-04-02 08:36:49 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Show the list of recurring_invoices.
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param RecurringInvoiceFilters $filters The filters
|
2019-04-02 08:36:49 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoices",
|
|
|
|
* operationId="getRecurringInvoices",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Gets a list of recurring_invoices",
|
|
|
|
* description="Lists recurring_invoices, search and filters allow fine grained lists to be generated.
|
|
|
|
|
|
|
|
Query parameters can be added to performed more fine grained filtering of the recurring_invoices, these are handled by the RecurringInvoiceFilters class which defines the methods available",
|
|
|
|
* @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 list of recurring_invoices",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function index(RecurringInvoiceFilters $filters)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
$recurring_invoices = RecurringInvoice::filter($filters);
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
return $this->listResponse($recurring_invoices);
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param CreateRecurringInvoiceRequest $request The request
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoices/create",
|
|
|
|
* operationId="getRecurringInvoicesCreate",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Gets a new blank RecurringInvoice 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 RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function create(CreateRecurringInvoiceRequest $request)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
$recurring_invoice = RecurringInvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
|
|
|
|
|
|
|
return $this->itemResponse($recurring_invoice);
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param StoreRecurringInvoiceRequest $request The request
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/recurring_invoices",
|
|
|
|
* operationId="storeRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Adds a RecurringInvoice",
|
|
|
|
* description="Adds an RecurringInvoice to the system",
|
|
|
|
* @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="Returns the saved RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function store(StoreRecurringInvoiceRequest $request)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-30 01:58:00 +02:00
|
|
|
$recurring_invoice = $this->recurring_invoice_repo->save($request->all(), RecurringInvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2021-10-13 07:41:11 +02:00
|
|
|
$recurring_invoice->service()
|
|
|
|
->triggeredActions($request)
|
|
|
|
->save();
|
|
|
|
|
2021-12-17 12:11:36 +01:00
|
|
|
event(new RecurringInvoiceWasCreated($recurring_invoice, $recurring_invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
|
|
|
|
2022-09-16 04:49:09 +02:00
|
|
|
return $this->itemResponse($recurring_invoice->fresh());
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param ShowRecurringInvoiceRequest $request The request
|
|
|
|
* @param RecurringInvoice $recurring_invoice The RecurringInvoice
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}",
|
|
|
|
* operationId="showRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Shows an RecurringInvoice",
|
|
|
|
* description="Displays an RecurringInvoice by id",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-12-30 22:59:12 +01:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param EditRecurringInvoiceRequest $request The request
|
|
|
|
* @param RecurringInvoice $recurring_invoice The RecurringInvoice
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}/edit",
|
|
|
|
* operationId="editRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Shows an RecurringInvoice for editting",
|
|
|
|
* description="Displays an RecurringInvoice by id",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function edit(EditRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-04-02 08:36:49 +02:00
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param UpdateRecurringInvoiceRequest $request The request
|
|
|
|
* @param RecurringInvoice $recurring_invoice The RecurringInvoice
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Put(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}",
|
|
|
|
* operationId="updateRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Updates an RecurringInvoice",
|
|
|
|
* description="Handles the updating of an RecurringInvoice by id",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function update(UpdateRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
if ($request->entityIsDeleted($recurring_invoice)) {
|
2019-12-30 22:59:12 +01:00
|
|
|
return $request->disallowUpdate();
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-05-30 01:58:00 +02:00
|
|
|
$recurring_invoice = $this->recurring_invoice_repo->save($request->all(), $recurring_invoice);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2022-03-30 05:12:53 +02:00
|
|
|
$recurring_invoice->service()
|
|
|
|
->triggeredActions($request)
|
|
|
|
->deletePdf()
|
|
|
|
->save();
|
2021-03-10 11:00:18 +01:00
|
|
|
|
2021-05-10 10:45:07 +02:00
|
|
|
event(new RecurringInvoiceWasUpdated($recurring_invoice, $recurring_invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param DestroyRecurringInvoiceRequest $request
|
|
|
|
* @param RecurringInvoice $recurring_invoice
|
2019-05-03 00:29:04 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @throws \Exception
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Delete(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}",
|
|
|
|
* operationId="deleteRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Deletes a RecurringInvoice",
|
|
|
|
* description="Handles the deletion of an RecurringInvoice by id",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns a HTTP status",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-04-02 08:36:49 +02:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function destroy(DestroyRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
2019-04-02 08:36:49 +02:00
|
|
|
{
|
2021-01-17 05:28:03 +01:00
|
|
|
$this->recurring_invoice_repo->delete($recurring_invoice);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2021-01-17 05:28:03 +01:00
|
|
|
return $this->itemResponse($recurring_invoice->fresh());
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
2021-01-15 03:02:55 +01:00
|
|
|
/**
|
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoice/{invitation_key}/download",
|
2021-03-09 11:30:34 +01:00
|
|
|
* operationId="downloadRecurringInvoice",
|
2021-01-15 03:02:55 +01:00
|
|
|
* tags={"invoices"},
|
|
|
|
* summary="Download a specific invoice by invitation key",
|
|
|
|
* description="Downloads a specific invoice",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="invitation_key",
|
|
|
|
* in="path",
|
|
|
|
* description="The Recurring Invoice Invitation Key",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the recurring invoice pdf",
|
|
|
|
* @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"),
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
* @param $invitation_key
|
|
|
|
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
|
|
|
*/
|
|
|
|
public function downloadPdf($invitation_key)
|
|
|
|
{
|
|
|
|
$invitation = $this->recurring_invoice_repo->getInvitationByKey($invitation_key);
|
|
|
|
$contact = $invitation->contact;
|
|
|
|
$recurring_invoice = $invitation->recurring_invoice;
|
|
|
|
|
2021-07-09 01:49:01 +02:00
|
|
|
$file = $recurring_invoice->service()->getInvoicePdf($contact);
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
return response()->streamDownload(function () use ($file) {
|
|
|
|
echo Storage::get($file);
|
|
|
|
}, basename($file), ['Content-Type' => 'application/pdf']);
|
2021-01-15 03:02:55 +01:00
|
|
|
}
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Perform bulk actions on the list view.
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-05-03 00:29:04 +02:00
|
|
|
* @return Collection
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/recurring_invoices/bulk",
|
|
|
|
* operationId="bulkRecurringInvoices",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Performs bulk actions on an array of recurring_invoices",
|
|
|
|
* 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(
|
2019-10-07 06:57:14 +02:00
|
|
|
* description="Hashed IDs",
|
2019-10-07 06:29:16 +02:00
|
|
|
* 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,
|
2019-10-07 06:57:14 +02:00
|
|
|
* description="The RecurringInvoice response",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
|
|
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
2019-10-07 06:57:14 +02:00
|
|
|
* @OA\JsonContent(ref="#/components/schemas/RecurringInvoice"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-05-03 00:29:04 +02:00
|
|
|
*/
|
|
|
|
public function bulk()
|
|
|
|
{
|
|
|
|
$action = request()->input('action');
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
$ids = request()->input('ids');
|
|
|
|
|
2019-11-21 09:38:57 +01:00
|
|
|
$recurring_invoices = RecurringInvoice::withTrashed()->find($this->transformKeys($ids));
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
$recurring_invoices->each(function ($recurring_invoice, $key) use ($action) {
|
|
|
|
if (auth()->user()->can('edit', $recurring_invoice)) {
|
2020-09-24 02:57:44 +02:00
|
|
|
$this->performAction($recurring_invoice, $action, true);
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
});
|
|
|
|
|
2019-11-21 09:38:57 +01:00
|
|
|
return $this->listResponse(RecurringInvoice::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
2019-10-07 06:29:16 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Recurring Invoice Actions.
|
2019-10-07 06:29:16 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}/{action}",
|
|
|
|
* operationId="actionRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Performs a custom action on an RecurringInvoice",
|
|
|
|
* description="Performs a custom action on an RecurringInvoice.
|
2019-12-30 22:59:12 +01:00
|
|
|
|
2020-10-28 11:10:49 +01:00
|
|
|
The current range of actions are as follows
|
|
|
|
- clone_to_RecurringInvoice
|
|
|
|
- clone_to_quote
|
|
|
|
- history
|
|
|
|
- delivery_note
|
|
|
|
- mark_paid
|
|
|
|
- download
|
|
|
|
- archive
|
|
|
|
- delete
|
|
|
|
- email",
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="action",
|
|
|
|
* in="path",
|
|
|
|
* description="The action string to be performed",
|
|
|
|
* example="clone_to_quote",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
2019-12-30 22:59:12 +01:00
|
|
|
* ),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the RecurringInvoice object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:29:16 +02:00
|
|
|
* @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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-07 06:29:16 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param ActionRecurringInvoiceRequest $request
|
|
|
|
* @param RecurringInvoice $recurring_invoice
|
|
|
|
* @param $action
|
|
|
|
* @return Response|mixed
|
2019-12-30 22:59:12 +01:00
|
|
|
*/
|
2019-05-03 00:29:04 +02:00
|
|
|
public function action(ActionRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice, $action)
|
2020-09-24 02:57:44 +02:00
|
|
|
{
|
|
|
|
return $this->performAction($recurring_invoice, $action);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function performAction(RecurringInvoice $recurring_invoice, string $action, $bulk = false)
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
|
|
|
switch ($action) {
|
|
|
|
case 'archive':
|
2020-09-24 02:57:44 +02:00
|
|
|
$this->recurring_invoice_repo->archive($recurring_invoice);
|
|
|
|
|
|
|
|
if (! $bulk) {
|
2022-08-18 06:08:50 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
2020-09-24 02:57:44 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'restore':
|
|
|
|
$this->recurring_invoice_repo->restore($recurring_invoice);
|
|
|
|
|
|
|
|
if (! $bulk) {
|
2022-08-18 06:08:50 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
2020-09-24 02:57:44 +02:00
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
break;
|
|
|
|
case 'delete':
|
2020-09-24 02:57:44 +02:00
|
|
|
$this->recurring_invoice_repo->delete($recurring_invoice);
|
|
|
|
|
|
|
|
if (! $bulk) {
|
2022-08-18 06:08:50 +02:00
|
|
|
return $this->itemResponse($recurring_invoice);
|
2020-09-24 02:57:44 +02:00
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
break;
|
|
|
|
case 'email':
|
|
|
|
//dispatch email to queue
|
|
|
|
break;
|
2020-09-24 02:57:44 +02:00
|
|
|
case 'start':
|
|
|
|
$recurring_invoice = $recurring_invoice->service()->start()->save();
|
2020-10-28 11:10:49 +01:00
|
|
|
|
2020-09-24 02:57:44 +02:00
|
|
|
if (! $bulk) {
|
|
|
|
$this->itemResponse($recurring_invoice);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'stop':
|
|
|
|
$recurring_invoice = $recurring_invoice->service()->stop()->save();
|
2020-10-28 11:10:49 +01:00
|
|
|
|
2020-09-24 02:57:44 +02:00
|
|
|
if (! $bulk) {
|
|
|
|
$this->itemResponse($recurring_invoice);
|
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2022-07-11 02:33:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'send_now':
|
|
|
|
$recurring_invoice = $recurring_invoice->service()->sendNow();
|
|
|
|
|
|
|
|
if (! $bulk) {
|
|
|
|
$this->itemResponse($recurring_invoice);
|
|
|
|
}
|
|
|
|
|
2020-09-24 02:57:44 +02:00
|
|
|
break;
|
2019-05-03 00:29:04 +02:00
|
|
|
default:
|
2020-09-06 11:38:10 +02:00
|
|
|
// code...
|
2019-05-03 00:29:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|
2021-02-15 21:58:19 +01:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
/**
|
2021-02-15 21:58:19 +01:00
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param UploadRecurringInvoiceRequest $request
|
|
|
|
* @param RecurringInvoice $recurring_invoice
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Put(
|
|
|
|
* path="/api/v1/recurring_invoices/{id}/upload",
|
|
|
|
* operationId="uploadRecurringInvoice",
|
|
|
|
* tags={"recurring_invoices"},
|
|
|
|
* summary="Uploads a document to a recurring_invoice",
|
|
|
|
* description="Handles the uploading of a document to a recurring_invoice",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The RecurringInvoice Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the RecurringInvoice 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/RecurringInvoice"),
|
|
|
|
* ),
|
|
|
|
* @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 upload(UploadRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
if (! $this->checkFeature(Account::FEATURE_DOCUMENTS)) {
|
2021-03-07 22:32:38 +01:00
|
|
|
return $this->featureFailure();
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->has('documents')) {
|
2021-02-15 21:58:19 +01:00
|
|
|
$this->saveDocuments($request->file('documents'), $recurring_invoice);
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2021-02-15 21:58:19 +01:00
|
|
|
|
|
|
|
return $this->itemResponse($recurring_invoice->fresh());
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2019-04-02 08:36:49 +02:00
|
|
|
}
|