import { Router } from 'express';
import { fiscalController } from './fiscal.controller.js';
import { authenticate } from '../../shared/middleware/auth.middleware.js';

const router = Router();

// All routes require authentication
router.use(authenticate);

// ========== TAX CATEGORIES ==========
router.get('/tax-categories', (req, res, next) => fiscalController.getTaxCategories(req, res, next));
router.get('/tax-categories/by-code/:code', (req, res, next) => fiscalController.getTaxCategoryByCode(req, res, next));
router.get('/tax-categories/by-sat-code/:satCode', (req, res, next) => fiscalController.getTaxCategoryBySatCode(req, res, next));
router.get('/tax-categories/:id', (req, res, next) => fiscalController.getTaxCategory(req, res, next));

// ========== FISCAL REGIMES ==========
router.get('/fiscal-regimes', (req, res, next) => fiscalController.getFiscalRegimes(req, res, next));
router.get('/fiscal-regimes/by-code/:code', (req, res, next) => fiscalController.getFiscalRegimeByCode(req, res, next));
router.get('/fiscal-regimes/person-type/:personType', (req, res, next) => fiscalController.getFiscalRegimesForPersonType(req, res, next));
router.get('/fiscal-regimes/:id', (req, res, next) => fiscalController.getFiscalRegime(req, res, next));

// ========== CFDI USES ==========
router.get('/cfdi-uses', (req, res, next) => fiscalController.getCfdiUses(req, res, next));
router.get('/cfdi-uses/by-code/:code', (req, res, next) => fiscalController.getCfdiUseByCode(req, res, next));
router.get('/cfdi-uses/person-type/:personType', (req, res, next) => fiscalController.getCfdiUsesForPersonType(req, res, next));
router.get('/cfdi-uses/regime/:regimeCode', (req, res, next) => fiscalController.getCfdiUsesForRegime(req, res, next));
router.get('/cfdi-uses/:id', (req, res, next) => fiscalController.getCfdiUse(req, res, next));

// ========== PAYMENT METHODS (SAT Forms of Payment) ==========
router.get('/payment-methods', (req, res, next) => fiscalController.getPaymentMethods(req, res, next));
router.get('/payment-methods/by-code/:code', (req, res, next) => fiscalController.getPaymentMethodByCode(req, res, next));
router.get('/payment-methods/:id', (req, res, next) => fiscalController.getPaymentMethod(req, res, next));

// ========== PAYMENT TYPES (SAT Payment Methods - PUE/PPD) ==========
router.get('/payment-types', (req, res, next) => fiscalController.getPaymentTypes(req, res, next));
router.get('/payment-types/by-code/:code', (req, res, next) => fiscalController.getPaymentTypeByCode(req, res, next));
router.get('/payment-types/:id', (req, res, next) => fiscalController.getPaymentType(req, res, next));

// ========== WITHHOLDING TYPES ==========
router.get('/withholding-types', (req, res, next) => fiscalController.getWithholdingTypes(req, res, next));
router.get('/withholding-types/by-code/:code', (req, res, next) => fiscalController.getWithholdingTypeByCode(req, res, next));
router.get('/withholding-types/by-category/:categoryId', (req, res, next) => fiscalController.getWithholdingTypesByCategory(req, res, next));
router.get('/withholding-types/:id', (req, res, next) => fiscalController.getWithholdingType(req, res, next));

export default router;
