This commit is contained in:
sebseb7
2025-08-02 08:26:08 +02:00
parent 5c416c77f0
commit da435d2e66
6 changed files with 44 additions and 31 deletions

View File

@@ -270,4 +270,4 @@ router.delete('/buchungsschluessel/:id', authenticateToken, async (req, res) =>
}
});
module.exports = router;
module.exports = router;

View File

@@ -143,8 +143,8 @@ router.get('/assignable-kreditors', authenticateToken, async (req, res) => {
const query = `
SELECT id, name, kreditorId
FROM fibdash.Kreditor
WHERE is_banking = 0
FROM fibdash.Kreditor
WHERE (is_banking = 0 OR is_banking IS NULL)
ORDER BY name
`;

View File

@@ -58,8 +58,9 @@ router.post('/kreditors', authenticateToken, async (req, res) => {
return res.status(400).json({ error: 'Name and kreditorId are required' });
}
if (!isBanking && (!iban || iban.trim() === '')) {
return res.status(400).json({ error: 'IBAN is required (except for banking accounts)' });
// Business rule: IBAN is required for banking kreditors (proxies), not required for real kreditors
if (isBanking && (!iban || iban.trim() === '')) {
return res.status(400).json({ error: 'IBAN is required for banking kreditors' });
}
if (iban && iban.trim() !== '') {
@@ -108,8 +109,9 @@ router.put('/kreditors/:id', authenticateToken, async (req, res) => {
return res.status(400).json({ error: 'Name and kreditorId are required' });
}
if (!isBanking && (!iban || iban.trim() === '')) {
return res.status(400).json({ error: 'IBAN is required (except for banking accounts)' });
// Business rule: IBAN is required for banking kreditors (proxies), not required for real kreditors
if (isBanking && (!iban || iban.trim() === '')) {
return res.status(400).json({ error: 'IBAN is required for banking kreditors' });
}
const checkQuery = `SELECT id FROM fibdash.Kreditor WHERE id = @id`;