mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: retrieve all due invoices and bills or for specific customer/vendor.
This commit is contained in:
@@ -47,6 +47,14 @@ export default class BillsController extends BaseController {
|
||||
asyncMiddleware(this.editBill.bind(this)),
|
||||
this.handleServiceError,
|
||||
);
|
||||
router.get(
|
||||
'/due', [
|
||||
...this.dueBillsListingValidationSchema
|
||||
],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getDueBills.bind(this)),
|
||||
this.handleServiceError,
|
||||
)
|
||||
router.get(
|
||||
'/:id', [
|
||||
...this.specificBillValidationSchema,
|
||||
@@ -139,6 +147,12 @@ export default class BillsController extends BaseController {
|
||||
query('sort_order').optional().isIn(['desc', 'asc']),
|
||||
];
|
||||
}
|
||||
|
||||
get dueBillsListingValidationSchema() {
|
||||
return [
|
||||
query('vendor_id').optional().trim().escape(),
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new bill and records journal transactions.
|
||||
@@ -255,6 +269,24 @@ export default class BillsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listing all due bills of the given vendor.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
public async getDueBills(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
const { vendorId } = this.matchedQueryData(req);
|
||||
|
||||
try {
|
||||
const bills = await this.billsService.getDueBills(tenantId, vendorId);
|
||||
return res.status(200).send({ bills });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles service errors.
|
||||
* @param {Error} error
|
||||
|
||||
Reference in New Issue
Block a user