merged
This commit is contained in:
commit
b346cc07d0
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,3 +6,7 @@ cli/config/dbconfig.ini
|
|||||||
*~
|
*~
|
||||||
.*~
|
.*~
|
||||||
.vscode/
|
.vscode/
|
||||||
|
cli/*.tex
|
||||||
|
cli/*.log
|
||||||
|
cli/*.pdf
|
||||||
|
cli/*.aux
|
||||||
|
@ -286,6 +286,7 @@ SELECT
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,minus_area
|
||||||
,account
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
ORDER BY
|
ORDER BY
|
||||||
@ -302,6 +303,7 @@ def insert_premise(user, token_info, **args):
|
|||||||
v_street = body["street"]
|
v_street = body["street"]
|
||||||
v_zip = body["zip"]
|
v_zip = body["zip"]
|
||||||
v_city = body["city"]
|
v_city = body["city"]
|
||||||
|
v_minus_area = body["minus_area"]
|
||||||
v_account = body["account"]
|
v_account = body["account"]
|
||||||
return dbInsert(user, token_info, {
|
return dbInsert(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
@ -311,6 +313,7 @@ INSERT INTO premise_t
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,minus_area
|
||||||
,account
|
,account
|
||||||
) VALUES (
|
) VALUES (
|
||||||
%s
|
%s
|
||||||
@ -318,6 +321,7 @@ INSERT INTO premise_t
|
|||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
@ -326,6 +330,7 @@ INSERT INTO premise_t
|
|||||||
,v_street
|
,v_street
|
||||||
,v_zip
|
,v_zip
|
||||||
,v_city
|
,v_city
|
||||||
|
,v_minus_area
|
||||||
,v_account
|
,v_account
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -343,6 +348,7 @@ SELECT
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,minus_area
|
||||||
,account
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
@ -358,6 +364,7 @@ def update_premise(user, token_info, premiseId=None, **args):
|
|||||||
v_street = body["street"]
|
v_street = body["street"]
|
||||||
v_zip = body["zip"]
|
v_zip = body["zip"]
|
||||||
v_city = body["city"]
|
v_city = body["city"]
|
||||||
|
v_minus_area = body["minus_area"]
|
||||||
return dbUpdate(user, token_info, {
|
return dbUpdate(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
UPDATE premise_t
|
UPDATE premise_t
|
||||||
@ -366,6 +373,7 @@ UPDATE premise_t
|
|||||||
,street = %s
|
,street = %s
|
||||||
,zip = %s
|
,zip = %s
|
||||||
,city = %s
|
,city = %s
|
||||||
|
,minus_area = %s
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
@ -374,6 +382,7 @@ UPDATE premise_t
|
|||||||
v_street,
|
v_street,
|
||||||
v_zip,
|
v_zip,
|
||||||
v_city,
|
v_city,
|
||||||
|
v_minus_area,
|
||||||
premiseId
|
premiseId
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -391,6 +400,7 @@ SELECT
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,minus_area
|
||||||
,account
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
WHERE account = %s
|
WHERE account = %s
|
||||||
@ -1305,6 +1315,7 @@ def get_account_entry_categorys(user, token_info):
|
|||||||
SELECT
|
SELECT
|
||||||
id
|
id
|
||||||
,description
|
,description
|
||||||
|
,considerMinusArea
|
||||||
,overhead_relevant
|
,overhead_relevant
|
||||||
FROM account_entry_category_t
|
FROM account_entry_category_t
|
||||||
ORDER BY
|
ORDER BY
|
||||||
@ -1318,21 +1329,25 @@ def insert_account_entry_category(user, token_info, **args):
|
|||||||
try:
|
try:
|
||||||
body = args["body"]
|
body = args["body"]
|
||||||
v_description = body["description"]
|
v_description = body["description"]
|
||||||
|
v_considerMinusArea = body["considerMinusArea"]
|
||||||
v_overhead_relevant = body["overhead_relevant"]
|
v_overhead_relevant = body["overhead_relevant"]
|
||||||
return dbInsert(user, token_info, {
|
return dbInsert(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
INSERT INTO account_entry_category_t
|
INSERT INTO account_entry_category_t
|
||||||
(
|
(
|
||||||
description
|
description
|
||||||
|
,considerMinusArea
|
||||||
,overhead_relevant
|
,overhead_relevant
|
||||||
) VALUES (
|
) VALUES (
|
||||||
%s
|
%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
"params": [
|
"params": [
|
||||||
v_description
|
v_description
|
||||||
|
,v_considerMinusArea
|
||||||
,v_overhead_relevant
|
,v_overhead_relevant
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -1347,6 +1362,7 @@ def get_account_entry_category(user, token_info, account_entry_categoryId=None):
|
|||||||
SELECT
|
SELECT
|
||||||
id
|
id
|
||||||
,description
|
,description
|
||||||
|
,considerMinusArea
|
||||||
,overhead_relevant
|
,overhead_relevant
|
||||||
FROM account_entry_category_t
|
FROM account_entry_category_t
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
@ -1365,7 +1381,7 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
,due_at
|
,fiscal_year
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1383,7 +1399,7 @@ def insert_account_entry(user, token_info, **args):
|
|||||||
v_description = body["description"]
|
v_description = body["description"]
|
||||||
v_account = body["account"]
|
v_account = body["account"]
|
||||||
v_created_at = body["created_at"]
|
v_created_at = body["created_at"]
|
||||||
v_due_at = body["due_at"]
|
v_fiscal_year = body["fiscal_year"]
|
||||||
v_amount = body["amount"]
|
v_amount = body["amount"]
|
||||||
v_document_no = body["document_no"]
|
v_document_no = body["document_no"]
|
||||||
v_account_entry_category = body["account_entry_category"]
|
v_account_entry_category = body["account_entry_category"]
|
||||||
@ -1394,7 +1410,7 @@ INSERT INTO account_entry_t
|
|||||||
description
|
description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
,due_at
|
,fiscal_year
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1413,7 +1429,7 @@ INSERT INTO account_entry_t
|
|||||||
v_description
|
v_description
|
||||||
,v_account
|
,v_account
|
||||||
,v_created_at
|
,v_created_at
|
||||||
,v_due_at
|
,v_fiscal_year
|
||||||
,v_amount
|
,v_amount
|
||||||
,v_document_no
|
,v_document_no
|
||||||
,v_account_entry_category
|
,v_account_entry_category
|
||||||
@ -1432,7 +1448,7 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
,due_at
|
,fiscal_year
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1453,7 +1469,7 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
,due_at
|
,fiscal_year
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1474,7 +1490,7 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
,due_at
|
,fiscal_year
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
|
@ -1644,6 +1644,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
city:
|
city:
|
||||||
type: string
|
type: string
|
||||||
|
minus_area:
|
||||||
|
type: number
|
||||||
account:
|
account:
|
||||||
type: integer
|
type: integer
|
||||||
flat:
|
flat:
|
||||||
@ -1779,6 +1781,8 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
|
considerMinusArea:
|
||||||
|
type: boolean
|
||||||
overhead_relevant:
|
overhead_relevant:
|
||||||
type: boolean
|
type: boolean
|
||||||
account_entry:
|
account_entry:
|
||||||
@ -1793,9 +1797,8 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
due_at:
|
fiscal_year:
|
||||||
type: string
|
type: integer
|
||||||
nullable: true
|
|
||||||
amount:
|
amount:
|
||||||
type: number
|
type: number
|
||||||
document_no:
|
document_no:
|
||||||
|
@ -5,6 +5,6 @@ from flask_cors import CORS
|
|||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
app = connexion.App('hv2-api')
|
app = connexion.App('hv2-api')
|
||||||
app.add_api('./openapi.yaml')
|
app.add_api('./openapi.yaml', options = {"swagger_ui": True})
|
||||||
CORS(app.app)
|
CORS(app.app)
|
||||||
app.run(port=8080)
|
app.run(port=8080)
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
stages:
|
|
||||||
- check
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
variables:
|
|
||||||
IMAGE_NAME: $CI_REGISTRY/$CI_PROJECT_PATH
|
|
||||||
|
|
||||||
check:
|
|
||||||
image: registry.hottis.de/dockerized/base-build-env:latest
|
|
||||||
stage: check
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- checksemver.py -v
|
|
||||||
--versionToValidate "${CI_COMMIT_TAG}"
|
|
||||||
--validateMessage
|
|
||||||
--messageToValidate "${CI_COMMIT_MESSAGE}"
|
|
||||||
|
|
||||||
build:
|
|
||||||
image: registry.hottis.de/dockerized/docker-bash:latest
|
|
||||||
stage: build
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
script:
|
|
||||||
- docker build --tag $IMAGE_NAME:latest .
|
|
||||||
- if [ "$CI_COMMIT_TAG" != "" ]; then
|
|
||||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:${CI_COMMIT_TAG};
|
|
||||||
docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY;
|
|
||||||
docker push $IMAGE_NAME:latest;
|
|
||||||
docker push $IMAGE_NAME:${CI_COMMIT_TAG};
|
|
||||||
fi
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
stage: deploy
|
|
||||||
image: registry.hottis.de/dockerized/docker-bash:latest
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
variables:
|
|
||||||
GIT_STRATEGY: none
|
|
||||||
script:
|
|
||||||
- CONTAINER_NAME=$CI_PROJECT_NAME
|
|
||||||
- SERVICE_VOLUME=$CI_PROJECT_NAME"-conf"
|
|
||||||
- SERVICE_PORT=5000
|
|
||||||
- docker volume inspect $SERVICE_VOLUME || docker volume create $SERVICE_VOLUME
|
|
||||||
- docker stop $CONTAINER_NAME || echo "$CONTAINER_NAME not running, anyway okay"
|
|
||||||
- docker rm $CONTAINER_NAME || echo "$CONTAINER_NAME not exsting, anyway okay"
|
|
||||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY;
|
|
||||||
- docker pull $IMAGE_NAME:${CI_COMMIT_TAG}
|
|
||||||
- docker run -d --restart always --name $CONTAINER_NAME --network docker-server --ip 172.16.10.38 -v $SERVICE_VOLUME:/opt/app/config $IMAGE_NAME:${CI_COMMIT_TAG}
|
|
||||||
|
|
88
ci-script-ui
88
ci-script-ui
@ -1,88 +0,0 @@
|
|||||||
stages:
|
|
||||||
- check
|
|
||||||
- build
|
|
||||||
- dockerize
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
variables:
|
|
||||||
IMAGE_NAME: $CI_REGISTRY/$CI_PROJECT_PATH
|
|
||||||
|
|
||||||
check:
|
|
||||||
image: registry.hottis.de/dockerized/base-build-env:latest
|
|
||||||
stage: check
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- checksemver.py -v
|
|
||||||
--versionToValidate "$CI_COMMIT_TAG"
|
|
||||||
--validateMessage
|
|
||||||
--messageToValidate "$CI_COMMIT_MESSAGE"
|
|
||||||
|
|
||||||
|
|
||||||
build:
|
|
||||||
image: registry.hottis.de/hv2/hv2-node-build-env:1.0.0
|
|
||||||
stage: build
|
|
||||||
variables:
|
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- dist.tgz
|
|
||||||
expire_in: 1 day
|
|
||||||
script:
|
|
||||||
- cd hv2-ui
|
|
||||||
- if [ "$CI_COMMIT_TAG" != "" ]; then
|
|
||||||
sed -i -e 's/GITTAGVERSION/'"$CI_COMMIT_TAG"':'"$CI_COMMIT_SHORT_SHA"'/' ./src/app/navigation/navigation.component.html;
|
|
||||||
fi
|
|
||||||
- npm install
|
|
||||||
- for F in ./src/app/*.tmpl; do
|
|
||||||
python ../helpers/hv2-api/generate.py -s ../helpers/hv2-api/schema.json -t $F;
|
|
||||||
done
|
|
||||||
- ./node_modules/.bin/ng build --prod
|
|
||||||
- tar -czf ../dist.tgz dist
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dockerize:
|
|
||||||
image: registry.hottis.de/dockerized/docker-bash:latest
|
|
||||||
stage: dockerize
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- tar -xzf dist.tgz
|
|
||||||
- docker build --tag $IMAGE_NAME:latest --tag $IMAGE_NAME:$CI_COMMIT_TAG .
|
|
||||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
|
||||||
- docker push $IMAGE_NAME:latest
|
|
||||||
- docker push $IMAGE_NAME:$CI_COMMIT_TAG
|
|
||||||
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
stage: deploy
|
|
||||||
image: registry.hottis.de/dockerized/docker-bash:latest
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- hottis
|
|
||||||
- linux
|
|
||||||
- docker
|
|
||||||
variables:
|
|
||||||
GIT_STRATEGY: none
|
|
||||||
script:
|
|
||||||
- CONTAINER_NAME=$CI_PROJECT_NAME
|
|
||||||
- docker stop $CONTAINER_NAME || echo "$CONTAINER_NAME not running, anyway okay"
|
|
||||||
- docker rm $CONTAINER_NAME || echo "$CONTAINER_NAME not exsting, anyway okay"
|
|
||||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY;
|
|
||||||
- docker pull $IMAGE_NAME:${CI_COMMIT_TAG}
|
|
||||||
- docker run -d --restart always --name $CONTAINER_NAME --network docker-server --ip 172.16.10.39 $IMAGE_NAME:${CI_COMMIT_TAG}
|
|
||||||
|
|
29
cli/AccountStatement.py
Normal file
29
cli/AccountStatement.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from db import dbGetMany
|
||||||
|
from loguru import logger
|
||||||
|
import datetime
|
||||||
|
import iso8601
|
||||||
|
from utils import getParam
|
||||||
|
from Cheetah.Template import Template
|
||||||
|
|
||||||
|
def perform(dbh, params):
|
||||||
|
year = getParam(params, 'year', datetime.datetime.today().year)
|
||||||
|
|
||||||
|
accountEntries = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement": "SELECT * FROM account_statement_v WHERE fiscal_year = %(year)s",
|
||||||
|
"params": {
|
||||||
|
'year': year
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
template = getParam(params, 'template', 'accountStatement.tmpl')
|
||||||
|
prefix = getParam(params, 'prefix', 'accountStatement')
|
||||||
|
suffix = getParam(params, 'suffix', 'tex')
|
||||||
|
input = { 'year': year, 'entries': accountEntries }
|
||||||
|
outputFile = f"{prefix}-{year}.{suffix}"
|
||||||
|
tmpl = Template(file=template, searchList=[ input ])
|
||||||
|
with open(outputFile, 'w') as f:
|
||||||
|
f.write(str(tmpl))
|
@ -2,14 +2,20 @@ from db import dbGetMany, dbGetOne
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import datetime
|
import datetime
|
||||||
|
import iso8601
|
||||||
|
|
||||||
def perform(dbh, params):
|
def perform(dbh, params):
|
||||||
try:
|
try:
|
||||||
createdAt = params['created_at']
|
createdAt = iso8601.parse_date(params['created_at'])
|
||||||
dueAt = createdAt.replace(day=1)
|
except iso8601.iso8601.ParseError:
|
||||||
|
msg = f"Can not parse given date {params['created_at']}"
|
||||||
|
logger.error(msg)
|
||||||
|
raise Exception(msg)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
createdAt = datetime.datetime.today().strftime("%Y-%m-%d")
|
createdAt = datetime.datetime.today()
|
||||||
dueAt = createdAt.replace(day=1)
|
|
||||||
|
year = createdAt.year
|
||||||
|
createdAt = createdAt.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
||||||
for tenant in tenants:
|
for tenant in tenants:
|
||||||
@ -101,11 +107,11 @@ def perform(dbh, params):
|
|||||||
accountEntry = dbGetOne(dbh, {
|
accountEntry = dbGetOne(dbh, {
|
||||||
"statement": """
|
"statement": """
|
||||||
INSERT INTO account_entry_t
|
INSERT INTO account_entry_t
|
||||||
(description, account, created_at, amount, account_entry_category)
|
(description, account, created_at, fiscal_year, amount, account_entry_category)
|
||||||
VALUES (%s, %s, %s, %s, (SELECT id FROM account_entry_category_t WHERE description = %s))
|
VALUES (%s, %s, %s, %s, %s, (SELECT id FROM account_entry_category_t WHERE description = %s))
|
||||||
RETURNING id
|
RETURNING id
|
||||||
""",
|
""",
|
||||||
"params": (request['description'], request['account'], request['created_at'], request['amount'], request['category'])
|
"params": (request['description'], request['account'], request['created_at'], year, request['amount'], request['category'])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
logger.info(f" account entry entered with id {accountEntry['id']}")
|
logger.info(f" account entry entered with id {accountEntry['id']}")
|
@ -2,83 +2,192 @@ from db import dbGetMany, dbGetOne
|
|||||||
import datetime
|
import datetime
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from decimal import *
|
from decimal import *
|
||||||
|
from utils import getParam
|
||||||
|
from Cheetah.Template import Template
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EPSILON = Decimal('0.000000001')
|
||||||
|
|
||||||
def perform(dbh, params):
|
def perform(dbh, params):
|
||||||
try:
|
year = getParam(params, 'year', datetime.datetime.today().year)
|
||||||
year = params['year']
|
|
||||||
except KeyError:
|
|
||||||
year = datetime.datetime.today().year
|
|
||||||
startDate = datetime.datetime(year, 1, 1, 0, 0, 0)
|
startDate = datetime.datetime(year, 1, 1, 0, 0, 0)
|
||||||
endDate = datetime.datetime(year, 12, 31, 23, 59, 59)
|
endDate = datetime.datetime(year, 12, 31, 23, 59, 59)
|
||||||
premises = (1, 2)
|
premises = (1, 2)
|
||||||
|
|
||||||
|
houses = {}
|
||||||
|
|
||||||
# get overhead sums by object, category and timespan
|
|
||||||
overheadSums = dbGetMany(
|
|
||||||
dbh,
|
|
||||||
{
|
|
||||||
"statement":
|
|
||||||
"""
|
|
||||||
select sum(ae.amount) as sum,
|
|
||||||
aec.description as category,
|
|
||||||
p.id as house_id,
|
|
||||||
p.description as house
|
|
||||||
from account_t a,
|
|
||||||
premise_t p,
|
|
||||||
account_entry_t ae,
|
|
||||||
account_entry_category_t aec
|
|
||||||
where p.account = a.id and
|
|
||||||
ae.account = a.id and
|
|
||||||
aec.overhead_relevant = 't' and
|
|
||||||
ae.account_entry_category = aec.id and
|
|
||||||
created_at between %(startDate)s and %(endDate)s and
|
|
||||||
p.id in %(premises)s
|
|
||||||
group by house_id, house, category
|
|
||||||
union
|
|
||||||
select 0 as sum,
|
|
||||||
aec.description as category,
|
|
||||||
p.id as house_id,
|
|
||||||
p.description as house
|
|
||||||
from account_t a,
|
|
||||||
premise_t p,
|
|
||||||
account_entry_t ae,
|
|
||||||
account_entry_category_t aec
|
|
||||||
where p.account = a.id and
|
|
||||||
ae.account = a.id and
|
|
||||||
aec.overhead_relevant = 't' and
|
|
||||||
aec.id not in (select distinct account_entry_category from account_entry_t) and
|
|
||||||
created_at between %(startDate)s and %(endDate)s and
|
|
||||||
p.id in %(premises)s
|
|
||||||
group by house_id, house, category
|
|
||||||
union
|
|
||||||
select 120 as sum,
|
|
||||||
'Waschmaschine' as category,
|
|
||||||
id as house_id,
|
|
||||||
description as house
|
|
||||||
from premise_t
|
|
||||||
where id in %(premises)s
|
|
||||||
order by house_id, category
|
|
||||||
""",
|
|
||||||
"params": {
|
|
||||||
"startDate": startDate,
|
|
||||||
"endDate": endDate,
|
|
||||||
"premises": premises
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# logger.info(f"{overheadSums=}")
|
|
||||||
for overheadSum in overheadSums:
|
|
||||||
logger.info(f"house: {overheadSum['house']}, category: {overheadSum['category']}, sum: {overheadSum['sum']}")
|
|
||||||
|
|
||||||
subtotal = {}
|
|
||||||
for premise in premises:
|
for premise in premises:
|
||||||
v = [ x['sum'] for x in overheadSums if x['house_id'] == premise ]
|
# get overhead sums by object, category and timespan
|
||||||
logger.info(f"{v=}")
|
overheadItems = dbGetMany(
|
||||||
subtotal[premise] = sum(v)
|
dbh,
|
||||||
logger.info(f"{subtotal=}")
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select sum(ae.amount) as sum,
|
||||||
|
aec.description as category,
|
||||||
|
aec.considerminusarea as considerminusarea
|
||||||
|
from account_t a,
|
||||||
|
premise_t p,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.account = a.id and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.overhead_relevant = 't' and
|
||||||
|
ae.account_entry_category = aec.id and
|
||||||
|
ae.fiscal_year = %(year)s and
|
||||||
|
p.id = %(premise)s
|
||||||
|
group by category, considerminusarea
|
||||||
|
union
|
||||||
|
select 0 as sum,
|
||||||
|
aec.description as category,
|
||||||
|
aec.considerminusarea as considerminusarea
|
||||||
|
from account_t a,
|
||||||
|
premise_t p,
|
||||||
|
account_entry_t ae,
|
||||||
|
account_entry_category_t aec
|
||||||
|
where p.account = a.id and
|
||||||
|
ae.account = a.id and
|
||||||
|
aec.overhead_relevant = 't' and
|
||||||
|
aec.id not in (select distinct account_entry_category from account_entry_t) and
|
||||||
|
ae.fiscal_year = %(year)s and
|
||||||
|
p.id = %(premise)s
|
||||||
|
group by category, considerminusarea
|
||||||
|
union
|
||||||
|
select 120 as sum,
|
||||||
|
'Waschmaschine' as category,
|
||||||
|
false as considerminusarea
|
||||||
|
from premise_t
|
||||||
|
where id = %(premise)s
|
||||||
|
order by category
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"year": year,
|
||||||
|
"premise": premise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
# get areas and factors
|
||||||
|
totalArea = {}
|
||||||
|
flatArea = dbGetOne(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
sum(f.area) as flat_area
|
||||||
|
from
|
||||||
|
premise_t p,
|
||||||
|
flat_t f
|
||||||
|
where
|
||||||
|
f.premise = p.id and
|
||||||
|
p.id = %(premise)s
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premise": premise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
totalArea['flat_area'] = flatArea['flat_area']
|
||||||
|
|
||||||
|
commercialArea = dbGetOne(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
coalesce(sum(c.area), 0) as commercial_area
|
||||||
|
from
|
||||||
|
premise_t p full outer join commercial_premise_t c on c.premise = p.id
|
||||||
|
where
|
||||||
|
p.id = %(premise)s
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premise": premise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
totalArea['commercial_area'] = commercialArea['commercial_area']
|
||||||
|
|
||||||
|
minusAreaAndDetails = dbGetOne(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
p.minus_area as minus_area,
|
||||||
|
p.id as house_id,
|
||||||
|
p.description as house
|
||||||
|
from
|
||||||
|
premise_t p
|
||||||
|
where
|
||||||
|
p.id = %(premise)s
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premise": premise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
totalArea['minus_area'] = minusAreaAndDetails['minus_area']
|
||||||
|
details = { 'id': minusAreaAndDetails['house_id'], 'description': minusAreaAndDetails['house'] }
|
||||||
|
|
||||||
|
totalArea['other_area'] = totalArea['commercial_area'] + totalArea['minus_area']
|
||||||
|
totalArea['total_area'] = totalArea['flat_area'] + totalArea['other_area']
|
||||||
|
totalArea['flat_factor'] = totalArea['flat_area'] / totalArea['total_area']
|
||||||
|
totalArea['other_factor'] = totalArea['other_area'] / totalArea['total_area']
|
||||||
|
totalArea['factor_check'] = totalArea['flat_factor'] + totalArea['other_factor']
|
||||||
|
|
||||||
|
totalSum = Decimal('0')
|
||||||
|
flatSum = Decimal('0')
|
||||||
|
otherSum = Decimal('0')
|
||||||
|
for overheadItem in overheadItems:
|
||||||
|
totalSum += overheadItem['sum']
|
||||||
|
overheadItem['flat_part'] = overheadItem['sum'] * totalArea['flat_factor'] if overheadItem['considerminusarea'] else overheadItem['sum']
|
||||||
|
flatSum += overheadItem['flat_part']
|
||||||
|
overheadItem['other_part'] = overheadItem['sum'] * totalArea['other_factor'] if overheadItem['considerminusarea'] else Decimal('0')
|
||||||
|
otherSum += overheadItem['other_part']
|
||||||
|
|
||||||
|
verifyDifference = totalSum - flatSum - otherSum
|
||||||
|
logger.debug(f"{totalSum=}, {verifyDifference=}")
|
||||||
|
if abs(verifyDifference) > EPSILON:
|
||||||
|
raise Exception(f"Verify Difference is too large: {premise=}, {verifyDifference=}")
|
||||||
|
|
||||||
|
umlageAusfallWagnis = flatSum * Decimal('0.02')
|
||||||
|
flatSum2 = flatSum + umlageAusfallWagnis
|
||||||
|
|
||||||
|
partByMonthArea = flatSum2 / Decimal('12') / totalArea['flat_area']
|
||||||
|
|
||||||
|
houses[details['id']] = {
|
||||||
|
'details': details,
|
||||||
|
'areas': totalArea,
|
||||||
|
'overhead_items': overheadItems,
|
||||||
|
'flat_sum': flatSum,
|
||||||
|
'flat_sum_2': flatSum2,
|
||||||
|
'other_sum': otherSum,
|
||||||
|
'total_sum': totalSum,
|
||||||
|
'umlage_ausfall_wagnis': umlageAusfallWagnis,
|
||||||
|
'part_by_montharea': partByMonthArea,
|
||||||
|
'year': year }
|
||||||
|
|
||||||
|
|
||||||
|
logger.info(f"{houses=}")
|
||||||
|
|
||||||
|
|
||||||
|
printOverviews = getParam(params, 'printOverviews', True)
|
||||||
|
if printOverviews:
|
||||||
|
overviewTemplate = getParam(params, 'overviewTemplate', 'betriebskostenuebersicht.tmpl')
|
||||||
|
overviewPrefix = getParam(params, 'overviewPrefix', 'overview')
|
||||||
|
overviewSuffix = getParam(params, 'overviewSuffix', 'tex')
|
||||||
|
|
||||||
|
for house in houses.values():
|
||||||
|
logger.debug(f"Processing item: {house}")
|
||||||
|
outputFile = f"{overviewPrefix}-{house['details']['id']}.{overviewSuffix}"
|
||||||
|
tmpl = Template(file=overviewTemplate, searchList=[ house ])
|
||||||
|
logger.debug(tmpl)
|
||||||
|
with open(outputFile, 'w') as f:
|
||||||
|
f.write(str(tmpl))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -88,10 +197,17 @@ def perform(dbh, params):
|
|||||||
"statement":
|
"statement":
|
||||||
"""
|
"""
|
||||||
select t.id as tenant_id,
|
select t.id as tenant_id,
|
||||||
|
t.salutation as tenant_salutation,
|
||||||
t.firstname as tenant_firstname,
|
t.firstname as tenant_firstname,
|
||||||
t.lastname as tenant_lastname,
|
t.lastname as tenant_lastname,
|
||||||
|
t.address1 as tenant_address1,
|
||||||
|
t.address2 as tenant_address2,
|
||||||
|
t.address3 as tenant_address3,
|
||||||
|
t.zip as tenant_zip,
|
||||||
|
t.city as tenant_city,
|
||||||
f.id as flat_id,
|
f.id as flat_id,
|
||||||
f.description as flat,
|
f.description as flat,
|
||||||
|
f.area as flat_area,
|
||||||
p.id as house_id,
|
p.id as house_id,
|
||||||
p.description as house,
|
p.description as house,
|
||||||
ty.startdate as startdate,
|
ty.startdate as startdate,
|
||||||
@ -117,8 +233,9 @@ def perform(dbh, params):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
letters = []
|
||||||
for tenant in tenants:
|
for tenant in tenants:
|
||||||
logger.info(f"firstname: {tenant['tenant_firstname']}, lastname: {tenant['tenant_lastname']}, house: {tenant['house']}, account: {tenant['tenant_account']}")
|
letter = {}
|
||||||
|
|
||||||
paidTotal = dbGetOne(
|
paidTotal = dbGetOne(
|
||||||
dbh,
|
dbh,
|
||||||
@ -130,15 +247,16 @@ def perform(dbh, params):
|
|||||||
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
|
||||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
fiscal_year = %(year)s
|
||||||
""",
|
""",
|
||||||
"params": {
|
"params": {
|
||||||
"account": tenant['tenant_account'],
|
"account": tenant['tenant_account'],
|
||||||
"startDate": startDate,
|
"year": year
|
||||||
"endDate": endDate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
tenant['paid_total'] = paidTotal['sum']
|
||||||
|
|
||||||
receivableFee = dbGetOne(
|
receivableFee = dbGetOne(
|
||||||
dbh,
|
dbh,
|
||||||
{
|
{
|
||||||
@ -149,22 +267,45 @@ def perform(dbh, params):
|
|||||||
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
|
||||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
fiscal_year = %(year)s
|
||||||
""",
|
""",
|
||||||
"params": {
|
"params": {
|
||||||
"account": tenant['tenant_account'],
|
"account": tenant['tenant_account'],
|
||||||
"startDate": startDate,
|
"year": year
|
||||||
"endDate": endDate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
tenant['receivable_fee'] = receivableFee['sum']
|
||||||
logger.info(f"Payments: cnt: {paidTotal['cnt']}, sum: {paidTotal['sum']}")
|
tenant['rent_time'] = receivableFee['cnt']
|
||||||
logger.info(f"Receivable fees: cnt: {receivableFee['cnt']}, sum: {receivableFee['sum']}")
|
|
||||||
|
|
||||||
paidOverheadAdvance = paidTotal['sum'] - receivableFee['sum']
|
tenant['paid_overhead'] = paidTotal['sum'] - receivableFee['sum']
|
||||||
logger.info(f"Paid overhead: {paidOverheadAdvance} (by month: {paidOverheadAdvance / Decimal(12)})")
|
|
||||||
|
letter['tenant'] = tenant
|
||||||
|
letter['year'] = year
|
||||||
|
letter['flat_area'] = houses[tenant['house_id']]['areas']['flat_area']
|
||||||
|
letter['receivable_overhead'] = tenant['flat_area'] * houses[tenant['house_id']]['part_by_montharea'] * tenant['rent_time']
|
||||||
|
letter['unbalanced_overhead'] = tenant['paid_overhead'] - letter['receivable_overhead']
|
||||||
|
letter['unbalanced_overhead_unsigned'] = abs(letter['unbalanced_overhead'])
|
||||||
|
letter['total_overhead'] = houses[tenant['house_id']]['flat_sum_2']
|
||||||
|
|
||||||
|
letters.append(letter)
|
||||||
|
|
||||||
|
logger.info(f"{letter=}")
|
||||||
|
|
||||||
|
|
||||||
|
printLetters = getParam(params, 'printLetters', True)
|
||||||
|
if printLetters:
|
||||||
|
letterTemplate = getParam(params, 'letterTemplate', 'jahresabrechnung.tmpl')
|
||||||
|
letterPrefix = getParam(params, 'letterPrefix', 'letter')
|
||||||
|
letterSuffix = getParam(params, 'letterSuffix', 'tex')
|
||||||
|
|
||||||
|
for letter in letters:
|
||||||
|
logger.debug(f"Processing item: {letter}")
|
||||||
|
outputFile = f"{letterPrefix}-{letter['tenant']['tenant_id']}.{letterSuffix}"
|
||||||
|
tmpl = Template(file=letterTemplate, searchList=[ letter ])
|
||||||
|
logger.debug(tmpl)
|
||||||
|
with open(outputFile, 'w') as f:
|
||||||
|
f.write(str(tmpl))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
37
cli/accountStatement.tmpl
Normal file
37
cli/accountStatement.tmpl
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
\documentclass[10pt]{article}
|
||||||
|
\usepackage{german}
|
||||||
|
\usepackage{eurosym}
|
||||||
|
\usepackage[a4paper, landscape=true, left=2cm, right=2cm, top=2cm]{geometry}
|
||||||
|
\usepackage{icomma}
|
||||||
|
\usepackage{longtable}
|
||||||
|
\usepackage{color}
|
||||||
|
\setlength{\parindent}{0pt}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\subsection*{Kontoauszug $year}
|
||||||
|
|
||||||
|
\begin{longtable}{rrp{5cm}rrrp{3cm}l}
|
||||||
|
\bf{id} & \bf{createdAt} & \bf{description} & \bf{amount} & \bf{documentNo} & \bf{fiscalYear} & \bf{category} & \bf{account} \\ \hline
|
||||||
|
\endfirsthead
|
||||||
|
\bf{id} & \bf{createdAt} & \bf{description} & \bf{amount} & \bf{documentNo} & \bf{fiscalYear} & \bf{category} & \bf{account} \\ \hline
|
||||||
|
\endhead
|
||||||
|
\hline \multicolumn{8}{r}{\em{to be continued}}
|
||||||
|
\endfoot
|
||||||
|
\hline
|
||||||
|
\endlastfoot
|
||||||
|
|
||||||
|
#for $entry in $entries
|
||||||
|
\tt{$entry['id']} & \tt{$entry['created_at']} & \tt{$entry['description']} & #slurp
|
||||||
|
#if not $entry['income']
|
||||||
|
\textcolor{red}{#slurp
|
||||||
|
#end if
|
||||||
|
\tt{$entry['amount']}#slurp
|
||||||
|
#if not $entry['income']
|
||||||
|
}#slurp
|
||||||
|
#end if
|
||||||
|
& \tt{$entry['document_no']} & \tt{$entry['fiscal_year']} & \tt{$entry['category']} & \tt{{ $entry['account'].replace('_', '\\textunderscore ') }} \\
|
||||||
|
#end for
|
||||||
|
\end{longtable}
|
||||||
|
|
||||||
|
\end{document}
|
42
cli/betriebskostenuebersicht.tmpl
Normal file
42
cli/betriebskostenuebersicht.tmpl
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
\documentclass[12pt]{article}
|
||||||
|
\usepackage{german}
|
||||||
|
\usepackage{eurosym}
|
||||||
|
\usepackage[a4paper, left=2cm, right=2cm, top=2cm]{geometry}
|
||||||
|
\usepackage{icomma}
|
||||||
|
\setlength{\parindent}{0pt}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\subsection*{Betriebskostenabrechnung}
|
||||||
|
|
||||||
|
|
||||||
|
\begin{tabular}{ll}
|
||||||
|
Objekt & $details['description'] \\
|
||||||
|
Jahr & $year \\
|
||||||
|
Eigent"umer & Nober Grundbesitz GmbH \\
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\addvspace{1cm}
|
||||||
|
|
||||||
|
\begin{tabular}{|p{5cm}|r|r|r|}
|
||||||
|
\hline Art & Wohnungen & andere Fl"achen & Gesamtfl"ache \\
|
||||||
|
\hline
|
||||||
|
\hline Fl"ache & \tt{$areas['flat_area']\,m\textsuperscript{2}} & \tt{$areas['other_area']\,m\textsuperscript{2}} & \tt{$areas['total_area']\,m\textsuperscript{2}} \\
|
||||||
|
\hline Faktor & \tt{#echo '%.10f' % $areas['flat_factor'] #} & \tt{#echo '%.10f' % $areas['other_factor'] #} & \\
|
||||||
|
\hline
|
||||||
|
|
||||||
|
#for $item in $overhead_items
|
||||||
|
\hline $item['category'] & \tt{#echo '%.2f' % $item['flat_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['other_part'] #\,\euro{}} & \tt{#echo '%.2f' % $item['sum'] #\,\euro{}} \\
|
||||||
|
#end for
|
||||||
|
|
||||||
|
\hline \multicolumn{4}{c}{ } \\
|
||||||
|
\hline Zwischensumme & \tt{#echo '%.2f' % $flat_sum #\,\euro{}} & \tt{#echo '%.2f' % $other_sum #\,\euro{}} & \tt{#echo '%.2f' % $total_sum #\,\euro{}} \\
|
||||||
|
\hline Umlageausfallwagnis & \tt{#echo '%.2f' % $umlage_ausfall_wagnis #\,\euro{}} & & \\
|
||||||
|
\hline Summe & \tt{#echo '%.2f' % $flat_sum_2 #\,\euro{}} & & \\
|
||||||
|
|
||||||
|
\hline \multicolumn{4}{c}{ } \\
|
||||||
|
\hline Anteil pro Monat und m\textsuperscript{2} & \tt{#echo '%.10f' % $part_by_montharea #\,\euro{}} & & \\
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\end{document}
|
74
cli/jahresabrechnung.tmpl
Normal file
74
cli/jahresabrechnung.tmpl
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
\documentclass[12pt]{dinbrief}
|
||||||
|
\usepackage{german}
|
||||||
|
\usepackage{eurosym}
|
||||||
|
|
||||||
|
|
||||||
|
\address{Nober Grundbesitz GbR\\
|
||||||
|
Eupenstr. 20\\
|
||||||
|
45259 Essen}
|
||||||
|
\backaddress{Nober Grundbesitz GbR, Eupenstr. 20, 45259 Essen}
|
||||||
|
\signature{Wolfgang Hottgenroth} %% Hier Unterschrift einfuegen
|
||||||
|
\nowindowrules
|
||||||
|
\writer{wh} %% Hier eigenen Namen oder Kuerzel einfuegen
|
||||||
|
\phone{0174}{3072474} %% Hier eigene Telefon einfuegen
|
||||||
|
|
||||||
|
\bottomtext{\sffamily\footnotesize Gesch"aftsf"uhrer: Wolfgang Hottgenroth, Robert Nober, Gregor Nober ---
|
||||||
|
EMail: hausverwaltung@nober.de\\
|
||||||
|
Bankverbindung: IBAN DE14 3605 0105 0001 5130 35, Sparkasse Essen}
|
||||||
|
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\pagenumbering{gobble}
|
||||||
|
\begin{letter}{$tenant['tenant_firstname'] $tenant['tenant_lastname']\\
|
||||||
|
#if $tenant['tenant_address1']
|
||||||
|
$tenant['tenant_address1']\\
|
||||||
|
#end if
|
||||||
|
#if $tenant['tenant_address2']
|
||||||
|
$tenant['tenant_address2']\\
|
||||||
|
#end if
|
||||||
|
#if $tenant['tenant_address3']
|
||||||
|
$tenant['tenant_address3']\\
|
||||||
|
#end if
|
||||||
|
$tenant['tenant_zip'] $tenant['tenant_city']}
|
||||||
|
\subject{Betriebskostenabrechnung $year}
|
||||||
|
\opening{$tenant['tenant_salutation'],}
|
||||||
|
|
||||||
|
f"ur die im vergangenen Jahr angefallenen Betriebskosten ergibt sich f"ur Sie folgende Abrechnung.
|
||||||
|
|
||||||
|
\begin{tabular}{|p{10cm}|r|}
|
||||||
|
\hline Jahr & \tt{$year} \\
|
||||||
|
\hline Haus & $tenant['house'] \\
|
||||||
|
\hline Betriebskosten gesamt & \tt{#echo '%.2f' % $total_overhead #\,\euro{}} \\
|
||||||
|
\hline Gesamt-Wohnfl"ache & \tt{$flat_area\,m\textsuperscript{2}} \\
|
||||||
|
\hline Ihre Wohnung & $tenant['flat'] \\
|
||||||
|
\hline Ihre Wohnfl"ache & \tt{$tenant['flat_area']\,m\textsuperscript{2}} \\
|
||||||
|
\hline Ihre Mietzeit & \tt{$tenant['rent_time']\,Monate} \\
|
||||||
|
\hline Ihr Betriebskostenanteil nach Fl"ache und Mietzeit & \tt{#echo '%.2f' % $receivable_overhead #\,\euro{}} \\
|
||||||
|
\hline Ihre Zahlungen & \tt{$tenant['paid_total']\,\euro{}} \\
|
||||||
|
\hline davon Anteil Miete & \tt{$tenant['receivable_fee']\,\euro{}} \\
|
||||||
|
\hline davon Anteil Betriebskostenvorauszahlung & \tt{$tenant['paid_overhead']\,\euro{}} \\
|
||||||
|
\hline
|
||||||
|
#if $unbalanced_overhead < 0
|
||||||
|
Zuwenig
|
||||||
|
#else
|
||||||
|
Zuviel
|
||||||
|
#end if
|
||||||
|
gezahlte Betriebskosten & \tt{#echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{}} \\
|
||||||
|
\hline
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
#if 1 < 0
|
||||||
|
Bitte "uberweisen Sie den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} kurzfristig auf mein Konto.
|
||||||
|
#else
|
||||||
|
Ich werde den Betrag von #echo '%.2f' % $unbalanced_overhead_unsigned #\,\euro{} in den n"achsten Tagen auf Ihr Konto "uberweisen.
|
||||||
|
#end if
|
||||||
|
|
||||||
|
Eine tabellarische "Ubersicht "uber die Zusammensetzung der Gesamt-Betriebskosten
|
||||||
|
finden Sie in der Anlage.
|
||||||
|
|
||||||
|
\closing{Mit freundlichen Gr"u"sen}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\end{letter}
|
||||||
|
\end{document}
|
2
cli/utils.py
Normal file
2
cli/utils.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def getParam(params, attr, default):
|
||||||
|
return params[attr] if attr in params else default
|
@ -3,6 +3,10 @@ from Cheetah.Template import Template
|
|||||||
import glob
|
import glob
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="generate.py")
|
parser = argparse.ArgumentParser(description="generate.py")
|
||||||
parser.add_argument('--schema', '-s',
|
parser.add_argument('--schema', '-s',
|
||||||
help='Schema file. Default: schema.json in the current folder.',
|
help='Schema file. Default: schema.json in the current folder.',
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
{ "name": "street", "sqltype": "varchar(128)", "notnull": true },
|
{ "name": "street", "sqltype": "varchar(128)", "notnull": true },
|
||||||
{ "name": "zip", "sqltype": "varchar(10)", "notnull": true },
|
{ "name": "zip", "sqltype": "varchar(10)", "notnull": true },
|
||||||
{ "name": "city", "sqltype": "varchar(128)", "notnull": true },
|
{ "name": "city", "sqltype": "varchar(128)", "notnull": true },
|
||||||
|
{ "name": "minus_area", "sqltype": "numeric(10,2)", "notnull": true, "default": 0},
|
||||||
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true, "immutable": true, "unique": true }
|
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true, "immutable": true, "unique": true }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -128,7 +129,8 @@
|
|||||||
"immutable": true,
|
"immutable": true,
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "name": "description", "sqltype": "varchar(128)", "notnull": true, "selector": 0, "unique": true },
|
{ "name": "description", "sqltype": "varchar(128)", "notnull": true, "selector": 0, "unique": true },
|
||||||
{ "name": "overhead_relevant", "sqltype": "boolean", "notnull": true, "default": "true" }
|
{ "name": "considerMinusArea", "sqltype": "boolean", "notnull": true, "default": true },
|
||||||
|
{ "name": "overhead_relevant", "sqltype": "boolean", "notnull": true, "default": true }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -138,7 +140,7 @@
|
|||||||
{ "name": "description", "sqltype": "varchar(1024)", "notnull": true },
|
{ "name": "description", "sqltype": "varchar(1024)", "notnull": true },
|
||||||
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
||||||
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()", "selector": 0 },
|
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()", "selector": 0 },
|
||||||
{ "name": "due_at", "sqltype": "timestamp", "notnull": false },
|
{ "name": "fiscal_year", "sqltype": "integer", "notnull": true },
|
||||||
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true },
|
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true },
|
||||||
{ "name": "document_no", "sqltype": "integer", "unique": true },
|
{ "name": "document_no", "sqltype": "integer", "unique": true },
|
||||||
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
|
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
|
||||||
|
17
schema/account-statement.sql
Normal file
17
schema/account-statement.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
create or replace view account_statement_v as
|
||||||
|
select ae.id as id,
|
||||||
|
ae.description as description,
|
||||||
|
ae.created_at::timestamp::date as created_at,
|
||||||
|
ae.amount as amount,
|
||||||
|
ae.document_no as document_no,
|
||||||
|
ae.fiscal_year as fiscal_year,
|
||||||
|
aec.description as category,
|
||||||
|
aec.income as income,
|
||||||
|
ac.description as account
|
||||||
|
from account_entry_t ae,
|
||||||
|
account_entry_category_t aec,
|
||||||
|
account_t ac
|
||||||
|
where ae.account_entry_category = aec.id and
|
||||||
|
ae.account = ac.id and
|
||||||
|
aec.id not in (3, 4)
|
||||||
|
order by created_at;
|
@ -39,6 +39,7 @@ CREATE TABLE premise_t (
|
|||||||
,street varchar(128) not null
|
,street varchar(128) not null
|
||||||
,zip varchar(10) not null
|
,zip varchar(10) not null
|
||||||
,city varchar(128) not null
|
,city varchar(128) not null
|
||||||
|
,minus_area numeric(10,2) not null default 0
|
||||||
,account integer not null references account_t (id) unique
|
,account integer not null references account_t (id) unique
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -139,7 +140,8 @@ GRANT SELECT, UPDATE ON tenancy_fee_mapping_t_id_seq TO hv2;
|
|||||||
CREATE TABLE account_entry_category_t (
|
CREATE TABLE account_entry_category_t (
|
||||||
id serial not null primary key
|
id serial not null primary key
|
||||||
,description varchar(128) not null unique
|
,description varchar(128) not null unique
|
||||||
,overhead_relevant boolean not null default true
|
,considerMinusArea boolean not null default True
|
||||||
|
,overhead_relevant boolean not null default True
|
||||||
);
|
);
|
||||||
|
|
||||||
GRANT SELECT, INSERT ON account_entry_category_t TO hv2;
|
GRANT SELECT, INSERT ON account_entry_category_t TO hv2;
|
||||||
@ -150,7 +152,7 @@ CREATE TABLE account_entry_t (
|
|||||||
,description varchar(1024) not null
|
,description varchar(1024) not null
|
||||||
,account integer not null references account_t (id)
|
,account integer not null references account_t (id)
|
||||||
,created_at timestamp not null default now()
|
,created_at timestamp not null default now()
|
||||||
,due_at timestamp
|
,fiscal_year integer not null
|
||||||
,amount numeric(10,2) not null
|
,amount numeric(10,2) not null
|
||||||
,document_no integer unique
|
,document_no integer unique
|
||||||
,account_entry_category integer not null references account_entry_category_t (id)
|
,account_entry_category integer not null references account_entry_category_t (id)
|
||||||
|
@ -6,11 +6,9 @@
|
|||||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline" id="addEntryfield">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Fälligkeit</mat-label>
|
<mat-label>Jahr</mat-label>
|
||||||
<input matInput ngModel name="dueAt" [matDatepicker]="dueAtPicker" [formControl]="presetDueAt"/>
|
<input matInput type="number" name="fiscalYear" [formControl]="presetFiscalYear" ngModel/>
|
||||||
<mat-datepicker-toggle matSuffix [for]="dueAtPicker"></mat-datepicker-toggle>
|
|
||||||
<mat-datepicker #dueAtPicker></mat-datepicker>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||||
<mat-label>Kategorie</mat-label>
|
<mat-label>Kategorie</mat-label>
|
||||||
@ -38,9 +36,9 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
|||||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="dueAt">
|
<ng-container matColumnDef="fiscalYear">
|
||||||
<th mat-header-cell *matHeaderCellDef>Fälligkeit</th>
|
<th mat-header-cell *matHeaderCellDef>Jahr</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.due_at | date}}</td>
|
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.fiscal_year}}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="description">
|
<ng-container matColumnDef="description">
|
||||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||||
|
@ -34,14 +34,14 @@ export class AccountComponent implements OnInit {
|
|||||||
account: Account
|
account: Account
|
||||||
accountEntries: DN_AccountEntry[]
|
accountEntries: DN_AccountEntry[]
|
||||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||||
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "dueAt", "category", "overhead_relevant" ]
|
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "fiscalYear", "category", "overhead_relevant" ]
|
||||||
saldo: Saldo
|
saldo: Saldo
|
||||||
|
|
||||||
accountEntryCategories: AccountEntryCategory[]
|
accountEntryCategories: AccountEntryCategory[]
|
||||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||||
|
|
||||||
presetDueAt: FormControl
|
presetFiscalYear: FormControl
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
@ -99,7 +99,7 @@ export class AccountComponent implements OnInit {
|
|||||||
description: formData.value.description,
|
description: formData.value.description,
|
||||||
account: this.account.id,
|
account: this.account.id,
|
||||||
created_at: formData.value.createdAt,
|
created_at: formData.value.createdAt,
|
||||||
due_at: formData.value.dueAt,
|
fiscal_year: this.presetFiscalYear.value,
|
||||||
amount: formData.value.amount,
|
amount: formData.value.amount,
|
||||||
id: 0,
|
id: 0,
|
||||||
document_no: uniquenumber.number,
|
document_no: uniquenumber.number,
|
||||||
@ -147,12 +147,8 @@ export class AccountComponent implements OnInit {
|
|||||||
|
|
||||||
private async init(): Promise<void> {
|
private async init(): Promise<void> {
|
||||||
let currentDate = new Date()
|
let currentDate = new Date()
|
||||||
let y = currentDate.getFullYear().toString()
|
let y = currentDate.getFullYear()
|
||||||
let m = (currentDate.getMonth()+1).toString()
|
this.presetFiscalYear = new FormControl(y)
|
||||||
if (m.length == 1) {
|
|
||||||
m = `0${m}`
|
|
||||||
}
|
|
||||||
this.presetDueAt = new FormControl(`${y}-${m}-01`)
|
|
||||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||||
this.getAccount()
|
this.getAccount()
|
||||||
await this.getAccountEntryCategories()
|
await this.getAccountEntryCategories()
|
||||||
|
@ -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.10.38:5000";
|
// export const serviceBaseUrl = "http://172.16.10.38:5000";
|
||||||
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"
|
||||||
|
@ -52,6 +52,7 @@ export interface Premise {
|
|||||||
street: string
|
street: string
|
||||||
zip: string
|
zip: string
|
||||||
city: string
|
city: string
|
||||||
|
minus_area: number
|
||||||
account: number
|
account: number
|
||||||
}
|
}
|
||||||
export const NULL_Premise: Premise = {
|
export const NULL_Premise: Premise = {
|
||||||
@ -60,6 +61,7 @@ export const NULL_Premise: Premise = {
|
|||||||
,street: ''
|
,street: ''
|
||||||
,zip: ''
|
,zip: ''
|
||||||
,city: ''
|
,city: ''
|
||||||
|
,minus_area: undefined
|
||||||
,account: undefined
|
,account: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +182,13 @@ export const NULL_TenancyFeeMapping: TenancyFeeMapping = {
|
|||||||
export interface AccountEntryCategory {
|
export interface AccountEntryCategory {
|
||||||
id: number
|
id: number
|
||||||
description: string
|
description: string
|
||||||
|
considerMinusArea: boolean
|
||||||
overhead_relevant: boolean
|
overhead_relevant: boolean
|
||||||
}
|
}
|
||||||
export const NULL_AccountEntryCategory: AccountEntryCategory = {
|
export const NULL_AccountEntryCategory: AccountEntryCategory = {
|
||||||
id: 0
|
id: 0
|
||||||
,description: ''
|
,description: ''
|
||||||
|
,considerMinusArea: false
|
||||||
,overhead_relevant: false
|
,overhead_relevant: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +197,7 @@ export interface AccountEntry {
|
|||||||
description: string
|
description: string
|
||||||
account: number
|
account: number
|
||||||
created_at: string
|
created_at: string
|
||||||
due_at: string
|
fiscal_year: number
|
||||||
amount: number
|
amount: number
|
||||||
document_no: number
|
document_no: number
|
||||||
account_entry_category: number
|
account_entry_category: number
|
||||||
@ -203,7 +207,7 @@ export const NULL_AccountEntry: AccountEntry = {
|
|||||||
,description: ''
|
,description: ''
|
||||||
,account: undefined
|
,account: undefined
|
||||||
,created_at: ''
|
,created_at: ''
|
||||||
,due_at: ''
|
,fiscal_year: undefined
|
||||||
,amount: undefined
|
,amount: undefined
|
||||||
,document_no: undefined
|
,document_no: undefined
|
||||||
,account_entry_category: undefined
|
,account_entry_category: undefined
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
<th mat-header-cell *matHeaderCellDef>Ort</th>
|
<th mat-header-cell *matHeaderCellDef>Ort</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.city}}</td>
|
<td mat-cell *matCellDef="let element">{{element.city}}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
<ng-container matColumnDef="minusArea">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>Minus-Fläche</th>
|
||||||
|
<td mat-cell *matCellDef="let element">{{element.minus_area | number:'1.2-2'}}</td>
|
||||||
|
</ng-container>
|
||||||
<ng-container matColumnDef="account">
|
<ng-container matColumnDef="account">
|
||||||
<th mat-header-cell *matHeaderCellDef>Betriebskostenkonto</th>
|
<th mat-header-cell *matHeaderCellDef>Betriebskostenkonto</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.account}}</td>
|
<td mat-cell *matCellDef="let element">{{element.account}}</td>
|
||||||
|
@ -13,7 +13,7 @@ export class MyPremisesComponent implements OnInit {
|
|||||||
|
|
||||||
premises: Premise[]
|
premises: Premise[]
|
||||||
dataSource: MatTableDataSource<Premise>
|
dataSource: MatTableDataSource<Premise>
|
||||||
displayedColumns: string[] = [ "description", "street", "zip", "city", "account" ]
|
displayedColumns: string[] = [ "description", "street", "zip", "city", "minusArea", "account" ]
|
||||||
|
|
||||||
|
|
||||||
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
<mat-label>Ort</mat-label>
|
<mat-label>Ort</mat-label>
|
||||||
<input matInput name="city" [(ngModel)]="premise.city"/>
|
<input matInput name="city" [(ngModel)]="premise.city"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
</div><div>
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Minus-Fläche</mat-label>
|
||||||
|
<input type="number" matInput name="minusArea" [(ngModel)]="premise.minus_area"/>
|
||||||
|
</mat-form-field>
|
||||||
</div><div>
|
</div><div>
|
||||||
<mat-form-field appearance="outline" *ngIf="premise.account">
|
<mat-form-field appearance="outline" *ngIf="premise.account">
|
||||||
<mat-label>Betriebskostenkonto</mat-label>
|
<mat-label>Betriebskostenkonto</mat-label>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user