mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: add opening quantity, cost and date to items.
This commit is contained in:
@@ -25,6 +25,7 @@ export default class ItemsController extends BaseController {
|
||||
|
||||
router.post('/', [
|
||||
...this.validateItemSchema,
|
||||
...this.validateNewItemSchema,
|
||||
],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.newItem.bind(this)),
|
||||
@@ -90,6 +91,17 @@ export default class ItemsController extends BaseController {
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* New item validation schema.
|
||||
*/
|
||||
get validateNewItemSchema(): ValidationChain[] {
|
||||
return [
|
||||
check('opening_quantity').default(0).isInt({ min: 0 }).toInt(),
|
||||
check('opening_cost').optional({ nullable: true }).isFloat({ min: 0 }).toFloat(),
|
||||
check('opening_date').optional({ nullable: true }).isISO8601(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item schema.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user