Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This commit modifies the log level in the configuration file from "trace" to "debug" for improved logging clarity. It also introduces new routes for fulfillment, return, and payment policies in the index file, enhancing the marketplace integration capabilities. Additionally, the initialization process is updated to start the marketplace worker, ensuring that the application can handle marketplace operations effectively. Various schemas are updated to include new fields and relationships for policies, improving the overall functionality and flexibility of the marketplace management system.
107 lines
3.3 KiB
JavaScript
107 lines
3.3 KiB
JavaScript
import express from 'express';
|
|
import { isAuthenticated } from '../../keycloak.js';
|
|
import { checkPermissions } from '../../database/permissions.js';
|
|
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
|
|
|
const router = express.Router();
|
|
|
|
const listAllowedFilters = [
|
|
'name',
|
|
'rate',
|
|
'rateType',
|
|
'active',
|
|
'country',
|
|
'jurisdiction',
|
|
'marketplaces.marketplace',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference',
|
|
];
|
|
const listAllowedSorters = [
|
|
'name',
|
|
'rate',
|
|
'rateType',
|
|
'active',
|
|
'country',
|
|
'jurisdiction',
|
|
'createdAt',
|
|
'_id',
|
|
'updatedAt',
|
|
];
|
|
const propertiesAllowedFilters = ['rateType', 'country', 'jurisdiction', 'active'];
|
|
import {
|
|
listTaxRatesRouteHandler,
|
|
getTaxRateRouteHandler,
|
|
editTaxRateRouteHandler,
|
|
newTaxRateRouteHandler,
|
|
deleteTaxRateRouteHandler,
|
|
listTaxRatesByPropertiesRouteHandler,
|
|
getTaxRateStatsRouteHandler,
|
|
getTaxRateHistoryRouteHandler,
|
|
searchTaxRatesRouteHandler,
|
|
getTaxRatePropertyValuesRouteHandler,
|
|
|
|
getTaxRateNeighborsRouteHandler
|
|
} from '../../services/management/taxrates.js';
|
|
|
|
// list of tax rates
|
|
router.get('/', isAuthenticated, checkPermissions('taxRate', 'list'), async (req, res) => {
|
|
const { page, limit, property, search, sortProperty, sortOrder } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
listTaxRatesRouteHandler(req, res, page, limit, property, filter, search, getSort(sortProperty, listAllowedSorters), sortOrder);
|
|
});
|
|
|
|
router.get('/properties', checkPermissions('taxRate', 'list'), isAuthenticated, async (req, res) => {
|
|
let properties = convertPropertiesString(req.query.properties);
|
|
const filter = await getFilter(req.query, propertiesAllowedFilters, false);
|
|
var masterFilter = {};
|
|
if (req.query.masterFilter) {
|
|
masterFilter = JSON.parse(req.query.masterFilter);
|
|
}
|
|
listTaxRatesByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
|
|
});
|
|
|
|
router.get('/values', checkPermissions('taxRate', 'list'), isAuthenticated, async (req, res) => {
|
|
const { property } = req.query;
|
|
getTaxRatePropertyValuesRouteHandler(req, res, property);
|
|
});
|
|
|
|
router.get('/search', checkPermissions('taxRate', 'list'), isAuthenticated, async (req, res) => {
|
|
const { search } = req.query;
|
|
searchTaxRatesRouteHandler(req, res, search);
|
|
});
|
|
|
|
router.post('/', isAuthenticated, checkPermissions('taxRate', 'new'), async (req, res) => {
|
|
newTaxRateRouteHandler(req, res);
|
|
});
|
|
|
|
// get tax rate stats
|
|
router.get('/stats', isAuthenticated, async (req, res) => {
|
|
getTaxRateStatsRouteHandler(req, res);
|
|
});
|
|
|
|
// get tax rate history
|
|
router.get('/history', isAuthenticated, async (req, res) => {
|
|
getTaxRateHistoryRouteHandler(req, res);
|
|
});
|
|
|
|
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
|
const { property, search, sortProperty, sortOrder, id } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
getTaxRateNeighborsRouteHandler(req, res, property, filter, search, getSort(sortProperty, listAllowedSorters), sortOrder, id);
|
|
});
|
|
|
|
router.get('/:id', isAuthenticated, async (req, res) => {
|
|
getTaxRateRouteHandler(req, res);
|
|
});
|
|
|
|
router.put('/:id', isAuthenticated, checkPermissions('taxRate', 'edit'), async (req, res) => {
|
|
editTaxRateRouteHandler(req, res);
|
|
});
|
|
|
|
router.delete('/:id', isAuthenticated, async (req, res) => {
|
|
deleteTaxRateRouteHandler(req, res);
|
|
});
|
|
|
|
export default router;
|