feat: retrieve bills that associated to payment made transaction.

feat: retrieve sale invoices that associated to payment receive transactions.
This commit is contained in:
Ahmed Bouhuolia
2020-10-28 22:41:16 +02:00
parent fd6a3224fa
commit a457005fd8
4 changed files with 93 additions and 4 deletions

View File

@@ -40,6 +40,13 @@ export default class PaymentReceivesController extends BaseController {
asyncMiddleware(this.newPaymentReceive.bind(this)),
this.handleServiceErrors,
);
router.get(
'/:id/invoices',
this.paymentReceiveValidation,
this.validationResult,
asyncMiddleware(this.getPaymentReceiveInvoices.bind(this)),
this.handleServiceErrors,
);
router.get(
'/:id',
this.paymentReceiveValidation,
@@ -209,6 +216,26 @@ export default class PaymentReceivesController extends BaseController {
}
}
/**
* Retrieve sale invoices that associated with the given payment receive.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/
async getPaymentReceiveInvoices(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req;
const { id: paymentReceiveId } = req.params;
try {
const invoices = await this.paymentReceiveService.getPaymentReceiveInvoices(
tenantId, paymentReceiveId,
);
return res.status(200).send({ sale_invoices: invoices });
} catch (error) {
next(error);
}
}
/**
* Retrieve payment receive list with pagination metadata.
* @param {Request} req