initial version

This commit is contained in:
Tobias Petrich 2024-03-25 12:20:05 +01:00
commit a7288032ba
Signed by: t.petrich
GPG Key ID: D99301AD0515015F
28 changed files with 5766 additions and 0 deletions

18
.eslintrc.cjs Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}

164
.gitignore vendored Normal file
View File

@ -0,0 +1,164 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Example user template template
### Example user template
# IntelliJ project files
.idea
*.iml
out
gen

30
README.md Normal file
View File

@ -0,0 +1,30 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level `parserOptions` property like this:
```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FaSTTUBe Rückerstattung</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

4378
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

38
package.json Normal file
View File

@ -0,0 +1,38 @@
{
"name": "ft-rueckerstattung",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5.15.14",
"@mui/material": "^5.15.14",
"@mui/x-date-pickers": "^7.0.0",
"@react-pdf/renderer": "^3.1.14",
"@types/iban": "^0.0.35",
"dayjs": "^1.11.10",
"iban": "^0.0.14",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}

1
public/vite.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

0
src/App.css Normal file
View File

46
src/App.tsx Normal file
View File

@ -0,0 +1,46 @@
import {useState} from 'react'
import './App.css'
import {Container, Grid, Typography} from "@mui/material";
import {PDFViewer} from "@react-pdf/renderer";
import {LocalizationProvider} from '@mui/x-date-pickers';
import 'dayjs/locale/de';
import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs'
import MyDocument from "./components/pdf/MyDocument.tsx";
import Person from "./data/Person.ts";
import Bank from "./data/Bank.ts";
import Inputs from "./components/organisms/Inputs.tsx";
import Posten from "./data/Posten.ts";
function App() {
const [person, setPerson] = useState(new Person());
const [bank, setBank] = useState(new Bank());
const postenList = [new Posten(1)];
const [posten, setPosten] = useState(postenList);
return (
<>
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="de">
<Container maxWidth={false}>
<Grid container>
<Grid item lg={12}>
<Typography variant={"h1"} align={"center"}>FaSTTUBe Rückerstattung</Typography>
</Grid>
<Grid item lg={6} sm={12} sx={{height: "90vh", overflow: "auto"}}>
<Inputs person={person} setPerson={setPerson} bank={bank} setBank={setBank} posten={posten}
setPosten={setPosten}/>
</Grid>
<Grid item lg={6} sm={12} sx={{height: "90vh"}}>
<PDFViewer style={{height: "100%", width: "100%"}}>
<MyDocument person={person} bankdaten={bank} posten={posten}></MyDocument>
</PDFViewer>
</Grid>
</Grid>
</Container>
</LocalizationProvider>
</>
)
}
export default App

1
src/assets/react.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,41 @@
import {TextField, Typography} from "@mui/material";
import Bank from "../../data/Bank.ts";
const styles = {
textfield: {
marginBottom: 1
}
}
const BankInput = ({bank, setBank}: { bank: Bank, setBank: any }) => {
return (
<>
<Typography variant={"h2"}>Bankdaten</Typography>
<TextField id="outlined-basic" label="Bank" variant="outlined" fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newBank = Object.assign(new Bank(), bank);
newBank.setName(event.target.value);
setBank(newBank);
}}/>
<TextField id="outlined-basic" label="IBAN" variant="outlined" error={!bank.isIbanCorrect()}
fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newBank = Object.assign(new Bank(), bank);
newBank.setIban(event.target.value);
setBank(newBank);
}}/>
<TextField id="outlined-basic" label="BIC" variant="outlined" error={!bank.isBicCorrect()}
fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newBank = Object.assign(new Bank(), bank);
newBank.setBic(event.target.value);
setBank(newBank);
}}/>
</>
);
}
export default BankInput;

View File

@ -0,0 +1,74 @@
import {TextField, Typography} from "@mui/material";
import Person from "../../data/Person.ts";
import {DatePicker} from "@mui/x-date-pickers/DatePicker";
import dayjs from "dayjs";
const styles = {
textfield: {
marginBottom: 1,
width: "100%"
}
}
const PersonInput = ({person, setPerson}: { person: Person, setPerson: any }) => {
return (
<>
<Typography variant={"h2"}>Personendaten</Typography>
<TextField id="outlined-basic" label="Name" variant="outlined" fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setName(event.target.value);
setPerson(newPerson);
}}/>
<TextField id="outlined-basic" label="Straße und Hausnummer" variant="outlined" fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setStreet(event.target.value);
setPerson(newPerson);
}}/>
<TextField id="outlined-basic" label="PLZ und Ort" variant="outlined"
error={!person.isPlzOrtCorrect()} fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setPlzOrt(event.target.value);
setPerson(newPerson);
}}/>
<TextField id="outlined-basic" label="Mobil" variant="outlined" fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setMobile(event.target.value);
setPerson(newPerson);
}}/>
<TextField id="outlined-basic" label="E-Mail" variant="outlined"
error={!person.isEmailCorrect()} fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setEmail(event.target.value);
setPerson(newPerson);
}}/>
<TextField id="outlined-basic" label="Steuer-ID" variant="outlined"
error={!person.isTaxIdCorrect()} fullWidth
sx={styles.textfield}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setTaxId(event.target.value);
setPerson(newPerson);
}}/>
<DatePicker id="outlined-basic" label="Geburtsdatum" variant="outlined"
error={!person.isBirthDateCorrect()} fullWidth
sx={styles.textfield}
onChange={(newvalue) => {
const newPerson = Object.assign(new Person(), person);
newPerson.setBirthDate(dayjs(newvalue));
setPerson(newPerson);
}}/>
</>
);
}
export default PersonInput;

View File

@ -0,0 +1,179 @@
import {TextField, Typography, Select, SelectChangeEvent, MenuItem, FormControl, Button} from "@mui/material";
import {DatePicker} from '@mui/x-date-pickers/DatePicker';
import DeleteIcon from '@mui/icons-material/Delete';
import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
import {Sachkonto, sachkontoDescription} from "../../data/Sachkonto.ts";
import Posten from "../../data/Posten.ts";
import Zahlungsart from "../../data/Zahlungsart.ts";
import dayjs from "dayjs";
import {useEffect, useState} from "react";
const styles = {
textfield: {
marginBottom: 1,
marginRight: 2
},
betragfield: {
marginBottom: 1,
marginRight: 2,
maxWidth: 150,
}
}
const PostenInput = ({thisPosten, posten, setPosten}: { thisPosten: Posten, posten: Posten[], setPosten: any }) => {
const [betragDisplay, setBetragDisplay] = useState('');
// useEffect(() => {
// // Format the initial posten betrag for display
// if (posten.getBetrag()) {
// const formattedValue = posten.getBetrag().toString().padStart(3, '0');
// const initialDisplayValue = formattedValue.slice(0, -2) + ',' + formattedValue.slice(-2);
// setBetragDisplay(initialDisplayValue);
// }
// }, [posten]);
const handleBetragChange = (event: React.ChangeEvent<HTMLInputElement>, isBlurred: boolean) => {
const originalValue = event.target.value;
let value = event.target.value;
// also work with dots: replace them with commas
value = value.replace('.', ',');
// check if comma is in string, if not, use the value as euros (multiply by 100 to get cents)
if (!value.includes(',')) {
value = (parseInt(event.target.value) * 100).toString();
} else {
// Get characters before and after the comma
const [euros, cents] = value.split(',');
// take only first two digits of cents
const formattedCents = cents.slice(0, 2);
// if cents are less than 10, pad with 0
value = euros + formattedCents.padEnd(2, '0');
// value = (parseInt(euros) * 100 + parseInt(formattedCents)).toString();
}
// Allow only digits
if (/^\d*$/.test(value)) {
const formattedValue = value.padStart(3, '0'); // Ensure at least 3 digits for formatting
const displayValue = formattedValue.slice(0, -2) + ',' + formattedValue.slice(-2);
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
thisPosten.setBetrag(parseInt(formattedValue, 10)); // Update posten in cents
return thisPosten;
}
return p;
});
setPosten(newList);
if (isBlurred) {
setBetragDisplay(displayValue);
} else {
setBetragDisplay(originalValue);
}
}
};
// onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
// const newPosten = Object.assign(new Posten(1), posten);
// newPosten.setBetrag(event.target.value);
// setPosten(newPosten);
// }}/>
return (
<>
<DatePicker id="outlined-basic" label="Datum" variant="outlined"
sx={styles.textfield}
value={thisPosten.getBelegDay()}
onChange={(newvalue) => {
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
thisPosten.setBelegdatum(dayjs(newvalue));
return thisPosten;
}
return p;
});
setPosten(newList);
}}/>
<TextField id="outlined-basic" label="Firma" variant="outlined"
sx={styles.textfield}
value={thisPosten.getFirma()}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
thisPosten.setFirma(event.target.value);
return thisPosten;
}
return p;
});
setPosten(newList);
}}/>
<Select id={"outlined-basic"} label={"Zahlungsart"} variant={"outlined"}
sx={styles.textfield}
value={thisPosten.getZahlungsart()}
onChange={(event: SelectChangeEvent<HTMLInputElement>) => {
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
thisPosten.setZahlungsart(event.target.value as string);
return thisPosten;
}
return p;
});
setPosten(newList);
}}>
{
Zahlungsart.map((zahlungsart) => {
return <MenuItem value={zahlungsart}>{zahlungsart}</MenuItem>
})
}
</Select>
<TextField id="outlined-basic" label="Betrag" variant="outlined"
sx={styles.betragfield}
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
handleBetragChange(event, true);
}}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
handleBetragChange(event, false);
}}
value={betragDisplay}
/>
<Button variant={"contained"}
color={"error"}
onClick={() => {
let toDeleteFound = false;
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
toDeleteFound = true;
return null;
}
if (!toDeleteFound) {
return p;
} else {
const newNummer = p.getNummer() - 1;
p.setNummer(newNummer);
return p;
}
}).filter((p) => p !== null);
setPosten(newList);
}}
>
<DeleteOutlineOutlinedIcon/>
</Button>
<TextField id="outlined-basic" label="Begründung" variant="outlined" fullWidth
sx={styles.textfield}
value={thisPosten.getBegruendung()}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
const newList = posten.map((p) => {
if (p.getNummer() === thisPosten.getNummer()) {
thisPosten.setBegruendung(event.target.value);
return thisPosten;
}
return p;
});
setPosten(newList);
}}/>
</>
);
}
export default PostenInput;

View File

@ -0,0 +1,48 @@
import {Box, Button, Typography} from "@mui/material";
import AddIcon from '@mui/icons-material/Add';
import Person from "../../data/Person.ts";
import Bank from "../../data/Bank.ts";
import PersonInput from "../molecules/PersonInput.tsx";
import BankInput from "../molecules/BankInput.tsx";
import PostenInput from "../molecules/PostenInput.tsx";
import Posten from "../../data/Posten.ts";
const Inputs = ({person, setPerson, bank, setBank, posten, setPosten}: {
person: Person,
setPerson: any,
bank: Bank,
setBank: any,
posten: Posten[],
setPosten: any
}) => {
return (
<>
<Box sx={{maxWidth: 500, margin: "auto"}}>
<PersonInput person={person} setPerson={setPerson}/>
<BankInput bank={bank} setBank={setBank}/>
</Box>
<Box sx={{margin: 10}}>
<Typography variant={"h2"}>Posten</Typography>
{posten.map((thisPosten: Posten) => {
return (
<PostenInput thisPosten={thisPosten} posten={posten} setPosten={setPosten}/>
);
})}
<Button variant={"contained"}
onClick={() => {
const newId = posten.length + 1;
const newPosten = new Posten(newId);
const newList = posten.concat(newPosten);
setPosten(newList);
}}
>
<AddIcon
/>
</Button>
</Box>
</>
);
}
export default Inputs;

View File

@ -0,0 +1,274 @@
import {Page, StyleSheet, Text, View} from "@react-pdf/renderer";
import WarningBox from "./WarningBox.tsx";
import Person from "../../data/Person.ts";
import Bank from "../../data/Bank.ts";
import Posten from "../../data/Posten.ts";
const styles = StyleSheet.create({
page: {
flexDirection: 'column',
backgroundColor: '#ffffff',
paddingLeft: '2cm',
paddingRight: '2cm',
paddingTop: '1.5cm',
paddingBottom: '1.5cm',
fontFamily: 'Helvetica',
fontSize: 11,
},
section: {
margin: 10,
padding: 10,
flexGrow: 1,
},
header: {
marginBottom: 20,
},
date: {
textAlign: 'right',
},
title: {
fontSize: 14,
textAlign: 'center',
marginBottom: 20,
fontWeight: 'heavy',
},
textBlock: {
// display: 'flex',
// flexDirection: 'row',
// flex: 1,
// flexWrap: 'wrap',
marginBottom: 10,
},
table: {
// display: "table",
width: "auto",
borderStyle: "solid",
borderWidth: 1,
borderRightWidth: 0,
borderBottomWidth: 0,
marginTop: 20,
marginBottom: 10,
},
tableRow: {
margin: "auto",
flexDirection: "row"
},
tableCol: {
width: "19%",
borderStyle: "solid",
borderWidth: 1,
borderLeftWidth: 0,
borderTopWidth: 0
},
tableColNum: {
width: "5%",
borderStyle: "solid",
borderWidth: 1,
borderLeftWidth: 0,
borderTopWidth: 0
},
tableColSmall: {
width: "14%",
borderStyle: "solid",
borderWidth: 1,
borderLeftWidth: 0,
borderTopWidth: 0
},
tableColBig: {
width: "29%",
borderStyle: "solid",
borderWidth: 1,
borderLeftWidth: 0,
borderTopWidth: 0
},
tableColSum: {
width: "86%",
borderStyle: "solid",
borderWidth: 1,
borderLeftWidth: 0,
borderTopWidth: 0
},
tableCell: {
margin: "auto",
marginTop: 5,
marginBottom: 5,
fontSize: 10
},
tableCellBetrag: {
// margin: "auto",
marginRight: 5,
marginTop: 5,
marginBottom: 5,
fontSize: 10,
textAlign: 'right',
},
signature: {
marginTop: 60,
paddingTop: 10,
borderTopWidth: 1,
borderTopColor: '#000',
borderTopStyle: 'solid',
width: '45%',
textAlign: 'left',
fontSize: 9,
},
tabbedRow: {
flexDirection: 'row',
width: '100%',
},
tabbedLeft: {
width: '10%',
},
richtigkeit: {
marginTop: 40,
},
});
const AuszahlungPage = ({person, bank, posten}: { person: Person, bank: Bank, posten: Posten[] }) => {
const current_date = new Date();
// <View style={styles.tableRow}>
// <View style={styles.tableColNum}>
// <Text style={styles.tableCell}>{posten.getNummer()}</Text>
// </View>
// <View style={styles.tableCol}>
// <Text style={styles.tableCell}>{posten.getBelegdatum()}</Text>
// </View>
// <View style={styles.tableCol}>
// <Text style={styles.tableCell}>{posten.getFirma()}</Text>
// </View>
// <View style={styles.tableColBig}>
// <Text style={styles.tableCell}>{posten.getBegruendung()}</Text>
// </View>
// <View style={styles.tableColSmall}>
// <Text style={styles.tableCell}>{posten.getZahlungsart()}</Text>
// </View>
// <View style={styles.tableColSmall}>
// <Text style={styles.tableCell}>{posten.getBetragString()}</Text>
// </View>
// </View>
const day = () => {
if (current_date.getDate() < 10) {
return '0' + current_date.getDate();
}
return current_date.getDate();
}
const month = () => {
if (current_date.getMonth() + 1 < 10) {
return '0' + (current_date.getMonth() + 1);
}
return current_date.getMonth() + 1;
}
const sum = posten.reduce((acc, posten) => acc + posten.getBetrag(), 0);
const sumEuros = Math.floor(sum / 100);
const sumCents = sum % 100;
const centsString = sumCents.toString().padStart(2, "0");
const sumString = sumEuros + ',' + centsString + ' €';
return (
<Page size="A4" wrap={true} style={styles.page}>
{(person.isCorrect() && bank.isCorrect()) ? null : <WarningBox incorrect={true}/>}
{(person.isComplete() && bank.isComplete()) ? null : <WarningBox incorrect={undefined}/>}
<View style={styles.header}>
<Text>{person.getName()}</Text>
<Text>{person.getStreet()}</Text>
<Text>{person.getPlzOrt()}</Text>
<Text>Mobil: {person.getMobile()}</Text>
<Text>E-Mail: {person.getEmail()}</Text>
<Text>Steuer-ID: {person.getTaxId()}</Text>
<Text>Geburtsdatum: {person.getBirthDate()}</Text>
</View>
<View style={styles.header}>
<Text>Technische Universität Berlin</Text>
<Text>Fachgebiet Kraftfahrzeuge / TIB 13</Text>
<Text>Gustav-Meyer-Allee 25</Text>
<Text>13355 Berlin</Text>
</View>
<Text style={styles.date}>Berlin, {day()}.{month()}.{current_date.getFullYear()}</Text>
<Text style={styles.title}>Auszahlung</Text>
<Text>Folgende für das studentische Lehrprojekt FaSTTUBe getätigte Ausgaben stelle ich in Rechnung:</Text>
<View style={styles.table}>
<View style={styles.tableRow}>
<View style={styles.tableColNum}>
<Text style={styles.tableCell}>#</Text>
</View>
<View style={styles.tableCol}>
<Text style={styles.tableCell}>Belegdatum</Text>
</View>
<View style={styles.tableCol}>
<Text style={styles.tableCell}>Firma</Text>
</View>
<View style={styles.tableColBig}>
<Text style={styles.tableCell}>Begründung</Text>
</View>
<View style={styles.tableColSmall}>
<Text style={styles.tableCell}>Zahlungsart</Text>
</View>
<View style={styles.tableColSmall}>
<Text style={styles.tableCell}>Betrag</Text>
</View>
</View>
{posten.map((posten) => {
return (
<View style={styles.tableRow}>
<View style={styles.tableColNum}>
<Text style={styles.tableCell}>{posten.getNummer()}</Text>
</View>
<View style={styles.tableCol}>
<Text style={styles.tableCell}>{posten.getBelegdatum()}</Text>
</View>
<View style={styles.tableCol}>
<Text style={styles.tableCell}>{posten.getFirma()}</Text>
</View>
<View style={styles.tableColBig}>
<Text style={styles.tableCell}>{posten.getBegruendung()}</Text>
</View>
<View style={styles.tableColSmall}>
<Text style={styles.tableCell}>{posten.getZahlungsart()}</Text>
</View>
<View style={styles.tableColSmall}>
<Text style={styles.tableCellBetrag}>{posten.getBetragString()}</Text>
</View>
</View>
);
})}
<View style={styles.tableRow}>
<View style={styles.tableColSum}>
<Text style={styles.tableCell}>Summe</Text>
</View>
<View style={styles.tableColSmall}>
<Text style={styles.tableCellBetrag}>{sumString}</Text>
</View>
</View>
</View>
<View style={styles.textBlock}>
<Text style={{marginBottom: 10}}>Bitte überweisen Sie den Betrag auf mein Konto:</Text>
<View style={styles.tabbedRow}>
<Text style={styles.tabbedLeft}>Bank:</Text>
<Text>{bank.getName()}</Text>
</View>
<View style={styles.tabbedRow}>
<Text style={styles.tabbedLeft}>IBAN:</Text>
<Text>{bank.getIban()}</Text>
</View>
<View style={styles.tabbedRow}>
<Text style={styles.tabbedLeft}>BIC:</Text>
<Text>{bank.getBic()}</Text>
</View>
</View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={styles.signature}>Unterschrift Rechnungssteller</Text>
<Text style={styles.signature}>Unterschrift Projektleitung</Text>
</View>
<Text style={styles.richtigkeit}>Für die Richtigkeit der Leistung / Lieferung:</Text>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={styles.signature}>Unterschrift, Datum</Text>
<Text style={styles.signature}>Name in Blockschrift</Text>
</View>
</Page>
);
}
export default AuszahlungPage;

View File

@ -0,0 +1,14 @@
import {Document} from '@react-pdf/renderer';
import Person from "../../data/Person.ts";
import AuszahlungPage from "./AuszahlungPage.tsx";
import Posten from "../../data/Posten.ts";
const MyDocument = ({person, bankdaten, posten}: { person: Person, bankdaten: any, posten: Posten[] }) => {
return (
<Document>
<AuszahlungPage person={person} bank={bankdaten} posten={posten}/>
</Document>
);
}
export default MyDocument;

View File

@ -0,0 +1,36 @@
import {StyleSheet, Text, View} from "@react-pdf/renderer";
const styles = StyleSheet.create({
box: {
width: "100%",
backgroundColor: "#ff0000",
display: "flex",
justifyContent: "center",
marginBottom: 10,
},
text: {
fontSize: 20,
textAlign: "center",
color: "#ffffff",
}
});
const WarningBox = ({incorrect}: { incorrect: boolean | undefined }) => {
if (incorrect) {
return (
<View style={styles.box}>
<Text style={styles.text}>Es gibt einen Fehler mit der Eingabe!</Text>
<Text style={styles.text}>Bitte prüfe die rot markierten Datenfelder!</Text>
</View>
);
}
return (
<View style={styles.box}>
<Text style={styles.text}>Es sind noch nicht alle Daten ausgefüllt!</Text>
<Text style={styles.text}>Bitte fülle alle Datenfelder auf der linken Seite aus!</Text>
</View>
);
}
export default WarningBox;

65
src/data/Bank.ts Normal file
View File

@ -0,0 +1,65 @@
import IBAN from "iban";
class Bank {
private name: string;
private bic: string;
private iban: string;
private nameSet: boolean = false;
private bicSet: boolean = false;
private ibanSet: boolean = false;
constructor() {
this.name = "Deutsche Fakebank AG";
this.bic = "FAKEDEM1001";
this.iban = "DE78500105172115399138";
}
public getName(): string {
return this.name;
}
public setName(name: string): void {
this.name = name;
this.nameSet = name !== "";
}
public getBic(): string {
return this.bic;
}
public setBic(bic: string): void {
this.bic = bic;
this.bicSet = bic !== "";
}
public isBicCorrect(): boolean {
return this.bic.match(/([a-zA-Z]{4})([a-zA-Z]{2})(([2-9a-zA-Z]{1})([0-9a-np-zA-NP-Z]{1}))((([0-9a-wy-zA-WY-Z]{1})([0-9a-zA-Z]{2}))|([xX]{3})|)/g) !== null;
}
public getIban(): string {
return IBAN.printFormat(this.iban, " ");
}
public setIban(iban: string): void {
this.iban = iban.replace(/ /g, "");
this.ibanSet = iban !== "";
}
public isIbanCorrect(): boolean {
return IBAN.isValid(this.iban);
}
public isComplete(): boolean {
return this.nameSet && this.bicSet && this.ibanSet;
}
public isCorrect(): boolean {
return this.isBicCorrect() && this.isIbanCorrect();
}
}
export default Bank;

135
src/data/Person.ts Normal file
View File

@ -0,0 +1,135 @@
import dayjs, {Dayjs} from "dayjs";
class Person {
private name: string;
private street: string;
private plzOrt: string;
private mobile: string;
private email: string;
private taxId: string;
private birthDate: Dayjs;
private nameSet: boolean = false;
private streetSet: boolean = false;
private plzOrtSet: boolean = false;
private mobileSet: boolean = false;
private emailSet: boolean = false;
private taxIdSet: boolean = false;
private birthDateSet: boolean = false;
constructor() {
this.name = "Max Mustermann";
this.street = "Musterstraße 1";
this.plzOrt = "12345 Musterstadt";
this.mobile = "0123 4567890";
this.email = "max@muster.de";
this.taxId = "12345678900";
this.birthDate = dayjs("01.01.1970", "DD.MM.YYYY");
}
public getName(): string {
return this.name;
}
public setName(name: string): void {
this.name = name;
this.nameSet = name !== "";
}
public getStreet(): string {
return this.street;
}
public setStreet(street: string): void {
this.street = street;
this.streetSet = street !== "";
}
public getPlzOrt(): string {
return this.plzOrt;
}
public setPlzOrt(plzOrt: string): void {
this.plzOrt = plzOrt;
this.plzOrtSet = plzOrt !== "";
}
public isPlzOrtCorrect(): boolean {
return this.plzOrt.match(/^\d{5} [a-zA-ZäöüÄÖÜß]+$/g) !== null;
}
public getMobile(): string {
return this.mobile;
}
public setMobile(mobile: string): void {
this.mobile = mobile;
this.mobileSet = mobile !== "";
}
public getEmail(): string {
return this.email;
}
public setEmail(email: string): void {
this.email = email;
this.emailSet = email !== "";
}
public isEmailCorrect(): boolean {
return this.email.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/g) !== null;
}
public getTaxId(): string {
// format such that the string is delimited by spaces every 3 digits from the right
let taxId = this.taxId;
// reverse the string
taxId = taxId.split("").reverse().join("");
// add spaces every 3 digits
taxId = taxId.replace(/(\d{3})(?=\d)/g, "$1 ");
// reverse the string back
taxId = taxId.split("").reverse().join("");
return taxId;
}
public setTaxId(taxId: string): void {
this.taxId = taxId;
this.taxIdSet = taxId !== "";
}
public isTaxIdCorrect(): boolean {
return this.taxId.match(/^\d{11}$/g) !== null;
}
public getBirthDate(): string {
return this.birthDate.format("DD.MM.YYYY");
}
public setBirthDate(birthDate: Dayjs): void {
this.birthDate = birthDate;
this.birthDateSet = birthDate !== dayjs("01.01.1970", "DD.MM.YYYY");
}
public isBirthDateCorrect(): boolean {
// return this.birthDate.match(/^\d{2}\.\d{2}\.\d{4}$/g) !== null;
// return true;
return this.birthDate.isValid();
}
public isComplete(): boolean {
return this.nameSet && this.streetSet && this.plzOrtSet && this.mobileSet && this.emailSet && this.taxIdSet && this.birthDateSet;
}
public isCorrect(): boolean {
return this.isPlzOrtCorrect() && this.isEmailCorrect() && this.isTaxIdCorrect() && this.isBirthDateCorrect();
}
}
export default Person;

91
src/data/Posten.ts Normal file
View File

@ -0,0 +1,91 @@
import Zahlungsart from "./Zahlungsart.ts";
import dayjs, {Dayjs} from "dayjs";
class Posten {
private nummer: number;
private belegdatum: Dayjs;
private firma: string;
private begruendung: string;
private zahlungsart: string;
private betrag: number;
constructor(nummer: number) {
this.nummer = nummer;
this.belegdatum = dayjs();
this.firma = "";
this.begruendung = "";
this.zahlungsart = Zahlungsart[0];
this.betrag = 0;
}
public assignFrom(posten: Posten): void {
this.belegdatum = posten.belegdatum;
this.firma = posten.firma;
this.begruendung = posten.begruendung;
this.zahlungsart = posten.zahlungsart;
this.betrag = posten.betrag;
}
public getNummer(): number {
return this.nummer;
}
public setNummer(nummer: number): void {
this.nummer = nummer;
}
public getBelegDay(): Dayjs {
return this.belegdatum;
}
public getBelegdatum(): string {
return this.belegdatum.format("DD.MM.YYYY");
}
public setBelegdatum(belegdatum: Dayjs): void {
this.belegdatum = belegdatum;
}
public getFirma(): string {
return this.firma;
}
public setFirma(firma: string): void {
this.firma = firma;
}
public getBegruendung(): string {
return this.begruendung;
}
public setBegruendung(begruendung: string): void {
this.begruendung = begruendung;
}
public getZahlungsart(): string {
return this.zahlungsart;
}
public setZahlungsart(zahlungsart: string): void {
this.zahlungsart = zahlungsart;
}
public getBetrag(): number {
return this.betrag;
}
public getBetragString(): string {
// Convert cents to euros without floating point arithmetic
const euros = Math.floor(this.betrag / 100);
const cents = this.betrag % 100;
// left pad cents to 2 digits
const centsString = cents.toString().padStart(2, "0");
return euros + "," + centsString + " €";
}
public setBetrag(betrag: number): void {
this.betrag = betrag;
}
}
export default Posten;

56
src/data/Sachkonto.ts Normal file
View File

@ -0,0 +1,56 @@
enum Sachkonto {
Werkstatt = "Werkstatt",
Verbrauchsmaterialien = "Verbrauchsmaterialien",
TankenMaut = "Tanken+Maut",
Bewirtung = "Bewirtung",
Geschaeftsbedarf = "Geschäftsbedarf",
MieteFahrzeug = "Miete Fahrzeug",
Dienstkleidung = "Dienstkleidung",
}
function sachkontoDescription(sachkonto: Sachkonto): string {
switch (sachkonto) {
case Sachkonto.Werkstatt:
return `Werkstatt (Teile für das Auto)
* Federn
* Schalter
* Wabenkern
* Sensoren
* Schläuche`;
case Sachkonto.Verbrauchsmaterialien:
return `Verbrauchsmaterialien (Allgemeine Arbeitsmittel, die für verschiedene Bereiche benötigt werden)
* Pinsel
* Einweghandschuhe
* Holzleim
* Drahtseil
* Kabelbinder
* Farbe
* Harz
* Lack
* Schrauben`;
case Sachkonto.TankenMaut:
return `Tanken + Maut
* Sprit
* Maut`;
case Sachkonto.Bewirtung:
return `Bewirtung (Essen und Getränke)
* Einkauf Lebensmittel`;
case Sachkonto.Geschaeftsbedarf:
return `Geschäftsbedarf
* Pavillion
* Klebeband
* Stifte`;
case Sachkonto.MieteFahrzeug:
return `Miete Fahrzeug (Autovermietung)
* Sprintermiete
* Anhängermiete`;
case Sachkonto.Dienstkleidung:
return `Dienstkleidung
* Schutzhandschuhe (mehrfach nutzbar)
* Schutzbrillen
* Teamkleidung`;
}
}
export default Sachkonto;
export {sachkontoDescription};

11
src/data/Zahlungsart.ts Normal file
View File

@ -0,0 +1,11 @@
// enum Zahlungsart {
// BAR = "Bar",
// UEBERWEISUNG = "Überweisung",
// PAYPAL = "PayPal",
// EC_KARTE = "EC-Karte",
// KREDITKARTE = "Kreditkarte",
// }
const Zahlungsart = ["Bar", "Überweisung", "PayPal", "EC-Karte", "Kreditkarte"];
export default Zahlungsart;

0
src/index.css Normal file
View File

10
src/main.tsx Normal file
View File

@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

1
src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

25
tsconfig.json Normal file
View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
tsconfig.node.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

7
vite.config.ts Normal file
View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})