overhead account stuff
This commit is contained in:
parent
ba63874a18
commit
28e505f570
@ -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']
|
||||
|
||||
|
@ -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": ()
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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": [
|
||||
|
@ -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)
|
||||
);
|
||||
|
@ -36,6 +36,10 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
</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">
|
||||
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||
|
@ -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<DN_AccountEntry>
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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<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
|
||||
address1: string
|
||||
saldo: number
|
||||
}
|
||||
|
||||
export interface UniqueNumber {
|
||||
number: number
|
||||
}
|
@ -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="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-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/premise/', row.id]"></tr>
|
||||
</table>
|
||||
|
@ -13,7 +13,8 @@ export class MyPremisesComponent implements OnInit {
|
||||
|
||||
premises: Premise[]
|
||||
dataSource: MatTableDataSource<Premise>
|
||||
displayedColumns: string[] = [ "description", "street", "zip", "city" ]
|
||||
displayedColumns: string[] = [ "description", "street", "zip", "city", "account" ]
|
||||
|
||||
|
||||
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
||||
|
||||
|
@ -9,31 +9,58 @@
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<form (ngSubmit)="savePremise()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="premise.description"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Strasse</mat-label>
|
||||
<input matInput name="street" [(ngModel)]="premise.street"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<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>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseDetails = true"
|
||||
(closed)="collapseDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Details
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<form (ngSubmit)="savePremise()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="premise.description"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Strasse</mat-label>
|
||||
<input matInput name="street" [(ngModel)]="premise.street"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<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">
|
||||
<mat-label>Betriebskostenkonto</mat-label>
|
||||
<input matInput name="street" [(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>
|
||||
</section>
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user