Enhance CSV import functionality with improved error messaging and logging

- Updated error message in CSVImportPanel to include a period for better readability.
- Added console logs in the CSV import API route to track the import process and precheck status.
- Removed redundant validation for 'Beguenstigter/Zahlungspflichtiger' to streamline error handling during CSV import.
This commit is contained in:
sebseb7
2025-08-21 04:46:30 +02:00
parent 8e8d93e4a6
commit bd7c6dddbf
2 changed files with 5 additions and 4 deletions

View File

@@ -457,7 +457,7 @@ class CSVImportPanel extends Component {
)}
{importResult.errors > 0 && (
<Typography variant="body1" color="warning.main">
<strong>Fehler:</strong> {importResult.errors} Zeilen konnten nicht verarbeitet werden
<strong>Fehler:</strong> {importResult.errors} Zeilen konnten nicht verarbeitet werden.
</Typography>
)}
{importResult.message && (

View File

@@ -129,6 +129,7 @@ router.post('/test-csv-import', async (req, res) => {
// Import CSV transactions to database
router.post('/import-csv-transactions', authenticateToken, async (req, res) => {
console.log('Importing CSV transactions');
try {
const { executeQuery } = require('../../config/database');
const { transactions, filename, batchId, headers } = req.body;
@@ -180,6 +181,7 @@ router.post('/import-csv-transactions', authenticateToken, async (req, res) => {
let successCount = 0;
let errorCount = 0;
const errors = [];
console.log('precheck done');
for (let i = 0; i < transactions.length; i++) {
const transaction = transactions[i];
@@ -195,9 +197,6 @@ router.post('/import-csv-transactions', authenticateToken, async (req, res) => {
validationErrors.push('Betrag is required');
}
if (!transaction['Beguenstigter/Zahlungspflichtiger'] || transaction['Beguenstigter/Zahlungspflichtiger'].trim() === '') {
validationErrors.push('Beguenstigter/Zahlungspflichtiger is required');
}
if (validationErrors.length > 2) {
console.log('Skipping invalid row ' + (i + 1) + ':', validationErrors);
@@ -287,6 +286,8 @@ router.post('/import-csv-transactions', authenticateToken, async (req, res) => {
errorCount++;
}
}
console.log('import done',errors);
res.json({
success: true,