Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
05fb3c1677 | |||
cbc96036d9
|
|||
44202ef9ed
|
|||
34f8e8ecd4
|
|||
6f3248f03c
|
|||
3c97fb3582
|
|||
3ad019b374
|
|||
28e505f570
|
|||
ba63874a18
|
|||
0e1e03f1a9
|
|||
272500df8c
|
|||
0ab106d021
|
|||
125af5a206
|
|||
419997cea5
|
|||
797151d547
|
|||
2b883aee02
|
|||
8c4dbe7d71
|
|||
d297eb60b3
|
|||
5744e84842
|
|||
b8083ec41e
|
|||
f559aba317
|
|||
97dfcbe2fb
|
|||
76255efbe9
|
|||
797cbb4b65
|
|||
4a54190b00
|
|||
3977685915
|
|||
66283bb533
|
|||
966ad7aee8
|
|||
2ec6311ca9
|
|||
db089a9f2a
|
|||
a8296ee210
|
|||
e3236b671d
|
|||
457ba1bee5
|
|||
22db10a31e
|
|||
4f88ac5d0e
|
|||
3ae92c020c
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,7 @@ __pycache__/
|
||||
ENV
|
||||
api/config/dbconfig.ini
|
||||
api/config/authservice.pub
|
||||
cli/config/dbconfig.ini
|
||||
*~
|
||||
.*~
|
||||
|
||||
|
30
api/additional_components.yaml
Normal file
30
api/additional_components.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
# -------------------------------------------------------------------
|
||||
# ATTENTION: This file will not be parsed by Cheetah
|
||||
# Use plain openapi/yaml syntax, no Cheetah
|
||||
# escaping
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
tenant_with_saldo:
|
||||
description: tenant with saldo
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
salutation:
|
||||
type: string
|
||||
nullable: true
|
||||
firstname:
|
||||
type: string
|
||||
nullable: true
|
||||
lastname:
|
||||
type: string
|
||||
nullable: true
|
||||
address1:
|
||||
type: string
|
||||
nullable: true
|
||||
saldo:
|
||||
type: number
|
||||
nullable: true
|
||||
|
@ -72,4 +72,59 @@
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/tenants/saldo:
|
||||
get:
|
||||
tags: [ "tenant", "account" ]
|
||||
summary: Return tenant with saldo of the account
|
||||
operationId: additional_methods.get_tenant_with_saldo
|
||||
responses:
|
||||
'200':
|
||||
description: get_tenant_with_saldo
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/tenant_with_saldo'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/accounts/bydescription/{description}:
|
||||
get:
|
||||
tags: [ "account" ]
|
||||
summary: Return the normalized account with given description
|
||||
operationId: additional_methods.get_account_by_description
|
||||
parameters:
|
||||
- name: description
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: account response
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/account'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/uniquenumber:
|
||||
get:
|
||||
tags: [ "uniquenumber" ]
|
||||
summary: Returns a unique number
|
||||
operationId: additional_methods.get_unique_number
|
||||
responses:
|
||||
'200':
|
||||
description: get_unique_number
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
number:
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
|
||||
|
@ -31,4 +31,33 @@ def get_account_saldo(user, token_info, accountId=None):
|
||||
"statement": "SELECT sum(amount) as saldo FROM account_entry_t WHERE account=%s",
|
||||
"params": (accountId, )
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def get_tenant_with_saldo(user, token_info):
|
||||
return dbGetMany(user, token_info, {
|
||||
"statement": """
|
||||
SELECT t.id, t.firstname, t.lastname, t.address1, sum(a.amount) AS saldo
|
||||
FROM tenant_t t LEFT OUTER JOIN account_entry_t a ON a.account = t.account
|
||||
GROUP BY t.id, t.firstname, t.lastname, t.address1
|
||||
""",
|
||||
"params": ()
|
||||
}
|
||||
)
|
||||
|
||||
def get_account_by_description(user, token_info, description=None):
|
||||
return dbGetOne(user, token_info, {
|
||||
"statement": """
|
||||
SELECT a.id ,a.description
|
||||
FROM account_t a
|
||||
WHERE a.description = %s""",
|
||||
"params": (description, )
|
||||
}
|
||||
)
|
||||
|
||||
def get_unique_number(user, token_info):
|
||||
return dbGetOne(user, token_info, {
|
||||
"statement": """
|
||||
SELECT nextval('unique_number_s') AS "number"
|
||||
""",
|
||||
"params": ()
|
||||
})
|
||||
|
@ -283,6 +283,7 @@ SELECT
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,account
|
||||
FROM premise_t
|
||||
ORDER BY
|
||||
description
|
||||
@ -298,6 +299,7 @@ def insert_premise(user, token_info, **args):
|
||||
v_street = body["street"]
|
||||
v_zip = body["zip"]
|
||||
v_city = body["city"]
|
||||
v_account = body["account"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
INSERT INTO premise_t
|
||||
@ -306,11 +308,13 @@ INSERT INTO premise_t
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,account
|
||||
) VALUES (
|
||||
%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
@ -319,6 +323,7 @@ INSERT INTO premise_t
|
||||
,v_street
|
||||
,v_zip
|
||||
,v_city
|
||||
,v_account
|
||||
]
|
||||
})
|
||||
except KeyError as e:
|
||||
@ -335,6 +340,7 @@ SELECT
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,account
|
||||
FROM premise_t
|
||||
WHERE id = %s
|
||||
""",
|
||||
@ -373,6 +379,23 @@ UPDATE premise_t
|
||||
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
||||
|
||||
|
||||
def get_premise_by_account(user, token_info, accountId=None):
|
||||
return dbGetMany(user, token_info, {
|
||||
"statement": """
|
||||
SELECT
|
||||
id
|
||||
,description
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,account
|
||||
FROM premise_t
|
||||
WHERE account = %s
|
||||
""",
|
||||
"params": (accountId, )
|
||||
}
|
||||
)
|
||||
|
||||
def get_flats(user, token_info):
|
||||
return dbGetMany(user, token_info, {
|
||||
"statement": """
|
||||
@ -1301,6 +1324,7 @@ SELECT
|
||||
,account
|
||||
,created_at
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
ORDER BY
|
||||
@ -1317,6 +1341,7 @@ def insert_account_entry(user, token_info, **args):
|
||||
v_account = body["account"]
|
||||
v_created_at = body["created_at"]
|
||||
v_amount = body["amount"]
|
||||
v_document_no = body["document_no"]
|
||||
v_account_entry_category = body["account_entry_category"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
@ -1326,6 +1351,7 @@ INSERT INTO account_entry_t
|
||||
,account
|
||||
,created_at
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
) VALUES (
|
||||
%s
|
||||
@ -1333,6 +1359,7 @@ INSERT INTO account_entry_t
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
@ -1341,6 +1368,7 @@ INSERT INTO account_entry_t
|
||||
,v_account
|
||||
,v_created_at
|
||||
,v_amount
|
||||
,v_document_no
|
||||
,v_account_entry_category
|
||||
]
|
||||
})
|
||||
@ -1358,6 +1386,7 @@ SELECT
|
||||
,account
|
||||
,created_at
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
WHERE id = %s
|
||||
@ -1377,6 +1406,7 @@ SELECT
|
||||
,account
|
||||
,created_at
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
WHERE account = %s
|
||||
@ -1394,6 +1424,7 @@ SELECT
|
||||
,account
|
||||
,created_at
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
WHERE account_entry_category = %s
|
||||
|
113
api/openapi.yaml
113
api/openapi.yaml
@ -299,6 +299,28 @@ paths:
|
||||
$ref: '#/components/schemas/premise'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/premises/account/{accountId}:
|
||||
get:
|
||||
tags: [ "premise", "account" ]
|
||||
summary: Return premise by $account
|
||||
operationId: methods.get_premise_by_account
|
||||
parameters:
|
||||
- name: accountId
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
description: premise response
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/premise'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/flats:
|
||||
get:
|
||||
tags: [ "flat" ]
|
||||
@ -1493,6 +1515,61 @@ paths:
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/tenants/saldo:
|
||||
get:
|
||||
tags: [ "tenant", "account" ]
|
||||
summary: Return tenant with saldo of the account
|
||||
operationId: additional_methods.get_tenant_with_saldo
|
||||
responses:
|
||||
'200':
|
||||
description: get_tenant_with_saldo
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/tenant_with_saldo'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/accounts/bydescription/{description}:
|
||||
get:
|
||||
tags: [ "account" ]
|
||||
summary: Return the normalized account with given description
|
||||
operationId: additional_methods.get_account_by_description
|
||||
parameters:
|
||||
- name: description
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: account response
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/account'
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
/v1/uniquenumber:
|
||||
get:
|
||||
tags: [ "uniquenumber" ]
|
||||
summary: Returns a unique number
|
||||
operationId: additional_methods.get_unique_number
|
||||
responses:
|
||||
'200':
|
||||
description: get_unique_number
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
number:
|
||||
type: number
|
||||
security:
|
||||
- jwt: ['secret']
|
||||
|
||||
|
||||
components:
|
||||
@ -1567,6 +1644,8 @@ components:
|
||||
type: string
|
||||
city:
|
||||
type: string
|
||||
account:
|
||||
type: integer
|
||||
flat:
|
||||
description: flat
|
||||
type: object
|
||||
@ -1713,6 +1792,9 @@ components:
|
||||
type: string
|
||||
amount:
|
||||
type: number
|
||||
document_no:
|
||||
type: integer
|
||||
nullable: true
|
||||
account_entry_category:
|
||||
type: integer
|
||||
note:
|
||||
@ -1727,3 +1809,34 @@ components:
|
||||
type: integer
|
||||
note:
|
||||
type: string
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# ATTENTION: This file will not be parsed by Cheetah
|
||||
# Use plain openapi/yaml syntax, no Cheetah
|
||||
# escaping
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
tenant_with_saldo:
|
||||
description: tenant with saldo
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
salutation:
|
||||
type: string
|
||||
nullable: true
|
||||
firstname:
|
||||
type: string
|
||||
nullable: true
|
||||
lastname:
|
||||
type: string
|
||||
nullable: true
|
||||
address1:
|
||||
type: string
|
||||
nullable: true
|
||||
saldo:
|
||||
type: number
|
||||
nullable: true
|
||||
|
@ -156,3 +156,5 @@ components:
|
||||
#end if
|
||||
#end for
|
||||
#end for
|
||||
|
||||
#include raw "./api/additional_components.yaml"
|
||||
|
126
cli/ConsistencyCheck.py
Normal file
126
cli/ConsistencyCheck.py
Normal file
@ -0,0 +1,126 @@
|
||||
from db import dbGetMany
|
||||
from loguru import logger
|
||||
|
||||
errorCnt = 0
|
||||
|
||||
def perform(dbh, params):
|
||||
global errorCnt
|
||||
checkTenant(dbh, params)
|
||||
checkFlats(dbh, params)
|
||||
checkParkings(dbh, params)
|
||||
checkCommercialPremise(dbh, params)
|
||||
|
||||
if (errorCnt > 0):
|
||||
logger.error(f"Total error count: {errorCnt}")
|
||||
|
||||
def checkTenant(dbh, params):
|
||||
global errorCnt
|
||||
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
||||
for tenant in tenants:
|
||||
outPre = f"Tenant: {tenant['firstname']} {tenant['lastname']}"
|
||||
logger.info(outPre)
|
||||
|
||||
# check tenancies
|
||||
tenancyCnt = 0
|
||||
flatTenancyCnt = 0
|
||||
tenancies = dbGetMany(dbh, {
|
||||
"statement": "SELECT * FROM tenancy_t WHERE tenant = %s AND startdate < now() AND (enddate > now() or enddate is null)",
|
||||
"params": (tenant['id'], )
|
||||
}
|
||||
)
|
||||
for tenancy in tenancies:
|
||||
tenancyCnt += 1
|
||||
if (tenancy['flat']):
|
||||
flatTenancyCnt += 1
|
||||
logger.info(f"{outPre}: Flat tenancy: {tenancy['id']}, start: {tenancy['startdate']}, end: {tenancy['enddate']}")
|
||||
if (tenancy['parking']):
|
||||
logger.info(f"{outPre}: Garage tenancy: {tenancy['id']}, start: {tenancy['startdate']}, end: {tenancy['enddate']}")
|
||||
if (tenancy['commercial_premise']):
|
||||
logger.info(f"{outPre}: Commercial premise tenancy: {tenancy['id']}, start: {tenancy['startdate']}, end: {tenancy['enddate']}")
|
||||
|
||||
if (flatTenancyCnt == 0):
|
||||
logger.warning(f"{outPre}: no flat tenancy")
|
||||
if (flatTenancyCnt > 1):
|
||||
logger.warning(f"{outPre}: more than one flat tenancy ({flatTenancyCnt})")
|
||||
if (tenancyCnt == 0):
|
||||
logger.error(f"{outPre}: no tenancy at all")
|
||||
errorCnt += 1
|
||||
noCurrentTenancies = dbGetMany(dbh, {
|
||||
"statement": "SELECT * FROM tenancy_t WHERE tenant = %s",
|
||||
"params": (tenant['id'], )
|
||||
}
|
||||
)
|
||||
for noCurrentTenancy in noCurrentTenancies:
|
||||
logger.error(f"{outPre}: but: flat {noCurrentTenancy['flat']}, parking: {noCurrentTenancy['parking']}, commercial premise: {noCurrentTenancy['commercial_premise']}, start: {noCurrentTenancy['startdate']}, end: {noCurrentTenancy['enddate']}")
|
||||
|
||||
def _checkRentals(dbh, params, rentalType):
|
||||
global errorCnt
|
||||
table = f"{rentalType}_t"
|
||||
rentals = dbGetMany(dbh, {
|
||||
"statement": f"SELECT * FROM {table}",
|
||||
"params": ()
|
||||
}
|
||||
)
|
||||
for rental in rentals:
|
||||
outPre = f"{rentalType}: {rental['description']}, premise: {rental['premise']}"
|
||||
logger.info(outPre)
|
||||
|
||||
if (rentalType == 'flat'):
|
||||
overheadMappingCnt = 0
|
||||
overheadMappings = dbGetMany(dbh, {
|
||||
"statement": "SELECT * FROM overhead_advance_flat_mapping_t WHERE flat = %s",
|
||||
"params": (rental['id'], )
|
||||
}
|
||||
)
|
||||
for overheadMapping in overheadMappings:
|
||||
overheadMappingCnt += 1
|
||||
logger.info(f"{outPre}: overhead mapping: {overheadMapping['id']}")
|
||||
if (overheadMappingCnt == 0):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: no overhead mapping available")
|
||||
if (overheadMappingCnt > 1):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: more than one overhead mapping available")
|
||||
|
||||
tenancyCnt = 0
|
||||
tenancies = dbGetMany(dbh, {
|
||||
"statement": f"SELECT * FROM tenancy_t WHERE {rentalType} = %s AND startdate < now() AND (enddate > now() or enddate is null)",
|
||||
"params": (rental['id'], )
|
||||
}
|
||||
)
|
||||
for tenancy in tenancies:
|
||||
tenancyCnt += 1
|
||||
logger.info(f"{outPre}: tenant: {tenancy['tenant']}, start: {tenancy['startdate']}, end: {tenancy['enddate']}")
|
||||
|
||||
feeMappingCnt = 0
|
||||
feeMappings = dbGetMany(dbh, {
|
||||
"statement": "SELECT * FROM tenancy_fee_mapping_t where tenancy = %s",
|
||||
"params": (tenancy['id'], )
|
||||
}
|
||||
)
|
||||
for feeMapping in feeMappings:
|
||||
feeMappingCnt += 1
|
||||
logger.info(f"{outPre}: fee mapping: {feeMapping['id']}")
|
||||
if (feeMappingCnt == 0):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: no fee mapping available")
|
||||
if (feeMappingCnt > 1):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: more than one fee mapping available")
|
||||
|
||||
if (tenancyCnt == 0):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: vacant")
|
||||
if (tenancyCnt > 1):
|
||||
errorCnt += 1
|
||||
logger.error(f"{outPre}: overbooked")
|
||||
|
||||
|
||||
def checkFlats(dbh, params):
|
||||
_checkRentals(dbh, params, "flat")
|
||||
|
||||
def checkParkings(dbh, params):
|
||||
_checkRentals(dbh, params, "parking")
|
||||
|
||||
def checkCommercialPremise(dbh, params):
|
||||
_checkRentals(dbh, params, "commercial_premise")
|
109
cli/MonthlyPaymentRequests.py
Normal file
109
cli/MonthlyPaymentRequests.py
Normal file
@ -0,0 +1,109 @@
|
||||
from db import dbGetMany, dbGetOne
|
||||
from loguru import logger
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
|
||||
def perform(dbh, params):
|
||||
try:
|
||||
createdAt = params['created_at']
|
||||
except KeyError:
|
||||
createdAt = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||
|
||||
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
||||
for tenant in tenants:
|
||||
logger.info(f"Tenant: {tenant['firstname']} {tenant['lastname']}")
|
||||
|
||||
# check tenancies
|
||||
tenancies = dbGetMany(dbh, {
|
||||
"statement": "SELECT * FROM tenancy_t WHERE tenant = %s AND startdate < now() AND (enddate > now() or enddate is null)",
|
||||
"params": (tenant['id'], )
|
||||
}
|
||||
)
|
||||
requests = []
|
||||
for tenancy in tenancies:
|
||||
fee = dbGetOne(dbh, {
|
||||
"statement": """
|
||||
SELECT f.amount, f.fee_type
|
||||
FROM fee_t f, tenancy_fee_mapping_t t
|
||||
WHERE t.tenancy = %s AND
|
||||
f.id = t.fee AND
|
||||
f.startdate < now() AND
|
||||
(f.enddate > now() OR f.enddate is null)
|
||||
""",
|
||||
"params": (tenancy['id'], )
|
||||
}
|
||||
)
|
||||
if (tenancy['flat']):
|
||||
logger.debug(f" Flat tenancy: {tenancy['id']}, Fee: {fee['amount']}, Fee_Type: {fee['fee_type']}")
|
||||
flat = dbGetOne(dbh, { "statement": "SELECT area FROM flat_t WHERE id = %s", "params": (tenancy['flat'], ) })
|
||||
logger.debug(f" Area: {flat['area']}")
|
||||
if (fee['fee_type'] == 'per_area'):
|
||||
feeRequest = flat['area'] * fee['amount']
|
||||
else:
|
||||
feeRequest = fee['amount']
|
||||
feeRequest = feeRequest.quantize(Decimal('1.00'))
|
||||
requests.append({
|
||||
'description': f"Miete {tenancy['description']}",
|
||||
'account': tenant['account'],
|
||||
'created_at': createdAt,
|
||||
'amount': feeRequest,
|
||||
'category': 'Mietforderung'
|
||||
})
|
||||
overheadAdvance = dbGetOne(dbh, {
|
||||
"statement": """
|
||||
SELECT o.amount
|
||||
FROM overhead_advance_t o, overhead_advance_flat_mapping_t m
|
||||
WHERE m.flat = %s AND
|
||||
o.id = m.overhead_advance AND
|
||||
o.startdate < now() AND
|
||||
(o.enddate > now() OR o.enddate is null)
|
||||
""",
|
||||
"params": (tenancy['flat'], )
|
||||
}
|
||||
)
|
||||
overheadAdvanceRequest = flat['area'] * overheadAdvance['amount']
|
||||
overheadAdvanceRequest = overheadAdvanceRequest.quantize(Decimal('1.00'))
|
||||
requests.append({
|
||||
'description': f"Betriebskosten {tenancy['description']}",
|
||||
'account': tenant['account'],
|
||||
'created_at': createdAt,
|
||||
'amount': overheadAdvanceRequest,
|
||||
'category': 'Betriebskostenforderung'
|
||||
})
|
||||
if (tenancy['parking']):
|
||||
logger.debug(f" Garage tenancy: {tenancy['id']}, Fee: {fee['amount']}, Fee_Type: {fee['fee_type']}")
|
||||
feeRequest = fee['amount']
|
||||
feeRequest = feeRequest.quantize(Decimal('1.00'))
|
||||
requests.append({
|
||||
'description': f"Miete {tenancy['description']}",
|
||||
'account': tenant['account'],
|
||||
'created_at': createdAt,
|
||||
'amount': feeRequest,
|
||||
'category': 'Mietforderung'
|
||||
})
|
||||
if (tenancy['commercial_premise']):
|
||||
logger.debug(f" Commercial premise tenancy: {tenancy['id']}, Fee: {fee['amount']}, Fee_Type: {fee['fee_type']}")
|
||||
feeRequest = fee['amount']
|
||||
feeRequest = feeRequest.quantize(Decimal('1.00'))
|
||||
requests.append({
|
||||
'description': f"Miete {tenancy['description']}",
|
||||
'account': tenant['account'],
|
||||
'created_at': createdAt,
|
||||
'amount': feeRequest,
|
||||
'category': 'Mietforderung'
|
||||
})
|
||||
|
||||
for request in requests:
|
||||
request['amount'] = Decimal('-1.0') * request['amount']
|
||||
logger.info(f" {request['description']}, {request['account']}, {request['created_at']}, {request['amount']}, {request['category']}")
|
||||
accountEntry = dbGetOne(dbh, {
|
||||
"statement": """
|
||||
INSERT INTO account_entry_t
|
||||
(description, account, created_at, amount, account_entry_category)
|
||||
VALUES (%s, %s, %s, %s, (SELECT id FROM account_entry_category_t WHERE description = %s))
|
||||
RETURNING id
|
||||
""",
|
||||
"params": (request['description'], request['account'], request['created_at'], request['amount'], request['category'])
|
||||
}
|
||||
)
|
||||
logger.info(f" account entry entered with id {accountEntry['id']}")
|
46
cli/db.py
Normal file
46
cli/db.py
Normal file
@ -0,0 +1,46 @@
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
from loguru import logger
|
||||
|
||||
|
||||
class NoDataFoundException(Exception): pass
|
||||
|
||||
class TooMuchDataFoundException(Exception): pass
|
||||
|
||||
|
||||
def execDatabaseOperation(dbh, func, params):
|
||||
cur = None
|
||||
try:
|
||||
with dbh.cursor(cursor_factory = psycopg2.extras.RealDictCursor) as cur:
|
||||
params["params"] = [ v if not v=='' else None for v in params["params"] ]
|
||||
logger.debug("edo: {}".format(str(params)))
|
||||
return func(cur, params)
|
||||
except psycopg2.Error as err:
|
||||
raise Exception("Error when working on cursor: {}".format(err))
|
||||
|
||||
|
||||
|
||||
def _opGetMany(cursor, params):
|
||||
items = []
|
||||
cursor.execute(params["statement"], params["params"])
|
||||
for itemObj in cursor:
|
||||
logger.debug("item received {}".format(str(itemObj)))
|
||||
items.append(itemObj)
|
||||
return items
|
||||
|
||||
def dbGetMany(dbh, params):
|
||||
return execDatabaseOperation(dbh, _opGetMany, params)
|
||||
|
||||
def _opGetOne(cursor, params):
|
||||
cursor.execute(params["statement"], params["params"])
|
||||
itemObj = cursor.fetchone()
|
||||
logger.debug(f"item received: {itemObj}")
|
||||
if not itemObj:
|
||||
raise NoDataFoundException
|
||||
dummyObj = cursor.fetchone()
|
||||
if dummyObj:
|
||||
raise TooMuchDataFoundException
|
||||
return itemObj
|
||||
|
||||
def dbGetOne(dbh, params):
|
||||
return execDatabaseOperation(dbh, _opGetOne, params)
|
77
cli/hv2cli.py
Normal file
77
cli/hv2cli.py
Normal file
@ -0,0 +1,77 @@
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
from loguru import logger
|
||||
import os
|
||||
import configparser
|
||||
import json
|
||||
import argparse
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
DB_USER = ""
|
||||
DB_PASS = ""
|
||||
DB_HOST = ""
|
||||
DB_NAME = ""
|
||||
try:
|
||||
DB_USER = os.environ["DB_USER"]
|
||||
DB_PASS = os.environ["DB_PASS"]
|
||||
DB_HOST = os.environ["DB_HOST"]
|
||||
DB_NAME = os.environ["DB_NAME"]
|
||||
except KeyError:
|
||||
config = configparser.ConfigParser()
|
||||
config.read('./config/dbconfig.ini')
|
||||
DB_USER = config["database"]["user"]
|
||||
DB_PASS = config["database"]["pass"]
|
||||
DB_HOST = config["database"]["host"]
|
||||
DB_NAME = config["database"]["name"]
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="hv2cli.py")
|
||||
parser.add_argument('--operation', '-o',
|
||||
help='Operation to perform.',
|
||||
required=True)
|
||||
parser.add_argument('--params', '-p',
|
||||
help='JSON string with parameter for the selected operation, default: {}',
|
||||
required=False,
|
||||
default="{}")
|
||||
parser.add_argument('--verbosity', '-v',
|
||||
help='Minimal log level for output: DEBUG, INFO, WARNING, ..., default: DEBUG',
|
||||
required=False,
|
||||
default="DEBUG")
|
||||
parser.add_argument('--nocolorize', '-n',
|
||||
help='disable colored output (for cron)',
|
||||
required=False,
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
operation = args.operation
|
||||
params = json.loads(args.params)
|
||||
logLevel = args.verbosity
|
||||
noColorize = args.nocolorize
|
||||
|
||||
|
||||
logger.remove()
|
||||
logger.add(sys.stderr, colorize=(not noColorize), level=logLevel)
|
||||
|
||||
|
||||
dbh = None
|
||||
try:
|
||||
opMod = importlib.import_module(operation)
|
||||
|
||||
dbh = psycopg2.connect(user = DB_USER, password = DB_PASS,
|
||||
host = DB_HOST, database = DB_NAME,
|
||||
sslmode = 'require')
|
||||
dbh.autocommit = False
|
||||
|
||||
with dbh:
|
||||
opMod.perform(dbh, params)
|
||||
except psycopg2.Error as err:
|
||||
raise Exception("Error when working on the database: {}".format(err))
|
||||
except Exception as err:
|
||||
raise err
|
||||
finally:
|
||||
if dbh:
|
||||
dbh.close()
|
||||
|
||||
|
5
cli/listTenants.py
Normal file
5
cli/listTenants.py
Normal file
@ -0,0 +1,5 @@
|
||||
from db import dbGetMany
|
||||
|
||||
def perform(dbh, params):
|
||||
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
||||
print(tenants)
|
@ -32,7 +32,8 @@
|
||||
{ "name": "description", "sqltype": "varchar(128)", "selector": 0, "unique": true },
|
||||
{ "name": "street", "sqltype": "varchar(128)", "notnull": true },
|
||||
{ "name": "zip", "sqltype": "varchar(10)", "notnull": true },
|
||||
{ "name": "city", "sqltype": "varchar(128)", "notnull": true }
|
||||
{ "name": "city", "sqltype": "varchar(128)", "notnull": true },
|
||||
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true, "immutable": true, "unique": true }
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -133,10 +134,11 @@
|
||||
"name": "account_entry",
|
||||
"immutable": true,
|
||||
"columns": [
|
||||
{ "name": "description", "sqltype": "varchar(128)", "notnull": true },
|
||||
{ "name": "description", "sqltype": "varchar(1024)", "notnull": true },
|
||||
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
||||
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()" },
|
||||
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true, "selector": 0 },
|
||||
{ "name": "document_no", "sqltype": "integer", "unique": true },
|
||||
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
|
||||
],
|
||||
"tableConstraints": [
|
||||
|
6
schema/changes01.sql
Normal file
6
schema/changes01.sql
Normal file
@ -0,0 +1,6 @@
|
||||
alter table premise_t add column account integer;
|
||||
alter table premise_t add constraint fk_premise_t_account foreign key (account) references account_t(id);
|
||||
alter table premise_t add constraint uk_premise_t_account unique(account);
|
||||
alter table account_entry_t add column document_no integer unique;
|
||||
create sequence unique_number_s start with 1 increment by 1;
|
||||
|
@ -39,6 +39,7 @@ CREATE TABLE premise_t (
|
||||
,street varchar(128) not null
|
||||
,zip varchar(10) not null
|
||||
,city varchar(128) not null
|
||||
,account integer not null references account_t (id) unique
|
||||
);
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE ON premise_t TO hv2;
|
||||
@ -145,10 +146,11 @@ GRANT SELECT, UPDATE ON account_entry_category_t_id_seq TO hv2;
|
||||
|
||||
CREATE TABLE account_entry_t (
|
||||
id serial not null primary key
|
||||
,description varchar(128) not null
|
||||
,description varchar(1024) not null
|
||||
,account integer not null references account_t (id)
|
||||
,created_at timestamp not null default now()
|
||||
,amount numeric(10,2) not null
|
||||
,document_no integer unique
|
||||
,account_entry_category integer not null references account_entry_category_t (id)
|
||||
,unique(description, account, created_at)
|
||||
);
|
||||
|
@ -3,6 +3,10 @@ table {
|
||||
border-spacing: 20px;
|
||||
}
|
||||
|
||||
.mat-table {
|
||||
border-spacing: 20px;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
@ -1,76 +1,58 @@
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{account?.description}} ({{account?.id}})
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapse = true"
|
||||
(closed)="collapse = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title *ngIf="!collapse">
|
||||
Kontoübersicht, Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<div id="firstBlock">
|
||||
<form (ngSubmit)="addAccountEntry()">
|
||||
<mat-form-field appearance="outline" id="addEntryfield">
|
||||
<mat-label>Datum</mat-label>
|
||||
<input matInput name="createdAt" [(ngModel)]="newAccountEntry.created_at" [matDatepicker]="createdAtPicker"/>
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select [(ngModel)]="newAccountEntry.account_entry_category" name="category" disabled="shallBeRentPayment">
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" [(ngModel)]="newAccountEntry.amount"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="newAccountEntry.description"/>
|
||||
</mat-form-field>
|
||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="large">
|
||||
Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
</div>
|
||||
<div id="secondBlock">
|
||||
<table mat-table [dataSource]="accountEntriesDataSource" #zftable>
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="description">
|
||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="category">
|
||||
<th mat-header-cell *matHeaderCellDef>Kategorie</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.accountEntryCategory}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="overhead_relevant">
|
||||
<th mat-header-cell *matHeaderCellDef>BK relevant</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.overheadRelevant}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="accountEntriesDisplayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: accountEntriesDisplayedColumns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<div id="firstBlock">
|
||||
<form (ngSubmit)="addAccountEntry(accountEntryForm)" #accountEntryForm="ngForm">
|
||||
<mat-form-field appearance="outline" id="addEntryfield">
|
||||
<mat-label>Datum</mat-label>
|
||||
<input matInput ngModel name="createdAt" [matDatepicker]="createdAtPicker"/>
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" ngModel/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [disabled]="shallBeRentPayment" ngModel/>
|
||||
</mat-form-field>
|
||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="large">
|
||||
Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
</div>
|
||||
<div id="secondBlock">
|
||||
<table mat-table [dataSource]="accountEntriesDataSource" #zftable>
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="description">
|
||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="document_no">
|
||||
<th mat-header-cell *matHeaderCellDef>Belegnummer</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.document_no}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="category">
|
||||
<th mat-header-cell *matHeaderCellDef>Kategorie</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.accountEntryCategory}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="overhead_relevant">
|
||||
<th mat-header-cell *matHeaderCellDef>BK relevant</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.overheadRelevant}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="accountEntriesDisplayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: accountEntriesDisplayedColumns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -1,10 +1,13 @@
|
||||
import { ViewFlags } from '@angular/compiler/src/core';
|
||||
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { AccountEntryCategoryService, AccountEntryService, AccountService } from '../data-object-service';
|
||||
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
|
||||
import { ErrorDialogService } from '../error-dialog.service';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { Saldo } from '../ext-data-objects';
|
||||
import { Saldo, UniqueNumber } from '../ext-data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
|
||||
@ -27,19 +30,16 @@ export class AccountComponent implements OnInit {
|
||||
@Input() shallBeRentPayment: boolean
|
||||
@ViewChild('addAccountEntryButton') addAccountEntryButton: MatButton
|
||||
|
||||
collapse: boolean = false
|
||||
|
||||
account: Account
|
||||
accountEntries: DN_AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt", "category", "overhead_relevant" ]
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "category", "overhead_relevant" ]
|
||||
saldo: Saldo
|
||||
|
||||
accountEntryCategories: AccountEntryCategory[]
|
||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
|
||||
|
||||
constructor(
|
||||
@ -47,9 +47,11 @@ export class AccountComponent implements OnInit {
|
||||
private accountEntryService: AccountEntryService,
|
||||
private extApiService: ExtApiService,
|
||||
private accountEntryCategoryService: AccountEntryCategoryService,
|
||||
private messageService: MessageService
|
||||
private messageService: MessageService,
|
||||
private errorDialogService: ErrorDialogService
|
||||
) { }
|
||||
|
||||
|
||||
async getAccount(): Promise<void> {
|
||||
try {
|
||||
if (this.selectedAccountId) {
|
||||
@ -86,20 +88,43 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async addAccountEntry(): Promise<void> {
|
||||
try {
|
||||
this.addAccountEntryButton.disabled = true
|
||||
this.newAccountEntry.account = this.account.id
|
||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(this.newAccountEntry, undefined, 4) }`)
|
||||
this.newAccountEntry = await this.accountEntryService.postAccountEntry(this.newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${this.newAccountEntry.id}`)
|
||||
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0, 'account_entry_category': 0 }
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
} finally {
|
||||
this.addAccountEntryButton.disabled = false
|
||||
async addAccountEntry(formData: any): Promise<void> {
|
||||
try {
|
||||
this.addAccountEntryButton.disabled = true
|
||||
this.messageService.add(`${JSON.stringify(formData.value, undefined, 4)}`)
|
||||
let uniquenumber: UniqueNumber = await this.extApiService.getUniqueNumber();
|
||||
this.messageService.add(`Got unique number as document_no: ${uniquenumber.number}`)
|
||||
let newAccountEntry: AccountEntry = {
|
||||
description: formData.value.description,
|
||||
account: this.account.id,
|
||||
created_at: formData.value.createdAt,
|
||||
amount: formData.value.amount,
|
||||
id: 0,
|
||||
document_no: uniquenumber.number,
|
||||
account_entry_category: 0
|
||||
}
|
||||
|
||||
if (this.shallBeRentPayment) {
|
||||
newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||
newAccountEntry.description = "Miete"
|
||||
this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`)
|
||||
} else {
|
||||
newAccountEntry.account_entry_category = formData.value.category
|
||||
this.messageService.add(`category is ${newAccountEntry.account_entry_category}`)
|
||||
}
|
||||
|
||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(newAccountEntry, undefined, 4) }`)
|
||||
newAccountEntry = await this.accountEntryService.postAccountEntry(newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${newAccountEntry.id}`)
|
||||
|
||||
formData.reset()
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
this.errorDialogService.openDialog('AccountComponent', 'addAccountEntry', JSON.stringify(err, undefined, 4))
|
||||
} finally {
|
||||
this.addAccountEntryButton.disabled = false
|
||||
}
|
||||
}
|
||||
|
||||
async getAccountEntryCategories(): Promise<void> {
|
||||
@ -122,10 +147,6 @@ export class AccountComponent implements OnInit {
|
||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
await this.getAccountEntryCategories()
|
||||
if (this.shallBeRentPayment) {
|
||||
this.messageService.add('shall be rentpayment')
|
||||
this.newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -136,4 +157,5 @@ export class AccountComponent implements OnInit {
|
||||
this.init()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ import { OverheadAdvanceListComponent } from './overhead-advance-list/overhead-a
|
||||
import { OverheadAdvanceDetailsComponent } from './overhead-advance-details/overhead-advance-details.component';
|
||||
import { FeeListComponent } from './fee-list/fee-list.component';
|
||||
import { FeeDetailsComponent } from './fee-details/fee-details.component';
|
||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
@ -41,8 +44,12 @@ const routes: Routes = [
|
||||
{ path: 'fees', component: FeeListComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'fee/:id', component: FeeDetailsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'fee', component: FeeDetailsComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'enterPayment', component: EnterPaymentComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'ledger', component: LedgerComponent, canActivate: [ AuthGuardService ] },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'logout', component: LogoutComponent },
|
||||
{ path: 'login', component: LoginComponent }
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: '', pathMatch: 'full', redirectTo: 'home' }
|
||||
]
|
||||
|
||||
@NgModule({
|
||||
|
@ -45,7 +45,11 @@ import { FeeDetailsComponent } from './fee-details/fee-details.component';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { AccountComponent } from './account/account.component';
|
||||
import { NoteComponent } from './note/note.component'
|
||||
import { MatMomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter'
|
||||
import { MatMomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
|
||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||
|
||||
registerLocaleData(localeDe)
|
||||
|
||||
@ -72,7 +76,11 @@ registerLocaleData(localeDe)
|
||||
FeeListComponent,
|
||||
FeeDetailsComponent,
|
||||
AccountComponent,
|
||||
NoteComponent
|
||||
NoteComponent,
|
||||
EnterPaymentComponent,
|
||||
HomeComponent,
|
||||
LedgerComponent,
|
||||
ErrorDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -130,6 +130,11 @@ export class PremiseService {
|
||||
}
|
||||
|
||||
|
||||
async getPremisesByAccount(id: number): Promise<Premise[]> {
|
||||
this.messageService.add(`PremiseService: get data by Account ${id}`);
|
||||
return this.http.get<Premise[]>(`${serviceBaseUrl}/v1/premises/account/${id}`).toPromise()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ export interface Premise {
|
||||
street: string
|
||||
zip: string
|
||||
city: string
|
||||
account: number
|
||||
}
|
||||
export const NULL_Premise: Premise = {
|
||||
id: 0
|
||||
@ -59,6 +60,7 @@ export const NULL_Premise: Premise = {
|
||||
,street: ''
|
||||
,zip: ''
|
||||
,city: ''
|
||||
,account: undefined
|
||||
}
|
||||
|
||||
export interface Flat {
|
||||
@ -190,6 +192,7 @@ export interface AccountEntry {
|
||||
account: number
|
||||
created_at: string
|
||||
amount: number
|
||||
document_no: number
|
||||
account_entry_category: number
|
||||
}
|
||||
export const NULL_AccountEntry: AccountEntry = {
|
||||
@ -198,6 +201,7 @@ export const NULL_AccountEntry: AccountEntry = {
|
||||
,account: undefined
|
||||
,created_at: ''
|
||||
,amount: undefined
|
||||
,document_no: undefined
|
||||
,account_entry_category: undefined
|
||||
}
|
||||
|
||||
|
22
ui/hv2-ui/src/app/enter-payment/enter-payment.component.html
Normal file
22
ui/hv2-ui/src/app/enter-payment/enter-payment.component.html
Normal file
@ -0,0 +1,22 @@
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
Mietzahlung eintragen
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<span>Mieter auswählen: </span>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-select #mapSelect [(ngModel)]="accountId" name="tenantAccount">
|
||||
<mat-label>Mieter</mat-label>
|
||||
<mat-option *ngFor="let p of tenants" [value]="p.id">{{p.firstname}} {{p.lastname}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<app-account [selectedAccountId]="accountId" [shallBeRentPayment]="true"></app-account>
|
||||
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EnterPaymentComponent } from './enter-payment.component';
|
||||
|
||||
describe('EnterPaymentComponent', () => {
|
||||
let component: EnterPaymentComponent;
|
||||
let fixture: ComponentFixture<EnterPaymentComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ EnterPaymentComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EnterPaymentComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
37
ui/hv2-ui/src/app/enter-payment/enter-payment.component.ts
Normal file
37
ui/hv2-ui/src/app/enter-payment/enter-payment.component.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { TenantService } from '../data-object-service';
|
||||
import { Tenant } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-enter-payment',
|
||||
templateUrl: './enter-payment.component.html',
|
||||
styleUrls: ['./enter-payment.component.css']
|
||||
})
|
||||
export class EnterPaymentComponent implements OnInit {
|
||||
|
||||
tenants: Tenant[]
|
||||
accountId: number
|
||||
|
||||
constructor(
|
||||
private tenantService: TenantService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
async getTenants(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load tenants")
|
||||
this.tenants = await this.tenantService.getTenants()
|
||||
this.messageService.add("Tenants loaded")
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getTenants()
|
||||
}
|
||||
|
||||
}
|
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export interface ErrorDialogData {
|
||||
module: string,
|
||||
func: string,
|
||||
msg: string
|
||||
}
|
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogService } from './error-dialog.service';
|
||||
|
||||
describe('ErrorDialogService', () => {
|
||||
let service: ErrorDialogService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ErrorDialogService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorDialogService {
|
||||
|
||||
constructor(public dialog: MatDialog) { }
|
||||
|
||||
openDialog(module: string, func: string, msg: string): void {
|
||||
const dialogRef = this.dialog.open(ErrorDialogComponent, {
|
||||
width: '450px',
|
||||
data: { module: module, func: func, msg: msg }
|
||||
})
|
||||
}
|
||||
}
|
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<h1>Fehler</h1>
|
||||
|
||||
<h2>Module</h2>
|
||||
<p>{{data.module}}</p>
|
||||
|
||||
<h2>Function</h2>
|
||||
<p>{{data.func}}</p>
|
||||
|
||||
<h2>Message</h2>
|
||||
<p>{{data.msg}}</p>
|
||||
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogComponent } from './error-dialog.component';
|
||||
|
||||
describe('ErrorDialogComponent', () => {
|
||||
let component: ErrorDialogComponent;
|
||||
let fixture: ComponentFixture<ErrorDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ErrorDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ErrorDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { ErrorDialogData } from '../error-dialog-data';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error-dialog',
|
||||
templateUrl: './error-dialog.component.html',
|
||||
styleUrls: ['./error-dialog.component.css']
|
||||
})
|
||||
export class ErrorDialogComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ErrorDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: ErrorDialogData
|
||||
) { }
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close()
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
@ -6,8 +6,8 @@ import { MessageService } from './message.service';
|
||||
import { serviceBaseUrl } from './config';
|
||||
|
||||
|
||||
import { Fee, OverheadAdvance } from './data-objects';
|
||||
import { Saldo } from './ext-data-objects';
|
||||
import { Account, Fee, OverheadAdvance } from './data-objects';
|
||||
import { Saldo, Tenant_with_Saldo, UniqueNumber } from './ext-data-objects';
|
||||
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@ -19,6 +19,11 @@ export class ExtApiService {
|
||||
return this.http.get<OverheadAdvance[]>(`${serviceBaseUrl}/v1/overhead_advances/flat/${id}`).toPromise()
|
||||
}
|
||||
|
||||
async getAccountByDescription(description: string): Promise<Account> {
|
||||
this.messageService.add(`ExtApiService: get account by description ${description}`);
|
||||
return this.http.get<Account>(`${serviceBaseUrl}/v1/accounts/bydescription/${description}`).toPromise()
|
||||
}
|
||||
|
||||
async getFeeByTenancies(id: number): Promise<Fee[]> {
|
||||
this.messageService.add(`ExtApiService: get fees by flat ${id}`);
|
||||
return this.http.get<Fee[]>(`${serviceBaseUrl}/v1/fees/tenancy/${id}`).toPromise()
|
||||
@ -28,4 +33,14 @@ export class ExtApiService {
|
||||
this.messageService.add(`ExtApiService: get saldo for account ${id}`);
|
||||
return this.http.get<Saldo>(`${serviceBaseUrl}/v1/account/saldo/${id}`).toPromise()
|
||||
}
|
||||
|
||||
async getTenantsWithSaldo(): Promise<Tenant_with_Saldo[]> {
|
||||
this.messageService.add("ExtApiService: get tenants with saldo");
|
||||
return this.http.get<Tenant_with_Saldo[]>(`${serviceBaseUrl}/v1/tenants/saldo`).toPromise()
|
||||
}
|
||||
|
||||
async getUniqueNumber(): Promise<UniqueNumber> {
|
||||
this.messageService.add("ExtApiService: get unique number");
|
||||
return this.http.get<UniqueNumber>(`${serviceBaseUrl}/v1/uniquenumber`).toPromise()
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,15 @@
|
||||
export interface Saldo {
|
||||
saldo: number
|
||||
}
|
||||
|
||||
|
||||
export interface Tenant_with_Saldo {
|
||||
id: number
|
||||
firstname: string
|
||||
lastname: string
|
||||
address1: string
|
||||
saldo: number
|
||||
}
|
||||
|
||||
export interface UniqueNumber {
|
||||
number: number
|
||||
}
|
0
ui/hv2-ui/src/app/home/home.component.css
Normal file
0
ui/hv2-ui/src/app/home/home.component.css
Normal file
1
ui/hv2-ui/src/app/home/home.component.html
Normal file
1
ui/hv2-ui/src/app/home/home.component.html
Normal file
@ -0,0 +1 @@
|
||||
<p>home works!</p>
|
25
ui/hv2-ui/src/app/home/home.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/home/home.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ HomeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
15
ui/hv2-ui/src/app/home/home.component.ts
Normal file
15
ui/hv2-ui/src/app/home/home.component.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
0
ui/hv2-ui/src/app/ledger/ledger.component.css
Normal file
0
ui/hv2-ui/src/app/ledger/ledger.component.css
Normal file
34
ui/hv2-ui/src/app/ledger/ledger.component.html
Normal file
34
ui/hv2-ui/src/app/ledger/ledger.component.html
Normal file
@ -0,0 +1,34 @@
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
Buchführung
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseExpenseDetails = true"
|
||||
(closed)="collapseExpenseDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Ausgaben
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
<div>Betriebskosten-relevante Ausgaben nicht hier sondern im Betriebskostenkonto unter "Meine Häuser" erfassen.</div>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account #expenseAccountComponent [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel (opened)="collapseIncomeDetails = true"
|
||||
(closed)="collapseIncomeDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Einnahmen
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account #incomeAccountComponent [selectedAccountId]="incomeAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
25
ui/hv2-ui/src/app/ledger/ledger.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/ledger/ledger.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LedgerComponent } from './ledger.component';
|
||||
|
||||
describe('LedgerComponent', () => {
|
||||
let component: LedgerComponent;
|
||||
let fixture: ComponentFixture<LedgerComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ LedgerComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LedgerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
48
ui/hv2-ui/src/app/ledger/ledger.component.ts
Normal file
48
ui/hv2-ui/src/app/ledger/ledger.component.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AccountComponent } from '../account/account.component';
|
||||
import { Account } from '../data-objects';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ledger',
|
||||
templateUrl: './ledger.component.html',
|
||||
styleUrls: ['./ledger.component.css']
|
||||
})
|
||||
export class LedgerComponent implements OnInit {
|
||||
|
||||
incomeAccount: Account
|
||||
incomeAccountId: number
|
||||
expenseAccount: Account
|
||||
expenseAccountId: number
|
||||
|
||||
collapseIncomeDetails: boolean = false
|
||||
collapseExpenseDetails: boolean = false
|
||||
|
||||
@ViewChild('incomeAccountComponent') incomeAccountComponent: AccountComponent
|
||||
@ViewChild('expenseAccountComponent') expenseAccountComponent: AccountComponent
|
||||
|
||||
|
||||
constructor(
|
||||
private extApiService: ExtApiService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
async getAccount(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load ledger account")
|
||||
this.incomeAccount = await this.extApiService.getAccountByDescription('LedgerIncome')
|
||||
this.expenseAccount = await this.extApiService.getAccountByDescription('LedgerExpense')
|
||||
this.messageService.add("Account loaded")
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this.getAccount()
|
||||
this.incomeAccountId = this.incomeAccount.id
|
||||
this.expenseAccountId = this.expenseAccount.id
|
||||
}
|
||||
|
||||
}
|
@ -26,6 +26,10 @@
|
||||
<th mat-header-cell *matHeaderCellDef>Ort</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.city}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="account">
|
||||
<th mat-header-cell *matHeaderCellDef>Betriebskostenkonto</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.account}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/premise/', row.id]"></tr>
|
||||
</table>
|
||||
|
@ -13,7 +13,8 @@ export class MyPremisesComponent implements OnInit {
|
||||
|
||||
premises: Premise[]
|
||||
dataSource: MatTableDataSource<Premise>
|
||||
displayedColumns: string[] = [ "description", "street", "zip", "city" ]
|
||||
displayedColumns: string[] = [ "description", "street", "zip", "city", "account" ]
|
||||
|
||||
|
||||
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
||||
|
||||
|
@ -22,6 +22,10 @@
|
||||
<th mat-header-cell *matHeaderCellDef>Adresse 1</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.address1}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="saldo">
|
||||
<th mat-header-cell *matHeaderCellDef>Saldo</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.saldo | number:'1.2-2'}} €</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/tenant/', row.id]"></tr>
|
||||
</table>
|
||||
|
@ -3,6 +3,9 @@ import { MessageService } from '../message.service';
|
||||
import { TenantService } from '../data-object-service';
|
||||
import { Tenant } from '../data-objects';
|
||||
import { MatTableDataSource } from '@angular/material/table'
|
||||
import { Tenant_with_Saldo } from '../ext-data-objects';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-my-tenants',
|
||||
@ -11,19 +14,22 @@ import { MatTableDataSource } from '@angular/material/table'
|
||||
})
|
||||
export class MyTenantsComponent implements OnInit {
|
||||
|
||||
tenants: Tenant[]
|
||||
dataSource: MatTableDataSource<Tenant>
|
||||
displayedColumns: string[] = ["lastname", "firstname", "address1"]
|
||||
tenants: Tenant_with_Saldo[]
|
||||
dataSource: MatTableDataSource<Tenant_with_Saldo>
|
||||
displayedColumns: string[] = ["lastname", "firstname", "address1", "saldo"]
|
||||
|
||||
constructor(private tenantService: TenantService, private messageService: MessageService) { }
|
||||
constructor(
|
||||
private extApiService: ExtApiService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
async getTenants(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load tenants")
|
||||
this.tenants = await this.tenantService.getTenants()
|
||||
this.tenants = await this.extApiService.getTenantsWithSaldo()
|
||||
this.messageService.add("Tenants loaded")
|
||||
|
||||
this.dataSource = new MatTableDataSource<Tenant>(this.tenants)
|
||||
this.dataSource = new MatTableDataSource<Tenant_with_Saldo>(this.tenants)
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
|
@ -4,17 +4,26 @@
|
||||
[mode]="(isHandset$ | async) ? 'over' : 'side'"
|
||||
[opened]="(isHandset$ | async) === false">
|
||||
<mat-toolbar>Menu</mat-toolbar>
|
||||
<mat-nav-list>
|
||||
<mat-nav-list *ngIf="!authenticated">
|
||||
<a mat-list-item href="/login">Anmelden</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/enterPayment">Mietzahlung eintragen</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
|
||||
</mat-nav-list><mat-divider></mat-divider><mat-nav-list>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/flats">Meine Wohnungen</a>
|
||||
<a mat-list-item href="/parkings">Meine Garagen</a>
|
||||
<a mat-list-item href="/commercialunits">Meine Büros</a>
|
||||
</mat-nav-list><mat-divider></mat-divider><mat-nav-list>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/overheadadvances">Betriebskostensätze</a>
|
||||
<a mat-list-item href="/fees">Mietsätze</a>
|
||||
</mat-nav-list><mat-divider></mat-divider><mat-nav-list>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/premises">Meine Häuser</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<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="/logout">Abmelden</a>
|
||||
</mat-nav-list>
|
||||
</mat-sidenav>
|
||||
<mat-sidenav-content>
|
||||
@ -31,13 +40,11 @@
|
||||
<span class="spacer"></span>
|
||||
<span class="gittagversion">GITTAGVERSION</span>
|
||||
<span class="gittagversion" *ngIf="authenticated">Läuft aus in {{expiryTime | async }} Sekunden</span>
|
||||
<a *ngIf="!authenticated" mat-button routerLink="/login">Login</a>
|
||||
<a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a>
|
||||
</mat-toolbar>
|
||||
<!-- Add Content Here -->
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
<app-messages></app-messages>
|
||||
|
||||
<app-messages *ngIf="authenticated"></app-messages>
|
||||
</mat-sidenav-content>
|
||||
|
||||
</mat-sidenav-container>
|
||||
|
@ -9,31 +9,59 @@
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<form (ngSubmit)="savePremise()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="premise.description"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Strasse</mat-label>
|
||||
<input matInput name="street" [(ngModel)]="premise.street"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>PLZ</mat-label>
|
||||
<input matInput name="zip" [(ngModel)]="premise.zip"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Ort</mat-label>
|
||||
<input matInput name="city" [(ngModel)]="premise.city"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseDetails = true"
|
||||
(closed)="collapseDetails = false"
|
||||
[expanded]="premise.id == 0">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Details
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form (ngSubmit)="savePremise()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="premise.description"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Strasse</mat-label>
|
||||
<input matInput name="street" [(ngModel)]="premise.street"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>PLZ</mat-label>
|
||||
<input matInput name="zip" [(ngModel)]="premise.zip"/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Ort</mat-label>
|
||||
<input matInput name="city" [(ngModel)]="premise.city"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline" *ngIf="premise.account">
|
||||
<mat-label>Betriebskostenkonto</mat-label>
|
||||
<input matInput name="account" [readonly]="true" [(ngModel)]="premise.account"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel (opened)="collapseOverheadAccount = true"
|
||||
(closed)="collapseOverheadAccount = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Betriebskostenkonto
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account #incomeAccountComponent [selectedAccountId]="overheadAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { PremiseService } from '../data-object-service';
|
||||
import { Premise } from '../data-objects';
|
||||
import { AccountService, PremiseService } from '../data-object-service';
|
||||
import { Account, NULL_Premise, Premise } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
@ -12,18 +13,19 @@ import { MessageService } from '../message.service';
|
||||
})
|
||||
export class PremiseDetailsComponent implements OnInit {
|
||||
|
||||
collapseDetails: boolean = false
|
||||
collapseOverheadAccount: boolean = false
|
||||
|
||||
@ViewChild('submitButton') submitButton: MatButton
|
||||
|
||||
premise: Premise = {
|
||||
id: 0,
|
||||
description: '',
|
||||
street: '',
|
||||
zip: '',
|
||||
city: ''
|
||||
}
|
||||
premise: Premise = NULL_Premise
|
||||
|
||||
overheadAccount: Account
|
||||
overheadAccountId: number
|
||||
|
||||
constructor(
|
||||
private premiseService: PremiseService,
|
||||
private accountService: AccountService,
|
||||
private messageService: MessageService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
@ -34,6 +36,8 @@ export class PremiseDetailsComponent implements OnInit {
|
||||
const id = +this.route.snapshot.paramMap.get('id')
|
||||
if (id != 0) {
|
||||
this.premise = await this.premiseService.getPremise(id)
|
||||
this.overheadAccount = await this.accountService.getAccount(this.premise.account)
|
||||
this.overheadAccountId = this.overheadAccount.id
|
||||
}
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
@ -47,6 +51,12 @@ export class PremiseDetailsComponent implements OnInit {
|
||||
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
|
||||
if (this.premise.id == 0) {
|
||||
this.messageService.add("about to insert new premise")
|
||||
this.overheadAccount = {
|
||||
"id": 0,
|
||||
"description": `overhead_account_${this.premise.description}`
|
||||
}
|
||||
this.overheadAccount = await this.accountService.postAccount(this.overheadAccount)
|
||||
this.premise.account = this.overheadAccount.id
|
||||
this.premise = await this.premiseService.postPremise(this.premise)
|
||||
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
||||
} else {
|
||||
|
@ -8,7 +8,8 @@
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseTenantDetails = true"
|
||||
(closed)="collapseTenantDetails = false">
|
||||
(closed)="collapseTenantDetails = false"
|
||||
[expanded]="tenant.id == 0">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title *ngIf="!collapseTenantDetails">
|
||||
Details
|
||||
@ -68,18 +69,18 @@
|
||||
<input matInput name="iban" [(ngModel)]="tenant.iban"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!--
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-form-field appearance="outline" *ngIf="tenant.account">
|
||||
<mat-label>Account ID</mat-label>
|
||||
<input matInput name="account_id" [readonly]="true" [ngModel]="account.id"/>
|
||||
<input matInput name="account_id" [readonly]="true" [ngModel]="tenant.account"/>
|
||||
</mat-form-field>
|
||||
<!--
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Account Description</mat-label>
|
||||
<input matInput name="account_desc" [readonly]="true" [ngModel]="account.description"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
-->
|
||||
-->
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -256,7 +257,27 @@
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<app-account [selectedAccountId]="tenant.account" [shallBeRentPayment]="true"></app-account>
|
||||
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{account?.description}} ({{account?.id}})
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseAccount = true"
|
||||
(closed)="collapseAccount = false" #mep>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title *ngIf="!collapseAccount">
|
||||
Kontoübersicht, Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account [selectedAccountId]="tenant.account" [shallBeRentPayment]="true"></app-account>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
</section>
|
||||
|
@ -52,6 +52,7 @@ export class TenantDetailsComponent implements OnInit {
|
||||
collapseTenantDetails: boolean = false
|
||||
collapseTenancies: boolean = false
|
||||
collapseTenancyMapping: boolean = false
|
||||
collapseAccount: boolean = false
|
||||
|
||||
selectedTenancy: Tenancy = undefined
|
||||
mappedFees: Fee[]
|
||||
@ -89,11 +90,18 @@ export class TenantDetailsComponent implements OnInit {
|
||||
async getTenant(): Promise<void> {
|
||||
try {
|
||||
const id = +this.route.snapshot.paramMap.get('id')
|
||||
this.messageService.add(`getTenant, id=${id}`)
|
||||
if (id != 0) {
|
||||
this.messageService.add("getTenant, not-0-branch")
|
||||
this.tenantId = id
|
||||
this.tenant = await this.tenantService.getTenant(id)
|
||||
this.account = await this.accountService.getAccount(this.tenant.account)
|
||||
this.getTenancies()
|
||||
} else {
|
||||
this.messageService.add("getTenant, 0-branch")
|
||||
this.tenant = NULL_Tenant
|
||||
this.account = NULL_Account
|
||||
this.tenancies = []
|
||||
}
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
|
@ -6,6 +6,7 @@ import jwt_decode from 'jwt-decode'
|
||||
import { Observable, interval, Subject, Subscription } from 'rxjs'
|
||||
import { map, takeWhile } from 'rxjs/operators'
|
||||
import { authserviceBaseUrl, applicationId } from './config'
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
|
||||
interface TokenTuple {
|
||||
@ -24,8 +25,11 @@ export class TokenService {
|
||||
private _expiryTime = new Subject<number>()
|
||||
private subscription: Subscription
|
||||
|
||||
constructor(private http: HttpClient, private messageService: MessageService) {
|
||||
}
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private router: Router,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
checkAuthenticated(): boolean {
|
||||
let result: boolean = false
|
||||
@ -60,7 +64,15 @@ export class TokenService {
|
||||
if (this.subscription && !this.subscription.closed) {
|
||||
this.subscription.unsubscribe()
|
||||
}
|
||||
this.subscription = interval(1000).pipe(map(v => start - v)).pipe(takeWhile(v => v != 0)).subscribe(v => this._expiryTime.next(v))
|
||||
this.subscription = interval(1000)
|
||||
.pipe(map(v => start - v))
|
||||
.pipe(takeWhile(v => v >= 0))
|
||||
.subscribe((v) => {
|
||||
this._expiryTime.next(v)
|
||||
if (v == 0) {
|
||||
this.router.navigate(['/logout'])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async login(login: string, password: string) : Promise<void> {
|
||||
|
@ -1,11 +1,15 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
html, body { height: 100%; }
|
||||
html, body {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
|
||||
table {
|
||||
width: 75%;
|
||||
border-spacing: 20px;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user