Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
b748ba7a77
|
|||
ab365c65a1 | |||
0e4fd12238
|
|||
cb632e9e8e
|
|||
2fc7922707
|
|||
422a8d37ab | |||
006b488c63 | |||
1d36d99462 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,4 +5,4 @@ api/config/authservice.pub
|
||||
cli/config/dbconfig.ini
|
||||
*~
|
||||
.*~
|
||||
|
||||
.vscode/
|
||||
|
@ -269,6 +269,9 @@ SELECT
|
||||
,account
|
||||
FROM tenant_t
|
||||
WHERE account = %s
|
||||
ORDER BY
|
||||
lastname
|
||||
,firstname
|
||||
""",
|
||||
"params": (accountId, )
|
||||
}
|
||||
@ -391,6 +394,8 @@ SELECT
|
||||
,account
|
||||
FROM premise_t
|
||||
WHERE account = %s
|
||||
ORDER BY
|
||||
description
|
||||
""",
|
||||
"params": (accountId, )
|
||||
}
|
||||
@ -507,6 +512,9 @@ SELECT
|
||||
,flat_no
|
||||
FROM flat_t
|
||||
WHERE premise = %s
|
||||
ORDER BY
|
||||
premise
|
||||
,description
|
||||
""",
|
||||
"params": (premiseId, )
|
||||
}
|
||||
@ -674,6 +682,9 @@ SELECT
|
||||
,flat
|
||||
FROM overhead_advance_flat_mapping_t
|
||||
WHERE overhead_advance = %s
|
||||
ORDER BY
|
||||
overhead_advance
|
||||
,flat
|
||||
""",
|
||||
"params": (overhead_advanceId, )
|
||||
}
|
||||
@ -688,6 +699,9 @@ SELECT
|
||||
,flat
|
||||
FROM overhead_advance_flat_mapping_t
|
||||
WHERE flat = %s
|
||||
ORDER BY
|
||||
overhead_advance
|
||||
,flat
|
||||
""",
|
||||
"params": (flatId, )
|
||||
}
|
||||
@ -784,6 +798,9 @@ SELECT
|
||||
,premise
|
||||
FROM parking_t
|
||||
WHERE premise = %s
|
||||
ORDER BY
|
||||
premise
|
||||
,description
|
||||
""",
|
||||
"params": (premiseId, )
|
||||
}
|
||||
@ -796,6 +813,7 @@ SELECT
|
||||
id
|
||||
,description
|
||||
,premise
|
||||
,area
|
||||
FROM commercial_premise_t
|
||||
ORDER BY
|
||||
premise
|
||||
@ -810,21 +828,25 @@ def insert_commercial_premise(user, token_info, **args):
|
||||
body = args["body"]
|
||||
v_description = body["description"]
|
||||
v_premise = body["premise"]
|
||||
v_area = body["area"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
INSERT INTO commercial_premise_t
|
||||
(
|
||||
description
|
||||
,premise
|
||||
,area
|
||||
) VALUES (
|
||||
%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
"params": [
|
||||
v_description
|
||||
,v_premise
|
||||
,v_area
|
||||
]
|
||||
})
|
||||
except KeyError as e:
|
||||
@ -839,6 +861,7 @@ SELECT
|
||||
id
|
||||
,description
|
||||
,premise
|
||||
,area
|
||||
FROM commercial_premise_t
|
||||
WHERE id = %s
|
||||
""",
|
||||
@ -851,18 +874,21 @@ def update_commercial_premise(user, token_info, commercial_premiseId=None, **arg
|
||||
body = args["body"]
|
||||
v_description = body["description"]
|
||||
v_premise = body["premise"]
|
||||
v_area = body["area"]
|
||||
return dbUpdate(user, token_info, {
|
||||
"statement": """
|
||||
UPDATE commercial_premise_t
|
||||
SET
|
||||
description = %s
|
||||
,premise = %s
|
||||
,area = %s
|
||||
WHERE id = %s
|
||||
RETURNING *
|
||||
""",
|
||||
"params": [
|
||||
v_description,
|
||||
v_premise,
|
||||
v_area,
|
||||
commercial_premiseId
|
||||
]
|
||||
})
|
||||
@ -878,8 +904,12 @@ SELECT
|
||||
id
|
||||
,description
|
||||
,premise
|
||||
,area
|
||||
FROM commercial_premise_t
|
||||
WHERE premise = %s
|
||||
ORDER BY
|
||||
premise
|
||||
,description
|
||||
""",
|
||||
"params": (premiseId, )
|
||||
}
|
||||
@ -1011,6 +1041,9 @@ SELECT
|
||||
,enddate
|
||||
FROM tenancy_t
|
||||
WHERE tenant = %s
|
||||
ORDER BY
|
||||
description
|
||||
,startdate
|
||||
""",
|
||||
"params": (tenantId, )
|
||||
}
|
||||
@ -1030,6 +1063,9 @@ SELECT
|
||||
,enddate
|
||||
FROM tenancy_t
|
||||
WHERE flat = %s
|
||||
ORDER BY
|
||||
description
|
||||
,startdate
|
||||
""",
|
||||
"params": (flatId, )
|
||||
}
|
||||
@ -1049,6 +1085,9 @@ SELECT
|
||||
,enddate
|
||||
FROM tenancy_t
|
||||
WHERE parking = %s
|
||||
ORDER BY
|
||||
description
|
||||
,startdate
|
||||
""",
|
||||
"params": (parkingId, )
|
||||
}
|
||||
@ -1068,6 +1107,9 @@ SELECT
|
||||
,enddate
|
||||
FROM tenancy_t
|
||||
WHERE commercial_premise = %s
|
||||
ORDER BY
|
||||
description
|
||||
,startdate
|
||||
""",
|
||||
"params": (commercial_premiseId, )
|
||||
}
|
||||
@ -1323,12 +1365,13 @@ SELECT
|
||||
,description
|
||||
,account
|
||||
,created_at
|
||||
,fiscal_year
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
ORDER BY
|
||||
amount
|
||||
created_at
|
||||
""",
|
||||
"params": ()
|
||||
}
|
||||
@ -1340,6 +1383,7 @@ def insert_account_entry(user, token_info, **args):
|
||||
v_description = body["description"]
|
||||
v_account = body["account"]
|
||||
v_created_at = body["created_at"]
|
||||
v_fiscal_year = body["fiscal_year"]
|
||||
v_amount = body["amount"]
|
||||
v_document_no = body["document_no"]
|
||||
v_account_entry_category = body["account_entry_category"]
|
||||
@ -1350,6 +1394,7 @@ INSERT INTO account_entry_t
|
||||
description
|
||||
,account
|
||||
,created_at
|
||||
,fiscal_year
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
@ -1360,6 +1405,7 @@ INSERT INTO account_entry_t
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
@ -1367,6 +1413,7 @@ INSERT INTO account_entry_t
|
||||
v_description
|
||||
,v_account
|
||||
,v_created_at
|
||||
,v_fiscal_year
|
||||
,v_amount
|
||||
,v_document_no
|
||||
,v_account_entry_category
|
||||
@ -1385,6 +1432,7 @@ SELECT
|
||||
,description
|
||||
,account
|
||||
,created_at
|
||||
,fiscal_year
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
@ -1405,11 +1453,14 @@ SELECT
|
||||
,description
|
||||
,account
|
||||
,created_at
|
||||
,fiscal_year
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
WHERE account = %s
|
||||
ORDER BY
|
||||
created_at
|
||||
""",
|
||||
"params": (accountId, )
|
||||
}
|
||||
@ -1423,11 +1474,14 @@ SELECT
|
||||
,description
|
||||
,account
|
||||
,created_at
|
||||
,fiscal_year
|
||||
,amount
|
||||
,document_no
|
||||
,account_entry_category
|
||||
FROM account_entry_t
|
||||
WHERE account_entry_category = %s
|
||||
ORDER BY
|
||||
created_at
|
||||
""",
|
||||
"params": (account_entry_categoryId, )
|
||||
}
|
||||
@ -1442,6 +1496,8 @@ SELECT
|
||||
,tenant
|
||||
,note
|
||||
FROM note_t
|
||||
ORDER BY
|
||||
created_at
|
||||
""",
|
||||
"params": ()
|
||||
}
|
||||
@ -1505,6 +1561,8 @@ SELECT
|
||||
,note
|
||||
FROM note_t
|
||||
WHERE tenant = %s
|
||||
ORDER BY
|
||||
created_at
|
||||
""",
|
||||
"params": (tenantId, )
|
||||
}
|
||||
|
@ -129,6 +129,14 @@ SELECT
|
||||
#end for
|
||||
FROM ${table.name}_t
|
||||
WHERE ${column.name} = %s
|
||||
#if $table.selectors
|
||||
ORDER BY
|
||||
#set $sep = ""
|
||||
#for $selector in $table.selectors
|
||||
$sep$selector
|
||||
#set $sep = ","
|
||||
#end for
|
||||
#end if
|
||||
""",
|
||||
"params": (${column.name}Id, )
|
||||
}
|
||||
|
@ -1714,6 +1714,9 @@ components:
|
||||
premise:
|
||||
type: integer
|
||||
nullable: true
|
||||
area:
|
||||
type: number
|
||||
nullable: true
|
||||
tenancy:
|
||||
description: tenancy
|
||||
type: object
|
||||
@ -1790,6 +1793,8 @@ components:
|
||||
type: integer
|
||||
created_at:
|
||||
type: string
|
||||
fiscal_year:
|
||||
type: integer
|
||||
amount:
|
||||
type: number
|
||||
document_no:
|
||||
|
@ -5,6 +5,6 @@ from flask_cors import CORS
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
app = connexion.App('hv2-api')
|
||||
app.add_api('./openapi.yaml')
|
||||
app.add_api('./openapi.yaml', options = {"swagger_ui": True})
|
||||
CORS(app.app)
|
||||
app.run(port=8080)
|
||||
|
@ -6,8 +6,10 @@ import datetime
|
||||
def perform(dbh, params):
|
||||
try:
|
||||
createdAt = params['created_at']
|
||||
dueAt = createdAt.replace(day=1)
|
||||
except KeyError:
|
||||
createdAt = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||
dueAt = createdAt.replace(day=1)
|
||||
|
||||
tenants = dbGetMany(dbh, { "statement": "SELECT * FROM tenant_t", "params": () })
|
||||
for tenant in tenants:
|
||||
|
173
cli/OverheadAccounts.py
Normal file
173
cli/OverheadAccounts.py
Normal file
@ -0,0 +1,173 @@
|
||||
from db import dbGetMany, dbGetOne
|
||||
import datetime
|
||||
from loguru import logger
|
||||
from decimal import *
|
||||
|
||||
def perform(dbh, params):
|
||||
try:
|
||||
year = params['year']
|
||||
except KeyError:
|
||||
year = datetime.datetime.today().year
|
||||
startDate = datetime.datetime(year, 1, 1, 0, 0, 0)
|
||||
endDate = datetime.datetime(year, 12, 31, 23, 59, 59)
|
||||
premises = (1, 2)
|
||||
|
||||
|
||||
|
||||
# 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:
|
||||
v = [ x['sum'] for x in overheadSums if x['house_id'] == premise ]
|
||||
logger.info(f"{v=}")
|
||||
subtotal[premise] = sum(v)
|
||||
logger.info(f"{subtotal=}")
|
||||
|
||||
|
||||
|
||||
|
||||
# get flat tenants by object and timespan with paid overhead and due overhead
|
||||
tenants = dbGetMany(
|
||||
dbh,
|
||||
{
|
||||
"statement":
|
||||
"""
|
||||
select t.id as tenant_id,
|
||||
t.firstname as tenant_firstname,
|
||||
t.lastname as tenant_lastname,
|
||||
f.id as flat_id,
|
||||
f.description as flat,
|
||||
p.id as house_id,
|
||||
p.description as house,
|
||||
ty.startdate as startdate,
|
||||
ty.enddate as enddate,
|
||||
t.account as tenant_account
|
||||
from tenant_t t,
|
||||
premise_t p,
|
||||
flat_t f,
|
||||
tenancy_t ty
|
||||
where ty.tenant = t.id and
|
||||
ty.flat = f.id and
|
||||
ty.startdate <= %(startDate)s and
|
||||
(ty.enddate >= %(endDate)s or ty.enddate is null) and
|
||||
f.premise = p.id and
|
||||
p.id in %(premises)s
|
||||
order by house_id, tenant_id
|
||||
""",
|
||||
"params": {
|
||||
"startDate": startDate,
|
||||
"endDate": endDate,
|
||||
"premises": premises
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
for tenant in tenants:
|
||||
logger.info(f"firstname: {tenant['tenant_firstname']}, lastname: {tenant['tenant_lastname']}, house: {tenant['house']}, account: {tenant['tenant_account']}")
|
||||
|
||||
paidTotal = dbGetOne(
|
||||
dbh,
|
||||
{
|
||||
"statement":
|
||||
"""
|
||||
SELECT sum(amount) AS sum,
|
||||
count(id) AS cnt
|
||||
FROM account_entry_t
|
||||
WHERE account = %(account)s AND
|
||||
account_entry_category = 2 AND
|
||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
||||
""",
|
||||
"params": {
|
||||
"account": tenant['tenant_account'],
|
||||
"startDate": startDate,
|
||||
"endDate": endDate
|
||||
}
|
||||
}
|
||||
)
|
||||
receivableFee = dbGetOne(
|
||||
dbh,
|
||||
{
|
||||
"statement":
|
||||
"""
|
||||
SELECT sum(amount) * -1 AS sum ,
|
||||
count(id) AS cnt
|
||||
FROM account_entry_t
|
||||
WHERE account = %(account)s AND
|
||||
account_entry_category = 3 AND
|
||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
||||
""",
|
||||
"params": {
|
||||
"account": tenant['tenant_account'],
|
||||
"startDate": startDate,
|
||||
"endDate": endDate
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
logger.info(f"Payments: cnt: {paidTotal['cnt']}, sum: {paidTotal['sum']}")
|
||||
logger.info(f"Receivable fees: cnt: {receivableFee['cnt']}, sum: {receivableFee['sum']}")
|
||||
|
||||
paidOverheadAdvance = paidTotal['sum'] - receivableFee['sum']
|
||||
logger.info(f"Paid overhead: {paidOverheadAdvance} (by month: {paidOverheadAdvance / Decimal(12)})")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ 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"] ]
|
||||
# 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:
|
||||
@ -21,6 +21,7 @@ def execDatabaseOperation(dbh, func, params):
|
||||
|
||||
|
||||
def _opGetMany(cursor, params):
|
||||
#logger.warning(f"{params=}")
|
||||
items = []
|
||||
cursor.execute(params["statement"], params["params"])
|
||||
for itemObj in cursor:
|
||||
|
38
cli/fixDueDate.py
Normal file
38
cli/fixDueDate.py
Normal file
@ -0,0 +1,38 @@
|
||||
from loguru import logger
|
||||
from db import dbGetMany, dbGetOne
|
||||
|
||||
def perform(dbh, params):
|
||||
accountEntries = dbGetMany(
|
||||
dbh,
|
||||
{
|
||||
"statement":
|
||||
"""
|
||||
select id, due_at from account_entry_t where due_at is not null
|
||||
""",
|
||||
"params": {}
|
||||
}
|
||||
)
|
||||
|
||||
for accountEntry in accountEntries:
|
||||
id = accountEntry['id']
|
||||
oldDueAt = accountEntry['due_at']
|
||||
newDueAt = oldDueAt.replace(day=1)
|
||||
logger.info(f"id: {id}, due_at: {oldDueAt} -> {newDueAt}")
|
||||
|
||||
fixedEntry = dbGetOne(
|
||||
dbh,
|
||||
{
|
||||
"statement":
|
||||
"""
|
||||
UPDATE account_entry_t
|
||||
SET due_at = %(dueAt)s
|
||||
WHERE id = %(id)s
|
||||
RETURNING *
|
||||
""",
|
||||
"params": {
|
||||
"id": id,
|
||||
"dueAt": newDueAt
|
||||
}
|
||||
}
|
||||
)
|
||||
logger.info("fixed")
|
@ -8,25 +8,12 @@ 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('--config', '-c',
|
||||
help="Config file, default is ./config/dbconfig.ini",
|
||||
required=False,
|
||||
default="./config/dbconfig.ini")
|
||||
parser.add_argument('--operation', '-o',
|
||||
help='Operation to perform.',
|
||||
required=True)
|
||||
@ -44,12 +31,30 @@ parser.add_argument('--nocolorize', '-n',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
operation = args.operation
|
||||
params = json.loads(args.params)
|
||||
logLevel = args.verbosity
|
||||
noColorize = args.nocolorize
|
||||
|
||||
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(args.config)
|
||||
DB_USER = config["database"]["user"]
|
||||
DB_PASS = config["database"]["pass"]
|
||||
DB_HOST = config["database"]["host"]
|
||||
DB_NAME = config["database"]["name"]
|
||||
|
||||
|
||||
logger.remove()
|
||||
logger.add(sys.stderr, colorize=(not noColorize), level=logLevel)
|
||||
|
10
schema.json
10
schema.json
@ -79,7 +79,8 @@
|
||||
"name": "commercial_premise",
|
||||
"columns": [
|
||||
{ "name": "description", "sqltype": "varchar(128)", "selector": 1 },
|
||||
{ "name": "premise", "sqltype": "integer", "foreignkey": true, "selector": 0 }
|
||||
{ "name": "premise", "sqltype": "integer", "foreignkey": true, "selector": 0 },
|
||||
{ "name": "area", "sqltype": "numeric(10,2)", "notnull": false }
|
||||
],
|
||||
"tableConstraints": [
|
||||
"unique(description, premise)"
|
||||
@ -136,8 +137,9 @@
|
||||
"columns": [
|
||||
{ "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": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()", "selector": 0 },
|
||||
{ "name": "fiscal_year", "sqltype": "integer", "notnull": true },
|
||||
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true },
|
||||
{ "name": "document_no", "sqltype": "integer", "unique": true },
|
||||
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
|
||||
],
|
||||
@ -149,7 +151,7 @@
|
||||
"name": "note",
|
||||
"immutable": true,
|
||||
"columns": [
|
||||
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()" },
|
||||
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()", "selector": 0 },
|
||||
{ "name": "tenant", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
||||
{ "name": "note", "sqltype": "varchar(4096)", "notnull": true }
|
||||
]
|
||||
|
@ -91,6 +91,7 @@ CREATE TABLE commercial_premise_t (
|
||||
id serial not null primary key
|
||||
,description varchar(128)
|
||||
,premise integer references premise_t (id)
|
||||
,area numeric(10,2)
|
||||
,unique(description, premise)
|
||||
);
|
||||
|
||||
@ -149,6 +150,7 @@ CREATE TABLE account_entry_t (
|
||||
,description varchar(1024) not null
|
||||
,account integer not null references account_t (id)
|
||||
,created_at timestamp not null default now()
|
||||
,fiscal_year integer not null
|
||||
,amount numeric(10,2) not null
|
||||
,document_no integer unique
|
||||
,account_entry_category integer not null references account_entry_category_t (id)
|
||||
|
@ -6,6 +6,10 @@
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Jahr</mat-label>
|
||||
<input matInput type="number" name="fiscalYear" [formControl]="presetFiscalYear" ngModel/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||
@ -32,6 +36,10 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="fiscalYear">
|
||||
<th mat-header-cell *matHeaderCellDef>Jahr</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.fiscal_year}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="description">
|
||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { ViewFlags } from '@angular/compiler/src/core';
|
||||
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
@ -33,14 +34,14 @@ export class AccountComponent implements OnInit {
|
||||
account: Account
|
||||
accountEntries: DN_AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "category", "overhead_relevant" ]
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "fiscalYear", "category", "overhead_relevant" ]
|
||||
saldo: Saldo
|
||||
|
||||
accountEntryCategories: AccountEntryCategory[]
|
||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
|
||||
presetFiscalYear: FormControl
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
@ -98,6 +99,7 @@ export class AccountComponent implements OnInit {
|
||||
description: formData.value.description,
|
||||
account: this.account.id,
|
||||
created_at: formData.value.createdAt,
|
||||
fiscal_year: formData.value.fiscalYear,
|
||||
amount: formData.value.amount,
|
||||
id: 0,
|
||||
document_no: uniquenumber.number,
|
||||
@ -144,9 +146,13 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
|
||||
private async init(): Promise<void> {
|
||||
let currentDate = new Date()
|
||||
let y = currentDate.getFullYear().toString()
|
||||
this.presetFiscalYear = new FormControl(`${y}`)
|
||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
await this.getAccountEntryCategories()
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@ -22,6 +22,10 @@
|
||||
<mat-option *ngFor="let p of premises" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Fläche</mat-label>
|
||||
<input type="number" matInput name="area" [(ngModel)]="commercialPremise.area"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
|
@ -119,11 +119,13 @@ export interface CommercialPremise {
|
||||
id: number
|
||||
description: string
|
||||
premise: number
|
||||
area: number
|
||||
}
|
||||
export const NULL_CommercialPremise: CommercialPremise = {
|
||||
id: 0
|
||||
,description: ''
|
||||
,premise: undefined
|
||||
,area: undefined
|
||||
}
|
||||
|
||||
export interface Tenancy {
|
||||
@ -191,6 +193,7 @@ export interface AccountEntry {
|
||||
description: string
|
||||
account: number
|
||||
created_at: string
|
||||
fiscal_year: number
|
||||
amount: number
|
||||
document_no: number
|
||||
account_entry_category: number
|
||||
@ -200,6 +203,7 @@ export const NULL_AccountEntry: AccountEntry = {
|
||||
,description: ''
|
||||
,account: undefined
|
||||
,created_at: ''
|
||||
,fiscal_year: undefined
|
||||
,amount: undefined
|
||||
,document_no: undefined
|
||||
,account_entry_category: undefined
|
||||
|
@ -19,8 +19,13 @@
|
||||
<th mat-header-cell *matHeaderCellDef>Haus</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.premise.description}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="area">
|
||||
<th mat-header-cell *matHeaderCellDef>Fläche</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.commercialPremise.area | number:'1.2-2'}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/commercialunit/', row.commercialPremise.id]"></tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
@ -21,7 +21,7 @@ export class MyCommercialUnitsComponent implements OnInit {
|
||||
dnCommercialPremises: DN_CommercialPremise[] = []
|
||||
|
||||
dataSource: MatTableDataSource<DN_CommercialPremise>
|
||||
displayedColumns: string[] = ["description", "premise"]
|
||||
displayedColumns: string[] = ["description", "premise", "area"]
|
||||
|
||||
constructor(
|
||||
private commercialPremiseService: CommercialPremiseService,
|
||||
|
Reference in New Issue
Block a user