Skip to content

Commit 233255b

Browse files
authored
Merge pull request ktt-ol#1 from PowerPan/master
merge diyww dev branch
2 parents e7fc5bf + a1c5d31 commit 233255b

28 files changed

+526
-210
lines changed

README README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The system consists of multiple daemons written in Vala, which communicate
3333
with each other using DBus.
3434

3535
Build Dependencies:
36-
* apt install build-essential valac libesmtp-dev libgpgme11-dev libncursesw5-dev libncurses5-dev libgee-0.8-dev libgmime-2.6-dev libarchive-dev libgstreamer1.0-dev libgtk2.0-dev librsvg2-dev libsoup2.4-dev libsqlite3-dev libpango1.0-dev libssl-dev dbus-x11
36+
* apt install build-essential valac libesmtp-dev libgpgme11-dev libncursesw5-dev libncurses5-dev libgee-0.8-dev libgmime-2.6-dev libarchive-dev libgstreamer1.0-dev libgtk2.0-dev librsvg2-dev libsoup2.4-dev libsqlite3-dev libpango1.0-dev libssl-dev dbus-x11 mdbus2 policykit-1
3737

3838
Additional runtime dependencies:
3939
* apt install fonts-lmodern gstreamer1.0-alsa gstreamer1.0-plugins-base
@@ -76,6 +76,15 @@ but you need to modify a few things.
7676
=== Database ===
7777

