minus_area in premise, calculation of areas and factors
This commit is contained in:
parent
e1ebfe254a
commit
b3a49b0fb6
@ -286,6 +286,7 @@ SELECT
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,minus_area
|
||||
,account
|
||||
FROM premise_t
|
||||
ORDER BY
|
||||
@ -302,6 +303,7 @@ def insert_premise(user, token_info, **args):
|
||||
v_street = body["street"]
|
||||
v_zip = body["zip"]
|
||||
v_city = body["city"]
|
||||
v_minus_area = body["minus_area"]
|
||||
v_account = body["account"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
@ -311,6 +313,7 @@ INSERT INTO premise_t
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,minus_area
|
||||
,account
|
||||
) VALUES (
|
||||
%s
|
||||
@ -318,6 +321,7 @@ INSERT INTO premise_t
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
@ -326,6 +330,7 @@ INSERT INTO premise_t
|
||||
,v_street
|
||||
,v_zip
|
||||
,v_city
|
||||
,v_minus_area
|
||||
,v_account
|
||||
]
|
||||
})
|
||||
@ -343,6 +348,7 @@ SELECT
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,minus_area
|
||||
,account
|
||||
FROM premise_t
|
||||
WHERE id = %s
|
||||
@ -358,6 +364,7 @@ def update_premise(user, token_info, premiseId=None, **args):
|
||||
v_street = body["street"]
|
||||
v_zip = body["zip"]
|
||||
v_city = body["city"]
|
||||
v_minus_area = body["minus_area"]
|
||||
return dbUpdate(user, token_info, {
|
||||
"statement": """
|
||||
UPDATE premise_t
|
||||
@ -366,6 +373,7 @@ UPDATE premise_t
|
||||
,street = %s
|
||||
,zip = %s
|
||||
,city = %s
|
||||
,minus_area = %s
|
||||
WHERE id = %s
|
||||
RETURNING *
|
||||
""",
|
||||
@ -374,6 +382,7 @@ UPDATE premise_t
|
||||
v_street,
|
||||
v_zip,
|
||||
v_city,
|
||||
v_minus_area,
|
||||
premiseId
|
||||
]
|
||||
})
|
||||
@ -391,6 +400,7 @@ SELECT
|
||||
,street
|
||||
,zip
|
||||
,city
|
||||
,minus_area
|
||||
,account
|
||||
FROM premise_t
|
||||
WHERE account = %s
|
||||
@ -1305,6 +1315,7 @@ def get_account_entry_categorys(user, token_info):
|
||||
SELECT
|
||||
id
|
||||
,description
|
||||
,considerMinusArea
|
||||
,overhead_relevant
|
||||
FROM account_entry_category_t
|
||||
ORDER BY
|
||||
@ -1318,21 +1329,25 @@ def insert_account_entry_category(user, token_info, **args):
|
||||
try:
|
||||
body = args["body"]
|
||||
v_description = body["description"]
|
||||
v_considerMinusArea = body["considerMinusArea"]
|
||||
v_overhead_relevant = body["overhead_relevant"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
INSERT INTO account_entry_category_t
|
||||
(
|
||||
description
|
||||
,considerMinusArea
|
||||
,overhead_relevant
|
||||
) VALUES (
|
||||
%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
"params": [
|
||||
v_description
|
||||
,v_considerMinusArea
|
||||
,v_overhead_relevant
|
||||
]
|
||||
})
|
||||
@ -1347,6 +1362,7 @@ def get_account_entry_category(user, token_info, account_entry_categoryId=None):
|
||||
SELECT
|
||||
id
|
||||
,description
|
||||
,considerMinusArea
|
||||
,overhead_relevant
|
||||
FROM account_entry_category_t
|
||||
WHERE id = %s
|
||||
|
@ -1644,6 +1644,8 @@ components:
|
||||
type: string
|
||||
city:
|
||||
type: string
|
||||
minus_area:
|
||||
type: number
|
||||
account:
|
||||
type: integer
|
||||
flat:
|
||||
@ -1779,6 +1781,8 @@ components:
|
||||
type: integer
|
||||
description:
|
||||
type: string
|
||||
considerMinusArea:
|
||||
type: boolean
|
||||
overhead_relevant:
|
||||
type: boolean
|
||||
account_entry:
|
||||
|
@ -23,7 +23,8 @@ def perform(dbh, params):
|
||||
select sum(ae.amount) as sum,
|
||||
aec.description as category,
|
||||
p.id as house_id,
|
||||
p.description as house
|
||||
p.description as house,
|
||||
aec.considerminusarea as considerminusarea
|
||||
from account_t a,
|
||||
premise_t p,
|
||||
account_entry_t ae,
|
||||
@ -32,14 +33,15 @@ def perform(dbh, params):
|
||||
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
|
||||
ae.fiscal_year = %(year)s and
|
||||
p.id in %(premises)s
|
||||
group by house_id, house, category
|
||||
group by house_id, house, category, considerminusarea
|
||||
union
|
||||
select 0 as sum,
|
||||
aec.description as category,
|
||||
p.id as house_id,
|
||||
p.description as house
|
||||
p.description as house,
|
||||
aec.considerminusarea as considerminusarea
|
||||
from account_t a,
|
||||
premise_t p,
|
||||
account_entry_t ae,
|
||||
@ -48,28 +50,28 @@ def perform(dbh, params):
|
||||
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
|
||||
ae.fiscal_year = %(year)s and
|
||||
p.id in %(premises)s
|
||||
group by house_id, house, category
|
||||
group by house_id, house, category, considerminusarea
|
||||
union
|
||||
select 120 as sum,
|
||||
'Waschmaschine' as category,
|
||||
id as house_id,
|
||||
description as house
|
||||
description as house,
|
||||
false as considerminusarea
|
||||
from premise_t
|
||||
where id in %(premises)s
|
||||
order by house_id, category
|
||||
""",
|
||||
"params": {
|
||||
"startDate": startDate,
|
||||
"endDate": endDate,
|
||||
"year": year,
|
||||
"premises": premises
|
||||
}
|
||||
}
|
||||
)
|
||||
# logger.info(f"{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 = {}
|
||||
for premise in premises:
|
||||
@ -79,6 +81,94 @@ def perform(dbh, params):
|
||||
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
|
||||
@ -130,12 +220,11 @@ def perform(dbh, params):
|
||||
FROM account_entry_t
|
||||
WHERE account = %(account)s AND
|
||||
account_entry_category = 2 AND
|
||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
||||
fiscal_year = %(year)s
|
||||
""",
|
||||
"params": {
|
||||
"account": tenant['tenant_account'],
|
||||
"startDate": startDate,
|
||||
"endDate": endDate
|
||||
"year": year
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -149,12 +238,11 @@ def perform(dbh, params):
|
||||
FROM account_entry_t
|
||||
WHERE account = %(account)s AND
|
||||
account_entry_category = 3 AND
|
||||
due_at BETWEEN %(startDate)s AND %(endDate)s
|
||||
fiscal_year = %(year)s
|
||||
""",
|
||||
"params": {
|
||||
"account": tenant['tenant_account'],
|
||||
"startDate": startDate,
|
||||
"endDate": endDate
|
||||
"year": year
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -33,6 +33,7 @@
|
||||
{ "name": "street", "sqltype": "varchar(128)", "notnull": true },
|
||||
{ "name": "zip", "sqltype": "varchar(10)", "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 }
|
||||
]
|
||||
},
|
||||
@ -128,7 +129,8 @@
|
||||
"immutable": true,
|
||||
"columns": [
|
||||
{ "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
|
||||
,zip varchar(10) 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
|
||||
);
|
||||
|
||||
@ -139,7 +140,8 @@ GRANT SELECT, UPDATE ON tenancy_fee_mapping_t_id_seq TO hv2;
|
||||
CREATE TABLE account_entry_category_t (
|
||||
id serial not null primary key
|
||||
,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;
|
||||
|
@ -52,6 +52,7 @@ export interface Premise {
|
||||
street: string
|
||||
zip: string
|
||||
city: string
|
||||
minus_area: number
|
||||
account: number
|
||||
}
|
||||
export const NULL_Premise: Premise = {
|
||||
@ -60,6 +61,7 @@ export const NULL_Premise: Premise = {
|
||||
,street: ''
|
||||
,zip: ''
|
||||
,city: ''
|
||||
,minus_area: undefined
|
||||
,account: undefined
|
||||
}
|
||||
|
||||
@ -180,11 +182,13 @@ export const NULL_TenancyFeeMapping: TenancyFeeMapping = {
|
||||
export interface AccountEntryCategory {
|
||||
id: number
|
||||
description: string
|
||||
considerMinusArea: boolean
|
||||
overhead_relevant: boolean
|
||||
}
|
||||
export const NULL_AccountEntryCategory: AccountEntryCategory = {
|
||||
id: 0
|
||||
,description: ''
|
||||
,considerMinusArea: false
|
||||
,overhead_relevant: false
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,10 @@
|
||||
<th mat-header-cell *matHeaderCellDef>Ort</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.city}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="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">
|
||||
<th mat-header-cell *matHeaderCellDef>Betriebskostenkonto</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.account}}</td>
|
||||
|
@ -13,7 +13,7 @@ export class MyPremisesComponent implements OnInit {
|
||||
|
||||
premises: 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) { }
|
||||
|
@ -40,6 +40,11 @@
|
||||
<mat-label>Ort</mat-label>
|
||||
<input matInput name="city" [(ngModel)]="premise.city"/>
|
||||
</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>
|
||||
<mat-form-field appearance="outline" *ngIf="premise.account">
|
||||
<mat-label>Betriebskostenkonto</mat-label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user