Spaces:
Runtime error
Runtime error
File size: 1,710 Bytes
222dbfc 2c97468 e66f26b 6147b1b 222dbfc 6147b1b 0949fd2 222dbfc e66f26b c9a0f3f e66f26b 6147b1b 9a25b53 e66f26b 9a25b53 222dbfc 2c97468 d747060 222dbfc 2b10760 e66f26b c9a0f3f e66f26b 6147b1b e66f26b d747060 e66f26b 6147b1b 2b10760 d747060 2b10760 e66f26b 2b10760 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import { Request, Response } from 'express';
import { logger } from '../../utils/logger';
import PWGlaccounts from '../../models/pwGlaccounts';
import { syncGlAccountsFromJsonService } from '../../shared/services/glaccounts.service';
const ExpenseAccountTypes = ['Expense', 'Income', 'Current Liability', 'Current Asset', 'Equity'];
export const fetchGLAccountsData = async (req: Request, res: Response) => {
try {
const glAccounts = await PWGlaccounts.findAll({
attributes: [['pw_id', 'id'], 'name'],
order: [['name', 'ASC']],
});
res.status(200).json(glAccounts);
} catch (error) {
logger.error('Error fetching GL accounts:', error);
logger.error(error);
res.status(500).json({ error: 'Error fetching GL accounts' });
}
};
export const fetchGLAccountsWithDetails = async (req: Request, res: Response) => {
try {
const glAccounts = await PWGlaccounts.findAll({
attributes: [['pw_id', 'id'], 'name', ['account_number', 'accountNumber']],
order: [['name', 'ASC']],
});
res.status(200).json(glAccounts);
} catch (error) {
logger.error('Error fetching GL accounts:', error);
logger.error(error);
res.status(500).json({ error: 'Error fetching GL accounts' });
}
};
export const syncGLAccounts = async (req: Request, res: Response) => {
try {
const result = await syncGlAccountsFromJsonService();
res.status(200).json(result);
} catch (error) {
logger.error('Error syncing GL accounts:', error);
logger.error(error);
res.status(500).json({ error: 'Error syncing GL accounts' });
}
};
|