due_at fix
This commit is contained in:
parent
422a8d37ab
commit
2fc7922707
@ -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, )
|
||||||
}
|
}
|
||||||
@ -391,6 +394,8 @@ SELECT
|
|||||||
,account
|
,account
|
||||||
FROM premise_t
|
FROM premise_t
|
||||||
WHERE account = %s
|
WHERE account = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
""",
|
""",
|
||||||
"params": (accountId, )
|
"params": (accountId, )
|
||||||
}
|
}
|
||||||
@ -507,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, )
|
||||||
}
|
}
|
||||||
@ -674,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, )
|
||||||
}
|
}
|
||||||
@ -688,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, )
|
||||||
}
|
}
|
||||||
@ -784,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, )
|
||||||
}
|
}
|
||||||
@ -880,6 +897,9 @@ SELECT
|
|||||||
,premise
|
,premise
|
||||||
FROM commercial_premise_t
|
FROM commercial_premise_t
|
||||||
WHERE premise = %s
|
WHERE premise = %s
|
||||||
|
ORDER BY
|
||||||
|
premise
|
||||||
|
,description
|
||||||
""",
|
""",
|
||||||
"params": (premiseId, )
|
"params": (premiseId, )
|
||||||
}
|
}
|
||||||
@ -1011,6 +1031,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE tenant = %s
|
WHERE tenant = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (tenantId, )
|
"params": (tenantId, )
|
||||||
}
|
}
|
||||||
@ -1030,6 +1053,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE flat = %s
|
WHERE flat = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (flatId, )
|
"params": (flatId, )
|
||||||
}
|
}
|
||||||
@ -1049,6 +1075,9 @@ SELECT
|
|||||||
,enddate
|
,enddate
|
||||||
FROM tenancy_t
|
FROM tenancy_t
|
||||||
WHERE parking = %s
|
WHERE parking = %s
|
||||||
|
ORDER BY
|
||||||
|
description
|
||||||
|
,startdate
|
||||||
""",
|
""",
|
||||||
"params": (parkingId, )
|
"params": (parkingId, )
|
||||||
}
|
}
|
||||||
@ -1068,6 +1097,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, )
|
||||||
}
|
}
|
||||||
@ -1323,12 +1355,13 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,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": ()
|
||||||
}
|
}
|
||||||
@ -1340,6 +1373,7 @@ def insert_account_entry(user, token_info, **args):
|
|||||||
v_description = body["description"]
|
v_description = body["description"]
|
||||||
v_account = body["account"]
|
v_account = body["account"]
|
||||||
v_created_at = body["created_at"]
|
v_created_at = body["created_at"]
|
||||||
|
v_due_at = body["due_at"]
|
||||||
v_amount = body["amount"]
|
v_amount = body["amount"]
|
||||||
v_document_no = body["document_no"]
|
v_document_no = body["document_no"]
|
||||||
v_account_entry_category = body["account_entry_category"]
|
v_account_entry_category = body["account_entry_category"]
|
||||||
@ -1350,6 +1384,7 @@ INSERT INTO account_entry_t
|
|||||||
description
|
description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1360,6 +1395,7 @@ INSERT INTO account_entry_t
|
|||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
,%s
|
,%s
|
||||||
|
,%s
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
""",
|
""",
|
||||||
@ -1367,6 +1403,7 @@ 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_document_no
|
||||||
,v_account_entry_category
|
,v_account_entry_category
|
||||||
@ -1385,6 +1422,7 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,document_no
|
||||||
,account_entry_category
|
,account_entry_category
|
||||||
@ -1405,11 +1443,14 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,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, )
|
||||||
}
|
}
|
||||||
@ -1423,11 +1464,14 @@ SELECT
|
|||||||
,description
|
,description
|
||||||
,account
|
,account
|
||||||
,created_at
|
,created_at
|
||||||
|
,due_at
|
||||||
,amount
|
,amount
|
||||||
,document_no
|
,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, )
|
||||||
}
|
}
|
||||||
@ -1442,6 +1486,8 @@ SELECT
|
|||||||
,tenant
|
,tenant
|
||||||
,note
|
,note
|
||||||
FROM note_t
|
FROM note_t
|
||||||
|
ORDER BY
|
||||||
|
created_at
|
||||||
""",
|
""",
|
||||||
"params": ()
|
"params": ()
|
||||||
}
|
}
|
||||||
@ -1505,6 +1551,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, )
|
||||||
}
|
}
|
||||||
|
@ -1790,6 +1790,9 @@ 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:
|
document_no:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import typing_extensions
|
|
||||||
from db import dbGetMany
|
from db import dbGetMany
|
||||||
import datetime
|
import datetime
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@ -14,7 +13,12 @@ def perform(dbh, params):
|
|||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
select t.id as tenant_id,
|
tenants = dbGetMany(
|
||||||
|
dbh,
|
||||||
|
{
|
||||||
|
"statement":
|
||||||
|
"""
|
||||||
|
select t.id as tenant_id,
|
||||||
t.firstname as tenant_firstname,
|
t.firstname as tenant_firstname,
|
||||||
t.lastname as tenant_lastname,
|
t.lastname as tenant_lastname,
|
||||||
f.id as flat_id,
|
f.id as flat_id,
|
||||||
@ -29,9 +33,20 @@ select t.id as tenant_id,
|
|||||||
tenancy_t ty
|
tenancy_t ty
|
||||||
where ty.tenant = t.id and
|
where ty.tenant = t.id and
|
||||||
ty.flat = f.id and
|
ty.flat = f.id and
|
||||||
f.premise = p.id
|
ty.startdate >= %(startDate)s and
|
||||||
order by house_id, tenant_id;
|
(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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
logger.info(f"{tenants=}")
|
||||||
|
|
||||||
|
|
||||||
# get overhead sums by object, category and timespan
|
# get overhead sums by object, category and timespan
|
||||||
|
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")
|
@ -136,8 +136,9 @@
|
|||||||
"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": "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 }
|
||||||
],
|
],
|
||||||
@ -149,7 +150,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 }
|
||||||
]
|
]
|
||||||
|
@ -149,6 +149,7 @@ CREATE TABLE account_entry_t (
|
|||||||
,description varchar(1024) not null
|
,description varchar(1024) not null
|
||||||
,account integer not null references account_t (id)
|
,account integer not null references account_t (id)
|
||||||
,created_at timestamp not null default now()
|
,created_at timestamp not null default now()
|
||||||
|
,due_at timestamp
|
||||||
,amount numeric(10,2) not null
|
,amount numeric(10,2) not null
|
||||||
,document_no integer unique
|
,document_no integer unique
|
||||||
,account_entry_category integer not null references account_entry_category_t (id)
|
,account_entry_category integer not null references account_entry_category_t (id)
|
||||||
|
@ -6,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"/>
|
||||||
|
<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">
|
||||||
@ -32,6 +38,10 @@ 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>
|
||||||
|
@ -33,7 +33,7 @@ export class AccountComponent implements OnInit {
|
|||||||
account: Account
|
account: Account
|
||||||
accountEntries: DN_AccountEntry[]
|
accountEntries: DN_AccountEntry[]
|
||||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||||
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "category", "overhead_relevant" ]
|
accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "dueAt", "category", "overhead_relevant" ]
|
||||||
saldo: Saldo
|
saldo: Saldo
|
||||||
|
|
||||||
accountEntryCategories: AccountEntryCategory[]
|
accountEntryCategories: AccountEntryCategory[]
|
||||||
@ -98,6 +98,7 @@ export class AccountComponent implements OnInit {
|
|||||||
description: formData.value.description,
|
description: formData.value.description,
|
||||||
account: this.account.id,
|
account: this.account.id,
|
||||||
created_at: formData.value.createdAt,
|
created_at: formData.value.createdAt,
|
||||||
|
due_at: formData.value.dueAt,
|
||||||
amount: formData.value.amount,
|
amount: formData.value.amount,
|
||||||
id: 0,
|
id: 0,
|
||||||
document_no: uniquenumber.number,
|
document_no: uniquenumber.number,
|
||||||
|
@ -191,6 +191,7 @@ 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
|
document_no: number
|
||||||
account_entry_category: number
|
account_entry_category: number
|
||||||
@ -200,6 +201,7 @@ export const NULL_AccountEntry: AccountEntry = {
|
|||||||
,description: ''
|
,description: ''
|
||||||
,account: undefined
|
,account: undefined
|
||||||
,created_at: ''
|
,created_at: ''
|
||||||
|
,due_at: ''
|
||||||
,amount: undefined
|
,amount: undefined
|
||||||
,document_no: undefined
|
,document_no: undefined
|
||||||
,account_entry_category: undefined
|
,account_entry_category: undefined
|
||||||
|
Loading…
x
Reference in New Issue
Block a user