refactoring: payment made form.

This commit is contained in:
a.bouhuolia
2021-02-21 13:00:06 +02:00
parent 265198103d
commit df2d215071
25 changed files with 542 additions and 145 deletions

View File

@@ -17,14 +17,32 @@ export default class FinancialStatementsService {
router() {
const router = Router();
router.use('/balance_sheet', Container.get(BalanceSheetController).router());
router.use('/profit_loss_sheet', Container.get(ProfitLossController).router());
router.use('/general_ledger', Container.get(GeneralLedgerController).router());
router.use('/trial_balance_sheet', Container.get(TrialBalanceSheetController).router());
router.use(
'/balance_sheet',
Container.get(BalanceSheetController).router()
);
router.use(
'/profit_loss_sheet',
Container.get(ProfitLossController).router()
);
router.use(
'/general_ledger',
Container.get(GeneralLedgerController).router()
);
router.use(
'/trial_balance_sheet',
Container.get(TrialBalanceSheetController).router()
);
router.use('/journal', Container.get(JournalSheetController).router());
router.use('/receivable_aging_summary', Container.get(ARAgingSummary).router());
router.use('/payable_aging_summary', Container.get(APAgingSummary).router());
router.use(
'/receivable_aging_summary',
Container.get(ARAgingSummary).router()
);
router.use(
'/payable_aging_summary',
Container.get(APAgingSummary).router()
);
return router;
}
};
}

View File

@@ -8,6 +8,7 @@ import BillPaymentsService from 'services/Purchases/BillPayments';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
import AccountsService from 'services/Accounts/AccountsService';
import ResourceController from '../Resources';
import { Request } from 'express-validator/src/base';
/**
* Bills payments controller.
@@ -30,6 +31,20 @@ 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],
@@ -76,6 +91,7 @@ export default class BillsPayments extends BaseController {
this.handleServiceError,
this.dynamicListService.handlerErrorsToResponse
);
return router;
}
@@ -118,6 +134,53 @@ export default class BillsPayments extends BaseController {
];
}
/**
* Retrieve bill payment new page entries.
* @param {Request} req -
* @param {Response} res -
*/
async getBillPaymentNewPageEntries(req: Request, res: Response) {
const { tenantId } = req;
const { vendorId } = this.matchedQueryData(req);
try {
const entries = await this.billPaymentService.getNewPageEntries(
tenantId,
vendorId
);
return res.status(200).send({
entries: this.transfromToResponse(entries),
});
} catch (error) {}
}
/**
* Retrieve the bill payment edit page details.
* @param {Request} req
* @param {Response} res
*/
async getBillPaymentEditPage(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req;
const { id: paymentReceiveId } = req.params;
try {
const {
billPayment,
entries,
} = await this.billPaymentService.getBillPaymentEditPage(
tenantId,
paymentReceiveId,
);
return res.status(200).send({
bill_payment: this.transfromToResponse(billPayment),
entries: this.transfromToResponse(entries),
});
} catch (error) {
next(error);
}
}
/**
* Creates a bill payment.
* @async

View File

@@ -54,6 +54,15 @@ export default class PaymentReceivesController extends BaseController {
asyncMiddleware(this.getPaymentReceiveEditPage.bind(this)),
this.handleServiceErrors
);
router.get(
'/new-page/entries',
[
query('customer_id').exists().isNumeric().toInt(),
],
this.validationResult,
asyncMiddleware(this.getPaymentReceiveNewPageEntries.bind(this)),
this.getPaymentReceiveNewPageEntries.bind(this)
);
router.get(
'/',
this.validatePaymentReceiveList,
@@ -303,6 +312,26 @@ export default class PaymentReceivesController extends BaseController {
}
}
/**
* Retrieve payment receive new page receivable entries.
* @param {Request} req - Request.
* @param {Response} res - Response.
*/
async getPaymentReceiveNewPageEntries(req, res) {
const { tenantId } = req;
const { customerId } = this.matchedQueryData(req);
try {
const entries = await this.paymentReceiveService.getNewPageEntries(
tenantId,
customerId
);
return res.status(200).send({
entries: this.transfromToResponse(entries),
});
} catch (error) {}
}
/**
* Handles service errors.
* @param error