Skip to content

Commit

Permalink
Merge pull request #172 from SebastianRzk/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SebastianRzk authored May 4, 2022
2 parents 7ade796 + b186b03 commit 1339598
Show file tree
Hide file tree
Showing 46 changed files with 19,050 additions and 9,427 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.fpm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
COPY butler_online/budgetbutler/package.json /app
RUN npm install
COPY butler_online/budgetbutler /app
RUN npm run build --prod
RUN npm run build -- --configuration=production
RUN ls -la /app/dist

# Stage 2
Expand All @@ -16,7 +16,7 @@ COPY butler_online_api/api /api
RUN composer install

# Assembly
FROM php:7-fpm-alpine
FROM php:8-fpm-alpine
RUN docker-php-ext-install pdo mysqli pdo_mysql
RUN mkdir -p /www/api
COPY butler_online_api/site.conf /etc/nginx/conf.d/default.conf
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
COPY butler_online/budgetbutler/package.json /app
RUN npm install
COPY butler_online/budgetbutler /app
RUN npm run build --prod
RUN npm run build -- --configuration=production
RUN ls -la /app/dist

# Stage 2
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
COPY butler_online/budgetbutler/package.json /app
RUN npm install
COPY butler_online/budgetbutler /app
RUN npm run build --prod
RUN npm run build -- --configuration=production
RUN ls -la /app/dist


Expand All @@ -30,7 +30,7 @@ COPY butler_online_api/api /api
RUN composer install

# Assembly
FROM php:7-fpm-alpine
FROM php:8-fpm-alpine
RUN docker-php-ext-install pdo mysqli pdo_mysql
RUN mkdir -p /www/api
COPY butler_online_api/site.conf /etc/nginx/conf.d/default.conf
Expand Down
9 changes: 5 additions & 4 deletions butler_offline/core/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from butler_offline.core.export.text_report import TextReportWriter
from butler_offline.viewcore import viewcore
from butler_offline.viewcore.converter import datum_to_german
import pandas as pd

from pandas import DataFrame

Expand Down Expand Up @@ -130,26 +131,26 @@ def abrechnen(self,
buchung_partner = self._berechne_abbuchung(row['Datum'], row['Kategorie'], row['Name'],
("%.2f" % (row['Wert'] * faktor_partner)))
buchung_partner.Dynamisch = False
ausgaben_fuer_partner = ausgaben_fuer_partner.append(buchung_partner)
ausgaben_fuer_partner = pd.concat([ausgaben_fuer_partner, buchung_partner])

buchung_self = self._berechne_abbuchung(row['Datum'], row['Kategorie'], row['Name'],
("%.2f" % (row['Wert'] * faktor_self)))
buchung_self.Dynamisch = False
ausgaben_fuer_self = ausgaben_fuer_self.append(buchung_self)
ausgaben_fuer_self = pd.concat([ausgaben_fuer_self, buchung_self])

if set_self_kategorie:
extra_wert = (ausgaben_gesamt * self._faktor_self(verhaeltnis)) - summe_halb
extra_ausgleichs_buchung = self._berechne_abbuchung(maxdate, set_self_kategorie, set_self_kategorie,
("%.2f" % extra_wert))
extra_ausgleichs_buchung.Dynamisch = False
ausgaben_fuer_self = ausgaben_fuer_self.append(extra_ausgleichs_buchung)
ausgaben_fuer_self = pd.concat([ausgaben_fuer_self, extra_ausgleichs_buchung])

if set_other_kategorie:
extra_wert = (ausgaben_gesamt * self._faktor_other(verhaeltnis)) - summe_halb
extra_ausgleichs_buchung = self._berechne_abbuchung(maxdate, set_other_kategorie, set_other_kategorie,
("%.2f" % extra_wert))
extra_ausgleichs_buchung.Dynamisch = False
ausgaben_fuer_partner = ausgaben_fuer_partner.append(extra_ausgleichs_buchung)
ausgaben_fuer_partner = pd.concat([ausgaben_fuer_partner, extra_ausgleichs_buchung])

report = TextReportWriter().generate_report(ausgaben_fuer_partner, abrechnunsdatei.to_string())

Expand Down
2 changes: 1 addition & 1 deletion butler_offline/core/database/database_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def parse(self, raw_table):
raw_table['Datum'] = raw_table['Datum'].map(lambda x: datetime.strptime(x, '%Y-%m-%d').date())
if 'Dynamisch' in self.content.columns:
raw_table['Dynamisch'] = False
self.content = self.content.append(raw_table, ignore_index=True)
self.content = pd.concat([self.content, raw_table], ignore_index=True)
self._sort()

def delete(self, index):
Expand Down
6 changes: 3 additions & 3 deletions butler_offline/core/database/dauerauftraege.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self):
def parse(self, raw_table):
raw_table['Startdatum'] = raw_table['Startdatum'].map(lambda x: datetime.strptime(x, '%Y-%m-%d').date())
raw_table['Endedatum'] = raw_table['Endedatum'].map(lambda x: datetime.strptime(x, '%Y-%m-%d').date())
self.content = self.content.append(raw_table, ignore_index=True)
self.content = pd.concat([self.content, raw_table], ignore_index=True)
self.content = self.content.sort_values(by=['Startdatum'])

