migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Restaurant\Http\Requests\Purchase;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PurchaseStoreRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'supplier_id' => ['nullable', 'exists:suppliers,id'],
|
||||
'purchase_date' => ['required', 'date'],
|
||||
|
||||
// Financials
|
||||
'sub_total' => ['required', 'numeric', 'min:0'],
|
||||
'discount_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'tax_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'total_amount' => ['required', 'numeric', 'min:0'],
|
||||
'payment_status' => ['nullable', Rule::in(['paid', 'unpaid', 'partial'])],
|
||||
'payment_method' => ['nullable', Rule::in(['cash', 'bank', 'credit'])],
|
||||
'purchase_type' => ['nullable', Rule::in(['ingredient', 'equipment', 'others'])],
|
||||
'created_by' => ['nullable', 'exists:users,id'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
|
||||
// Items array
|
||||
'items' => ['required', 'array', 'min:1'],
|
||||
'items.*.ingredient_id' => ['required', 'exists:ingredients,id'],
|
||||
'items.*.food_variant_id' => ['nullable', 'exists:food_variants,id'],
|
||||
'items.*.quantity' => ['required', 'numeric', 'min:0.01'],
|
||||
'items.*.unit_price' => ['required', 'numeric', 'min:0'],
|
||||
'items.*.total_cost' => ['required', 'numeric', 'min:0'],
|
||||
'items.*.tax_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.discount_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.batch_no' => ['nullable', 'string'],
|
||||
'items.*.expiry_date' => ['nullable', 'date'],
|
||||
'items.*.received_quantity' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.wastage_quantity' => ['nullable', 'numeric', 'min:0'],
|
||||
];
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Restaurant\Http\Requests\Purchase;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PurchaseUpdateRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'supplier_id' => ['nullable', 'exists:suppliers,id'],
|
||||
'purchase_date' => ['required', 'date'],
|
||||
|
||||
// Financials
|
||||
'sub_total' => ['required', 'numeric', 'min:0'],
|
||||
'discount_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'tax_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'total_amount' => ['required', 'numeric', 'min:0'],
|
||||
|
||||
'payment_status' => ['nullable', Rule::in(['paid', 'unpaid', 'partial'])],
|
||||
'payment_method' => ['nullable', Rule::in(['cash', 'bank', 'credit'])],
|
||||
'purchase_type' => ['nullable', Rule::in(['ingredient', 'equipment', 'others'])],
|
||||
'created_by' => ['nullable', 'exists:users,id'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
|
||||
// Items
|
||||
'items' => ['required', 'array', 'min:1'],
|
||||
|
||||
// id is optional — if present = update, if missing = create
|
||||
'items.*.id' => ['nullable', 'exists:purchase_items,id'],
|
||||
|
||||
'items.*.ingredient_id' => ['required', 'exists:ingredients,id'],
|
||||
'items.*.food_variant_id' => ['nullable', 'exists:food_variants,id'],
|
||||
'items.*.quantity' => ['required', 'numeric', 'min:0.01'],
|
||||
'items.*.unit_price' => ['required', 'numeric', 'min:0'],
|
||||
'items.*.total_cost' => ['required', 'numeric', 'min:0'],
|
||||
'items.*.tax_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.discount_amount' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.batch_no' => ['nullable', 'string'],
|
||||
'items.*.expiry_date' => ['nullable', 'date'],
|
||||
'items.*.received_quantity' => ['nullable', 'numeric', 'min:0'],
|
||||
'items.*.wastage_quantity' => ['nullable', 'numeric', 'min:0'],
|
||||
];
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user