Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
07dff73152
|
|||
10b7f89831
|
|||
69005569aa
|
|||
0e6ee3b2c5
|
|||
3a56c4fa0f | |||
b79ef11401 | |||
18cd0eeebc | |||
06e8a2f4bf | |||
b1b81eeb07 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,3 +11,6 @@ cli/*.tex
|
|||||||
cli/*.log
|
cli/*.log
|
||||||
cli/*.pdf
|
cli/*.pdf
|
||||||
cli/*.aux
|
cli/*.aux
|
||||||
|
.DS_Store
|
||||||
|
.Rproj.user
|
||||||
|
.venv
|
||||||
|
@ -11,19 +11,6 @@ ARG CONF_DIR="${APP_DIR}/config"
|
|||||||
RUN \
|
RUN \
|
||||||
apt update && \
|
apt update && \
|
||||||
apt install -y postgresql-client-common && \
|
apt install -y postgresql-client-common && \
|
||||||
pip3 install psycopg2 && \
|
|
||||||
pip3 install dateparser && \
|
|
||||||
pip3 install connexion && \
|
|
||||||
pip3 install connexion[swagger-ui] && \
|
|
||||||
pip3 install uwsgi && \
|
|
||||||
pip3 install flask-cors && \
|
|
||||||
pip3 install python-jose[cryptography] && \
|
|
||||||
pip3 install loguru && \
|
|
||||||
pip3 install Cheetah3
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
mkdir -p ${APP_DIR} && \
|
mkdir -p ${APP_DIR} && \
|
||||||
mkdir -p ${CONF_DIR} && \
|
mkdir -p ${CONF_DIR} && \
|
||||||
useradd -d ${APP_DIR} -u 1000 user
|
useradd -d ${APP_DIR} -u 1000 user
|
||||||
@ -31,11 +18,15 @@ RUN \
|
|||||||
COPY *.py ${APP_DIR}/
|
COPY *.py ${APP_DIR}/
|
||||||
COPY openapi.yaml ${APP_DIR}/
|
COPY openapi.yaml ${APP_DIR}/
|
||||||
COPY methods.py ${APP_DIR}/
|
COPY methods.py ${APP_DIR}/
|
||||||
|
COPY requirements.txt ${APP_DIR}/
|
||||||
COPY server.ini ${CONF_DIR}/
|
COPY server.ini ${CONF_DIR}/
|
||||||
|
|
||||||
WORKDIR ${APP_DIR}
|
WORKDIR ${APP_DIR}
|
||||||
VOLUME ${CONF_DIR}
|
VOLUME ${CONF_DIR}
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
100
api/methods.py
100
api/methods.py
@ -1584,3 +1584,103 @@ SELECT
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_contracts(user, token_info):
|
||||||
|
return dbGetMany(user, token_info, {
|
||||||
|
"statement": """
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
,supplier
|
||||||
|
,content
|
||||||
|
,identifier
|
||||||
|
,notes
|
||||||
|
FROM contract_t
|
||||||
|
ORDER BY
|
||||||
|
supplier
|
||||||
|
,content
|
||||||
|
""",
|
||||||
|
"params": ()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def insert_contract(user, token_info, **args):
|
||||||
|
try:
|
||||||
|
body = args["body"]
|
||||||
|
v_supplier = body["supplier"]
|
||||||
|
v_content = body["content"]
|
||||||
|
v_identifier = body["identifier"]
|
||||||
|
v_notes = body["notes"]
|
||||||
|
return dbInsert(user, token_info, {
|
||||||
|
"statement": """
|
||||||
|
INSERT INTO contract_t
|
||||||
|
(
|
||||||
|
supplier
|
||||||
|
,content
|
||||||
|
,identifier
|
||||||
|
,notes
|
||||||
|
) VALUES (
|
||||||
|
%s
|
||||||
|
,%s
|
||||||
|
,%s
|
||||||
|
,%s
|
||||||
|
)
|
||||||
|
RETURNING *
|
||||||
|
""",
|
||||||
|
"params": [
|
||||||
|
v_supplier
|
||||||
|
,v_content
|
||||||
|
,v_identifier
|
||||||
|
,v_notes
|
||||||
|
]
|
||||||
|
})
|
||||||
|
except KeyError as e:
|
||||||
|
logger.warning("insert_contract: parameter missing: {}".format(e))
|
||||||
|
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
def get_contract(user, token_info, contractId=None):
|
||||||
|
return dbGetOne(user, token_info, {
|
||||||
|
"statement": """
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
,supplier
|
||||||
|
,content
|
||||||
|
,identifier
|
||||||
|
,notes
|
||||||
|
FROM contract_t
|
||||||
|
WHERE id = %s
|
||||||
|
""",
|
||||||
|
"params": (contractId, )
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def update_contract(user, token_info, contractId=None, **args):
|
||||||
|
try:
|
||||||
|
body = args["body"]
|
||||||
|
v_supplier = body["supplier"]
|
||||||
|
v_content = body["content"]
|
||||||
|
v_identifier = body["identifier"]
|
||||||
|
v_notes = body["notes"]
|
||||||
|
return dbUpdate(user, token_info, {
|
||||||
|
"statement": """
|
||||||
|
UPDATE contract_t
|
||||||
|
SET
|
||||||
|
supplier = %s
|
||||||
|
,content = %s
|
||||||
|
,identifier = %s
|
||||||
|
,notes = %s
|
||||||
|
WHERE id = %s
|
||||||
|
RETURNING *
|
||||||
|
""",
|
||||||
|
"params": [
|
||||||
|
v_supplier,
|
||||||
|
v_content,
|
||||||
|
v_identifier,
|
||||||
|
v_notes,
|
||||||
|
contractId
|
||||||
|
]
|
||||||
|
})
|
||||||
|
except KeyError as e:
|
||||||
|
logger.warning("update_contract: parameter missing: {}".format(e))
|
||||||
|
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
101
api/openapi.yaml
101
api/openapi.yaml
@ -1440,6 +1440,92 @@ paths:
|
|||||||
$ref: '#/components/schemas/note'
|
$ref: '#/components/schemas/note'
|
||||||
security:
|
security:
|
||||||
- jwt: ['secret']
|
- jwt: ['secret']
|
||||||
|
/v1/contracts:
|
||||||
|
get:
|
||||||
|
tags: [ "contract" ]
|
||||||
|
summary: Return all normalized contracts
|
||||||
|
operationId: methods.get_contracts
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: contracts response
|
||||||
|
content:
|
||||||
|
'application/json':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
security:
|
||||||
|
- jwt: ['secret']
|
||||||
|
post:
|
||||||
|
tags: [ "contract" ]
|
||||||
|
summary: Insert a contract
|
||||||
|
operationId: methods.insert_contract
|
||||||
|
requestBody:
|
||||||
|
description: contract
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: contract successfully inserted
|
||||||
|
content:
|
||||||
|
'application/json':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
security:
|
||||||
|
- jwt: ['secret']
|
||||||
|
/v1/contracts/{contractId}:
|
||||||
|
get:
|
||||||
|
tags: [ "contract" ]
|
||||||
|
summary: Return the normalized contract with given id
|
||||||
|
operationId: methods.get_contract
|
||||||
|
parameters:
|
||||||
|
- name: contractId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: contract response
|
||||||
|
content:
|
||||||
|
'application/json':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
security:
|
||||||
|
- jwt: ['secret']
|
||||||
|
put:
|
||||||
|
tags: [ "contract" ]
|
||||||
|
summary: Update a contract
|
||||||
|
operationId: methods.update_contract
|
||||||
|
parameters:
|
||||||
|
- name: contractId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
requestBody:
|
||||||
|
description: contract
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: contract successfully inserted
|
||||||
|
content:
|
||||||
|
'application/json':
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/contract'
|
||||||
|
security:
|
||||||
|
- jwt: ['secret']
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# ATTENTION: This file will not be parsed by Cheetah
|
# ATTENTION: This file will not be parsed by Cheetah
|
||||||
@ -1818,6 +1904,21 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
note:
|
note:
|
||||||
type: string
|
type: string
|
||||||
|
contract:
|
||||||
|
description: contract
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
supplier:
|
||||||
|
type: string
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
identifier:
|
||||||
|
type: string
|
||||||
|
notes:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# ATTENTION: This file will not be parsed by Cheetah
|
# ATTENTION: This file will not be parsed by Cheetah
|
||||||
|
40
api/requirements.txt
Normal file
40
api/requirements.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
attrs==22.2.0
|
||||||
|
certifi==2022.12.7
|
||||||
|
cffi==1.15.1
|
||||||
|
charset-normalizer==2.1.1
|
||||||
|
Cheetah3==3.2.6.post1
|
||||||
|
click==8.1.3
|
||||||
|
clickclick==20.10.2
|
||||||
|
connexion==2.14.1
|
||||||
|
cryptography==39.0.0
|
||||||
|
dateparser==1.1.5
|
||||||
|
ecdsa==0.18.0
|
||||||
|
Flask==2.2.2
|
||||||
|
Flask-Cors==3.0.10
|
||||||
|
idna==3.4
|
||||||
|
inflection==0.5.1
|
||||||
|
itsdangerous==2.1.2
|
||||||
|
Jinja2==3.1.2
|
||||||
|
jsonschema==4.17.3
|
||||||
|
loguru==0.6.0
|
||||||
|
MarkupSafe==2.1.1
|
||||||
|
packaging==22.0
|
||||||
|
psycopg2==2.9.5
|
||||||
|
pyasn1==0.4.8
|
||||||
|
pycparser==2.21
|
||||||
|
pyrsistent==0.19.3
|
||||||
|
python-dateutil==2.8.2
|
||||||
|
python-jose==3.3.0
|
||||||
|
pytz==2022.7
|
||||||
|
pytz-deprecation-shim==0.1.0.post0
|
||||||
|
PyYAML==6.0
|
||||||
|
regex==2022.10.31
|
||||||
|
requests==2.28.1
|
||||||
|
rsa==4.9
|
||||||
|
six==1.16.0
|
||||||
|
swagger-ui-bundle==0.0.9
|
||||||
|
tzdata==2022.7
|
||||||
|
tzlocal==4.2
|
||||||
|
urllib3==1.26.13
|
||||||
|
uWSGI==2.0.21
|
||||||
|
Werkzeug==2.2.2
|
@ -48,7 +48,61 @@ def perform(dbh, params):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sum_total = dbGetOne(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement": "select sum(amount) as sum from account_statement_v where fiscal_year = %(year)s",
|
||||||
|
"params": {
|
||||||
|
'year': year
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
sum_error = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement": """
|
||||||
|
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 1 as error, 'booked in %(year1)s, accounted in %(year0)s' as remark from account_statement_v where fiscal_year = %(year0)s and extract(year from created_at) = %(year1)s
|
||||||
|
union
|
||||||
|
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 2 as error, 'booked in %(year0)s, accounted in %(year1)s' as remark from account_statement_v where fiscal_year = %(year1)s and extract(year from created_at) = %(year0)s
|
||||||
|
union
|
||||||
|
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 3 as error, 'booked in %(year2)s, accounted in %(year1)s' as remark from account_statement_v where fiscal_year = %(year1)s and extract(year from created_at) = %(year2)s
|
||||||
|
union
|
||||||
|
select coalesce(sum(amount), 0::numeric(10,2)) as sum, 4 as error, 'booked in %(year1)s, accounted in %(year2)s' as remark from account_statement_v where fiscal_year = %(year2)s and extract(year from created_at) = %(year1)s
|
||||||
|
order by error
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
'year0': year - 1,
|
||||||
|
'year1': year,
|
||||||
|
'year2': year + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
count_entries = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement": "select extract(month from created_at) as month, count(*) as count from account_statement_v where extract(year from created_at) = %(year)s group by month",
|
||||||
|
"params": {
|
||||||
|
"year": year
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
raw_total = sum_total['sum']
|
||||||
|
logger.info(f"{raw_total=}")
|
||||||
|
err1 = sum_error[0]['sum']
|
||||||
|
logger.info(f"{err1=}")
|
||||||
|
err2 = sum_error[1]['sum']
|
||||||
|
logger.info(f"{err2=}")
|
||||||
|
err3 = sum_error[2]['sum']
|
||||||
|
logger.info(f"{err3=}")
|
||||||
|
err4 = sum_error[3]['sum']
|
||||||
|
logger.info(f"{err4=}")
|
||||||
|
adjusted_total = raw_total + err1 - err2 - err3 + err4
|
||||||
|
logger.info(f"{adjusted_total=}")
|
||||||
|
|
||||||
template = getParam(params, 'template', 'accountStatement.tmpl')
|
template = getParam(params, 'template', 'accountStatement.tmpl')
|
||||||
input = { 'year': year, 'entries': accountEntries, 'overview': overview, 'related': sum_related, 'unrelated': sum_unrelated }
|
input = { 'year': year, 'entries': accountEntries, 'overview': overview, 'related': sum_related, 'unrelated': sum_unrelated, 'total': sum_total, 'errors': sum_error, 'adjusted_total' :adjusted_total, 'count_entries': count_entries }
|
||||||
tmpl = Template(file=template, searchList=[ input ])
|
tmpl = Template(file=template, searchList=[ input ])
|
||||||
print(tmpl)
|
print(tmpl)
|
||||||
|
@ -4,8 +4,8 @@ from loguru import logger
|
|||||||
from decimal import *
|
from decimal import *
|
||||||
from utils import getParam
|
from utils import getParam
|
||||||
from Cheetah.Template import Template
|
from Cheetah.Template import Template
|
||||||
|
import xlsxwriter
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
EPSILON = Decimal('0.000000001')
|
EPSILON = Decimal('0.000000001')
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ def perform(dbh, params):
|
|||||||
where p.account = a.id and
|
where p.account = a.id and
|
||||||
ae.account = a.id and
|
ae.account = a.id and
|
||||||
aec.overhead_relevant = 't' and
|
aec.overhead_relevant = 't' and
|
||||||
aec.id not in (select distinct account_entry_category from account_entry_t where fiscal_year = %(year)s) and
|
aec.id not in (select distinct account_entry_category from account_entry_t where fiscal_year = %(year)s and account = p.account) and
|
||||||
ae.fiscal_year = %(year)s and
|
ae.fiscal_year = %(year)s and
|
||||||
p.id = %(premise)s
|
p.id = %(premise)s
|
||||||
group by category, considerminusarea
|
group by category, considerminusarea
|
||||||
@ -190,6 +190,7 @@ def perform(dbh, params):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# get flat tenants by object and timespan with paid overhead and due overhead
|
# get flat tenants by object and timespan with paid overhead and due overhead
|
||||||
tenants = dbGetMany(
|
tenants = dbGetMany(
|
||||||
dbh,
|
dbh,
|
||||||
@ -212,17 +213,23 @@ def perform(dbh, params):
|
|||||||
p.description as house,
|
p.description as house,
|
||||||
ty.startdate as startdate,
|
ty.startdate as startdate,
|
||||||
ty.enddate as enddate,
|
ty.enddate as enddate,
|
||||||
t.account as tenant_account
|
t.account as tenant_account,
|
||||||
|
fe.amount as fee,
|
||||||
|
fe.fee_type as fee_type
|
||||||
from tenant_t t,
|
from tenant_t t,
|
||||||
premise_t p,
|
premise_t p,
|
||||||
flat_t f,
|
flat_t f,
|
||||||
tenancy_t ty
|
tenancy_t ty,
|
||||||
|
tenancy_fee_mapping_t tyfm,
|
||||||
|
fee_t fe
|
||||||
where ty.tenant = t.id and
|
where ty.tenant = t.id and
|
||||||
ty.flat = f.id and
|
ty.flat = f.id and
|
||||||
ty.startdate <= %(startDate)s and
|
ty.startdate <= %(startDate)s and
|
||||||
(ty.enddate >= %(endDate)s or ty.enddate is null) and
|
(ty.enddate >= %(endDate)s or ty.enddate is null) and
|
||||||
f.premise = p.id and
|
f.premise = p.id and
|
||||||
p.id in %(premises)s
|
p.id in %(premises)s and
|
||||||
|
tyfm.tenancy = ty.id and
|
||||||
|
tyfm.fee = fe.id
|
||||||
order by house_id, tenant_id
|
order by house_id, tenant_id
|
||||||
""",
|
""",
|
||||||
"params": {
|
"params": {
|
||||||
@ -242,8 +249,7 @@ def perform(dbh, params):
|
|||||||
{
|
{
|
||||||
"statement":
|
"statement":
|
||||||
"""
|
"""
|
||||||
SELECT sum(amount) AS sum,
|
SELECT sum(amount) AS sum
|
||||||
count(id) AS cnt
|
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
WHERE account = %(account)s AND
|
WHERE account = %(account)s AND
|
||||||
account_entry_category = 2 AND
|
account_entry_category = 2 AND
|
||||||
@ -262,8 +268,7 @@ def perform(dbh, params):
|
|||||||
{
|
{
|
||||||
"statement":
|
"statement":
|
||||||
"""
|
"""
|
||||||
SELECT sum(amount) * -1 AS sum ,
|
SELECT sum(amount) * -1 AS sum
|
||||||
count(id) AS cnt
|
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
WHERE account = %(account)s AND
|
WHERE account = %(account)s AND
|
||||||
account_entry_category = 3 AND
|
account_entry_category = 3 AND
|
||||||
@ -276,7 +281,9 @@ def perform(dbh, params):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
tenant['receivable_fee'] = receivableFee['sum']
|
tenant['receivable_fee'] = receivableFee['sum']
|
||||||
tenant['rent_time'] = receivableFee['cnt']
|
|
||||||
|
delta = relativedelta((tenant['enddate'] or datetime.date(year, 12, 31)), (tenant['startdate'] if (tenant['startdate'].year == year) else datetime.date(year, 1, 1)))
|
||||||
|
tenant['rent_time'] = delta.months if delta.days == 0 else delta.months + 1
|
||||||
|
|
||||||
tenant['paid_overhead'] = paidTotal['sum'] - receivableFee['sum']
|
tenant['paid_overhead'] = paidTotal['sum'] - receivableFee['sum']
|
||||||
|
|
||||||
@ -307,8 +314,49 @@ def perform(dbh, params):
|
|||||||
with open(outputFile, 'w') as f:
|
with open(outputFile, 'w') as f:
|
||||||
f.write(str(tmpl))
|
f.write(str(tmpl))
|
||||||
|
|
||||||
|
if printOverviews:
|
||||||
|
tenantsOverviewPrefix = getParam(params, 'tenantsOverviewPrefix', 'tenantsOverview')
|
||||||
|
tenantsOverviewSuffix = getParam(params, 'tenantsOverviewSuffix', 'xlsx')
|
||||||
|
|
||||||
|
logger.debug(f"Processing letters: {letters}")
|
||||||
|
outputFile = f"./output/{tenantsOverviewPrefix}-{year}.{tenantsOverviewSuffix}"
|
||||||
|
|
||||||
|
workbook = xlsxwriter.Workbook(outputFile)
|
||||||
|
worksheet = workbook.add_worksheet()
|
||||||
|
|
||||||
|
worksheet.write(0, 0, 'id')
|
||||||
|
worksheet.write(0, 1, 'lastname')
|
||||||
|
worksheet.write(0, 2, 'firstname')
|
||||||
|
worksheet.write(0, 3, 'house')
|
||||||
|
worksheet.write(0, 4, 'overhead_part_by_montharea')
|
||||||
|
worksheet.write(0, 5, 'flat')
|
||||||
|
worksheet.write(0, 6, 'flat_area')
|
||||||
|
worksheet.write(0, 7, 'fee')
|
||||||
|
worksheet.write(0, 8, 'rent_time')
|
||||||
|
worksheet.write(0, 9, 'paid_total')
|
||||||
|
worksheet.write(0, 10, 'receivable_fee')
|
||||||
|
worksheet.write(0, 11, 'paid_overhead')
|
||||||
|
worksheet.write(0, 12, 'receivable_overhead')
|
||||||
|
worksheet.write(0, 13, 'unbalanced_overhead')
|
||||||
|
|
||||||
|
row = 1
|
||||||
|
|
||||||
|
for entry in letters:
|
||||||
|
worksheet.write(row, 0, entry['tenant']['tenant_id'])
|
||||||
|
worksheet.write(row, 1, entry['tenant']['tenant_lastname'])
|
||||||
|
worksheet.write(row, 2, entry['tenant']['tenant_firstname'])
|
||||||
|
worksheet.write(row, 3, entry['tenant']['house'])
|
||||||
|
worksheet.write(row, 4, houses[entry['tenant']['house_id']]['part_by_montharea'])
|
||||||
|
worksheet.write(row, 5, entry['tenant']['flat'])
|
||||||
|
worksheet.write(row, 6, entry['tenant']['flat_area'])
|
||||||
|
worksheet.write(row, 7, entry['tenant']['fee'])
|
||||||
|
worksheet.write(row, 8, entry['tenant']['rent_time'])
|
||||||
|
worksheet.write(row, 9, entry['tenant']['paid_total'])
|
||||||
|
worksheet.write(row, 10, entry['tenant']['receivable_fee'])
|
||||||
|
worksheet.write(row, 11, entry['tenant']['paid_overhead'])
|
||||||
|
worksheet.write(row, 12, entry['receivable_overhead'])
|
||||||
|
worksheet.write(row, 13, entry['unbalanced_overhead'])
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
workbook.close()
|
||||||
|
|
||||||
|
0
cli/accountStatement
Normal file
0
cli/accountStatement
Normal file
@ -53,6 +53,30 @@
|
|||||||
|
|
||||||
\hline \hline related & \tt{$related['sum']} \,\euro{} \\
|
\hline \hline related & \tt{$related['sum']} \,\euro{} \\
|
||||||
\hline unrelated & \tt{$unrelated['sum']} \,\euro{} \\
|
\hline unrelated & \tt{$unrelated['sum']} \,\euro{} \\
|
||||||
|
\hline total & \tt{$total['sum']} \,\euro{} \\
|
||||||
|
\hline \hline
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
|
\subsection*{Errors}
|
||||||
|
|
||||||
|
\begin{tabular}{|r|r|l|} \hline
|
||||||
|
\hline \textcolor{blue}{\bf{type}} & \textcolor{blue}{\bf{sum}} & \textcolor{blue}{\bf{remark}} \\
|
||||||
|
#for $entry in $errors
|
||||||
|
\hline \tt{$entry['error']} & \tt{$entry['sum']} \,\euro{} & \tt{$entry['remark']} \\
|
||||||
|
#end for
|
||||||
|
\hline \tt{0} & \tt{$adjusted_total} \,\euro{} & \tt{adjusted total} \\
|
||||||
|
\hline \hline
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
|
\subsection*{Counts}
|
||||||
|
|
||||||
|
\begin{tabular}{|r|r|} \hline
|
||||||
|
\hline \textcolor{blue}{\bf{Month}} & \textcolor{blue}{\bf{Count}} \\
|
||||||
|
#for $entry in $count_entries
|
||||||
|
\hline \tt{$entry['month']} & \tt{$entry['count']} \\
|
||||||
|
#end for
|
||||||
\hline \hline
|
\hline \hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
|
|
@ -57,7 +57,7 @@
|
|||||||
\hline
|
\hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
|
|
||||||
#if 1 < 0
|
#if $unbalanced_overhead < 0
|
||||||
Bitte "uberweisen Sie den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} kurzfristig auf mein Konto.
|
Bitte "uberweisen Sie den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} kurzfristig auf mein Konto.
|
||||||
#else
|
#else
|
||||||
Ich werde den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} in den n"achsten Tagen auf Ihr Konto "uberweisen.
|
Ich werde den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} in den n"achsten Tagen auf Ihr Konto "uberweisen.
|
236
r-scripts/hv2-analysis/.Rhistory
Normal file
236
r-scripts/hv2-analysis/.Rhistory
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
source("~/.active-rstudio-document")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
View(amounts)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
View(amounts)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
print(amounts)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
print(amounts)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
print(amounts)
|
||||||
|
print(amounts, digits=2)
|
||||||
|
print(amounts, width=100)
|
||||||
|
print(amounts, width=10)
|
||||||
|
print(amounts, width=100)
|
||||||
|
print(amounts, digits=10)
|
||||||
|
options(pillar.sigfig=7)
|
||||||
|
print(amounts)
|
||||||
|
options(pillar.sigfig=10)
|
||||||
|
print(amounts)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
library(tidyverse)
|
||||||
|
flextable::flextable
|
||||||
|
library(table)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
sum(amounts$fee)
|
||||||
|
sum(amounts$fee) + sum(amounts$overhead)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
sum(amounts$Betriebskosten)
|
||||||
|
sum(amounts$Betriebskosten, na.rm = TRUE)
|
||||||
|
sum(amounts$Betriebskosten, na.rm = FALSE)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
sum(amounts$Betriebskosten)
|
||||||
|
sum(amounts$Betriebskosten, na.rm = T)
|
||||||
|
sum(amounts$Betriebskosten, na.omit())
|
||||||
|
sum(amounts$Betriebskosten
|
||||||
|
)
|
||||||
|
sum(amounts$Betriebskosten)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
amounts$Betriebskosten
|
||||||
|
amounts$Betriebskosten[is.na(.)]
|
||||||
|
amounts$Betriebskosten[is.na()]
|
||||||
|
amounts$Betriebskosten[NA]
|
||||||
|
amounts$Betriebskosten[1]
|
||||||
|
amounts$Betriebskosten[is.na()]
|
||||||
|
amounts$Betriebskosten[is.na]
|
||||||
|
d <- amounts$Betriebskosten
|
||||||
|
d
|
||||||
|
d[is.na(d)]
|
||||||
|
d[is.na(d)] <- 0
|
||||||
|
d
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
View(expense)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
expense
|
||||||
|
expense[overhead_relevant==T]
|
||||||
|
expense[expense$overhead_relevant == T]
|
||||||
|
expense[expense$overhead_relevant == TRUE]
|
||||||
|
expense[expense$overhead_relevant]
|
||||||
|
expense %>% filter(overhead_relevant == TRUE)
|
||||||
|
source("~/Workspace/hv2-all-in-one/r-scripts/hv2-analysis/income.R")
|
||||||
|
View(expense)
|
||||||
|
knitr::opts_chunk$set(echo = TRUE)
|
||||||
|
total_fee <- sum(income$Miete)
|
||||||
|
knitr::opts_chunk$set(echo = TRUE)
|
||||||
|
library(tidyverse, warn.conflicts = FALSE)
|
||||||
|
library(DBI, warn.conflicts = FALSE)
|
||||||
|
library(tidyr, warn.conflicts = FALSE)
|
||||||
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
YEAR <- 2021
|
||||||
|
HOME <- Sys.getenv("HOME")
|
||||||
|
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||||
|
PGDATABASE = "hv2",
|
||||||
|
PGPORT = 5432,
|
||||||
|
PGUSER = "wn",
|
||||||
|
PGSSLMODE = "verify-ca",
|
||||||
|
PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""),
|
||||||
|
PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""),
|
||||||
|
PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep=""))
|
||||||
|
con <- dbConnect(RPostgres::Postgres())
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_t a,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.id = f.premise and
|
||||||
|
ty.flat = f.id and
|
||||||
|
ty.tenant = t.id and
|
||||||
|
a.id = t.account and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
ae.fiscal_year = $1 and
|
||||||
|
aec.description in ('Mietzahlung', 'Mietforderung', 'Betriebskostenforderung', 'Betriebskostenausgleich')
|
||||||
|
group by p.description,
|
||||||
|
f.description,
|
||||||
|
aec.description;
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
income <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
income <- income %>%
|
||||||
|
pivot_wider(names_from = category, values_from = amount) %>%
|
||||||
|
mutate(Miete := -1 * Mietforderung) %>%
|
||||||
|
mutate(Betriebskosten := Mietzahlung - Miete + Betriebskostenausgleich) %>%
|
||||||
|
select(flat, premise, Miete, Betriebskosten) %>%
|
||||||
|
arrange(premise, flat) %>%
|
||||||
|
mutate(across(where(is.numeric), ~num(., digits=2))) %>%
|
||||||
|
mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
knitr::kable(income)
|
||||||
|
total_fee <- sum(income$Miete)
|
||||||
|
total_overhead <- sum(income$Betriebskosten)
|
||||||
|
total_income <- total_fee + total_overhead
|
||||||
|
View(income)
|
||||||
|
knitr::opts_chunk$set(echo = TRUE)
|
||||||
|
library(tidyverse, warn.conflicts = FALSE)
|
||||||
|
library(DBI, warn.conflicts = FALSE)
|
||||||
|
library(tidyr, warn.conflicts = FALSE)
|
||||||
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
YEAR <- 2021
|
||||||
|
HOME <- Sys.getenv("HOME")
|
||||||
|
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||||
|
PGDATABASE = "hv2",
|
||||||
|
PGPORT = 5432,
|
||||||
|
PGUSER = "wn",
|
||||||
|
PGSSLMODE = "verify-ca",
|
||||||
|
PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""),
|
||||||
|
PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""),
|
||||||
|
PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep=""))
|
||||||
|
con <- dbConnect(RPostgres::Postgres())
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_t a,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.id = f.premise and
|
||||||
|
ty.flat = f.id and
|
||||||
|
ty.tenant = t.id and
|
||||||
|
a.id = t.account and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
ae.fiscal_year = $1 and
|
||||||
|
aec.description in ('Mietzahlung', 'Mietforderung', 'Betriebskostenforderung', 'Betriebskostenausgleich')
|
||||||
|
group by p.description,
|
||||||
|
f.description,
|
||||||
|
aec.description;
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
income <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
income <- income %>%
|
||||||
|
pivot_wider(names_from = category, values_from = amount) %>%
|
||||||
|
mutate(Miete := -1 * Mietforderung) %>%
|
||||||
|
mutate(Betriebskosten := Mietzahlung - Miete + Betriebskostenausgleich) %>%
|
||||||
|
select(flat, premise, Miete, Betriebskosten) %>%
|
||||||
|
arrange(premise, flat) %>%
|
||||||
|
mutate(across(where(is.numeric), ~num(., digits=2))) %>%
|
||||||
|
mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
knitr::kable(income)
|
||||||
|
total_fee <- sum(income$Miete)
|
||||||
|
total_overhead <- sum(income$Betriebskosten)
|
||||||
|
total_income <- total_fee + total_overhead
|
||||||
|
toString(total_fee)
|
||||||
|
total_fee$value
|
||||||
|
total_fee[1]
|
||||||
|
total_fee[2]
|
||||||
|
total_fee[1]
|
||||||
|
t=total_fee
|
||||||
|
t
|
||||||
|
unnest(t)
|
||||||
|
a <- 6.4234
|
||||||
|
a
|
||||||
|
num(a, digits=2)
|
||||||
|
a
|
||||||
|
format(a, digits=2)
|
||||||
|
format(a, digits=3)
|
||||||
|
a<-100.4234234
|
||||||
|
a
|
||||||
|
format(a, digits=3)
|
||||||
|
format(a, nsmall=2)
|
13
r-scripts/hv2-analysis/hv2-analysis.Rproj
Normal file
13
r-scripts/hv2-analysis/hv2-analysis.Rproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Version: 1.0
|
||||||
|
|
||||||
|
RestoreWorkspace: Default
|
||||||
|
SaveWorkspace: Default
|
||||||
|
AlwaysSaveHistory: Default
|
||||||
|
|
||||||
|
EnableCodeIndexing: Yes
|
||||||
|
UseSpacesForTab: Yes
|
||||||
|
NumSpacesForTab: 2
|
||||||
|
Encoding: UTF-8
|
||||||
|
|
||||||
|
RnwWeave: Sweave
|
||||||
|
LaTeX: pdfLaTeX
|
173
r-scripts/hv2-analysis/income-expense-analysis.Rmd
Normal file
173
r-scripts/hv2-analysis/income-expense-analysis.Rmd
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
---
|
||||||
|
title: "HV2 Jahresabrechnung"
|
||||||
|
author: "Wolfgang Hottgenroth"
|
||||||
|
date: "2022-09-18"
|
||||||
|
output:
|
||||||
|
pdf_document: default
|
||||||
|
html_document: default
|
||||||
|
word_document: default
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
```{r setup, include=FALSE, echo=FALSE, message=FALSE}
|
||||||
|
knitr::opts_chunk$set(echo = FALSE, message=FALSE)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
library(tidyverse, warn.conflicts = FALSE)
|
||||||
|
library(DBI, warn.conflicts = FALSE)
|
||||||
|
library(tidyr, warn.conflicts = FALSE)
|
||||||
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
```
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
YEAR <- 2021
|
||||||
|
|
||||||
|
HOME <- Sys.getenv("HOME")
|
||||||
|
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||||
|
PGDATABASE = "hv2",
|
||||||
|
PGPORT = 5432,
|
||||||
|
PGUSER = "wn",
|
||||||
|
PGSSLMODE = "verify-ca",
|
||||||
|
PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""),
|
||||||
|
PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""),
|
||||||
|
PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep=""))
|
||||||
|
|
||||||
|
|
||||||
|
con <- dbConnect(RPostgres::Postgres())
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Übersicht über die Einnahmen
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_t a,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.id = f.premise and
|
||||||
|
ty.flat = f.id and
|
||||||
|
ty.tenant = t.id and
|
||||||
|
a.id = t.account and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
ae.fiscal_year = $1 and
|
||||||
|
aec.description in ('Mietzahlung', 'Mietforderung', 'Betriebskostenforderung', 'Betriebskostenausgleich')
|
||||||
|
group by p.description,
|
||||||
|
f.description,
|
||||||
|
aec.description;
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
|
||||||
|
income <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
|
||||||
|
income <- income %>%
|
||||||
|
pivot_wider(names_from = category, values_from = amount) %>%
|
||||||
|
mutate(Miete := -1 * Mietforderung) %>%
|
||||||
|
mutate(Betriebskosten := Mietzahlung - Miete + Betriebskostenausgleich) %>%
|
||||||
|
select(flat, premise, Miete, Betriebskosten) %>%
|
||||||
|
arrange(premise, flat) %>%
|
||||||
|
# mutate(across(where(is.numeric), ~num(., digits=2))) %>%
|
||||||
|
mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
knitr::kable(income)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Übersicht über die Ausgaben
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select aec.overhead_relevant as overhead_relevant,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from account_entry_category_t aec,
|
||||||
|
account_entry_t ae
|
||||||
|
where aec.id = ae.account_entry_category and
|
||||||
|
aec.id not in (2, 3, 4, 29) and
|
||||||
|
ae.fiscal_year = $1
|
||||||
|
group by aec.overhead_relevant,
|
||||||
|
aec.description
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
|
||||||
|
expense <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
|
||||||
|
expense <- expense %>%
|
||||||
|
arrange(overhead_relevant, category) %>%
|
||||||
|
# mutate(across(where(is.numeric), ~num(., digits=2))) %>%
|
||||||
|
mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
```
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
knitr::kable(expense)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Zusammenfassung
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```{r}
|
||||||
|
total_fee <- sum(income$Miete)
|
||||||
|
total_overhead <- sum(income$Betriebskosten)
|
||||||
|
total_income <- total_fee + total_overhead
|
||||||
|
|
||||||
|
total_expense <- sum(expense$amount)
|
||||||
|
overhead_relevant_expense <- expense %>%
|
||||||
|
filter(overhead_relevant == TRUE)
|
||||||
|
total_overhead_relevant_expense <- sum(overhead_relevant_expense$amount)
|
||||||
|
|
||||||
|
total <- total_income + total_expense
|
||||||
|
|
||||||
|
overview.income <- as_tibble(
|
||||||
|
data.frame(
|
||||||
|
"Kategorie" = c("Mieteinnahmen", "Betriebskostenvorauszahlungen", "Einnahmen ingesamt"),
|
||||||
|
"Betrag" = c(total_fee, total_overhead, total_income)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
overview.expense <- as_tibble(
|
||||||
|
data.frame(
|
||||||
|
"Kategorie" = c("Ausgaben insgesamt", "davon Betriebskostenausgaben"),
|
||||||
|
"Betrag" = c(-1 * total_expense, -1 * total_overhead_relevant_expense)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
overview.gain <- as_tibble(
|
||||||
|
data.frame(
|
||||||
|
"Überschuss" = c(total)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Einnahmen
|
||||||
|
```{r}
|
||||||
|
knitr::kable(overview.income)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ausgaben
|
||||||
|
```{r}
|
||||||
|
knitr::kable(overview.expense)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Überschuss
|
||||||
|
```{r}
|
||||||
|
knitr::kable(overview.gain)
|
||||||
|
```
|
BIN
r-scripts/hv2-analysis/income-expense-analysis.docx
Normal file
BIN
r-scripts/hv2-analysis/income-expense-analysis.docx
Normal file
Binary file not shown.
720
r-scripts/hv2-analysis/income-expense-analysis.html
Normal file
720
r-scripts/hv2-analysis/income-expense-analysis.html
Normal file
File diff suppressed because one or more lines are too long
BIN
r-scripts/hv2-analysis/income-expense-analysis.pdf
Normal file
BIN
r-scripts/hv2-analysis/income-expense-analysis.pdf
Normal file
Binary file not shown.
118
r-scripts/hv2-analysis/income.R
Normal file
118
r-scripts/hv2-analysis/income.R
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
library(tidyverse, warn.conflicts = FALSE)
|
||||||
|
library(DBI, warn.conflicts = FALSE)
|
||||||
|
library(tidyr, warn.conflicts = FALSE)
|
||||||
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
# library(lubridate, warn.conflicts = FALSE)
|
||||||
|
# library(R.utils, warn.conflicts = FALSE)
|
||||||
|
|
||||||
|
|
||||||
|
YEAR <- 2021
|
||||||
|
|
||||||
|
HOME <- Sys.getenv("HOME")
|
||||||
|
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||||
|
PGDATABASE = "hv2",
|
||||||
|
PGPORT = 5432,
|
||||||
|
PGUSER = "wn",
|
||||||
|
PGSSLMODE = "verify-ca",
|
||||||
|
PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""),
|
||||||
|
PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""),
|
||||||
|
PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep=""))
|
||||||
|
|
||||||
|
con <- dbConnect(RPostgres::Postgres())
|
||||||
|
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_t a,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.id = f.premise and
|
||||||
|
ty.flat = f.id and
|
||||||
|
ty.tenant = t.id and
|
||||||
|
a.id = t.account and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
ae.fiscal_year = $1 and
|
||||||
|
aec.description in ('Mietzahlung', 'Mietforderung', 'Betriebskostenforderung', 'Betriebskostenausgleich')
|
||||||
|
group by p.description,
|
||||||
|
f.description,
|
||||||
|
aec.description;
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
|
||||||
|
income <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
|
||||||
|
income <- income %>%
|
||||||
|
pivot_wider(names_from = category, values_from = amount) %>%
|
||||||
|
mutate(Miete := -1 * Mietforderung) %>%
|
||||||
|
mutate(Betriebskosten := Mietzahlung - Miete + Betriebskostenausgleich) %>%
|
||||||
|
select(flat, premise, Miete, Betriebskosten) %>%
|
||||||
|
arrange(premise, flat) %>%
|
||||||
|
mutate(across(where(is.numeric), ~num(., digits=2))) %>%
|
||||||
|
mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
|
||||||
|
|
||||||
|
total_fee <- sum(income$Miete)
|
||||||
|
total_overhead <- sum(income$Betriebskosten)
|
||||||
|
total_income <- total_fee + total_overhead
|
||||||
|
|
||||||
|
|
||||||
|
res <- dbSendQuery(con, "
|
||||||
|
select aec.overhead_relevant as overhead_relevant,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from account_entry_category_t aec,
|
||||||
|
account_entry_t ae
|
||||||
|
where aec.id = ae.account_entry_category and
|
||||||
|
aec.id not in (2, 3, 4, 29) and
|
||||||
|
ae.fiscal_year = $1
|
||||||
|
group by aec.overhead_relevant,
|
||||||
|
aec.description
|
||||||
|
")
|
||||||
|
dbBind(res, list(YEAR))
|
||||||
|
|
||||||
|
expense <- dbFetch(res)
|
||||||
|
dbClearResult(res)
|
||||||
|
|
||||||
|
expense <- expense %>%
|
||||||
|
arrange(overhead_relevant, category) #%>%
|
||||||
|
#mutate(across(where(is.numeric), ~num(., digits=2))) #%>%
|
||||||
|
#mutate(across(where(is.numeric), ~replace(., is.na(.), 0)))
|
||||||
|
|
||||||
|
total_expense <- sum(expense$amount)
|
||||||
|
|
||||||
|
overhead_relevant_expense <- expense %>%
|
||||||
|
filter(overhead_relevant == TRUE)
|
||||||
|
|
||||||
|
total_overhead_relevant_expense <- sum(overhead_relevant_expense$amount)
|
||||||
|
|
||||||
|
print("Einkuenfte pro Wohnung")
|
||||||
|
print(income)
|
||||||
|
|
||||||
|
print("Einkuenfte Miete")
|
||||||
|
print(total_fee)
|
||||||
|
print("Einkuenfte Betriebskosten")
|
||||||
|
print(total_overhead)
|
||||||
|
print("Einkuenfte Total")
|
||||||
|
print(total_income)
|
||||||
|
|
||||||
|
print("Ausgaben")
|
||||||
|
print(expense)
|
||||||
|
|
||||||
|
print(total_expense)
|
||||||
|
|
||||||
|
print("davon betriebskosten-relevant")
|
||||||
|
print(total_overhead_relevant_expense)
|
||||||
|
|
||||||
|
profit <- total_income + total_expense
|
||||||
|
print("Überschuss")
|
||||||
|
print(profit)
|
||||||
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Tools and Templates
|
## Tools and Templates
|
||||||
|
|
||||||
|
* venv for Python tools is used, remember to activate, install dependencies via ``requirements.txt``, keep it up to date using ``pip freeze > requirements.txt``
|
||||||
* all tools provide should work on Linux and on Windows, shell scripts are avoided
|
* all tools provide should work on Linux and on Windows, shell scripts are avoided
|
||||||
* templates files must be generated at development time, generated files must be put into the repository
|
* templates files must be generated at development time, generated files must be put into the repository
|
||||||
* use ``generate.py`` in the umbrella project's root without any arguments to generate all template files in all subdirectories using the ``schema.json`` from the umbrella project's root
|
* use ``generate.py`` in the umbrella project's root without any arguments to generate all template files in all subdirectories using the ``schema.json`` from the umbrella project's root
|
||||||
@ -14,3 +15,5 @@
|
|||||||
* make sure these configuration files are not added to the repository, they contain secrets
|
* make sure these configuration files are not added to the repository, they contain secrets
|
||||||
* in the development environment the API will answer at ``http://localhost:8080``, the Swagger-UI is available at ``http://localhost:8080/ui``
|
* in the development environment the API will answer at ``http://localhost:8080``, the Swagger-UI is available at ``http://localhost:8080/ui``
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Cheetah3==3.2.6.post1
|
13
schema.json
13
schema.json
@ -157,6 +157,19 @@
|
|||||||
{ "name": "tenant", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
{ "name": "tenant", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
||||||
{ "name": "note", "sqltype": "varchar(4096)", "notnull": true }
|
{ "name": "note", "sqltype": "varchar(4096)", "notnull": true }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contract",
|
||||||
|
"immutable": false,
|
||||||
|
"columns": [
|
||||||
|
{ "name": "supplier", "sqltype": "varchar(256)", "notnull": true, "selector": 0 },
|
||||||
|
{ "name": "content", "sqltype": "varchar(256)", "notnull": true, "selector": 1 },
|
||||||
|
{ "name": "identifier", "sqltype": "varchar(256)", "notnull": true },
|
||||||
|
{ "name": "notes", "sqltype": "varchar(4096)", "notnull": false }
|
||||||
|
],
|
||||||
|
"tableConstraints": [
|
||||||
|
"unique(supplier, content)"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -21,3 +21,72 @@ create or replace view account_statement_v as
|
|||||||
|
|
||||||
grant select on account_statement_v to hv2;
|
grant select on account_statement_v to hv2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
create or replace view income_v as
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
ae.amount as amount,
|
||||||
|
ty.id as tenancy_id,
|
||||||
|
t.lastname as tenant
|
||||||
|
|
||||||
|
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
|
||||||
|
where p.id = f.premise and
|
||||||
|
f.id = ty.flat and
|
||||||
|
t.id = ty.tenant and
|
||||||
|
ae.id = t.account and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
aec.description = 'Mietzahlung' and
|
||||||
|
ae.fiscal_year = 2021
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
select f.description as flat,
|
||||||
|
p.description as premise,
|
||||||
|
--ty.id as tenancy_id,
|
||||||
|
--t.lastname || ', ' || t.firstname as tenant,
|
||||||
|
--a.description as account,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from flat_t f,
|
||||||
|
premise_t p,
|
||||||
|
tenancy_t ty,
|
||||||
|
tenant_t t,
|
||||||
|
account_t a,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.id = f.premise and
|
||||||
|
ty.flat = f.id and
|
||||||
|
ty.tenant = t.id and
|
||||||
|
a.id = t.account and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.id = ae.account_entry_category and
|
||||||
|
ae.fiscal_year = 2021 and
|
||||||
|
aec.description in ('Mietzahlung', 'Mietforderung', 'Betriebskostenforderung')
|
||||||
|
|
||||||
|
group by p.description,
|
||||||
|
f.description,
|
||||||
|
aec.description
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
select aec.overhead_relevant as overhead_relevant,
|
||||||
|
aec.description as category,
|
||||||
|
sum(ae.amount) as amount
|
||||||
|
from account_entry_category_t aec,
|
||||||
|
account_entry_t ae
|
||||||
|
where aec.id = ae.account_entry_category and
|
||||||
|
aec.id not in (2, 3, 4, 29) and
|
||||||
|
ae.fiscal_year = 2021
|
||||||
|
group by aec.overhead_relevant,
|
||||||
|
aec.description
|
||||||
|
order by aec.overhead_relevant;
|
||||||
|
11
schema/changes-contract.sql
Normal file
11
schema/changes-contract.sql
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
CREATE TABLE contract_t (
|
||||||
|
id serial not null primary key
|
||||||
|
,supplier varchar(256) not null
|
||||||
|
,content varchar(256) not null
|
||||||
|
,identifier varchar(256) not null
|
||||||
|
,unique(supplier, content)
|
||||||
|
);
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE ON contract_t TO hv2;
|
||||||
|
GRANT SELECT, UPDATE ON contract_t_id_seq TO hv2;
|
@ -172,6 +172,18 @@ CREATE TABLE note_t (
|
|||||||
GRANT SELECT, INSERT ON note_t TO hv2;
|
GRANT SELECT, INSERT ON note_t TO hv2;
|
||||||
GRANT SELECT, UPDATE ON note_t_id_seq TO hv2;
|
GRANT SELECT, UPDATE ON note_t_id_seq TO hv2;
|
||||||
|
|
||||||
|
CREATE TABLE contract_t (
|
||||||
|
id serial not null primary key
|
||||||
|
,supplier varchar(256) not null
|
||||||
|
,content varchar(256) not null
|
||||||
|
,identifier varchar(256) not null
|
||||||
|
,notes varchar(4096)
|
||||||
|
,unique(supplier, content)
|
||||||
|
);
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE ON contract_t TO hv2;
|
||||||
|
GRANT SELECT, UPDATE ON contract_t_id_seq TO hv2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
17420
ui/hv2-ui/package-lock.json
generated
17420
ui/hv2-ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,6 @@
|
|||||||
"@types/jasmine": "~3.6.0",
|
"@types/jasmine": "~3.6.0",
|
||||||
"@types/node": "^12.11.1",
|
"@types/node": "^12.11.1",
|
||||||
"codelyzer": "^6.0.0",
|
"codelyzer": "^6.0.0",
|
||||||
"jasmine-core": "~3.6.0",
|
|
||||||
"jasmine-spec-reporter": "~5.0.0",
|
|
||||||
"karma": "~5.1.0",
|
"karma": "~5.1.0",
|
||||||
"karma-chrome-launcher": "~3.1.0",
|
"karma-chrome-launcher": "~3.1.0",
|
||||||
"karma-coverage": "~2.0.3",
|
"karma-coverage": "~2.0.3",
|
||||||
|
@ -20,11 +20,14 @@ import { FeeDetailsComponent } from './fee-details/fee-details.component';
|
|||||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||||
import { HomeComponent } from './home/home.component';
|
import { HomeComponent } from './home/home.component';
|
||||||
import { LedgerComponent } from './ledger/ledger.component';
|
import { LedgerComponent } from './ledger/ledger.component';
|
||||||
|
import { ContractComponent } from './contract/contract.component';
|
||||||
|
import { MyContractsComponent } from './my-contracts/my-contracts.component';
|
||||||
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: 'tenants', component: MyTenantsComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'tenants', component: MyTenantsComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'premises', component: MyPremisesComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'premises', component: MyPremisesComponent, canActivate: [ AuthGuardService ] },
|
||||||
|
{ path: 'contracts', component: MyContractsComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'flats', component: MyFlatsComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'flats', component: MyFlatsComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] },
|
||||||
@ -46,6 +49,8 @@ const routes: Routes = [
|
|||||||
{ path: 'fee', component: FeeDetailsComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'fee', component: FeeDetailsComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'enterPayment', component: EnterPaymentComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'enterPayment', component: EnterPaymentComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'ledger', component: LedgerComponent, canActivate: [ AuthGuardService ] },
|
{ path: 'ledger', component: LedgerComponent, canActivate: [ AuthGuardService ] },
|
||||||
|
{ path: 'contract', component: ContractComponent, canActivate: [ AuthGuardService ] },
|
||||||
|
{ path: 'contract/:id', component: ContractComponent, canActivate: [ AuthGuardService ] },
|
||||||
{ path: 'home', component: HomeComponent },
|
{ path: 'home', component: HomeComponent },
|
||||||
{ path: 'logout', component: LogoutComponent },
|
{ path: 'logout', component: LogoutComponent },
|
||||||
{ path: 'login', component: LoginComponent },
|
{ path: 'login', component: LoginComponent },
|
||||||
|
@ -51,6 +51,8 @@ import { HomeComponent } from './home/home.component';
|
|||||||
import { LedgerComponent } from './ledger/ledger.component';
|
import { LedgerComponent } from './ledger/ledger.component';
|
||||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||||
import { MatSortModule } from '@angular/material/sort';
|
import { MatSortModule } from '@angular/material/sort';
|
||||||
|
import { ContractComponent } from './contract/contract.component';
|
||||||
|
import { MyContractsComponent } from './my-contracts/my-contracts.component';
|
||||||
|
|
||||||
registerLocaleData(localeDe)
|
registerLocaleData(localeDe)
|
||||||
|
|
||||||
@ -81,7 +83,9 @@ registerLocaleData(localeDe)
|
|||||||
EnterPaymentComponent,
|
EnterPaymentComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
LedgerComponent,
|
LedgerComponent,
|
||||||
ErrorDialogComponent
|
ErrorDialogComponent,
|
||||||
|
ContractComponent,
|
||||||
|
MyContractsComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const serviceBaseUrl = "https://api.hv.nober.de";
|
// export const serviceBaseUrl = "https://api.hv.nober.de";
|
||||||
// export const serviceBaseUrl = "http://172.16.3.96:8080";
|
// export const serviceBaseUrl = "http://172.16.3.96:8080";
|
||||||
// export const serviceBaseUrl = "http://localhost:8080"
|
export const serviceBaseUrl = "http://localhost:8080"
|
||||||
export const authserviceBaseUrl = "https://authservice.hottis.de"
|
export const authserviceBaseUrl = "https://authservice.hottis.de"
|
||||||
export const applicationId = "hv2"
|
export const applicationId = "hv2"
|
||||||
|
4
ui/hv2-ui/src/app/contract/contract.component.css
Normal file
4
ui/hv2-ui/src/app/contract/contract.component.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
.notearea {
|
||||||
|
width: 75%;
|
||||||
|
}
|
46
ui/hv2-ui/src/app/contract/contract.component.html
Normal file
46
ui/hv2-ui/src/app/contract/contract.component.html
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<section class="mat-typography">
|
||||||
|
<mat-card class="defaultCard">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>
|
||||||
|
{{contract?.supplier}} {{contract?.content}}
|
||||||
|
</mat-card-title>
|
||||||
|
<mat-card-subtitle>
|
||||||
|
ID: {{contract?.id}}
|
||||||
|
</mat-card-subtitle>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<div>>
|
||||||
|
<form (ngSubmit)="saveContract()">
|
||||||
|
<div>
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Partner</mat-label>
|
||||||
|
<input matInput name="supplier" [(ngModel)]="contract.supplier"/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div><div>
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Gegenstand</mat-label>
|
||||||
|
<input matInput name="content" [(ngModel)]="contract.content"/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div><div>
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>ID</mat-label>
|
||||||
|
<input matInput name="identifier" [(ngModel)]="contract.identifier"/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div><div>
|
||||||
|
<mat-form-field appearance="outline" class="notearea">
|
||||||
|
<mat-label>Notizen</mat-label>
|
||||||
|
<textarea matInput
|
||||||
|
cdkTextareaAutosize
|
||||||
|
#autosize="cdkTextareaAutosize"
|
||||||
|
cdkAutosizeMinRows="5"
|
||||||
|
cdkAutosizeMaxRows="10"
|
||||||
|
name="notes" [(ngModel)]="contract.notes"></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</section>
|
25
ui/hv2-ui/src/app/contract/contract.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/contract/contract.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ContractComponent } from './contract.component';
|
||||||
|
|
||||||
|
describe('ContractComponent', () => {
|
||||||
|
let component: ContractComponent;
|
||||||
|
let fixture: ComponentFixture<ContractComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ ContractComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ContractComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
61
ui/hv2-ui/src/app/contract/contract.component.ts
Normal file
61
ui/hv2-ui/src/app/contract/contract.component.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { MatButton } from '@angular/material/button';
|
||||||
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { ContractService } from '../data-object-service';
|
||||||
|
import { Contract, NULL_CommercialPremise, NULL_Contract } from '../data-objects';
|
||||||
|
import { MessageService } from '../message.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-contract',
|
||||||
|
templateUrl: './contract.component.html',
|
||||||
|
styleUrls: ['./contract.component.css']
|
||||||
|
})
|
||||||
|
export class ContractComponent implements OnInit {
|
||||||
|
|
||||||
|
@ViewChild('submitButton') submitButton: MatButton
|
||||||
|
|
||||||
|
contract: Contract = NULL_Contract
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private contractService: ContractService,
|
||||||
|
private messageService: MessageService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router
|
||||||
|
) { }
|
||||||
|
|
||||||
|
async getContract(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const id = +this.route.snapshot.paramMap.get('id')
|
||||||
|
if (id != 0) {
|
||||||
|
this.contract = await this.contractService.getContract(id)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveContract() {
|
||||||
|
try {
|
||||||
|
this.submitButton.disabled = true
|
||||||
|
this.messageService.add(`saveContract: ${ JSON.stringify(this.contract, undefined, 4) }`)
|
||||||
|
if (this.contract.id == 0) {
|
||||||
|
this.messageService.add("about to insert new contract")
|
||||||
|
this.contract = await this.contractService.postContract(this.contract)
|
||||||
|
this.messageService.add(`Successfully added contract with id ${this.contract.id}`)
|
||||||
|
} else {
|
||||||
|
this.messageService.add("about to update existing contract")
|
||||||
|
this.contract = await this.contractService.putContract(this.contract)
|
||||||
|
this.messageService.add(`Successfully changed contract with id ${this.contract.id}`)
|
||||||
|
}
|
||||||
|
this.router.navigate(['/contracts'])
|
||||||
|
} finally {
|
||||||
|
this.submitButton.disabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.getContract()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -27,6 +27,7 @@ import { TenancyFeeMapping } from './data-objects';
|
|||||||
import { AccountEntryCategory } from './data-objects';
|
import { AccountEntryCategory } from './data-objects';
|
||||||
import { AccountEntry } from './data-objects';
|
import { AccountEntry } from './data-objects';
|
||||||
import { Note } from './data-objects';
|
import { Note } from './data-objects';
|
||||||
|
import { Contract } from './data-objects';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -519,4 +520,35 @@ export class NoteService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class ContractService {
|
||||||
|
constructor(private messageService: MessageService, private http: HttpClient) { }
|
||||||
|
|
||||||
|
async getContracts(): Promise<Contract[]> {
|
||||||
|
this.messageService.add(`ContractService: get data`);
|
||||||
|
return this.http.get<Contract[]>(`${serviceBaseUrl}/v1/contracts`).toPromise()
|
||||||
|
}
|
||||||
|
|
||||||
|
async getContract(id: number): Promise<Contract> {
|
||||||
|
this.messageService.add(`ContractService: get data for ${id}`);
|
||||||
|
return this.http.get<Contract>(`${serviceBaseUrl}/v1/contracts/${id}`).toPromise()
|
||||||
|
}
|
||||||
|
|
||||||
|
async postContract(item: Contract): Promise<Contract> {
|
||||||
|
let itemStr: string = JSON.stringify(item, undefined, 4)
|
||||||
|
this.messageService.add(`ContractService: post data for ${itemStr}`);
|
||||||
|
return this.http.post<Contract>(`${serviceBaseUrl}/v1/contracts`, item).toPromise()
|
||||||
|
}
|
||||||
|
|
||||||
|
async putContract(item: Contract): Promise<Contract> {
|
||||||
|
let itemStr: string = JSON.stringify(item, undefined, 4)
|
||||||
|
this.messageService.add(`ContractService: put data for ${itemStr}`)
|
||||||
|
let id: number = item["id"]
|
||||||
|
return this.http.put<Contract>(`${serviceBaseUrl}/v1/contracts/${id}`, item).toPromise()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,4 +226,19 @@ export const NULL_Note: Note = {
|
|||||||
,note: ''
|
,note: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Contract {
|
||||||
|
id: number
|
||||||
|
supplier: string
|
||||||
|
content: string
|
||||||
|
identifier: string
|
||||||
|
notes: string
|
||||||
|
}
|
||||||
|
export const NULL_Contract: Contract = {
|
||||||
|
id: 0
|
||||||
|
,supplier: ''
|
||||||
|
,content: ''
|
||||||
|
,identifier: ''
|
||||||
|
,notes: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
31
ui/hv2-ui/src/app/my-contracts/my-contracts.component.html
Normal file
31
ui/hv2-ui/src/app/my-contracts/my-contracts.component.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<section class="mat-typography">
|
||||||
|
<mat-card class="defaultCard">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>
|
||||||
|
<span>Meine Verträge</span>
|
||||||
|
<span class="spacer"></span>
|
||||||
|
<a mat-button routerLink="/contract">Neu anlegen</a>
|
||||||
|
</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<div>
|
||||||
|
<table mat-table [dataSource]="dataSource" #zftable>
|
||||||
|
<ng-container matColumnDef="supplier">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>Partner</th>
|
||||||
|
<td mat-cell *matCellDef="let element">{{element.supplier}}</td>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container matColumnDef="content">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>Gegenstand</th>
|
||||||
|
<td mat-cell *matCellDef="let element">{{element.content}}</td>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container matColumnDef="identifier">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>ID</th>
|
||||||
|
<td mat-cell *matCellDef="let element">{{element.identifier}}</td>
|
||||||
|
</ng-container>
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/contract/', row.id]"></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</section>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { MyContractsComponent } from './my-contracts.component';
|
||||||
|
|
||||||
|
describe('MyContractsComponent', () => {
|
||||||
|
let component: MyContractsComponent;
|
||||||
|
let fixture: ComponentFixture<MyContractsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ MyContractsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(MyContractsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
38
ui/hv2-ui/src/app/my-contracts/my-contracts.component.ts
Normal file
38
ui/hv2-ui/src/app/my-contracts/my-contracts.component.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { ContractService } from '../data-object-service';
|
||||||
|
import { Contract } from '../data-objects';
|
||||||
|
import { MessageService } from '../message.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-my-contracts',
|
||||||
|
templateUrl: './my-contracts.component.html',
|
||||||
|
styleUrls: ['./my-contracts.component.css']
|
||||||
|
})
|
||||||
|
export class MyContractsComponent implements OnInit {
|
||||||
|
|
||||||
|
contracts: Contract[]
|
||||||
|
dataSource: MatTableDataSource<Contract>
|
||||||
|
displayedColumns: string[] = [ "supplier", "content", "identifier" ]
|
||||||
|
|
||||||
|
constructor(private contractService: ContractService, private messageService: MessageService) { }
|
||||||
|
|
||||||
|
async getContracts(): Promise<void> {
|
||||||
|
try {
|
||||||
|
this.messageService.add("Trying to load contracts")
|
||||||
|
this.contracts = await this.contractService.getContracts();
|
||||||
|
this.messageService.add("Contracts loaded")
|
||||||
|
|
||||||
|
this.dataSource = new MatTableDataSource<Contract>(this.contracts)
|
||||||
|
} catch (err) {
|
||||||
|
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.messageService.add("MyContractsComponent.ngOnInit")
|
||||||
|
this.getContracts()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,8 @@
|
|||||||
<a mat-list-item href="/premises">Meine Häuser</a>
|
<a mat-list-item href="/premises">Meine Häuser</a>
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/ledger">Buchführung</a>
|
<a mat-list-item href="/ledger">Buchführung</a>
|
||||||
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
|
<a mat-list-item href="/contracts">Verträge</a>
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/logout">Abmelden</a>
|
<a mat-list-item href="/logout">Abmelden</a>
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
|
Reference in New Issue
Block a user