Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
0e4fd12238
|
|||
cb632e9e8e
|
|||
2fc7922707
|
|||
422a8d37ab | |||
006b488c63 | |||
1d36d99462 | |||
05fb3c1677 | |||
cbc96036d9
|
|||
44202ef9ed
|
|||
34f8e8ecd4
|
|||
6f3248f03c
|
|||
3c97fb3582
|
|||
3ad019b374
|
|||
28e505f570
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,4 +3,6 @@ ENV
|
|||||||
api/config/dbconfig.ini
|
api/config/dbconfig.ini
|
||||||
api/config/authservice.pub
|
api/config/authservice.pub
|
||||||
cli/config/dbconfig.ini
|
cli/config/dbconfig.ini
|
||||||
|
*~
|
||||||
|
.*~
|
||||||
|
.vscode/
|
||||||
|
@ -110,4 +110,21 @@
|
|||||||
$ref: '#/components/schemas/account'
|
$ref: '#/components/schemas/account'
|
||||||
security:
|
security:
|
||||||
- jwt: ['secret']
|
- 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']
|
||||||
|
|
||||||
|
@ -54,3 +54,10 @@ SELECT a.id ,a.description
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_unique_number(user, token_info):
|
||||||
|
return dbGetOne(user, token_info, {
|
||||||
|
"statement": """
|
||||||
|
SELECT nextval('unique_number_s') AS "number"
|
||||||
|
""",
|
||||||
|
"params": ()
|
||||||
|
})
|
||||||
|
@ -269,6 +269,9 @@ SELECT
|
|||||||
,account
|
,account
|
||||||
FROM tenant_t
|
FROM tenant_t
|
||||||
WHERE account = %s
|
WHERE account = %s
|
||||||
|
ORDER BY
|
||||||
|
lastname
|
||||||
|
,firstname
|
||||||
""",
|
""",
|
||||||
"params": (accountId, )
|
"params": (accountId, )
|
||||||
}
|
}
|
||||||
@ -283,6 +286,7 @@ SELECT
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
ORDER BY
|
ORDER BY
|
||||||
description
|
description
|
||||||
@ -298,6 +302,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_account = body["account"]
|
||||||
return dbInsert(user, token_info, {
|
return dbInsert(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
INSERT INTO premise_t
|
INSERT INTO premise_t
|
||||||
@ -306,11 +311,13 @@ INSERT INTO premise_t
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,account
|
||||||
) VALUES (
|
) VALUES (
|
||||||
%s
|
%s
|
||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
@ -319,6 +326,7 @@ INSERT INTO premise_t
|
|||||||
,v_street
|
,v_street
|
||||||
,v_zip
|
,v_zip
|
||||||
,v_city
|
,v_city
|
||||||
|
,v_account
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
@ -335,6 +343,7 @@ SELECT
|
|||||||
,street
|
,street
|
||||||
,zip
|
,zip
|
||||||
,city
|
,city
|
||||||
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
""",
|
""",
|
||||||
@ -373,6 +382,25 @@ UPDATE premise_t
|
|||||||
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
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
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
""",
|
||||||
|
"params": (accountId, )
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def get_flats(user, token_info):
|
def get_flats(user, token_info):
|
||||||
return dbGetMany(user, token_info, {
|
return dbGetMany(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
@ -484,6 +512,9 @@ SELECT
|
|||||||
,flat_no
|
,flat_no
|
||||||
FROM flat_t
|
FROM flat_t
|
||||||
WHERE premise = %s
|
WHERE premise = %s
|
||||||
|
ORDER BY
|
||||||
|
premise
|
||||||
|
,description
|
||||||
""",
|
""",
|
||||||
"params": (premiseId, )
|
"params": (premiseId, )
|
||||||
}
|
}
|
||||||
@ -651,6 +682,9 @@ SELECT
|
|||||||
,flat
|
,flat
|
||||||
FROM overhead_advance_flat_mapping_t
|
FROM overhead_advance_flat_mapping_t
|
||||||
WHERE overhead_advance = %s
|
WHERE overhead_advance = %s
|
||||||
|
ORDER BY
|
||||||
|
overhead_advance
|
||||||
|
,flat
|
||||||
""",
|
""",
|
||||||
"params": (overhead_advanceId, )
|
"params": (overhead_advanceId, )
|
||||||
}
|
}
|
||||||
@ -665,6 +699,9 @@ SELECT
|
|||||||
,flat
|
,flat
|
||||||
FROM overhead_advance_flat_mapping_t
|
FROM overhead_advance_flat_mapping_t
|
||||||
WHERE flat = %s
|
WHERE flat = %s
|
||||||
|
ORDER BY
|
||||||
|
overhead_advance
|
||||||
|
,flat
|
||||||
""",
|
""",
|
||||||
"params": (flatId, )
|
"params": (flatId, )
|
||||||
}
|
}
|
||||||
@ -761,6 +798,9 @@ SELECT
|
|||||||
,premise
|
,premise
|
||||||
FROM parking_t
|
FROM parking_t
|
||||||
WHERE premise = %s
|
WHERE premise = %s
|
||||||
|
ORDER BY
|
||||||
|
premise
|
||||||
|
,description
|
||||||
""",
|
""",
|
||||||
"params": (premiseId, )
|
"params": (premiseId, )
|
||||||
}
|
}
|
||||||
@ -773,6 +813,7 @@ SELECT
|
|||||||
id
|
id
|
||||||
,description
|
,description
|
||||||
,premise
|
,premise
|
||||||
|
,area
|
||||||
FROM commercial_premise_t
|
FROM commercial_premise_t
|
||||||
ORDER BY
|
ORDER BY
|
||||||
premise
|
premise
|
||||||
@ -787,21 +828,25 @@ def insert_commercial_premise(user, token_info, **args):
|
|||||||
body = args["body"]
|
body = args["body"]
|
||||||
v_description = body["description"]
|
v_description = body["description"]
|
||||||
v_premise = body["premise"]
|
v_premise = body["premise"]
|
||||||
|
v_area = body["area"]
|
||||||
return dbInsert(user, token_info, {
|
return dbInsert(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
INSERT INTO commercial_premise_t
|
INSERT INTO commercial_premise_t
|
||||||
(
|
(
|
||||||
description
|
description
|
||||||
,premise
|
,premise
|
||||||
|
,area
|
||||||
) VALUES (
|
) VALUES (
|
||||||
%s
|
%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
"params": [
|
"params": [
|
||||||
v_description
|
v_description
|
||||||
,v_premise
|
,v_premise
|
||||||
|
,v_area
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
@ -816,6 +861,7 @@ SELECT
|
|||||||
id
|
id
|
||||||
,description
|
,description
|
||||||
,premise
|
,premise
|
||||||
|
,area
|
||||||
FROM commercial_premise_t
|
FROM commercial_premise_t
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
""",
|
""",
|
||||||
@ -828,18 +874,21 @@ def update_commercial_premise(user, token_info, commercial_premiseId=None, **arg
|
|||||||
body = args["body"]
|
body = args["body"]
|
||||||
v_description = body["description"]
|
v_description = body["description"]
|
||||||
v_premise = body["premise"]
|
v_premise = body["premise"]
|
||||||
|
v_area = body["area"]
|
||||||
return dbUpdate(user, token_info, {
|
return dbUpdate(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
UPDATE commercial_premise_t
|
UPDATE commercial_premise_t
|
||||||
SET
|
SET
|
||||||
description = %s
|
description = %s
|
||||||
,premise = %s
|
,premise = %s
|
||||||
|
,area = %s
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
"params": [
|
"params": [
|
||||||
v_description,
|
v_description,
|
||||||
v_premise,
|
v_premise,
|
||||||
|
v_area,
|
||||||
commercial_premiseId
|
commercial_premiseId
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -855,8 +904,12 @@ SELECT
|
|||||||
id
|
id
|
||||||
,description
|
,description
|
||||||
,premise
|
,premise
|
||||||
|
,area
|
||||||
FROM commercial_premise_t
|
FROM commercial_premise_t
|
||||||
WHERE premise = %s
|
WHERE premise = %s
|
||||||
|
ORDER BY
|
||||||
|
premise
|
||||||
|
,description
|
||||||
""",
|
""",
|
||||||
"params": (premiseId, )
|
"params": (premiseId, )
|
||||||
}
|
}
|
||||||
@ -988,6 +1041,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE tenant = %s
|
WHERE tenant = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (tenantId, )
|
"params": (tenantId, )
|
||||||
}
|
}
|
||||||
@ -1007,6 +1063,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE flat = %s
|
WHERE flat = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (flatId, )
|
"params": (flatId, )
|
||||||
}
|
}
|
||||||
@ -1026,6 +1085,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE parking = %s
|
WHERE parking = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (parkingId, )
|
"params": (parkingId, )
|
||||||
}
|
}
|
||||||
@ -1045,6 +1107,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE commercial_premise = %s
|
WHERE commercial_premise = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (commercial_premiseId, )
|
"params": (commercial_premiseId, )
|
||||||
}
|
}
|
||||||
@ -1300,11 +1365,13 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
ORDER BY
|
ORDER BY
|
||||||
amount
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": ()
|
"params": ()
|
||||||
}
|
}
|
||||||
@ -1316,7 +1383,9 @@ 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_amount = body["amount"]
|
v_amount = body["amount"]
|
||||||
|
v_document_no = body["document_no"]
|
||||||
v_account_entry_category = body["account_entry_category"]
|
v_account_entry_category = body["account_entry_category"]
|
||||||
return dbInsert(user, token_info, {
|
return dbInsert(user, token_info, {
|
||||||
"statement": """
|
"statement": """
|
||||||
@ -1325,7 +1394,9 @@ INSERT INTO account_entry_t
|
|||||||
description
|
description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
) VALUES (
|
) VALUES (
|
||||||
%s
|
%s
|
||||||
@ -1333,6 +1404,8 @@ INSERT INTO account_entry_t
|
|||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
@ -1340,7 +1413,9 @@ INSERT INTO account_entry_t
|
|||||||
v_description
|
v_description
|
||||||
,v_account
|
,v_account
|
||||||
,v_created_at
|
,v_created_at
|
||||||
|
,v_due_at
|
||||||
,v_amount
|
,v_amount
|
||||||
|
,v_document_no
|
||||||
,v_account_entry_category
|
,v_account_entry_category
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -1357,7 +1432,9 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
WHERE id = %s
|
WHERE id = %s
|
||||||
@ -1376,10 +1453,14 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
WHERE account = %s
|
WHERE account = %s
|
||||||
|
ORDER BY
|
||||||
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": (accountId, )
|
"params": (accountId, )
|
||||||
}
|
}
|
||||||
@ -1393,10 +1474,14 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
FROM account_entry_t
|
FROM account_entry_t
|
||||||
WHERE account_entry_category = %s
|
WHERE account_entry_category = %s
|
||||||
|
ORDER BY
|
||||||
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": (account_entry_categoryId, )
|
"params": (account_entry_categoryId, )
|
||||||
}
|
}
|
||||||
@ -1411,6 +1496,8 @@ SELECT
|
|||||||
,tenant
|
,tenant
|
||||||
,note
|
,note
|
||||||
FROM note_t
|
FROM note_t
|
||||||
|
ORDER BY
|
||||||
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": ()
|
"params": ()
|
||||||
}
|
}
|
||||||
@ -1474,6 +1561,8 @@ SELECT
|
|||||||
,note
|
,note
|
||||||
FROM note_t
|
FROM note_t
|
||||||
WHERE tenant = %s
|
WHERE tenant = %s
|
||||||
|
ORDER BY
|
||||||
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": (tenantId, )
|
"params": (tenantId, )
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,14 @@ SELECT
|
|||||||
#end for
|
#end for
|
||||||
FROM ${table.name}_t
|
FROM ${table.name}_t
|
||||||
WHERE ${column.name} = %s
|
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, )
|
"params": (${column.name}Id, )
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,28 @@ paths:
|
|||||||
$ref: '#/components/schemas/premise'
|
$ref: '#/components/schemas/premise'
|
||||||
security:
|
security:
|
||||||
- jwt: ['secret']
|
- 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:
|
/v1/flats:
|
||||||
get:
|
get:
|
||||||
tags: [ "flat" ]
|
tags: [ "flat" ]
|
||||||
@ -1531,6 +1553,23 @@ paths:
|
|||||||
$ref: '#/components/schemas/account'
|
$ref: '#/components/schemas/account'
|
||||||
security:
|
security:
|
||||||
- jwt: ['secret']
|
- 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:
|
components:
|
||||||
@ -1605,6 +1644,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
city:
|
city:
|
||||||
type: string
|
type: string
|
||||||
|
account:
|
||||||
|
type: integer
|
||||||
flat:
|
flat:
|
||||||
description: flat
|
description: flat
|
||||||
type: object
|
type: object
|
||||||
@ -1673,6 +1714,9 @@ components:
|
|||||||
premise:
|
premise:
|
||||||
type: integer
|
type: integer
|
||||||
nullable: true
|
nullable: true
|
||||||
|
area:
|
||||||
|
type: number
|
||||||
|
nullable: true
|
||||||
tenancy:
|
tenancy:
|
||||||
description: tenancy
|
description: tenancy
|
||||||
type: object
|
type: object
|
||||||
@ -1749,8 +1793,14 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
|
due_at:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
amount:
|
amount:
|
||||||
type: number
|
type: number
|
||||||
|
document_no:
|
||||||
|
type: integer
|
||||||
|
nullable: true
|
||||||
account_entry_category:
|
account_entry_category:
|
||||||
type: integer
|
type: integer
|
||||||
note:
|
note:
|
||||||
|
@ -6,8 +6,10 @@ import datetime
|
|||||||
def perform(dbh, params):
|
def perform(dbh, params):
|
||||||
try:
|
try:
|
||||||
createdAt = params['created_at']
|
createdAt = params['created_at']
|
||||||
|
dueAt = createdAt.replace(day=1)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
createdAt = datetime.datetime.today().strftime("%Y-%m-%d")
|
createdAt = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||||
|
dueAt = createdAt.replace(day=1)
|
||||||
|
|
||||||
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:
|
||||||
|
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
|
cur = None
|
||||||
try:
|
try:
|
||||||
with dbh.cursor(cursor_factory = psycopg2.extras.RealDictCursor) as cur:
|
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)))
|
logger.debug("edo: {}".format(str(params)))
|
||||||
return func(cur, params)
|
return func(cur, params)
|
||||||
except psycopg2.Error as err:
|
except psycopg2.Error as err:
|
||||||
@ -21,6 +21,7 @@ def execDatabaseOperation(dbh, func, params):
|
|||||||
|
|
||||||
|
|
||||||
def _opGetMany(cursor, params):
|
def _opGetMany(cursor, params):
|
||||||
|
#logger.warning(f"{params=}")
|
||||||
items = []
|
items = []
|
||||||
cursor.execute(params["statement"], params["params"])
|
cursor.execute(params["statement"], params["params"])
|
||||||
for itemObj in cursor:
|
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 importlib
|
||||||
import sys
|
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 = 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',
|
parser.add_argument('--operation', '-o',
|
||||||
help='Operation to perform.',
|
help='Operation to perform.',
|
||||||
required=True)
|
required=True)
|
||||||
@ -44,12 +31,30 @@ parser.add_argument('--nocolorize', '-n',
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
operation = args.operation
|
operation = args.operation
|
||||||
params = json.loads(args.params)
|
params = json.loads(args.params)
|
||||||
logLevel = args.verbosity
|
logLevel = args.verbosity
|
||||||
noColorize = args.nocolorize
|
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.remove()
|
||||||
logger.add(sys.stderr, colorize=(not noColorize), level=logLevel)
|
logger.add(sys.stderr, colorize=(not noColorize), level=logLevel)
|
||||||
|
14
schema.json
14
schema.json
@ -32,7 +32,8 @@
|
|||||||
{ "name": "description", "sqltype": "varchar(128)", "selector": 0, "unique": true },
|
{ "name": "description", "sqltype": "varchar(128)", "selector": 0, "unique": true },
|
||||||
{ "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": "account", "sqltype": "integer", "notnull": true, "foreignkey": true, "immutable": true, "unique": true }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -78,7 +79,8 @@
|
|||||||
"name": "commercial_premise",
|
"name": "commercial_premise",
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "name": "description", "sqltype": "varchar(128)", "selector": 1 },
|
{ "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": [
|
"tableConstraints": [
|
||||||
"unique(description, premise)"
|
"unique(description, premise)"
|
||||||
@ -135,8 +137,10 @@
|
|||||||
"columns": [
|
"columns": [
|
||||||
{ "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()" },
|
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()", "selector": 0 },
|
||||||
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true, "selector": 0 },
|
{ "name": "due_at", "sqltype": "timestamp", "notnull": false },
|
||||||
|
{ "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 }
|
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
|
||||||
],
|
],
|
||||||
"tableConstraints": [
|
"tableConstraints": [
|
||||||
@ -147,7 +151,7 @@
|
|||||||
"name": "note",
|
"name": "note",
|
||||||
"immutable": true,
|
"immutable": true,
|
||||||
"columns": [
|
"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": "tenant", "sqltype": "integer", "notnull": true, "foreignkey": true },
|
||||||
{ "name": "note", "sqltype": "varchar(4096)", "notnull": true }
|
{ "name": "note", "sqltype": "varchar(4096)", "notnull": true }
|
||||||
]
|
]
|
||||||
|
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
|
,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
|
||||||
|
,account integer not null references account_t (id) unique
|
||||||
);
|
);
|
||||||
|
|
||||||
GRANT SELECT, INSERT, UPDATE ON premise_t TO hv2;
|
GRANT SELECT, INSERT, UPDATE ON premise_t TO hv2;
|
||||||
@ -90,6 +91,7 @@ CREATE TABLE commercial_premise_t (
|
|||||||
id serial not null primary key
|
id serial not null primary key
|
||||||
,description varchar(128)
|
,description varchar(128)
|
||||||
,premise integer references premise_t (id)
|
,premise integer references premise_t (id)
|
||||||
|
,area numeric(10,2)
|
||||||
,unique(description, premise)
|
,unique(description, premise)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -148,7 +150,9 @@ 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
|
||||||
,amount numeric(10,2) not null
|
,amount numeric(10,2) not null
|
||||||
|
,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)
|
||||||
,unique(description, account, created_at)
|
,unique(description, account, created_at)
|
||||||
);
|
);
|
||||||
|
@ -6,6 +6,12 @@
|
|||||||
<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-label>Fälligkeit</mat-label>
|
||||||
|
<input matInput ngModel name="dueAt" [matDatepicker]="dueAtPicker" [formControl]="presetDueAt"/>
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="dueAtPicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #dueAtPicker></mat-datepicker>
|
||||||
|
</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>
|
||||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||||
@ -16,9 +22,9 @@
|
|||||||
<mat-label>Betrag (€)</mat-label>
|
<mat-label>Betrag (€)</mat-label>
|
||||||
<input matInput type="number" name="amount" ngModel/>
|
<input matInput type="number" name="amount" ngModel/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||||
<mat-label>Beschreibung</mat-label>
|
<mat-label>Beschreibung</mat-label>
|
||||||
<input matInput name="description" ngModel/>
|
<input matInput name="description" [disabled]="shallBeRentPayment" ngModel/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||||
</form>
|
</form>
|
||||||
@ -32,10 +38,18 @@ 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">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>Fälligkeit</th>
|
||||||
|
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.due_at | date}}</td>
|
||||||
|
</ng-container>
|
||||||
<ng-container matColumnDef="description">
|
<ng-container matColumnDef="description">
|
||||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||||
</ng-container>
|
</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">
|
<ng-container matColumnDef="amount">
|
||||||
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
||||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ViewFlags } from '@angular/compiler/src/core';
|
import { ViewFlags } from '@angular/compiler/src/core';
|
||||||
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
|
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
|
||||||
|
import { FormControl } from '@angular/forms';
|
||||||
import { MatButton } from '@angular/material/button';
|
import { MatButton } from '@angular/material/button';
|
||||||
import { MatExpansionPanel } from '@angular/material/expansion';
|
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
@ -7,7 +8,7 @@ import { AccountEntryCategoryService, AccountEntryService, AccountService } from
|
|||||||
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
|
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
|
||||||
import { ErrorDialogService } from '../error-dialog.service';
|
import { ErrorDialogService } from '../error-dialog.service';
|
||||||
import { ExtApiService } from '../ext-data-object-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';
|
import { MessageService } from '../message.service';
|
||||||
|
|
||||||
|
|
||||||
@ -33,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", "amount", "createdAt", "category", "overhead_relevant" ]
|
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "dueAt", "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
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
@ -92,17 +93,22 @@ export class AccountComponent implements OnInit {
|
|||||||
try {
|
try {
|
||||||
this.addAccountEntryButton.disabled = true
|
this.addAccountEntryButton.disabled = true
|
||||||
this.messageService.add(`${JSON.stringify(formData.value, undefined, 4)}`)
|
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 = {
|
let newAccountEntry: AccountEntry = {
|
||||||
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,
|
||||||
amount: formData.value.amount,
|
amount: formData.value.amount,
|
||||||
id: 0,
|
id: 0,
|
||||||
|
document_no: uniquenumber.number,
|
||||||
account_entry_category: 0
|
account_entry_category: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.shallBeRentPayment) {
|
if (this.shallBeRentPayment) {
|
||||||
newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||||
|
newAccountEntry.description = "Miete"
|
||||||
this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`)
|
this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`)
|
||||||
} else {
|
} else {
|
||||||
newAccountEntry.account_entry_category = formData.value.category
|
newAccountEntry.account_entry_category = formData.value.category
|
||||||
@ -140,9 +146,17 @@ export class AccountComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async init(): Promise<void> {
|
private async init(): Promise<void> {
|
||||||
|
let currentDate = new Date()
|
||||||
|
let y = currentDate.getFullYear().toString()
|
||||||
|
let m = (currentDate.getMonth()+1).toString()
|
||||||
|
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()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
<mat-option *ngFor="let p of premises" [value]="p.id">{{p.description}}</mat-option>
|
<mat-option *ngFor="let p of premises" [value]="p.id">{{p.description}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</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>
|
</div>
|
||||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -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"
|
||||||
|
@ -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
|
street: string
|
||||||
zip: string
|
zip: string
|
||||||
city: string
|
city: string
|
||||||
|
account: number
|
||||||
}
|
}
|
||||||
export const NULL_Premise: Premise = {
|
export const NULL_Premise: Premise = {
|
||||||
id: 0
|
id: 0
|
||||||
@ -59,6 +60,7 @@ export const NULL_Premise: Premise = {
|
|||||||
,street: ''
|
,street: ''
|
||||||
,zip: ''
|
,zip: ''
|
||||||
,city: ''
|
,city: ''
|
||||||
|
,account: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Flat {
|
export interface Flat {
|
||||||
@ -117,11 +119,13 @@ export interface CommercialPremise {
|
|||||||
id: number
|
id: number
|
||||||
description: string
|
description: string
|
||||||
premise: number
|
premise: number
|
||||||
|
area: number
|
||||||
}
|
}
|
||||||
export const NULL_CommercialPremise: CommercialPremise = {
|
export const NULL_CommercialPremise: CommercialPremise = {
|
||||||
id: 0
|
id: 0
|
||||||
,description: ''
|
,description: ''
|
||||||
,premise: undefined
|
,premise: undefined
|
||||||
|
,area: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Tenancy {
|
export interface Tenancy {
|
||||||
@ -189,7 +193,9 @@ export interface AccountEntry {
|
|||||||
description: string
|
description: string
|
||||||
account: number
|
account: number
|
||||||
created_at: string
|
created_at: string
|
||||||
|
due_at: string
|
||||||
amount: number
|
amount: number
|
||||||
|
document_no: number
|
||||||
account_entry_category: number
|
account_entry_category: number
|
||||||
}
|
}
|
||||||
export const NULL_AccountEntry: AccountEntry = {
|
export const NULL_AccountEntry: AccountEntry = {
|
||||||
@ -197,7 +203,9 @@ export const NULL_AccountEntry: AccountEntry = {
|
|||||||
,description: ''
|
,description: ''
|
||||||
,account: undefined
|
,account: undefined
|
||||||
,created_at: ''
|
,created_at: ''
|
||||||
|
,due_at: ''
|
||||||
,amount: undefined
|
,amount: undefined
|
||||||
|
,document_no: undefined
|
||||||
,account_entry_category: undefined
|
,account_entry_category: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import { serviceBaseUrl } from './config';
|
|||||||
|
|
||||||
|
|
||||||
import { Account, Fee, OverheadAdvance } from './data-objects';
|
import { Account, Fee, OverheadAdvance } from './data-objects';
|
||||||
import { Saldo, Tenant_with_Saldo } from './ext-data-objects';
|
import { Saldo, Tenant_with_Saldo, UniqueNumber } from './ext-data-objects';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
@ -38,4 +38,9 @@ export class ExtApiService {
|
|||||||
this.messageService.add("ExtApiService: get tenants with saldo");
|
this.messageService.add("ExtApiService: get tenants with saldo");
|
||||||
return this.http.get<Tenant_with_Saldo[]>(`${serviceBaseUrl}/v1/tenants/saldo`).toPromise()
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,8 @@ export interface Tenant_with_Saldo {
|
|||||||
lastname: string
|
lastname: string
|
||||||
address1: string
|
address1: string
|
||||||
saldo: number
|
saldo: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UniqueNumber {
|
||||||
|
number: number
|
||||||
}
|
}
|
@ -13,6 +13,7 @@
|
|||||||
Ausgaben
|
Ausgaben
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
<mat-panel-description>
|
<mat-panel-description>
|
||||||
|
<div>Betriebskosten-relevante Ausgaben nicht hier sondern im Betriebskostenkonto unter "Meine Häuser" erfassen.</div>
|
||||||
</mat-panel-description>
|
</mat-panel-description>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<app-account #expenseAccountComponent [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
|
<app-account #expenseAccountComponent [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
|
||||||
|
@ -19,8 +19,13 @@
|
|||||||
<th mat-header-cell *matHeaderCellDef>Haus</th>
|
<th mat-header-cell *matHeaderCellDef>Haus</th>
|
||||||
<td mat-cell *matCellDef="let element">{{element.premise.description}}</td>
|
<td mat-cell *matCellDef="let element">{{element.premise.description}}</td>
|
||||||
</ng-container>
|
</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-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/commercialunit/', row.commercialPremise.id]"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/commercialunit/', row.commercialPremise.id]"></tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
@ -21,7 +21,7 @@ export class MyCommercialUnitsComponent implements OnInit {
|
|||||||
dnCommercialPremises: DN_CommercialPremise[] = []
|
dnCommercialPremises: DN_CommercialPremise[] = []
|
||||||
|
|
||||||
dataSource: MatTableDataSource<DN_CommercialPremise>
|
dataSource: MatTableDataSource<DN_CommercialPremise>
|
||||||
displayedColumns: string[] = ["description", "premise"]
|
displayedColumns: string[] = ["description", "premise", "area"]
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private commercialPremiseService: CommercialPremiseService,
|
private commercialPremiseService: CommercialPremiseService,
|
||||||
|
@ -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="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-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/premise/', row.id]"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/premise/', row.id]"></tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -13,7 +13,8 @@ export class MyPremisesComponent implements OnInit {
|
|||||||
|
|
||||||
premises: Premise[]
|
premises: Premise[]
|
||||||
dataSource: MatTableDataSource<Premise>
|
dataSource: MatTableDataSource<Premise>
|
||||||
displayedColumns: string[] = [ "description", "street", "zip", "city" ]
|
displayedColumns: string[] = [ "description", "street", "zip", "city", "account" ]
|
||||||
|
|
||||||
|
|
||||||
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
<mat-nav-list *ngIf="authenticated">
|
<mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/enterPayment">Mietzahlung eintragen</a>
|
<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="/ledger">Buchführung</a>
|
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
|
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
@ -22,6 +20,8 @@
|
|||||||
<a mat-list-item href="/fees">Mietsätze</a>
|
<a mat-list-item href="/fees">Mietsätze</a>
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/premises">Meine Häuser</a>
|
<a mat-list-item href="/premises">Meine Häuser</a>
|
||||||
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
|
<a mat-list-item href="/ledger">Buchführung</a>
|
||||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||||
<a mat-list-item href="/logout">Abmelden</a>
|
<a mat-list-item href="/logout">Abmelden</a>
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
|
@ -9,31 +9,59 @@
|
|||||||
</mat-card-subtitle>
|
</mat-card-subtitle>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div>
|
<mat-accordion>
|
||||||
<form (ngSubmit)="savePremise()">
|
<mat-expansion-panel (opened)="collapseDetails = true"
|
||||||
<div>
|
(closed)="collapseDetails = false"
|
||||||
<mat-form-field appearance="outline">
|
[expanded]="premise.id == 0">
|
||||||
<mat-label>Beschreibung</mat-label>
|
<mat-expansion-panel-header>
|
||||||
<input matInput name="description" [(ngModel)]="premise.description"/>
|
<mat-panel-title>
|
||||||
</mat-form-field>
|
Details
|
||||||
</div><div>
|
</mat-panel-title>
|
||||||
<mat-form-field appearance="outline">
|
<mat-panel-description>
|
||||||
<mat-label>Strasse</mat-label>
|
</mat-panel-description>
|
||||||
<input matInput name="street" [(ngModel)]="premise.street"/>
|
</mat-expansion-panel-header>
|
||||||
</mat-form-field>
|
<form (ngSubmit)="savePremise()">
|
||||||
</div><div>
|
<div>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>PLZ</mat-label>
|
<mat-label>Beschreibung</mat-label>
|
||||||
<input matInput name="zip" [(ngModel)]="premise.zip"/>
|
<input matInput name="description" [(ngModel)]="premise.description"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline">
|
</div><div>
|
||||||
<mat-label>Ort</mat-label>
|
<mat-form-field appearance="outline">
|
||||||
<input matInput name="city" [(ngModel)]="premise.city"/>
|
<mat-label>Strasse</mat-label>
|
||||||
</mat-form-field>
|
<input matInput name="street" [(ngModel)]="premise.street"/>
|
||||||
</div>
|
</mat-form-field>
|
||||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
</div><div>
|
||||||
</form>
|
<mat-form-field appearance="outline">
|
||||||
</div>
|
<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-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</section>
|
</section>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { MatButton } from '@angular/material/button';
|
import { MatButton } from '@angular/material/button';
|
||||||
|
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { PremiseService } from '../data-object-service';
|
import { AccountService, PremiseService } from '../data-object-service';
|
||||||
import { Premise } from '../data-objects';
|
import { Account, NULL_Premise, Premise } from '../data-objects';
|
||||||
import { MessageService } from '../message.service';
|
import { MessageService } from '../message.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -12,18 +13,19 @@ import { MessageService } from '../message.service';
|
|||||||
})
|
})
|
||||||
export class PremiseDetailsComponent implements OnInit {
|
export class PremiseDetailsComponent implements OnInit {
|
||||||
|
|
||||||
|
collapseDetails: boolean = false
|
||||||
|
collapseOverheadAccount: boolean = false
|
||||||
|
|
||||||
@ViewChild('submitButton') submitButton: MatButton
|
@ViewChild('submitButton') submitButton: MatButton
|
||||||
|
|
||||||
premise: Premise = {
|
premise: Premise = NULL_Premise
|
||||||
id: 0,
|
|
||||||
description: '',
|
overheadAccount: Account
|
||||||
street: '',
|
overheadAccountId: number
|
||||||
zip: '',
|
|
||||||
city: ''
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private premiseService: PremiseService,
|
private premiseService: PremiseService,
|
||||||
|
private accountService: AccountService,
|
||||||
private messageService: MessageService,
|
private messageService: MessageService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router
|
private router: Router
|
||||||
@ -34,6 +36,8 @@ export class PremiseDetailsComponent implements OnInit {
|
|||||||
const id = +this.route.snapshot.paramMap.get('id')
|
const id = +this.route.snapshot.paramMap.get('id')
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
this.premise = await this.premiseService.getPremise(id)
|
this.premise = await this.premiseService.getPremise(id)
|
||||||
|
this.overheadAccount = await this.accountService.getAccount(this.premise.account)
|
||||||
|
this.overheadAccountId = this.overheadAccount.id
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
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))
|
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
|
||||||
if (this.premise.id == 0) {
|
if (this.premise.id == 0) {
|
||||||
this.messageService.add("about to insert new premise")
|
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.premise = await this.premiseService.postPremise(this.premise)
|
||||||
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-accordion>
|
<mat-accordion>
|
||||||
<mat-expansion-panel (opened)="collapseTenantDetails = true"
|
<mat-expansion-panel (opened)="collapseTenantDetails = true"
|
||||||
(closed)="collapseTenantDetails = false">
|
(closed)="collapseTenantDetails = false"
|
||||||
|
[expanded]="tenant.id == 0">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title *ngIf="!collapseTenantDetails">
|
<mat-panel-title *ngIf="!collapseTenantDetails">
|
||||||
Details
|
Details
|
||||||
@ -68,18 +69,18 @@
|
|||||||
<input matInput name="iban" [(ngModel)]="tenant.iban"/>
|
<input matInput name="iban" [(ngModel)]="tenant.iban"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<div>
|
<div>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline" *ngIf="tenant.account">
|
||||||
<mat-label>Account ID</mat-label>
|
<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>
|
||||||
|
<!--
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Account Description</mat-label>
|
<mat-label>Account Description</mat-label>
|
||||||
<input matInput name="account_desc" [readonly]="true" [ngModel]="account.description"/>
|
<input matInput name="account_desc" [readonly]="true" [ngModel]="account.description"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
-->
|
||||||
-->
|
</div>
|
||||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user