mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 13:24:36 -04:00
Fixes for category IDs for recurring expenses
This commit is contained in:
parent
8251c53340
commit
af0b459f94
@ -135,11 +135,45 @@ class ExpenseCategoryController extends BaseController
|
|||||||
return $this->itemResponse($expense_category);
|
return $this->itemResponse($expense_category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param StoreExpenseCategoryRequest $request
|
* @param StoreInvoiceRequest $request The request
|
||||||
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @OA\Post(
|
||||||
|
* path="/api/v1/expense_categories",
|
||||||
|
* operationId="storeExpenseCategory",
|
||||||
|
* tags={"expense_categories"},
|
||||||
|
* summary="Adds a expense category",
|
||||||
|
* description="Adds an expense category to the system",
|
||||||
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
||||||
|
* @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 invoice 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/ExpenseCategory"),
|
||||||
|
* ),
|
||||||
|
* @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(StoreExpenseCategoryRequest $request)
|
public function store(StoreExpenseCategoryRequest $request)
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,7 @@ class StoreRecurringExpenseRequest extends Request
|
|||||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||||
$rules['frequency_id'] = 'required|integer|digits_between:1,12';
|
$rules['frequency_id'] = 'required|integer|digits_between:1,12';
|
||||||
$rules['tax_amount1'] = 'numeric';
|
$rules['tax_amount1'] = 'numeric';
|
||||||
$rules['tax_amount2'] = 'numeric';
|
$rules['tax_amount2'] = 'numeric';
|
||||||
@ -61,10 +62,6 @@ class StoreRecurringExpenseRequest extends Request
|
|||||||
$input['next_send_date_client'] = $input['next_send_date'];
|
$input['next_send_date_client'] = $input['next_send_date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('category_id', $input) && is_string($input['category_id'])) {
|
|
||||||
$input['category_id'] = $this->decodePrimaryKey($input['category_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
||||||
$input['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
|
$input['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ class UpdateRecurringExpenseRequest extends Request
|
|||||||
$rules['tax_amount1'] = 'numeric';
|
$rules['tax_amount1'] = 'numeric';
|
||||||
$rules['tax_amount2'] = 'numeric';
|
$rules['tax_amount2'] = 'numeric';
|
||||||
$rules['tax_amount3'] = 'numeric';
|
$rules['tax_amount3'] = 'numeric';
|
||||||
|
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
@ -70,10 +71,6 @@ class UpdateRecurringExpenseRequest extends Request
|
|||||||
$input['next_send_date_client'] = $input['next_send_date'];
|
$input['next_send_date_client'] = $input['next_send_date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('category_id', $input) && is_string($input['category_id'])) {
|
|
||||||
$input['category_id'] = $this->decodePrimaryKey($input['category_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if (array_key_exists('documents', $input)) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user