diff --git a/api/additional_endpoints.yaml b/api/additional_endpoints.yaml
index 8b20cad..1266fe1 100644
--- a/api/additional_endpoints.yaml
+++ b/api/additional_endpoints.yaml
@@ -110,4 +110,21 @@
$ref: '#/components/schemas/account'
security:
- 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']
diff --git a/api/additional_methods.py b/api/additional_methods.py
index 0fde45c..bf330f0 100644
--- a/api/additional_methods.py
+++ b/api/additional_methods.py
@@ -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": ()
+ })
diff --git a/api/methods.py b/api/methods.py
index d164904..a3556bc 100644
--- a/api/methods.py
+++ b/api/methods.py
@@ -283,6 +283,7 @@ SELECT
,street
,zip
,city
+ ,account
FROM premise_t
ORDER BY
description
@@ -298,6 +299,7 @@ def insert_premise(user, token_info, **args):
v_street = body["street"]
v_zip = body["zip"]
v_city = body["city"]
+ v_account = body["account"]
return dbInsert(user, token_info, {
"statement": """
INSERT INTO premise_t
@@ -306,11 +308,13 @@ INSERT INTO premise_t
,street
,zip
,city
+ ,account
) VALUES (
%s
,%s
,%s
,%s
+ ,%s
)
RETURNING *
""",
@@ -319,6 +323,7 @@ INSERT INTO premise_t
,v_street
,v_zip
,v_city
+ ,v_account
]
})
except KeyError as e:
@@ -335,6 +340,7 @@ SELECT
,street
,zip
,city
+ ,account
FROM premise_t
WHERE id = %s
""",
@@ -373,6 +379,23 @@ UPDATE premise_t
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
+ """,
+ "params": (accountId, )
+ }
+ )
+
def get_flats(user, token_info):
return dbGetMany(user, token_info, {
"statement": """
@@ -1301,6 +1324,7 @@ SELECT
,account
,created_at
,amount
+ ,document_no
,account_entry_category
FROM account_entry_t
ORDER BY
@@ -1317,6 +1341,7 @@ def insert_account_entry(user, token_info, **args):
v_account = body["account"]
v_created_at = body["created_at"]
v_amount = body["amount"]
+ v_document_no = body["document_no"]
v_account_entry_category = body["account_entry_category"]
return dbInsert(user, token_info, {
"statement": """
@@ -1326,6 +1351,7 @@ INSERT INTO account_entry_t
,account
,created_at
,amount
+ ,document_no
,account_entry_category
) VALUES (
%s
@@ -1333,6 +1359,7 @@ INSERT INTO account_entry_t
,%s
,%s
,%s
+ ,%s
)
RETURNING *
""",
@@ -1341,6 +1368,7 @@ INSERT INTO account_entry_t
,v_account
,v_created_at
,v_amount
+ ,v_document_no
,v_account_entry_category
]
})
@@ -1358,6 +1386,7 @@ SELECT
,account
,created_at
,amount
+ ,document_no
,account_entry_category
FROM account_entry_t
WHERE id = %s
@@ -1377,6 +1406,7 @@ SELECT
,account
,created_at
,amount
+ ,document_no
,account_entry_category
FROM account_entry_t
WHERE account = %s
@@ -1394,6 +1424,7 @@ SELECT
,account
,created_at
,amount
+ ,document_no
,account_entry_category
FROM account_entry_t
WHERE account_entry_category = %s
diff --git a/api/openapi.yaml b/api/openapi.yaml
index ee4c3cd..44ffc46 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -299,6 +299,28 @@ paths:
$ref: '#/components/schemas/premise'
security:
- 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:
get:
tags: [ "flat" ]
@@ -1531,6 +1553,23 @@ paths:
$ref: '#/components/schemas/account'
security:
- 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:
@@ -1605,6 +1644,8 @@ components:
type: string
city:
type: string
+ account:
+ type: integer
flat:
description: flat
type: object
@@ -1751,6 +1792,9 @@ components:
type: string
amount:
type: number
+ document_no:
+ type: integer
+ nullable: true
account_entry_category:
type: integer
note:
diff --git a/schema.json b/schema.json
index 13e41a9..3dd0032 100644
--- a/schema.json
+++ b/schema.json
@@ -32,7 +32,8 @@
{ "name": "description", "sqltype": "varchar(128)", "selector": 0, "unique": true },
{ "name": "street", "sqltype": "varchar(128)", "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 }
]
},
{
@@ -137,6 +138,7 @@
{ "name": "account", "sqltype": "integer", "notnull": true, "foreignkey": true },
{ "name": "created_at", "sqltype": "timestamp", "notnull": true, "default": "now()" },
{ "name": "amount", "sqltype": "numeric(10,2)", "notnull": true, "selector": 0 },
+ { "name": "document_no", "sqltype": "integer", "unique": true },
{ "name": "account_entry_category", "sqltype": "integer", "notnull": true, "foreignkey": true }
],
"tableConstraints": [
diff --git a/schema/create.sql b/schema/create.sql
index d6392fd..4520315 100644
--- a/schema/create.sql
+++ b/schema/create.sql
@@ -39,6 +39,7 @@ CREATE TABLE premise_t (
,street varchar(128) not null
,zip varchar(10) 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;
@@ -149,6 +150,7 @@ CREATE TABLE account_entry_t (
,account integer not null references account_t (id)
,created_at timestamp not null default now()
,amount numeric(10,2) not null
+ ,document_no integer unique
,account_entry_category integer not null references account_entry_category_t (id)
,unique(description, account, created_at)
);
diff --git a/ui/hv2-ui/src/app/account/account.component.html b/ui/hv2-ui/src/app/account/account.component.html
index 2066789..a7bc2b9 100644
--- a/ui/hv2-ui/src/app/account/account.component.html
+++ b/ui/hv2-ui/src/app/account/account.component.html
@@ -36,6 +36,10 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
Beschreibung |
{{element.rawAccountEntry.description}} |
+
+ Belegnummer |
+ {{element.rawAccountEntry.document_no}} |
+
Betrag |
{{element.rawAccountEntry.amount | number:'1.2-2'}} € |
diff --git a/ui/hv2-ui/src/app/account/account.component.ts b/ui/hv2-ui/src/app/account/account.component.ts
index 6414f65..a7a25c8 100644
--- a/ui/hv2-ui/src/app/account/account.component.ts
+++ b/ui/hv2-ui/src/app/account/account.component.ts
@@ -7,7 +7,7 @@ import { AccountEntryCategoryService, AccountEntryService, AccountService } from
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
import { ErrorDialogService } from '../error-dialog.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';
@@ -33,7 +33,7 @@ export class AccountComponent implements OnInit {
account: Account
accountEntries: DN_AccountEntry[]
accountEntriesDataSource: MatTableDataSource
- accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt", "category", "overhead_relevant" ]
+ accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "category", "overhead_relevant" ]
saldo: Saldo
accountEntryCategories: AccountEntryCategory[]
@@ -92,12 +92,15 @@ export class AccountComponent implements OnInit {
try {
this.addAccountEntryButton.disabled = true
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 = {
description: formData.value.description,
account: this.account.id,
created_at: formData.value.createdAt,
amount: formData.value.amount,
id: 0,
+ document_no: uniquenumber.number,
account_entry_category: 0
}
diff --git a/ui/hv2-ui/src/app/config.ts b/ui/hv2-ui/src/app/config.ts
index 7cdcad6..3b143eb 100644
--- a/ui/hv2-ui/src/app/config.ts
+++ b/ui/hv2-ui/src/app/config.ts
@@ -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://localhost:8080"
+export const serviceBaseUrl = "http://localhost:8080"
export const authserviceBaseUrl = "https://authservice.hottis.de"
export const applicationId = "hv2"
diff --git a/ui/hv2-ui/src/app/data-object-service.ts b/ui/hv2-ui/src/app/data-object-service.ts
index db4c594..13a5dba 100644
--- a/ui/hv2-ui/src/app/data-object-service.ts
+++ b/ui/hv2-ui/src/app/data-object-service.ts
@@ -130,6 +130,11 @@ export class PremiseService {
}
+ async getPremisesByAccount(id: number): Promise {
+ this.messageService.add(`PremiseService: get data by Account ${id}`);
+ return this.http.get(`${serviceBaseUrl}/v1/premises/account/${id}`).toPromise()
+ }
+
}
diff --git a/ui/hv2-ui/src/app/data-objects.ts b/ui/hv2-ui/src/app/data-objects.ts
index d8fa3fc..f36c617 100644
--- a/ui/hv2-ui/src/app/data-objects.ts
+++ b/ui/hv2-ui/src/app/data-objects.ts
@@ -52,6 +52,7 @@ export interface Premise {
street: string
zip: string
city: string
+ account: number
}
export const NULL_Premise: Premise = {
id: 0
@@ -59,6 +60,7 @@ export const NULL_Premise: Premise = {
,street: ''
,zip: ''
,city: ''
+ ,account: undefined
}
export interface Flat {
@@ -190,6 +192,7 @@ export interface AccountEntry {
account: number
created_at: string
amount: number
+ document_no: number
account_entry_category: number
}
export const NULL_AccountEntry: AccountEntry = {
@@ -198,6 +201,7 @@ export const NULL_AccountEntry: AccountEntry = {
,account: undefined
,created_at: ''
,amount: undefined
+ ,document_no: undefined
,account_entry_category: undefined
}
diff --git a/ui/hv2-ui/src/app/ext-data-object-service.ts b/ui/hv2-ui/src/app/ext-data-object-service.ts
index 5e1d869..d41cf4e 100644
--- a/ui/hv2-ui/src/app/ext-data-object-service.ts
+++ b/ui/hv2-ui/src/app/ext-data-object-service.ts
@@ -7,7 +7,7 @@ import { serviceBaseUrl } from './config';
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' })
@@ -38,4 +38,9 @@ export class ExtApiService {
this.messageService.add("ExtApiService: get tenants with saldo");
return this.http.get(`${serviceBaseUrl}/v1/tenants/saldo`).toPromise()
}
+
+ async getUniqueNumber(): Promise {
+ this.messageService.add("ExtApiService: get unique number");
+ return this.http.get(`${serviceBaseUrl}/v1/uniquenumber`).toPromise()
+ }
}
diff --git a/ui/hv2-ui/src/app/ext-data-objects.ts b/ui/hv2-ui/src/app/ext-data-objects.ts
index 37d9aed..260262b 100644
--- a/ui/hv2-ui/src/app/ext-data-objects.ts
+++ b/ui/hv2-ui/src/app/ext-data-objects.ts
@@ -9,4 +9,8 @@ export interface Tenant_with_Saldo {
lastname: string
address1: string
saldo: number
+}
+
+export interface UniqueNumber {
+ number: number
}
\ No newline at end of file
diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.html b/ui/hv2-ui/src/app/my-premises/my-premises.component.html
index 942f70e..71fe14e 100644
--- a/ui/hv2-ui/src/app/my-premises/my-premises.component.html
+++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.html
@@ -26,6 +26,10 @@
Ort |
{{element.city}} |
+
+ Betriebskostenkonto |
+ {{element.account}} |
+
diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.ts b/ui/hv2-ui/src/app/my-premises/my-premises.component.ts
index 35a64c1..18ddc89 100644
--- a/ui/hv2-ui/src/app/my-premises/my-premises.component.ts
+++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.ts
@@ -13,7 +13,8 @@ export class MyPremisesComponent implements OnInit {
premises: Premise[]
dataSource: MatTableDataSource
- displayedColumns: string[] = [ "description", "street", "zip", "city" ]
+ displayedColumns: string[] = [ "description", "street", "zip", "city", "account" ]
+
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
diff --git a/ui/hv2-ui/src/app/premise-details/premise-details.component.html b/ui/hv2-ui/src/app/premise-details/premise-details.component.html
index 68d6f87..e280e9b 100644
--- a/ui/hv2-ui/src/app/premise-details/premise-details.component.html
+++ b/ui/hv2-ui/src/app/premise-details/premise-details.component.html
@@ -9,31 +9,58 @@
-
+
+
+
+
+ Details
+
+
+
+
+
+
+
+
+
+ Betriebskostenkonto
+
+
+
+
+
+
+
+
diff --git a/ui/hv2-ui/src/app/premise-details/premise-details.component.ts b/ui/hv2-ui/src/app/premise-details/premise-details.component.ts
index 2eb4a08..503da66 100644
--- a/ui/hv2-ui/src/app/premise-details/premise-details.component.ts
+++ b/ui/hv2-ui/src/app/premise-details/premise-details.component.ts
@@ -1,8 +1,8 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatButton } from '@angular/material/button';
import { ActivatedRoute, Router } from '@angular/router';
-import { PremiseService } from '../data-object-service';
-import { Premise } from '../data-objects';
+import { AccountService, PremiseService } from '../data-object-service';
+import { Account, NULL_Premise, Premise } from '../data-objects';
import { MessageService } from '../message.service';
@Component({
@@ -12,18 +12,19 @@ import { MessageService } from '../message.service';
})
export class PremiseDetailsComponent implements OnInit {
+ collapseDetails: boolean = false
+ collapseOverheadAccount: boolean = false
+
@ViewChild('submitButton') submitButton: MatButton
- premise: Premise = {
- id: 0,
- description: '',
- street: '',
- zip: '',
- city: ''
- }
+ premise: Premise = NULL_Premise
+
+ overheadAccount: Account
+ overheadAccountId: number
constructor(
private premiseService: PremiseService,
+ private accountService: AccountService,
private messageService: MessageService,
private route: ActivatedRoute,
private router: Router
@@ -34,6 +35,8 @@ export class PremiseDetailsComponent implements OnInit {
const id = +this.route.snapshot.paramMap.get('id')
if (id != 0) {
this.premise = await this.premiseService.getPremise(id)
+ this.overheadAccount = await this.accountService.getAccount(this.premise.account)
+ this.overheadAccountId = this.overheadAccount.id
}
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))