Compare commits
10 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83ff3a1414 | |||
|
|
83eb443319 | ||
| def9f4563f | |||
| 3b5f085417 | |||
|
|
f4dc94084a | ||
|
|
6624feb433 | ||
|
|
22a1ffa601 | ||
|
|
ce0b4e0de8 | ||
|
|
ecb380db40 | ||
|
|
fb1e3bcb85 |
7 changed files with 346 additions and 216 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -26,3 +26,8 @@ dist-ssr
|
|||
|
||||
out/
|
||||
Tagesabrechnung
|
||||
|
||||
dist/
|
||||
fyne-cross
|
||||
*.tar
|
||||
*.xz
|
||||
|
|
|
|||
47
.goreleaser.yaml
Normal file
47
.goreleaser.yaml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||
# Make sure to check the documentation at https://goreleaser.com
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
# you may remove this if you don't need go generate
|
||||
- go generate ./...
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=1
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- arm64
|
||||
- amd64
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
# this name template makes the OS and Arch compatible with the results of uname.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- title .Os }}_
|
||||
{{- if eq .Arch "amd64" }}x86_64
|
||||
{{- else if eq .Arch "386" }}i386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||
# use zip for windows archives
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
name_template: "{{ incpatch .Version }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
|
||||
# The lines beneath this are called `modelines`. See `:help modeline`
|
||||
# Feel free to remove those if you don't want/use them.
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||
10
README.md
Normal file
10
README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# README
|
||||
## Base information
|
||||
This is a simple Program to calculate the daily balance earn by a shop.
|
||||
|
||||
## Building the program
|
||||
To build and package the program use the following command:
|
||||
### Linux
|
||||
fyne package -os linux -icon Icon.png
|
||||
### Windows
|
||||
fyne-cross windows -arch=amd64
|
||||
BIN
abrechnung.db
BIN
abrechnung.db
Binary file not shown.
11
build.md
Normal file
11
build.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Build Commands
|
||||
## Packaging for Windows
|
||||
to build and package the App for windows use the following command:
|
||||
```shell
|
||||
sudo /home/pata/go/bin/fyne-cross windows -arch=amd64 -app-id=hegenberg.Tagesabrechnung
|
||||
```
|
||||
## Packaging for linux
|
||||
to build and package the App for linux use the command:
|
||||
```shell
|
||||
~/go/bin/fyne package -os linux
|
||||
```
|
||||
486
main.go
486
main.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
|
@ -25,9 +26,14 @@ type numericalEntry struct {
|
|||
widget.Entry
|
||||
}
|
||||
|
||||
func newNumericalEntry() *numericalEntry {
|
||||
func newNumericalEntry(text string) *numericalEntry {
|
||||
entry := &numericalEntry{}
|
||||
entry.ExtendBaseWidget(entry)
|
||||
if text == "int" {
|
||||
entry.SetPlaceHolder("0")
|
||||
} else {
|
||||
entry.SetPlaceHolder("0.00")
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +60,15 @@ func (e *numericalEntry) Keyboard() mobile.KeyboardType {
|
|||
return mobile.NumberKeyboard
|
||||
}
|
||||
|
||||
// TODO: main function needs to be refactored to be more readable and maintainable
|
||||
func checkSqliteExistence() {
|
||||
// this function checks if the file abrechnung.db exists
|
||||
// and creates it if it doesn't
|
||||
_, err := os.Stat("./abrechnung.db")
|
||||
if os.IsNotExist(err) {
|
||||
os.Create("abrechnung.db")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
myApp := app.New()
|
||||
myWindow := myApp.NewWindow("Tagesabrechnung")
|
||||
|
|
@ -69,8 +83,214 @@ func main() {
|
|||
// Prüfen, ob die Tabelle vorhanden ist
|
||||
tableExists := tableExists(db, "abrechnungen")
|
||||
if !tableExists {
|
||||
// Wenn die Tabelle nicht vorhanden ist, sie erstellen
|
||||
createTableQuery := `
|
||||
createTable(db)
|
||||
} else {
|
||||
fmt.Println("Tabelle existiert bereits.")
|
||||
}
|
||||
|
||||
data := getTableData(db)
|
||||
lastBilanz := getLastBilanz(db)
|
||||
table := createTableWidget(data)
|
||||
|
||||
mainContent := createMainContent(db, table, lastBilanz)
|
||||
|
||||
myWindow.SetContent(mainContent)
|
||||
myWindow.Resize(fyne.NewSize(1200, 800))
|
||||
myWindow.ShowAndRun()
|
||||
}
|
||||
|
||||
// TODO: createMainContent functions needs to be cleaned up to make it more readable and maintainable
|
||||
func createMainContent(db *sql.DB, table *widget.Table, lastBilanz string) *fyne.Container {
|
||||
papierGesamt := newNumericalEntry("float")
|
||||
barGesamt := newNumericalEntry("float")
|
||||
ecGesamt := newNumericalEntry("float")
|
||||
summeRollen := newNumericalEntry("float")
|
||||
summeKarte := newNumericalEntry("float")
|
||||
zBon := newNumericalEntry("float")
|
||||
sonderAus := newNumericalEntry("float")
|
||||
sonderEin := newNumericalEntry("float")
|
||||
stornoViel := newNumericalEntry("float")
|
||||
stornoWenig := newNumericalEntry("float")
|
||||
papierZurueck := newNumericalEntry("float")
|
||||
einzahlung := newNumericalEntry("float")
|
||||
tagesbilanz := newNumericalEntry("float")
|
||||
differenz := newNumericalEntry("float")
|
||||
|
||||
muenzgeld := newNumericalEntry("float")
|
||||
fuenfScheine := newNumericalEntry("int")
|
||||
zehnScheine := newNumericalEntry("int")
|
||||
zwanzigScheine := newNumericalEntry("int")
|
||||
fuenfzigScheine := newNumericalEntry("int")
|
||||
hundertScheine := newNumericalEntry("int")
|
||||
zweiHundertScheine := newNumericalEntry("int")
|
||||
|
||||
form := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Münzgeld", Widget: muenzgeld},
|
||||
{Text: "5€ Scheine", Widget: fuenfScheine},
|
||||
{Text: "10€ Scheine", Widget: zehnScheine},
|
||||
{Text: "20€ Scheine:", Widget: zwanzigScheine},
|
||||
{Text: "50€ Scheine:", Widget: fuenfzigScheine},
|
||||
{Text: "100€ Scheine:", Widget: hundertScheine},
|
||||
{Text: "200€ Scheine:", Widget: zweiHundertScheine},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
// err := updateBarGesamt(summeRollen.Text, muenzgeld.Text, fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, barGesamt)
|
||||
err := updateBarGesamt(summeRollen.Text, muenzgeld.Text, papierGesamt.Text, barGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updatePapierGesamt(fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, papierGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updateEcGesamt(barGesamt.Text, summeKarte.Text, ecGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = calcDifferenz(ecGesamt.Text, papierZurueck.Text, einzahlung.Text, summeKarte.Text, differenz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
form.SubmitText = "Zwischenberechnung"
|
||||
|
||||
form2 := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Summe Rollengeld", Widget: summeRollen},
|
||||
{Text: "Summe Kartenzahlung", Widget: summeKarte},
|
||||
{Text: "zBon Kassenbericht", Widget: zBon},
|
||||
{Text: "Sonder aus Kasse", Widget: sonderAus},
|
||||
{Text: "Sonder in Kasse", Widget: sonderEin},
|
||||
{Text: "Storno - zu viel", Widget: stornoViel},
|
||||
{Text: "Storno - zu wenig", Widget: stornoWenig},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
err := updateBarGesamt(summeRollen.Text, muenzgeld.Text, papierGesamt.Text, barGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updatePapierGesamt(fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, papierGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updateEcGesamt(barGesamt.Text, summeKarte.Text, ecGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = calcTagesbilanz(ecGesamt.Text, zBon.Text, sonderAus.Text, sonderEin.Text, stornoWenig.Text, stornoViel.Text, lastBilanz, tagesbilanz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = zurueckKasse(muenzgeld.Text, summeRollen.Text, papierZurueck)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = Einzahlung(barGesamt.Text, papierZurueck.Text, einzahlung)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = calcDifferenz(ecGesamt.Text, papierZurueck.Text, einzahlung.Text, summeKarte.Text, differenz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
form2.SubmitText = "Berechnen"
|
||||
|
||||
form3 := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Gesamtes Papiergeld:", Widget: papierGesamt},
|
||||
{Text: "Gesamtes Bargeld:", Widget: barGesamt},
|
||||
{Text: "Gesamtes Bargeld mit EC:", Widget: ecGesamt},
|
||||
{Text: "Papiergeld zurück:", Widget: papierZurueck},
|
||||
{Text: "Einzahlung:", Widget: einzahlung},
|
||||
{Text: "Tagesbilanz:", Widget: tagesbilanz},
|
||||
{Text: "Differenz:", Widget: differenz},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
now := time.Now().Format("2006-01-02")
|
||||
insertQuery := `INSERT INTO abrechnungen (datum, einzahlung, tagesbilanz, bargeld) VALUES (?, ?, ?, ?)`
|
||||
_, err := db.Exec(insertQuery, now, einzahlung.Text, tagesbilanz.Text, papierZurueck.Text)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updateTable(db)
|
||||
table.Refresh()
|
||||
|
||||
fmt.Println("Daten gespeichert.")
|
||||
},
|
||||
}
|
||||
form3.SubmitText = "Speichern"
|
||||
|
||||
// Flexibles Layout erstellen und die Tabelle hinzufügen
|
||||
forms := container.NewGridWithColumns(3, form, form2, form3)
|
||||
formBox := widget.NewCard("Neuer Eintrag", "", forms)
|
||||
tableBox := widget.NewCard("Einträge", "", table)
|
||||
mainContent := container.NewGridWithRows(2,
|
||||
formBox,
|
||||
tableBox,
|
||||
)
|
||||
return mainContent
|
||||
}
|
||||
|
||||
func createTableWidget(data [][]string) *widget.Table {
|
||||
createEmptyTableCell := func() fyne.CanvasObject {
|
||||
return widget.NewLabel(".....................")
|
||||
}
|
||||
|
||||
// Funktion zur Erstellung der Zelleninhalte für die Tabelle
|
||||
createTableCell := func(id widget.TableCellID, content fyne.CanvasObject) {
|
||||
content.(*widget.Label).SetText(data[id.Row][id.Col])
|
||||
}
|
||||
|
||||
// Tabelle erstellen
|
||||
table := widget.NewTable(
|
||||
func() (int, int) {
|
||||
return len(data), len(data[0])
|
||||
},
|
||||
createEmptyTableCell, // Leere CanvasObject-Funktion
|
||||
createTableCell, // Funktion zur Erstellung der Zelleninhalte
|
||||
)
|
||||
return table
|
||||
}
|
||||
|
||||
func getLastBilanz(db *sql.DB) string {
|
||||
lastBilanz := ""
|
||||
last, err := db.Query("SELECT tagesbilanz FROM abrechnungen ORDER BY datum DESC Limit 1")
|
||||
if err != nil {
|
||||
log.Fatal("Can't query last entry ", err)
|
||||
}
|
||||
defer last.Close()
|
||||
for last.Next() {
|
||||
var tagesbilanz float64
|
||||
err := last.Scan(&tagesbilanz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
lastBilanz = fmt.Sprintf("%.2f", tagesbilanz)
|
||||
}
|
||||
return lastBilanz
|
||||
}
|
||||
|
||||
// Funktion zur Überprüfung, ob eine Tabelle in der Datenbank existiert
|
||||
func tableExists(db *sql.DB, tableName string) bool {
|
||||
query := "SELECT name FROM sqlite_master WHERE type='table' AND name=?"
|
||||
var name string
|
||||
err := db.QueryRow(query, tableName).Scan(&name)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return false
|
||||
}
|
||||
log.Fatal(err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func createTable(db *sql.DB) {
|
||||
// Wenn die Tabelle nicht vorhanden ist, sie erstellen
|
||||
createTableQuery := `
|
||||
CREATE TABLE abrechnungen (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
datum TEXT,
|
||||
|
|
@ -79,28 +299,27 @@ func main() {
|
|||
bargeld REAL
|
||||
);
|
||||
`
|
||||
_, err := db.Exec(createTableQuery)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
_, err := db.Exec(createTableQuery)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Datum des Vortags im Format "YYYY-MM-DD" erhalten
|
||||
yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
||||
// Mit einem ersten Eintrag befüllen
|
||||
insertDataQuery := `
|
||||
// Datum des Vortags im Format "YYYY-MM-DD" erhalten
|
||||
yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
||||
// Mit einem ersten Eintrag befüllen
|
||||
insertDataQuery := `
|
||||
INSERT INTO abrechnungen (datum, einzahlung, tagesbilanz, bargeld)
|
||||
VALUES (? , 0.00, 0.00, 300.00);
|
||||
`
|
||||
_, err = db.Exec(insertDataQuery, yesterday)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println("Tabelle erstellt und mit Daten befüllt.")
|
||||
} else {
|
||||
fmt.Println("Tabelle existiert bereits.")
|
||||
_, err = db.Exec(insertDataQuery, yesterday)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println("Tabelle erstellt und mit Daten befüllt.")
|
||||
}
|
||||
|
||||
func getTableData(db *sql.DB) [][]string {
|
||||
rows, err := db.Query("SELECT * FROM abrechnungen")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
@ -128,202 +347,11 @@ func main() {
|
|||
fmt.Println(idString, datum, fmt.Sprintf("%.2f", einzahlung), fmt.Sprintf("%.2f", tagesbilanz), fmt.Sprintf("%.2f", bargeld))
|
||||
data = append(data, []string{idString, datum, fmt.Sprintf("%.2f", einzahlung), fmt.Sprintf("%.2f", tagesbilanz), fmt.Sprintf("%.2f", bargeld)})
|
||||
}
|
||||
|
||||
lastBilanz := ""
|
||||
last, err := db.Query("SELECT tagesbilanz FROM abrechnungen ORDER BY datum DESC Limit 1")
|
||||
if err != nil {
|
||||
log.Fatal("Can't query last entry ", err)
|
||||
}
|
||||
defer last.Close()
|
||||
for last.Next() {
|
||||
var tagesbilanz float64
|
||||
err := last.Scan(&tagesbilanz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
lastBilanz = fmt.Sprintf("%.2f", tagesbilanz)
|
||||
}
|
||||
// Funktion zur Erstellung leerer CanvasObject für die Tabelle
|
||||
createEmptyTableCell := func() fyne.CanvasObject {
|
||||
return widget.NewLabel(".....................")
|
||||
}
|
||||
|
||||
// Funktion zur Erstellung der Zelleninhalte für die Tabelle
|
||||
createTableCell := func(id widget.TableCellID, content fyne.CanvasObject) {
|
||||
content.(*widget.Label).SetText(data[id.Row][id.Col])
|
||||
}
|
||||
|
||||
// Tabelle erstellen
|
||||
table := widget.NewTable(
|
||||
func() (int, int) {
|
||||
return len(data), len(data[0])
|
||||
},
|
||||
createEmptyTableCell, // Leere CanvasObject-Funktion
|
||||
createTableCell, // Funktion zur Erstellung der Zelleninhalte
|
||||
)
|
||||
|
||||
papierGesamt := newNumericalEntry()
|
||||
papierGesamt.SetPlaceHolder("0.00")
|
||||
barGesamt := newNumericalEntry()
|
||||
barGesamt.SetPlaceHolder("0.00")
|
||||
ecGesamt := newNumericalEntry()
|
||||
ecGesamt.SetPlaceHolder("0.00")
|
||||
summeRollen := newNumericalEntry()
|
||||
summeRollen.SetPlaceHolder("0.00")
|
||||
summeKarte := newNumericalEntry()
|
||||
summeKarte.SetPlaceHolder("0.00")
|
||||
zBon := newNumericalEntry()
|
||||
zBon.SetPlaceHolder("0.00")
|
||||
sonderAus := newNumericalEntry()
|
||||
sonderAus.SetPlaceHolder("0.00")
|
||||
sonderEin := newNumericalEntry()
|
||||
sonderEin.SetPlaceHolder("0.00")
|
||||
stornoViel := newNumericalEntry()
|
||||
stornoViel.SetPlaceHolder("0.00")
|
||||
stornoWenig := newNumericalEntry()
|
||||
stornoWenig.SetPlaceHolder("0.00")
|
||||
papierZurueck := newNumericalEntry()
|
||||
papierZurueck.SetPlaceHolder("0.00")
|
||||
papierZurueck.Disable()
|
||||
einzahlung := newNumericalEntry()
|
||||
einzahlung.SetPlaceHolder("0.00")
|
||||
tagesbilanz := newNumericalEntry()
|
||||
tagesbilanz.SetPlaceHolder("0.00")
|
||||
|
||||
muenzgeld := newNumericalEntry()
|
||||
muenzgeld.SetPlaceHolder("0.00")
|
||||
fuenfScheine := newNumericalEntry()
|
||||
fuenfScheine.SetPlaceHolder("0")
|
||||
zehnScheine := newNumericalEntry()
|
||||
zehnScheine.SetPlaceHolder("0")
|
||||
zwanzigScheine := newNumericalEntry()
|
||||
zwanzigScheine.SetPlaceHolder("0")
|
||||
fuenfzigScheine := newNumericalEntry()
|
||||
fuenfzigScheine.SetPlaceHolder("0")
|
||||
hundertScheine := newNumericalEntry()
|
||||
hundertScheine.SetPlaceHolder("0")
|
||||
zweiHundertScheine := newNumericalEntry()
|
||||
zweiHundertScheine.SetPlaceHolder("0")
|
||||
|
||||
form := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Gesamtes Münzgeld", Widget: muenzgeld},
|
||||
{Text: "5€ Scheine", Widget: fuenfScheine},
|
||||
{Text: "10€ Scheine", Widget: zehnScheine},
|
||||
{Text: "20€ Scheine:", Widget: zwanzigScheine},
|
||||
{Text: "50€ Scheine:", Widget: fuenfzigScheine},
|
||||
{Text: "100€ Scheine:", Widget: hundertScheine},
|
||||
{Text: "200€ Scheine:", Widget: zweiHundertScheine},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
err := updateBarGesamt(summeRollen.Text, muenzgeld.Text, fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, barGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updatePapierGesamt(fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, papierGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updateEcGesamt(barGesamt.Text, summeKarte.Text, ecGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
form.SubmitText = "Zwischenberechnung"
|
||||
|
||||
form2 := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Summe Rollengeld", Widget: summeRollen},
|
||||
{Text: "Summe Kartenzahlung", Widget: summeKarte},
|
||||
{Text: "zBon Kassenbericht", Widget: zBon},
|
||||
{Text: "Sonderausgabe aus Kasse", Widget: sonderAus},
|
||||
{Text: "Sondereingabe in Kasse", Widget: sonderEin},
|
||||
{Text: "Storno - zu viel", Widget: stornoViel},
|
||||
{Text: "Storno - zu wenig", Widget: stornoWenig},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
err := updateBarGesamt(summeRollen.Text, muenzgeld.Text, fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, barGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updatePapierGesamt(fuenfScheine.Text, zehnScheine.Text, zwanzigScheine.Text, fuenfzigScheine.Text, hundertScheine.Text, zweiHundertScheine.Text, papierGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = updateEcGesamt(barGesamt.Text, summeKarte.Text, ecGesamt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = calcTagesbilanz(ecGesamt.Text, zBon.Text, sonderAus.Text, sonderEin.Text, stornoWenig.Text, stornoViel.Text, lastBilanz, tagesbilanz)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = zurueckKasse(muenzgeld.Text, summeRollen.Text, papierZurueck)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = Einzahlung(barGesamt.Text, papierZurueck.Text, einzahlung)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
form2.SubmitText = "Berechnen"
|
||||
|
||||
form3 := &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
{Text: "Papiergeld zurück in die Kasse", Widget: papierZurueck},
|
||||
{Text: "Einzahlung auf Konto", Widget: einzahlung},
|
||||
{Text: "Tagesbilanz vgl- Einnahme zu zBon", Widget: tagesbilanz},
|
||||
{Text: "Gesamtes Papiergeld:", Widget: papierGesamt},
|
||||
{Text: "Gesamtes Bargeld:", Widget: barGesamt},
|
||||
{Text: "Gesamtes Bargeld mit EC:", Widget: ecGesamt},
|
||||
},
|
||||
OnSubmit: func() {
|
||||
now := time.Now().Format("2006-01-02")
|
||||
insertQuery := `INSERT INTO abrechnungen (datum, einzahlung, tagesbilanz, bargeld) VALUES (?, ?, ?, ?)`
|
||||
_, err := db.Exec(insertQuery, now, einzahlung.Text, tagesbilanz.Text, papierZurueck.Text)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
updateTable(db)
|
||||
table.Refresh()
|
||||
|
||||
fmt.Println("Daten gespeichert.")
|
||||
},
|
||||
}
|
||||
form3.SubmitText = "Speichern"
|
||||
|
||||
// Flexibles Layout erstellen und die Tabelle hinzufügen
|
||||
forms := container.NewGridWithColumns(3, form, form2, form3)
|
||||
formBox := widget.NewCard("Neuer Eintrag", "", forms)
|
||||
tableBox := widget.NewCard("Einträge", "", table)
|
||||
mainContent := container.NewGridWithRows(2,
|
||||
formBox,
|
||||
tableBox,
|
||||
)
|
||||
|
||||
myWindow.SetContent(mainContent)
|
||||
myWindow.Resize(fyne.NewSize(800, 600))
|
||||
myWindow.ShowAndRun()
|
||||
return data
|
||||
}
|
||||
|
||||
// Funktion zur Überprüfung, ob eine Tabelle in der Datenbank existiert
|
||||
func tableExists(db *sql.DB, tableName string) bool {
|
||||
query := "SELECT name FROM sqlite_master WHERE type='table' AND name=?"
|
||||
var name string
|
||||
err := db.QueryRow(query, tableName).Scan(&name)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return false
|
||||
}
|
||||
log.Fatal(err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func updateBarGesamt(rollen, muenz, fuenf, zehn, zwanzig, fuenfzig, hundert, zweihundert string, barGesamt fyne.Widget) error {
|
||||
// func updateBarGesamt(rollen, muenz, fuenf, zehn, zwanzig, fuenfzig, hundert, zweihundert string, barGesamt fyne.Widget) error {
|
||||
func updateBarGesamt(rollen, muenz, papier string, barGesamt fyne.Widget) error {
|
||||
rollenf, err := convertToFloat(rollen)
|
||||
if err != nil {
|
||||
log.Fatal("Error converting Rollengeld", err)
|
||||
|
|
@ -332,7 +360,7 @@ func updateBarGesamt(rollen, muenz, fuenf, zehn, zwanzig, fuenfzig, hundert, zwe
|
|||
if err != nil {
|
||||
log.Fatal("Error converting Münzgeld", err)
|
||||
}
|
||||
fuenff, err := convertToInt(fuenf)
|
||||
/*fuenff, err := convertToInt(fuenf)
|
||||
if err != nil {
|
||||
log.Fatal("Error converting Fünf", err)
|
||||
}
|
||||
|
|
@ -353,10 +381,14 @@ func updateBarGesamt(rollen, muenz, fuenf, zehn, zwanzig, fuenfzig, hundert, zwe
|
|||
log.Fatal("Error converting Hundert", err)
|
||||
}
|
||||
zweihundertf, err := convertToInt(zweihundert)
|
||||
if err != nil {
|
||||
log.Fatal("Error converting Zweihundert", err)
|
||||
}*/
|
||||
papierf, err := convertToFloat(papier)
|
||||
if err != nil {
|
||||
log.Fatal("Error converting Zweihundert", err)
|
||||
}
|
||||
result := rollenf + muenzf + float64(fuenff*5) + float64(zehnf*10) + float64(zwanzigf*20) + float64(fuenfzigf*50) + float64(hundertf*100) + float64(zweihundertf*200)
|
||||
result := rollenf + muenzf + float64(papierf) // float64(zehnf*10) + float64(zwanzigf*20) + float64(fuenfzigf*50) + float64(hundertf*100) + float64(zweihundertf*200)
|
||||
|
||||
barGesamt.(*numericalEntry).SetText(fmt.Sprintf("%.2f", result))
|
||||
return nil
|
||||
|
|
@ -526,3 +558,25 @@ func updateTable(db *sql.DB) {
|
|||
data = append(data, []string{idString, datum, fmt.Sprintf("%.2f", einzahlung), fmt.Sprintf("%.2f", tagesbilanz), fmt.Sprintf("%.2f", bargeld)})
|
||||
}
|
||||
}
|
||||
|
||||
func calcDifferenz(ecGesamt, papierZurueck, einzahlung, summeKarte string, differenz fyne.Widget) error {
|
||||
ecf, err := convertToFloat(ecGesamt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
papierf, err := convertToFloat(papierZurueck)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
einzahlungf, err := convertToFloat(einzahlung)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
summeKartef, err := convertToFloat(summeKarte)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := ecf - papierf - einzahlungf - summeKartef
|
||||
differenz.(*numericalEntry).SetText(fmt.Sprintf("%.2f", result))
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
3
renovate.json
Normal file
3
renovate.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue