| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const express = require('express');
- const app = express();
- app.use(express.json()); //für das Parsing von JSON-Daten
- app.post('/calculate', (req, res) => {
- let totalIncome = 0;
- const persons = req.body;
- for (const person of persons) {
- for (const income of person.incomes) {
- let annualIncome = income.amount * income.frequency;
- annualIncome -= income.advertisingCosts;
- totalIncome += annualIncome;
- }
- }
- //Beispiel Berechnung entspricht nicht der WBS Berechnung
- let maxIncome = persons.length * 12000;
- let wbsGranted = maxIncome <= totalIncome;
- res.send({ wbsGranted: wbsGranted });
- });
- app.get('/frequencies', (req, res) => {
- const frequencies = [
- { value: 365, description: 'täglich' },
- { value: 12, description: 'monatlich' },
- { value: 4, description: 'vierteljährlich' },
- { value: 1, description: 'jährlich' }
- //usw...
- ];
- res.send(frequencies);
- });
- app.get('/types', (req, res) => {
- const types = [
- { value: 'work', description: 'als Arbeitnehmer' },
- { value: 'pensioner', description: 'als Rentner' },
- { value: 'social', description: 'Einnahme aus Sozialeistungen' },
- { value: 'entertains', description: 'Unterhalt' }
- //usw...
- ];
- res.send(frequencies);
- });
- const port = process.env.PORT || 3000;
- app.listen(port, () => console.log(`Server läuft auf Port ${port}...`));
|