7878
* Create user
79-
`sqlite3 shop.db "INSERT INTO users (id, email, firstname, lastname) VALUES (1, "test@tester", "Firstname", "Lastname");`
79+
`sqlite3 shop.db "INSERT INTO users (id, email, firstname, lastname) VALUES (1, 'test@tester', 'Firstname', 'Lastname');"`
8080
* Setup user password
81-
`mdbus2 io.mainframe.shopsystem.Database /io/mainframe/shopsystem/database io.mainframe.shopsystem.Database.SetUserPassword 1 "password"`
81+
`mdbus2 -s io.mainframe.shopsystem.Database /io/mainframe/shopsystem/database io.mainframe.shopsystem.Database.SetUserPassword 1 "password"`
82+
`sqlite3 shop.db "UPDATE authentication set superuser = 1,auth_users = 1, auth_products = 1,auth_cashbox = 1 where user = 1";`
83+
* Demo Data
84+
`sqlite3 shop.db "INSERT INTO categories (name) VALUES ('Getränke')";`
85+
`sqlite3 shop.db "INSERT INTO supplier (name,city,postal_code,street,phone,website) VALUES ('Demo Lieferant','Musterstadt','12345','Musterstraße 5','+49 1234 56789','https://www.ktt.de')";`
86+
87+
== Customize Your Shop ==
88+
89+
Edit the Logo in the logo.txt File.
90+
A helpful tool you will found here [http://patorjk.com/software/taag/](http://patorjk.com/software/taag/)

example.cfg

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[GENERAL]
2+
longname = Kreativität trifft Technik e.V.
3+
shortname = KTT
4+
spacename = Mainframe
15
[DATABASE]
26
file = /path/to/shop.db
37
[INPUT]
@@ -8,6 +12,8 @@ port = 587
812
913
password = my_top_secret_password
1014
starttls = true
15+
mailfromaddress = [email protected]
16+
treasurermailaddress = [email protected]
1117
[AUDIO]
1218
path = /path/to/sounds/
1319
[PGP]
@@ -18,3 +24,10 @@ filepath = /path/to/web/templates/
1824
port = 8080
1925
[INVOICE]
2026
datadir = /path/to/invoice/
27+
umsatzsteuer = no
28+
addressrow = Kreativität trifft Technik e.V., Bahnhofsplatz 10, 26122 Oldenburg
29+
footer1 = <b>Kreativität trifft Technik e.V.</b>\nAmtsgericht Oldenburg VR 201044\n\nHackspace „Mainframe“\nFabLab „Fab-O-Lab“\nSchnittstelle „Schnittstelle“\n\nBahnhofsplatz 10 • 26122 Oldenburg
30+
footer2 = <b>Raiffeisenbank Oldenburg</b>\nIBAN: DE34 2806 0228 0037 0185 00\nBIC: GENODEF1OL2\n\n\n<b>Finanzamt Oldenburg</b>\nAls gemeinnützig anerkannt.\nSteuer Nr.: 64/220/18413
31+
footer3 = <b>Mail:</b> [email protected]\n<b>Web:</b> www.kreativitaet-trifft-technik.de\n\n\n\n<b>BGB-Vorstand:</b>\nPatrick Günther, Jan Janssen, Andre Schäfer, Lars Hüsemann
32+
[JVEREIN]
33+
mitgliedsnummern = intern

invoice/invoice.final.html

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
{{{INVOICE_TABLE}}}
77

8-
<p>Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft Technik e.V.
9-
als Kleinunternehmen unter die Regelung des
10-
<a href="http://www.gesetze-im-internet.de/ustg_1980/__19.html">§ 19 Abs. 1 UStG</a>
11-
fällt.</p>
8+
{{{UMSATZSTEUER}}}
129

13-
<p>Grüße aus dem Mainframe,<br>
10+
<p>Grüße aus dem {{{SPACENAME}}},<br>
1411
das Shop-System</p>

invoice/invoice.final.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ wie folgt zu berechnen:
55

66
{{{INVOICE_TABLE}}}
77

8-
Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft
9-
Technik e.V. als Kleinunternehmen unter die Regelung des § 19
10-
Abs. 1 UStG fällt.
8+
{{{UMSATZSTEUER}}}
119

12-
Grüße aus dem Mainframe,
10+
Grüße aus dem {{{SPACENAME}}},
1311
das Shop-System

invoice/invoice.temporary.html

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55

66
{{{INVOICE_TABLE}}}
77

8-
<p>Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft Technik e.V.
9-
als Kleinunternehmen unter die Regelung des
10-
<a href="http://www.gesetze-im-internet.de/ustg_1980/__19.html">§ 19 Abs. 1 UStG</a>
11-
fällt.</p>
8+
{{{UMSATZSTEUER}}}
129

1310
<p>Bei dieser Abrechnung handelt es sich lediglich um einen Zwischenstand. Die
1411
Hauptrechnung wird einmal monatlich getrennt zugestellt und der Gesamtbetrag
1512
wird dann vom angegebenen Bankkonto eingezogen.</p>
1613

1714
<p>Der Gesamtbetrag für den aktuellen Monat beträgt bisher:</p> <b>{{{SUM_MONTH}}} €</b>
1815

19-
<p>Grüße aus dem Mainframe,<br>
16+
<p>Grüße aus dem {{{SPACENAME}}},<br>
2017
das Shop-System</p>

invoice/invoice.temporary.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ wie folgt zu berechnen:
55

66
{{{INVOICE_TABLE}}}
77

8-
Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft
9-
Technik e.V. als Kleinunternehmen unter die Regelung des § 19
10-
Abs. 1 UStG fällt.
8+
{{{UMSATZSTEUER}}}
119

1210
Bei dieser Abrechnung handelt es sich lediglich um einen Zwischenstand.
1311
Die Hauptrechnung wird einmal monatlich getrennt zugestellt und der
1412
Gesamtbetrag wird dann vom angegebenen Bankkonto eingezogen.
1513

1614
Der Gesamtbetrag für den aktuellen Monat beträgt bisher: {{{SUM_MONTH}}} €
1715

18-
Grüße aus dem Mainframe,
16+
Grüße aus dem {{{SPACENAME}}},
1917
das Shop-System

invoice/pdf-template.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ wir erlauben uns, Ihnen für den Verzehr von Speisen und Getränken <b>{{{SUM}}}
44

55
Eine detaillierte Auflistung der einzelnen Posten befindet sich, mit genauer Zeitangabe des Einkaufs, auf den folgenden Seiten.
66

7-
Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft Technik e.V. als Kleinunternehmen unter die Regelung des § 19 Abs. 1 UStG fällt.
7+
{{{UMSATZSTEUER}}}
88

99
Der Gesamtbetrag wird in 10 Tagen von dem angegebenen Bankkonto eingezogen.
1010
Mit freundlichen Grüßen
1111

12-
Kreativität trifft Technik e.V.
12+
{{{VEREINSNAME}}}

invoice/treasurer.mail.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ and an additional csv-file in the attachment. The members'
55
invoices are for your files and the csv-file can be used
66
for automatic money collection.
77

8-
-- KtT Shopsystem
8+
-- {{{SHORTNAME}}} Shopsystem

invoice/umsatzsteuer.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p>Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft Technik e.V.
2+
als Kleinunternehmen unter die Regelung des
3+
<a href="http://www.gesetze-im-internet.de/ustg_1980/__19.html">§ 19 Abs. 1 UStG</a>
4+
fällt.</p>

invoice/umsatzsteuer.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Umsatzsteuer wird nicht erhoben, da der Verein Kreativität trifft
2+
Technik e.V. als Kleinunternehmen unter die Regelung des § 19
3+
Abs. 1 UStG fällt.

logo.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
██╗ ██╗████████╗████████╗ ███████╗██╗ ██╗ ██████╗ ██████╗
2+
██║ ██╔╝╚══██╔══╝╚══██╔══╝ ██╔════╝██║ ██║██╔═══██╗██╔══██╗
3+
█████╔╝ ██║ ██║ ███████╗███████║██║ ██║██████╔╝
4+
██╔═██╗ ██║ ██║ ╚════██║██╔══██║██║ ██║██╔═══╝
5+
██║ ██╗ ██║ ██║ ███████║██║ ██║╚██████╔╝██║
6+
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝

src/audio/audio-interface.vala

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ public interface AudioPlayer : Object {
2222
public abstract string[] get_user_themes() throws IOError;
2323
public abstract void play_user(string theme, string type) throws IOError;
2424
}
25+
26+
public enum AudioType {
27+
ERROR,
28+
LOGIN,
29+
LOGOUT,
30+
PURCHASE,
31+
INFO
32+
}

src/config/main.vala

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Cfg cfg;
1818
public static int main(string[] args) {
1919
string binarylocation = File.new_for_path(args[0]).get_parent().get_path();
2020

21-
cfg = new Cfg(binarylocation + "/../../ktt-shopsystem.cfg");
21+
cfg = new Cfg(binarylocation + "/../../config.cfg");
2222

2323
Bus.own_name(
2424
BusType.SYSTEM,

src/curses-ui/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all: curses-ui
22
@echo > /dev/null
33

4-
curses-ui: *.vala ../audio/audio-interface.vala ../scanner-session/scannersession-interface.vala
4+
curses-ui: *.vala ../audio/audio-interface.vala ../scanner-session/scannersession-interface.vala ../config/config-interface.vala
55
valac -X -w -o $@ --pkg curses -X -lncursesw --pkg posix --pkg gio-2.0 $^
66

77
clean:

src/curses-ui/curses-ui.vala

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CursesUI {
2121
//StatusPanel statuswin;
2222
MessageBoxOverlay mbOverlay;
2323

24-
public CursesUI() {
24+
public CursesUI(string binarylocation) {
2525
/* unicode support */
2626
Intl.setlocale(LocaleCategory.CTYPE, "");
2727

@@ -37,8 +37,8 @@ public class CursesUI {
3737
Curses.init_pair(1, Curses.Color.GREEN, Curses.Color.BLACK);
3838
Curses.init_pair(2, Curses.Color.WHITE, Curses.Color.RED);
3939

40-
/* initialize widgets */
41-
banner = new Logo();
40+
/* initialize widgets */
41+
banner = new Logo(binarylocation);
4242
//statuswin = new StatusPanel();
4343
messages = new MessageBox();
4444
clkwin = new ClockWindow();
@@ -68,26 +68,26 @@ public class CursesUI {
6868
//}
6969

7070
public void log(MessageType type, string message) {
71-
switch (type) {
71+
switch (type) {
7272
case MessageType.WARNING:
7373
messages.add(message, MessageBox.WARN_COLOR);
7474
break;
75-
case MessageType.ERROR:
75+
case MessageType.ERROR:
7676
messages.add(message, MessageBox.ERROR_COLOR);
7777
break;
7878
default:
7979
messages.add(message, MessageBox.INFO_COLOR);
8080
break;
8181
}
82-
82+
8383
}
8484

8585
public void log_overlay(string title, string message, int closeAfter) {
8686
mbOverlay = new MessageBoxOverlay(title, message, closeAfter);
8787
Timeout.add_seconds(closeAfter, closeMbOverlay);
8888
}
8989

90-
public void dialog_open(string title, string message, int closeAfter=0) {
90+
public void dialog_open(string title, string message, int closeAfter=0) {
9191
dialog = new Dialog(message, title, closeAfter);
9292
if (closeAfter > 0) {
9393
Timeout.add_seconds(closeAfter, close);
@@ -102,7 +102,7 @@ public class CursesUI {
102102
return false;
103103
}
104104

105-
bool close() {
105+
bool close() {
106106
dialog_close();
107107
// just call me once
108108
return false;

src/curses-ui/logo.vala

+20-7
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,30 @@ using Curses;
1818
public class Logo {
1919
Window win;
2020

21-
public Logo() {
21+
public Logo(string binarylocation) {
2222
win = new Window(8, COLS - 2, 0, 1);
2323
win.bkgdset(COLOR_PAIR(1) | Attribute.BOLD);
2424

2525
win.addstr("\n");
26-
win.addstr(" _ ___ _____ ____ _ \n");
27-
win.addstr(" | |/ / ||_ _| / ___|| |__ ___ _ __ \n");
28-
win.addstr(" | ' /| __|| | \\___ \\| '_ \\ / _ \\| '_ \\ \n");
29-
win.addstr(" | . \\| |_ | | ___) | | | | (_) | |_) )\n");
30-
win.addstr(" |_|\\_\\\\__||_| |____/|_| |_|\\___/| .__/ \n");
31-
win.addstr(" |_| \n");
26+
27+
var file = File.new_for_path (binarylocation + "/../../logo.txt");
28+
29+
if (!file.query_exists ()) {
30+
stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
31+
}
32+
33+
try {
34+
// Open file for reading and wrap returned FileInputStream into a
35+
// DataInputStream, so we can read line by line
36+
var dis = new DataInputStream (file.read ());
37+
string line;
38+
// Read lines until end of file (null) is reached
39+
while ((line = dis.read_line (null)) != null) {
40+
win.addstr(line+"\n");
41+
}
42+
} catch (Error e) {
43+
error ("%s", e.message);
44+
}
3245

3346
win.clrtobot();
3447

src/curses-ui/main.vala

+12-1
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,24 @@ public static int main(string[] args) {
5353
error("IOError: %s\n", e.message);
5454
}
5555

56-
ui = new CursesUI();
56+
string binarylocation = File.new_for_path(args[0]).get_parent().get_path();
57+
58+
ui = new CursesUI(binarylocation);
5759

5860
Log.set_default_handler(log_handler);
5961

6062
scanner.msg.connect(msg_handler);
6163
scanner.msg_overlay.connect(msg_overlay_handler);
6264

65+
/* get configuration */
66+
Config config = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
67+
var shopname = "--SHOPNAME--";
68+
try {
69+
shopname = config.get_string("GENERAL", "longname");
70+
} catch(KeyFileError e) {
71+
shopname = "Missing in Config";
72+
}
73+
6374
ui.log(MessageType.INFO, "KtT Shop System has been started");
6475
play("startup.ogg");
6576

src/database/database.vala

+13
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,19 @@ public class DataBase : Object {
273273
}
274274
#endif
275275

276+
public Product get_product_for_ean(uint64 ean) throws DatabaseError {
277+
Product product = Product();
278+
try {
279+
product.ean = ean_alias_get(ean);
280+
product.name = get_product_name(ean);
281+
product.memberprice = get_product_price(1, ean);
282+
product.guestprice = get_product_price(0, ean);
283+
return product;
284+
} catch(DatabaseError e){
285+
throw e;
286+
}
287+
}
288+
276289
public StockEntry[] get_stock() {
277290
StockEntry[] result = {};
278291

src/database/db-interface.vala

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public interface Database : Object {
6464
public abstract uint64 ean_alias_get(uint64 ean) throws IOError;
6565
public abstract EanAlias[] ean_alias_list() throws IOError;
6666
public abstract BestBeforeEntry[] bestbeforelist() throws IOError;
67+
public abstract Product get_product_for_ean(uint64 ean) throws IOError, DatabaseError;
6768
}
6869

6970
public struct Category {
@@ -155,6 +156,8 @@ public struct UserAuth {
155156
public struct Product {
156157
public uint64 ean;
157158
public string name;
159+
public Price memberprice;
160+
public Price guestprice;
158161
}
159162

160163
public struct InvoiceEntry {

0 commit comments

Comments
 (0)