def einnahmenausgaben_until_today(self,
Expand Down Expand Up @@ -45,15 +45,15 @@ def get_all_einzelbuchungen_until_today(self):
row['Wert'],
row['Kategorie'])
for buchung in dauerauftrag_buchungen:
all_rows = all_rows.append(buchung, ignore_index=True)
all_rows = pd.concat([all_rows, buchung], ignore_index=True)
return all_rows

def add(self, startdatum, endedatum, kategorie, name, rhythmus, wert):
neuer_dauerauftrag = pd.DataFrame(
[[endedatum, kategorie, name, rhythmus, startdatum, wert]],
columns=self.TABLE_HEADER
)
self.content = self.content.append(neuer_dauerauftrag, ignore_index=True)
self.content = pd.concat([self.content, neuer_dauerauftrag], ignore_index=True)
self.taint()
print('DATABASE: Dauerauftrag hinzugefügt')

Expand Down
5 changes: 2 additions & 3 deletions butler_offline/core/database/einzelbuchungen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pandas as pd

from butler_offline.viewcore import viewcore
from butler_offline.core.database.database_object import DatabaseObject


Expand All @@ -21,7 +20,7 @@ def _sort(self):

def add(self, datum, kategorie, name, wert, dynamisch=False):
neue_einzelbuchung = pd.DataFrame([[datum, kategorie, name, wert, [], dynamisch]], columns=self.TABLE_HEADER)
self.content = self.content.append(neue_einzelbuchung, ignore_index=True)
self.content = pd.concat([self.content, neue_einzelbuchung], ignore_index=True)
self.taint()
self._sort()

Expand Down Expand Up @@ -59,7 +58,7 @@ def _berechne_prozentual(self, tabelle):
return result

def append_row(self, row):
self.content = self.content.append(row, ignore_index=True)
self.content = pd.concat([self.content, row], ignore_index=True)
self._sort()

def get_monate(self):
Expand Down
6 changes: 3 additions & 3 deletions butler_offline/core/database/gemeinsamebuchungen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pandas.core.frame import DataFrame
from butler_offline.core.database.database_object import DatabaseObject
from butler_offline.core.database.selector import GemeinsamSelector
import pandas as pd


class Gemeinsamebuchungen(DatabaseObject):
Expand All @@ -11,15 +12,15 @@ def __init__(self):

def add(self, ausgaben_datum, kategorie, ausgaben_name, wert, person):
row = DataFrame([[ausgaben_datum, kategorie, ausgaben_name, wert, person]], columns=self.TABLE_HEADER)
self.content = self.content.append(row, ignore_index=True)
self.content = pd.concat([self.content, row], ignore_index=True)
self._sort()
self.taint()

def anteil_gemeinsamer_buchungen(self):
anteil_gemeinsamer_buchungen = DataFrame()
for _, row in self.content.iterrows():
einzelbuchung = DataFrame([[row.Datum, row.Kategorie, str(row.Name) + " (noch nicht abgerechnet, von " + str(row.Person) + ")", row.Wert * 0.5, True]], columns=('Datum', 'Kategorie', 'Name', 'Wert', 'Dynamisch'))
anteil_gemeinsamer_buchungen = anteil_gemeinsamer_buchungen.append(einzelbuchung, ignore_index=True)
anteil_gemeinsamer_buchungen = pd.concat([anteil_gemeinsamer_buchungen, einzelbuchung], ignore_index=True)
return anteil_gemeinsamer_buchungen

def drop(self, indices_to_drop):
Expand Down Expand Up @@ -60,7 +61,6 @@ def drop_all(self):
self.content = self.content.iloc[0:0]
self.taint()


def _rename_person(self, person_name, mapping):
if person_name in mapping:
return mapping[person_name]
Expand Down
10 changes: 6 additions & 4 deletions butler_offline/core/database/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def inject_zeros_for_year(self, year, max_month=12):
data = self.content.copy()
for month in range(1, max_month + 1):
inject_month = date(day=1, month=month, year=year)
data = data.append(pd.DataFrame([[inject_month, 0]], columns=['Datum', 'Wert']), ignore_index=True)
data = pd.concat([data, pd.DataFrame([[inject_month, 0]], columns=['Datum', 'Wert'])], ignore_index=True)
return Selektor(data)

