diff --git a/src/controllers/pharmacy/item_master.ts b/src/controllers/pharmacy/item_master.ts index 5b746cf..7cbc99a 100644 --- a/src/controllers/pharmacy/item_master.ts +++ b/src/controllers/pharmacy/item_master.ts @@ -68,6 +68,27 @@ export class ItemMasterController { } } + + static async option(req: Request, res: Response, next: NextFunction): Promise { + /* + #swagger.tags = ['Pharmacy - ItemMaster'] + #swagger.security = [{ "bearerAuth": [] }] + */ + try { + const query = await ItemMasterModel.list(); // ← hapus await disini, karena list() return QueryBuilder + + const total_count_data = await query.getCount(); + const list_data = await query.getMany(); + const count_data = CommonHelper.countObject(list_data); + + return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data); + } catch (e: unknown) { + log.error(e); + const err = e as Error; + return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message); + } + } + static async export(req: Request, res: Response, next: NextFunction): Promise { /* #swagger.tags = ['Pharmacy - ItemMaster'] @@ -110,7 +131,7 @@ export class ItemMasterController { var query = await ItemMasterModel.list(filter); const data = await query.getMany(); - + const filename = "item_master.csv"; res.setHeader('Content-Type', 'text/csv'); diff --git a/src/controllers/pharmacy/unit.ts b/src/controllers/pharmacy/unit.ts index 8b94b3d..8f2ef92 100644 --- a/src/controllers/pharmacy/unit.ts +++ b/src/controllers/pharmacy/unit.ts @@ -110,7 +110,7 @@ export class UnitController { var query = await UnitModel.list(filter); const data = await query.getMany(); - + const filename = "unit.csv"; res.setHeader('Content-Type', 'text/csv'); @@ -173,6 +173,8 @@ export class UnitController { try { const schema = Joi.object().keys({ unit_name: Joi.string().max(256).required().label('Name'), + small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'), + large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'), }); const param: any = await schema.validateAsync(req.body); @@ -223,6 +225,8 @@ export class UnitController { const schema = Joi.object().keys({ id: Joi.string().uuid().required().label('ID'), unit_name: Joi.string().max(256).required().label('Name'), + small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'), + large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'), }); req.body.id = req.params['id']; diff --git a/src/routes/private.ts b/src/routes/private.ts index fc2173a..4ca0bae 100644 --- a/src/routes/private.ts +++ b/src/routes/private.ts @@ -345,6 +345,7 @@ export class RoutePrivate { // app.put('/api/pharmacy/factory-to-supplier/restore/:supplier_id', FactorytoSupplierController.restore) app.get('/api/pharmacy/item-master/list', ItemMasterController.list) + app.get('/api/pharmacy/item-master/option', ItemMasterController.option) app.get('/api/pharmacy/item-master/export', ItemMasterController.export) app.post('/api/pharmacy/item-master/create', ItemMasterController.create) app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update)