minus_area in premise, calculation of areas and factors
This commit is contained in:
parent
e1ebfe254a
commit
b3a49b0fb6
@ -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
|
||||||
|
@ -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:
|
||||||
|
@ -23,7 +23,8 @@ def perform(dbh, params):
|
|||||||
select sum(ae.amount) as sum,
|
select sum(ae.amount) as sum,
|
||||||
aec.description as category,
|
aec.description as category,
|
||||||
p.id as house_id,
|
p.id as house_id,
|
||||||
p.description as house
|
p.description as house,
|
||||||
|
aec.considerminusarea as considerminusarea
|
||||||
from account_t a,
|
from account_t a,
|
||||||
premise_t p,
|
premise_t p,
|
||||||
account_entry_t ae,
|
account_entry_t ae,
|
||||||
@ -32,14 +33,15 @@ def perform(dbh, params):
|
|||||||
ae.account = a.id and
|
ae.account = a.id and
|
||||||
aec.overhead_relevant = 't' and
|
aec.overhead_relevant = 't' and
|
||||||
ae.account_entry_category = aec.id and
|
ae.account_entry_category = aec.id and
|
||||||
created_at between %(startDate)s and %(endDate)s and
|
ae.fiscal_year = %(year)s and
|
||||||
p.id in %(premises)s
|
p.id in %(premises)s
|
||||||
group by house_id, house, category
|
group by house_id, house, category, considerminusarea
|
||||||
union
|
union
|
||||||
select 0 as sum,
|
select 0 as sum,
|
||||||
aec.description as category,
|
aec.description as category,
|
||||||
p.id as house_id,
|
p.id as house_id,
|
||||||
p.description as house
|
p.description as house,
|
||||||
|
aec.considerminusarea as considerminusarea
|
||||||
from account_t a,
|
from account_t a,
|
||||||
premise_t p,
|
premise_t p,
|
||||||
account_entry_t ae,
|
account_entry_t ae,
|
||||||
@ -48,28 +50,28 @@ def perform(dbh, params):
|
|||||||
ae.account = a.id and
|
ae.account = a.id and
|
||||||
aec.overhead_relevant = 't' and
|
aec.overhead_relevant = 't' and
|
||||||
aec.id not in (select distinct account_entry_category from account_entry_t) and
|
aec.id not in (select distinct account_entry_category from account_entry_t) and
|
||||||
created_at between %(startDate)s and %(endDate)s and
|
ae.fiscal_year = %(year)s and
|
||||||
p.id in %(premises)s
|
p.id in %(premises)s
|
||||||
group by house_id, house, category
|
group by house_id, house, category, considerminusarea
|
||||||
union
|
union
|
||||||
select 120 as sum,
|
select 120 as sum,
|
||||||
'Waschmaschine' as category,
|
'Waschmaschine' as category,
|
||||||
id as house_id,
|
id as house_id,
|
||||||
description as house
|
description as house,
|
||||||
|
false as considerminusarea
|
||||||
from premise_t
|
from premise_t
|
||||||
where id in %(premises)s
|
where id in %(premises)s
|
||||||
order by house_id, category
|
order by house_id, category
|
||||||
""",
|
""",
|
||||||
"params": {
|
"params": {
|
||||||
"startDate": startDate,
|
"year": year,
|
||||||
"endDate": endDate,
|
|
||||||
"premises": premises
|
"premises": premises
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# logger.info(f"{overheadSums=}")
|
# logger.info(f"{overheadSums=}")
|
||||||
for overheadSum in overheadSums:
|
for overheadSum in overheadSums:
|
||||||
logger.info(f"house: {overheadSum['house']}, category: {overheadSum['category']}, sum: {overheadSum['sum']}")
|
logger.info(f"house: {overheadSum['house']}, considerMinusArea: {overheadSum['considerminusarea']}, category: {overheadSum['category']}, sum: {overheadSum['sum']}")
|
||||||
|
|
||||||
subtotal = {}
|
subtotal = {}
|
||||||
for premise in premises:
|
for premise in premises:
|
||||||
@ -79,6 +81,94 @@ def perform(dbh, params):
|
|||||||
logger.info(f"{subtotal=}")
|
logger.info(f"{subtotal=}")
|
||||||
|
|
||||||
|
|
||||||
|
# get areas and factors
|
||||||
|
totalAreas = {}
|
||||||
|
flatAreas = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
p.id as house_id,
|
||||||
|
p.description as house,
|
||||||
|
sum(f.area) as flat_area
|
||||||
|
from
|
||||||
|
premise_t p,
|
||||||
|
flat_t f
|
||||||
|
where
|
||||||
|
f.premise = p.id and
|
||||||
|
p.id in %(premises)s
|
||||||
|
group by house_id
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premises": premises
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
for area in flatAreas:
|
||||||
|
logger.info(f"{area['house']=}, {area['flat_area']=}")
|
||||||
|
totalAreas[area['house_id']] = { 'flat_area': area['flat_area'] }
|
||||||
|
|
||||||
|
commercialAreas = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
p.id as house_id,
|
||||||
|
p.description as house,
|
||||||
|
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 in %(premises)s
|
||||||
|
group by house_id
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premises": premises
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
for area in commercialAreas:
|
||||||
|
logger.info(f"{area['house']=}, {area['commercial_area']=}")
|
||||||
|
totalAreas[area['house_id']] |= { 'commercial_area': area['commercial_area'] }
|
||||||
|
|
||||||
|
minusAreas = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select
|
||||||
|
p.id as house_id,
|
||||||
|
p.description as house,
|
||||||
|
p.minus_area as minus_area
|
||||||
|
from
|
||||||
|
premise_t p
|
||||||
|
where
|
||||||
|
p.id in %(premises)s
|
||||||
|
group by house_id
|
||||||
|
""",
|
||||||
|
"params": {
|
||||||
|
"premises": premises
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
for area in minusAreas:
|
||||||
|
logger.info(f"{area['house']=}, {area['minus_area']=}")
|
||||||
|
totalAreas[area['house_id']] |= { 'minus_area': area['minus_area'] }
|
||||||
|
|
||||||
|
for premise in premises:
|
||||||
|
totalAreas[premise]['other_area'] = totalAreas[premise]['commercial_area'] + totalAreas[premise]['minus_area']
|
||||||
|
totalAreas[premise]['total_area'] = totalAreas[premise]['flat_area'] + totalAreas[premise]['other_area']
|
||||||
|
totalAreas[premise]['flat_factor'] = totalAreas[premise]['flat_area'] / totalAreas[premise]['total_area']
|
||||||
|
totalAreas[premise]['other_factor'] = totalAreas[premise]['other_area'] / totalAreas[premise]['total_area']
|
||||||
|
totalAreas[premise]['factor_check'] = totalAreas[premise]['flat_factor'] + totalAreas[premise]['other_factor']
|
||||||
|
logger.info(f"{totalAreas=}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -130,12 +220,11 @@ 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -149,12 +238,11 @@ 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -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 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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