def inject_zeroes_for_year_and_kategories(self, year, max_month=12):
Expand All @@ -77,7 +77,9 @@ def inject_zeroes_for_year_and_kategories(self, year, max_month=12):

injections = it.product(dates, kategorien)
for injection_date, injection_kategorie in injections:
data = data.append(pd.DataFrame([[injection_date, injection_kategorie, 0]], columns=['Datum', 'Kategorie', 'Wert']), ignore_index=True)
data = pd.concat([data,
pd.DataFrame([[injection_date, injection_kategorie, 0]], columns=['Datum', 'Kategorie', 'Wert'])],
ignore_index=True)
return Selektor(data)

def sum_monthly(self):
Expand Down Expand Up @@ -145,7 +147,7 @@ def get_month_summary(self):
if datum_alt != row.Datum:
zusammenfassung.append((datum_to_german(datum_alt), tag_liste))
tag_liste = []
tag_liste.append({'kategorie':kategorie_alt, 'name':name_alt, 'summe':'%.2f' % summe_alt})
tag_liste.append({'kategorie': kategorie_alt, 'name':name_alt, 'summe': '%.2f' % summe_alt})
datum_alt = row.Datum
summe_alt = row.Wert
kategorie_alt = row.Kategorie
Expand All @@ -163,7 +165,7 @@ def get_month_summary(self):
name_alt = name_alt + ', ' + row.Name + '(' + str(row.Wert) + '€)'
summe_alt += row.Wert

tag_liste.append({'kategorie':kategorie_alt, 'name':name_alt, 'summe':'%.2f' % summe_alt})
tag_liste.append({'kategorie': kategorie_alt, 'name': name_alt, 'summe': '%.2f' % summe_alt})
zusammenfassung.append([datum_to_german(datum_alt), tag_liste])
return zusammenfassung

Expand Down
2 changes: 1 addition & 1 deletion butler_offline/core/database/sparen/depotauszuege.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self):

def add(self, datum, depotwert, konto, wert):
neuer_auszug = pd.DataFrame([[datum, depotwert, konto, wert]], columns=self.TABLE_HEADER)
self.content = self.content.append(neuer_auszug, ignore_index=True)
self.content = pd.concat([self.content, neuer_auszug], ignore_index=True)
self.taint()
self._sort()

Expand Down
41 changes: 35 additions & 6 deletions butler_offline/core/database/sparen/depotwerte.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,45 @@


class Depotwerte(DatabaseObject):
TABLE_HEADER = ['Name', 'ISIN']
TYP = 'Typ'
TYP_ETF = 'ETF'
TYP_FOND = 'Fond'
TYP_EINZELAKTIE = 'Einzelaktie'
TYP_CRYPTO = 'Crypto'
TYP_ROBOT = 'Robot'
TYP_DEFAULT = TYP_ETF

TABLE_HEADER = ['Name', 'ISIN', 'Typ']
TYPES = [TYP_ETF, TYP_FOND, TYP_EINZELAKTIE, TYP_CRYPTO, TYP_ROBOT]

def __init__(self):
super().__init__(self.TABLE_HEADER)

def add(self, name, isin):
neuer_depotwert = pd.DataFrame([[name, isin]], columns=self.TABLE_HEADER)
self.content = self.content.append(neuer_depotwert, ignore_index=True)
def add(self, name, isin, typ):
neuer_depotwert = pd.DataFrame([[name, isin, typ]], columns=self.TABLE_HEADER)
self.content = pd.concat([self.content, neuer_depotwert], ignore_index=True)
self.taint()
self._sort()

def get_all(self):
return self.content

def edit(self, index, name, isin):
def edit(self, index, name, isin, typ):
self.edit_element(index, {
'Name': name,
'ISIN': isin
'ISIN': isin,
'Typ': typ
})

def parse_and_migrate(self, raw_table):
migrated_raw_table = self.migrate(raw_table)
self.parse(migrated_raw_table)

def migrate(self, raw_table):
if self.TYP not in raw_table.columns:
raw_table[self.TYP] = self.TYP_DEFAULT
return raw_table

def get_depotwerte(self):
return sorted(list(self.content.ISIN))

Expand All @@ -46,3 +65,13 @@ def get_valid_isins(self):
def _sort(self):
self.content = self.content.sort_values(by=['Name', 'ISIN'])
self.content = self.content.reset_index(drop=True)

def get_isin_nach_typ(self):
content = self.content.copy()
result_frame = content[['ISIN', 'Typ']].groupby(by='Typ').agg({'ISIN': lambda x: list(x)})
result = {}

