mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: ability to publish and draft inventory adjustment transactions.
This commit is contained in:
@@ -16,6 +16,13 @@ export default class InventoryAdjustmentsController extends BaseController {
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
'/:id/publish',
|
||||
[param('id').exists().isNumeric().toInt()],
|
||||
this.validationResult,
|
||||
this.asyncMiddleware(this.publishInventoryAdjustment.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.delete(
|
||||
'/:id',
|
||||
[param('id').exists().isNumeric().toInt()],
|
||||
@@ -62,6 +69,7 @@ export default class InventoryAdjustmentsController extends BaseController {
|
||||
.exists()
|
||||
.isFloat()
|
||||
.toInt(),
|
||||
check('publish').default(false).isBoolean().toBoolean(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -124,6 +132,34 @@ export default class InventoryAdjustmentsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the given inventory adjustment transaction.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
async publishInventoryAdjustment(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { id: adjustmentId } = req.params;
|
||||
|
||||
try {
|
||||
await this.inventoryAdjustmentService.publishInventoryAdjustment(
|
||||
tenantId,
|
||||
adjustmentId
|
||||
);
|
||||
return res.status(200).send({
|
||||
id: adjustmentId,
|
||||
message: 'The inventory adjustment has been published successfully.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the inventory adjustments paginated list.
|
||||
* @param {Request} req
|
||||
|
||||
Reference in New Issue
Block a user