mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: get specifici payment receive/made details.
This commit is contained in:
@@ -31,20 +31,6 @@ export default class BillsPayments extends BaseController {
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/new-page/entries',
|
||||
[query('vendor_id').exists()],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getBillPaymentNewPageEntries.bind(this)),
|
||||
this.handleServiceError
|
||||
);
|
||||
router.get(
|
||||
'/:id/edit-page',
|
||||
this.specificBillPaymentValidateSchema,
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getBillPaymentEditPage.bind(this)),
|
||||
this.handleServiceError
|
||||
);
|
||||
router.post(
|
||||
'/',
|
||||
[...this.billPaymentSchemaValidation],
|
||||
@@ -69,6 +55,20 @@ export default class BillsPayments extends BaseController {
|
||||
asyncMiddleware(this.deleteBillPayment.bind(this)),
|
||||
this.handleServiceError
|
||||
);
|
||||
router.get(
|
||||
'/new-page/entries',
|
||||
[query('vendor_id').exists()],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getBillPaymentNewPageEntries.bind(this)),
|
||||
this.handleServiceError
|
||||
);
|
||||
router.get(
|
||||
'/:id/edit-page',
|
||||
this.specificBillPaymentValidateSchema,
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getBillPaymentEditPage.bind(this)),
|
||||
this.handleServiceError
|
||||
);
|
||||
router.get(
|
||||
'/:id/bills',
|
||||
this.specificBillPaymentValidateSchema,
|
||||
@@ -156,10 +156,14 @@ export default class BillsPayments extends BaseController {
|
||||
|
||||
/**
|
||||
* Retrieve the bill payment edit page details.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
*/
|
||||
async getBillPaymentEditPage(req: Request, res: Response, next: NextFunction) {
|
||||
async getBillPaymentEditPage(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { id: paymentReceiveId } = req.params;
|
||||
|
||||
@@ -169,7 +173,7 @@ export default class BillsPayments extends BaseController {
|
||||
entries,
|
||||
} = await this.billPaymentService.getBillPaymentEditPage(
|
||||
tenantId,
|
||||
paymentReceiveId,
|
||||
paymentReceiveId
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
@@ -265,16 +269,13 @@ export default class BillsPayments extends BaseController {
|
||||
const { id: billPaymentId } = req.params;
|
||||
|
||||
try {
|
||||
const {
|
||||
billPayment,
|
||||
payableBills,
|
||||
paymentMadeBills,
|
||||
} = await this.billPaymentService.getBillPayment(tenantId, billPaymentId);
|
||||
const billPayment = await this.billPaymentService.getBillPayment(
|
||||
tenantId,
|
||||
billPaymentId
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
bill_payment: this.transfromToResponse({ ...billPayment }),
|
||||
payable_bills: this.transfromToResponse([...payableBills]),
|
||||
payment_bills: this.transfromToResponse([...paymentMadeBills]),
|
||||
bill_payment: this.transfromToResponse(billPayment),
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
@@ -40,13 +40,6 @@ 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/edit-page',
|
||||
this.paymentReceiveValidation,
|
||||
@@ -56,13 +49,24 @@ export default class PaymentReceivesController extends BaseController {
|
||||
);
|
||||
router.get(
|
||||
'/new-page/entries',
|
||||
[
|
||||
query('customer_id').exists().isNumeric().toInt(),
|
||||
],
|
||||
[query('customer_id').exists().isNumeric().toInt()],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getPaymentReceiveNewPageEntries.bind(this)),
|
||||
this.getPaymentReceiveNewPageEntries.bind(this)
|
||||
);
|
||||
router.get(
|
||||
'/:id/invoices',
|
||||
this.paymentReceiveValidation,
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.getPaymentReceiveInvoices.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/:id',
|
||||
this.paymentReceiveValidation,
|
||||
this.asyncMiddleware(this.getPaymentReceive.bind(this)),
|
||||
this.handleServiceErrors
|
||||
);
|
||||
router.get(
|
||||
'/',
|
||||
this.validatePaymentReceiveList,
|
||||
@@ -224,14 +228,18 @@ export default class PaymentReceivesController extends BaseController {
|
||||
* @param {Request} req -
|
||||
* @param {Response} res -
|
||||
*/
|
||||
async getPaymentReceiveEditPage(req: Request, res: Response, next: NextFunction) {
|
||||
async getPaymentReceiveEditPage(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId, user } = req;
|
||||
const { id: paymentReceiveId } = req.params;
|
||||
|
||||
try {
|
||||
const {
|
||||
paymentReceive,
|
||||
entries
|
||||
entries,
|
||||
} = await this.paymentReceiveService.getPaymentReceiveEditPage(
|
||||
tenantId,
|
||||
paymentReceiveId,
|
||||
@@ -317,10 +325,14 @@ export default class PaymentReceivesController extends BaseController {
|
||||
* @param {Request} req - Request.
|
||||
* @param {Response} res - Response.
|
||||
*/
|
||||
async getPaymentReceiveNewPageEntries(req, res) {
|
||||
async getPaymentReceiveNewPageEntries(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { customerId } = this.matchedQueryData(req);
|
||||
|
||||
|
||||
try {
|
||||
const entries = await this.paymentReceiveService.getNewPageEntries(
|
||||
tenantId,
|
||||
@@ -329,7 +341,33 @@ export default class PaymentReceivesController extends BaseController {
|
||||
return res.status(200).send({
|
||||
entries: this.transfromToResponse(entries),
|
||||
});
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the payment receive details.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
async getPaymentReceive(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
const { id: paymentReceiveId } = req.params;
|
||||
|
||||
try {
|
||||
const paymentReceive = await this.paymentReceiveService.getPaymentReceive(
|
||||
tenantId,
|
||||
paymentReceiveId
|
||||
);
|
||||
|
||||
return res
|
||||
.status(200)
|
||||
.send({ payment_receive: this.transfromToResponse(paymentReceive) });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,9 +401,7 @@ export default class PaymentReceivesController extends BaseController {
|
||||
}
|
||||
if (error.errorType === 'DEPOSIT_ACCOUNT_INVALID_TYPE') {
|
||||
return res.boom.badRequest(null, {
|
||||
errors: [
|
||||
{ type: 'DEPOSIT_ACCOUNT_INVALID_TYPE', code: 300 },
|
||||
],
|
||||
errors: [{ type: 'DEPOSIT_ACCOUNT_INVALID_TYPE', code: 300 }],
|
||||
});
|
||||
}
|
||||
if (error.errorType === 'INVALID_PAYMENT_AMOUNT_INVALID') {
|
||||
|
||||
Reference in New Issue
Block a user