for depotwert_type, name_list in result_frame.iterrows():
result[depotwert_type] = name_list['ISIN']

return result
2 changes: 1 addition & 1 deletion butler_offline/core/database/sparen/kontos.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):

def add(self, kontoname, kontotyp):
neues_konto = pd.DataFrame([[kontoname, kontotyp]], columns=self.TABLE_HEADER)
self.content = self.content.append(neues_konto, ignore_index=True)
self.content = pd.concat([self.content, neues_konto], ignore_index=True)
self.taint()
self._sort()

Expand Down
7 changes: 2 additions & 5 deletions butler_offline/core/database/sparen/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def __init__(self):

def add(self, datum, name, konto, depotwert, wert, dynamisch=False):
neue_order = pd.DataFrame([[datum, name, konto, depotwert, wert, dynamisch]], columns=self.TABLE_HEADER)
self.content = self.content.append(neue_order, ignore_index=True)
self.content = pd.concat([self.content, neue_order], ignore_index=True)
self.taint()
self._sort()

def get_all(self):
return self.content

def append_row(self, row):
self.content = self.content.append(row, ignore_index=True)
self.content = pd.concat([self.content, row], ignore_index=True)
self._sort()

def edit(self, index, datum, name, konto, depotwert, wert):
Expand Down Expand Up @@ -68,6 +68,3 @@ def select_year(self, year):
def get_static_content(self):
static_content = self.content.copy()[self.content.Dynamisch == False]
return static_content[self.STATIC_TABLE_HEADER]



25 changes: 10 additions & 15 deletions butler_offline/core/database/sparen/orderdauerauftrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def add(self, startdatum, endedatum, rhythmus, name, konto, depotwert, wert):
neue_order = pd.DataFrame(
[[startdatum, endedatum, rhythmus, name, konto, depotwert, wert]],
columns=self.TABLE_HEADER)
self.content = self.content.append(neue_order, ignore_index=True)
self.content = pd.concat([self.content, neue_order], ignore_index=True)
self.taint()
self._sort()

Expand All @@ -25,7 +25,7 @@ def get_all(self):
def parse(self, raw_table):
raw_table['Startdatum'] = raw_table['Startdatum'].map(lambda x: datetime.strptime(x, '%Y-%m-%d').date())
raw_table['Endedatum'] = raw_table['Endedatum'].map(lambda x: datetime.strptime(x, '%Y-%m-%d').date())
self.content = self.content.append(raw_table, ignore_index=True)
self.content = pd.concat([self.content, raw_table], ignore_index=True)
self.content = self.content.sort_values(by=['Startdatum'])

def edit(self, index, startdatum, endedatum, rhythmus, name, konto, depotwert, wert):
Expand All @@ -52,18 +52,17 @@ def get_all_order_until_today(self):
row['Depotwert'],
row['Wert'])
for buchung in dauerauftrag_buchungen:
all_rows = all_rows.append(buchung, ignore_index=True)
all_rows = pd.concat([all_rows, buchung], ignore_index=True)
return all_rows


def _order_until_today(self,
startdatum,
endedatum,
frequenzfunktion,
name,
konto,
depotwert,
wert,):
startdatum,
endedatum,
frequenzfunktion,
name,
konto,
depotwert,
wert,):
laufdatum = startdatum
frequency_function = get_function_for_name(frequenzfunktion)
result = []
Expand All @@ -77,7 +76,6 @@ def _berechne_order(self, laufdatum, konto, depotwert, name, wert):
return pd.DataFrame([[laufdatum, konto, depotwert, name, wert, True]],
columns=['Datum', 'Konto', 'Depotwert' , 'Name', 'Wert', 'Dynamisch'])


def _sort(self):
self.content = self.content.sort_values(by=['Startdatum', 'Endedatum', 'Name'])
self.content = self.content.reset_index(drop=True)
Expand All @@ -99,6 +97,3 @@ def future(self):
dauerauftraege = self.content.copy()
dauerauftraege = dauerauftraege[dauerauftraege.Startdatum > date.today()]
return self.frame_to_list_of_dicts(dauerauftraege)



2 changes: 1 addition & 1 deletion butler_offline/core/database/sparen/sparbuchungen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):

def add(self, datum, name, wert, typ, konto, dynamisch=False):
neue_sparbuchung = pd.DataFrame([[datum, name, wert, typ, konto, dynamisch]], columns=self.TABLE_HEADER)
self.content = self.content.append(neue_sparbuchung, ignore_index=True)
self.content = pd.concat([self.content, neue_sparbuchung], ignore_index=True)
self.taint()
self._sort()

Expand Down
Loading

0 comments on commit 1339598

Please sign in to comment.