refactoring: custom views service.

fix: constraints of delete item from storage.
fix: constraints of delete item category from storage.
fix: localize database seeds files.
fix: view meta data in accounts list response.
This commit is contained in:
Ahmed Bouhuolia
2020-10-05 19:09:56 +02:00
parent 0114ed9f8b
commit 99e6fe273f
64 changed files with 1593 additions and 1103 deletions

View File

@@ -1,4 +1,4 @@
import { Router, Request, Response } from 'express';
import { Router, Request, Response, NextFunction } from 'express';
import { check, param, query, matchedData } from 'express-validator';
import { difference } from 'lodash';
import { raw } from 'objection';
@@ -7,7 +7,8 @@ import BaseController from '../BaseController';
import asyncMiddleware from 'api/middleware/asyncMiddleware';
import SaleInvoiceService from 'services/Sales/SalesInvoices';
import ItemsService from 'services/Items/ItemsService';
import { ISaleInvoiceOTD } from 'interfaces';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
import { ISaleInvoiceOTD, ISalesInvoicesFilter } from 'interfaces';
@Service()
export default class SaleInvoicesController extends BaseController{
@@ -17,6 +18,9 @@ export default class SaleInvoicesController extends BaseController{
@Inject()
saleInvoiceService: SaleInvoiceService;
@Inject()
dynamicListService: DynamicListingService;
/**
* Router constructor.
*/
@@ -412,7 +416,21 @@ export default class SaleInvoicesController extends BaseController{
* @param {Response} res
* @param {Function} next
*/
async getSalesInvoices(req, res) {
public async getSalesInvoices(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req.params;
const salesInvoicesFilter: ISalesInvoicesFilter = req.query;
try {
const { salesInvoices, filterMeta, pagination } = await this.saleInvoiceService.salesInvoicesList(
tenantId, salesInvoicesFilter,
);
return res.status(200).send({
sales_invoices: salesInvoices,
pagination: this.transfromToResponse(pagination),
filter_meta: this.transfromToResponse(filterMeta),
});
} catch (error) {
next(error);
}
}
}