Fixes for missing routes

This commit is contained in:
Lars Kusch 2024-03-10 16:55:49 +01:00
parent d8d70f0227
commit db54fa39ac
2 changed files with 71 additions and 0 deletions

View File

@ -851,4 +851,71 @@ class PurchaseOrderController extends BaseController
echo $file;
}, $purchase_order->numberFormatter().".pdf", $headers);
}
/**
* @OA\Get(
* path="/api/v1/credit/{invitation_key}/download_e_purchase_order",
* operationId="downloadEPurchaseOrder",
* tags={"purchase_orders"},
* summary="Download a specific E-Purchase-Order by invitation key",
* description="Downloads a specific E-Purchase-Order",
* @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 E-Purchase-Order Invitation Key",
* example="D2J234DFA",
* required=true,
* @OA\Schema(
* type="string",
* format="string",
* ),
* ),
* @OA\Response(
* response=200,
* description="Returns the E-Purchase-Order 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 downloadEPurchaseOrder($invitation_key)
{
$invitation = $this->purchase_order_repository->getInvitationByKey($invitation_key);
if (! $invitation) {
return response()->json(['message' => 'no record found'], 400);
}
$contact = $invitation->contact;
$purchase_order = $invitation->purchase_order;
$file = $purchase_order->service()->getEPurchaseOrder($contact);
$file_name = $purchase_order->getFileName("xml");
$headers = ['Content-Type' => 'application/xml'];
if (request()->input('inline') == 'true') {
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
}
return response()->streamDownload(function () use ($file) {
echo $file;
}, $file_name, $headers);
}
}

View File

@ -204,6 +204,8 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
Route::get('credits/{credit}/{action}', [CreditController::class, 'action'])->name('credits.action');
Route::post('credits/bulk', [CreditController::class, 'bulk'])->name('credits.bulk');
Route::get('credit/{invitation_key}/download', [CreditController::class, 'downloadPdf'])->name('credits.downloadPdf');
Route::get('credit/{invitation_key}/download_e_credit', [CreditController::class, 'downloadECredit'])->name('credits.downloadECredit');
Route::resource('designs', DesignController::class); // name = (payments. index / create / show / update / destroy / edit
Route::post('designs/bulk', [DesignController::class, 'bulk'])->name('designs.bulk');
@ -281,12 +283,14 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
Route::put('purchase_orders/{purchase_order}/upload', [PurchaseOrderController::class, 'upload']);
Route::get('purchase_orders/{purchase_order}/{action}', [PurchaseOrderController::class, 'action'])->name('purchase_orders.action');
Route::get('purchase_order/{invitation_key}/download', [PurchaseOrderController::class, 'downloadPdf'])->name('purchase_orders.downloadPdf');
Route::get('purchase_order/{invitation_key}/download_e_purchase_order', [PurchaseOrderController::class, 'downloadEPurchaseOrder'])->name('purchase_orders.downloadEPurchaseOrder');
Route::resource('quotes', QuoteController::class); // name = (quotes. index / create / show / update / destroy / edit
Route::get('quotes/{quote}/{action}', [QuoteController::class, 'action'])->name('quotes.action');
Route::post('quotes/bulk', [QuoteController::class, 'bulk'])->name('quotes.bulk');
Route::put('quotes/{quote}/upload', [QuoteController::class, 'upload']);
Route::get('quote/{invitation_key}/download', [QuoteController::class, 'downloadPdf'])->name('quotes.downloadPdf');
Route::get('quote/{invitation_key}/download_e_quote', [QuoteController::class, 'downloadEQuote'])->name('quotes.downloadEQuote');
Route::resource('recurring_expenses', RecurringExpenseController::class);
Route::post('recurring_expenses/bulk', [RecurringExpenseController::class, 'bulk'])->name('recurring_expenses.bulk');