Merge pull request #11048 from Godmartinz/bug/sc-18989/purchase-cost-can-be-negative

Fixed validation for purchase cost allowed to be negative
This commit is contained in:
snipe 2022-05-10 17:36:01 -07:00 committed by GitHub
commit 446e44deb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 4 deletions

View file

@ -61,7 +61,7 @@ class Accessory extends SnipeModel
'category_id' => 'required|integer|exists:categories,id',
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
'purchase_cost' => 'numeric|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
];

View file

@ -111,7 +111,7 @@ class Asset extends Depreciable
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
'status' => 'integer',
'serial' => 'unique_serial|nullable',
'purchase_cost' => 'numeric|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
'next_audit_date' => 'date|nullable',
'last_audit_date' => 'date|nullable',
'supplier_id' => 'exists:suppliers,id|nullable',

View file

@ -36,7 +36,7 @@ class Component extends SnipeModel
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
'purchase_date' => 'date|nullable',
'purchase_cost' => 'numeric|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
];
/**

View file

@ -39,7 +39,7 @@ class Consumable extends SnipeModel
'category_id' => 'required|integer',
'company_id' => 'integer|nullable',
'min_amt' => 'integer|min:0|nullable',
'purchase_cost' => 'numeric|nullable',
'purchase_cost' => 'numeric|nullable|gte:0',
];
/**

View file

@ -48,6 +48,7 @@ class License extends Depreciable
'notes' => 'string|nullable',
'category_id' => 'required|exists:categories,id',
'company_id' => 'integer|nullable',
'purchase_cost'=> 'numeric|nullable|gte:0',
];
/**

View file

@ -91,6 +91,10 @@ return [
'url' => 'The :attribute format is invalid.',
'unique_undeleted' => 'The :attribute must be unique.',
'non_circular' => 'The :attribute must not create a circular reference.',
'gte' => [
'numeric' => 'Value cannot be negative'
],
/*
|--------------------------------------------------------------------------