Compare commits
12 Commits
0.0.22
...
overhead_a
Author | SHA1 | Date | |
---|---|---|---|
44202ef9ed
|
|||
34f8e8ecd4
|
|||
6f3248f03c
|
|||
3c97fb3582
|
|||
3ad019b374
|
|||
28e505f570
|
|||
ba63874a18
|
|||
0e1e03f1a9
|
|||
272500df8c
|
|||
0ab106d021
|
|||
125af5a206
|
|||
419997cea5
|
@ -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": [
|
||||
|
6
schema/changes01.sql
Normal file
6
schema/changes01.sql
Normal file
@ -0,0 +1,6 @@
|
||||
alter table premise_t add column account integer;
|
||||
alter table premise_t add constraint fk_premise_t_account foreign key (account) references account_t(id);
|
||||
alter table premise_t add constraint uk_premise_t_account unique(account);
|
||||
alter table account_entry_t add column document_no integer unique;
|
||||
create sequence unique_number_s start with 1 increment by 1;
|
||||
|
@ -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)
|
||||
);
|
||||
|
@ -1,24 +1,24 @@
|
||||
<div id="firstBlock">
|
||||
<form (ngSubmit)="addAccountEntry()">
|
||||
<form (ngSubmit)="addAccountEntry(accountEntryForm)" #accountEntryForm="ngForm">
|
||||
<mat-form-field appearance="outline" id="addEntryfield">
|
||||
<mat-label>Datum</mat-label>
|
||||
<input matInput name="createdAt" [(ngModel)]="newAccountEntry.created_at" [matDatepicker]="createdAtPicker"/>
|
||||
<input matInput ngModel name="createdAt" [matDatepicker]="createdAtPicker"/>
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select [(ngModel)]="newAccountEntry.account_entry_category" name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" [(ngModel)]="newAccountEntry.amount"/>
|
||||
<input matInput type="number" name="amount" ngModel/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="newAccountEntry.description"/>
|
||||
<input matInput name="description" ngModel/>
|
||||
</mat-form-field>
|
||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||
</form>
|
||||
@ -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>
|
||||
|
@ -5,8 +5,9 @@ import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { AccountEntryCategoryService, AccountEntryService, AccountService } from '../data-object-service';
|
||||
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';
|
||||
|
||||
|
||||
@ -32,14 +33,13 @@ 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[]
|
||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
|
||||
|
||||
constructor(
|
||||
@ -47,7 +47,8 @@ export class AccountComponent implements OnInit {
|
||||
private accountEntryService: AccountEntryService,
|
||||
private extApiService: ExtApiService,
|
||||
private accountEntryCategoryService: AccountEntryCategoryService,
|
||||
private messageService: MessageService
|
||||
private messageService: MessageService,
|
||||
private errorDialogService: ErrorDialogService
|
||||
) { }
|
||||
|
||||
|
||||
@ -87,20 +88,42 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async addAccountEntry(): Promise<void> {
|
||||
try {
|
||||
this.addAccountEntryButton.disabled = true
|
||||
this.newAccountEntry.account = this.account.id
|
||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(this.newAccountEntry, undefined, 4) }`)
|
||||
this.newAccountEntry = await this.accountEntryService.postAccountEntry(this.newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${this.newAccountEntry.id}`)
|
||||
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0, 'account_entry_category': 0 }
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
} finally {
|
||||
this.addAccountEntryButton.disabled = false
|
||||
async addAccountEntry(formData: any): Promise<void> {
|
||||
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
|
||||
}
|
||||
|
||||
if (this.shallBeRentPayment) {
|
||||
newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||
this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`)
|
||||
} else {
|
||||
newAccountEntry.account_entry_category = formData.value.category
|
||||
this.messageService.add(`category is ${newAccountEntry.account_entry_category}`)
|
||||
}
|
||||
|
||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(newAccountEntry, undefined, 4) }`)
|
||||
newAccountEntry = await this.accountEntryService.postAccountEntry(newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${newAccountEntry.id}`)
|
||||
|
||||
formData.reset()
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
this.errorDialogService.openDialog('AccountComponent', 'addAccountEntry', JSON.stringify(err, undefined, 4))
|
||||
} finally {
|
||||
this.addAccountEntryButton.disabled = false
|
||||
}
|
||||
}
|
||||
|
||||
async getAccountEntryCategories(): Promise<void> {
|
||||
@ -123,10 +146,6 @@ export class AccountComponent implements OnInit {
|
||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
await this.getAccountEntryCategories()
|
||||
if (this.shallBeRentPayment) {
|
||||
this.messageService.add('shall be rentpayment')
|
||||
this.newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -137,4 +156,5 @@ export class AccountComponent implements OnInit {
|
||||
this.init()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ import { NoteComponent } from './note/note.component'
|
||||
import { MatMomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
|
||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component'
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||
|
||||
registerLocaleData(localeDe)
|
||||
|
||||
@ -78,7 +79,8 @@ registerLocaleData(localeDe)
|
||||
NoteComponent,
|
||||
EnterPaymentComponent,
|
||||
HomeComponent,
|
||||
LedgerComponent
|
||||
LedgerComponent,
|
||||
ErrorDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export interface ErrorDialogData {
|
||||
module: string,
|
||||
func: string,
|
||||
msg: string
|
||||
}
|
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogService } from './error-dialog.service';
|
||||
|
||||
describe('ErrorDialogService', () => {
|
||||
let service: ErrorDialogService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ErrorDialogService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorDialogService {
|
||||
|
||||
constructor(public dialog: MatDialog) { }
|
||||
|
||||
openDialog(module: string, func: string, msg: string): void {
|
||||
const dialogRef = this.dialog.open(ErrorDialogComponent, {
|
||||
width: '450px',
|
||||
data: { module: module, func: func, msg: msg }
|
||||
})
|
||||
}
|
||||
}
|
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<h1>Fehler</h1>
|
||||
|
||||
<h2>Module</h2>
|
||||
<p>{{data.module}}</p>
|
||||
|
||||
<h2>Function</h2>
|
||||
<p>{{data.func}}</p>
|
||||
|
||||
<h2>Message</h2>
|
||||
<p>{{data.msg}}</p>
|
||||
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogComponent } from './error-dialog.component';
|
||||
|
||||
describe('ErrorDialogComponent', () => {
|
||||
let component: ErrorDialogComponent;
|
||||
let fixture: ComponentFixture<ErrorDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ErrorDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ErrorDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { ErrorDialogData } from '../error-dialog-data';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error-dialog',
|
||||
templateUrl: './error-dialog.component.html',
|
||||
styleUrls: ['./error-dialog.component.css']
|
||||
})
|
||||
export class ErrorDialogComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ErrorDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: ErrorDialogData
|
||||
) { }
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close()
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
@ -6,6 +6,18 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseExpenseDetails = true"
|
||||
(closed)="collapseExpenseDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Ausgaben
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
<div>Betriebskosten-relevante Ausgaben nicht hier sondern im Betriebskostenkonto unter "Meine Häuser" erfassen.</div>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account #expenseAccountComponent [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel (opened)="collapseIncomeDetails = true"
|
||||
(closed)="collapseIncomeDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
@ -15,18 +27,7 @@
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account [selectedAccountId]="incomeAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel (opened)="collapseExpenseDetails = true"
|
||||
(closed)="collapseExpenseDetails = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Ausgaben
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-account [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
<app-account #incomeAccountComponent [selectedAccountId]="incomeAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</mat-card-content>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AccountComponent } from '../account/account.component';
|
||||
import { Account } from '../data-objects';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { MessageService } from '../message.service';
|
||||
@ -18,6 +19,9 @@ export class LedgerComponent implements OnInit {
|
||||
collapseIncomeDetails: boolean = false
|
||||
collapseExpenseDetails: boolean = false
|
||||
|
||||
@ViewChild('incomeAccountComponent') incomeAccountComponent: AccountComponent
|
||||
@ViewChild('expenseAccountComponent') expenseAccountComponent: AccountComponent
|
||||
|
||||
|
||||
constructor(
|
||||
private extApiService: ExtApiService,
|
||||
|
@ -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,8 +9,6 @@
|
||||
</mat-nav-list>
|
||||
<mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/enterPayment">Mietzahlung eintragen</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/ledger">Buchführung</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
@ -22,6 +20,8 @@
|
||||
<a mat-list-item href="/fees">Mietsätze</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/premises">Meine Häuser</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/ledger">Buchführung</a>
|
||||
</mat-nav-list><mat-divider *ngIf="authenticated"></mat-divider><mat-nav-list *ngIf="authenticated">
|
||||
<a mat-list-item href="/logout">Abmelden</a>
|
||||
</mat-nav-list>
|
||||
|
@ -9,31 +9,59 @@
|
||||
</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"
|
||||
[expanded]="premise.id == 0">
|
||||
<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" *ngIf="premise.account">
|
||||
<mat-label>Betriebskostenkonto</mat-label>
|
||||
<input matInput name="account" [readonly]="true" [(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,9 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
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 +13,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 +36,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))
|
||||
@ -47,6 +51,12 @@ export class PremiseDetailsComponent implements OnInit {
|
||||
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
|
||||
if (this.premise.id == 0) {
|
||||
this.messageService.add("about to insert new premise")
|
||||
this.overheadAccount = {
|
||||
"id": 0,
|
||||
"description": `overhead_account_${this.premise.description}`
|
||||
}
|
||||
this.overheadAccount = await this.accountService.postAccount(this.overheadAccount)
|
||||
this.premise.account = this.overheadAccount.id
|
||||
this.premise = await this.premiseService.postPremise(this.premise)
|
||||
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
||||
} else {
|
||||
|
@ -8,7 +8,8 @@
|
||||
<mat-card-content>
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel (opened)="collapseTenantDetails = true"
|
||||
(closed)="collapseTenantDetails = false">
|
||||
(closed)="collapseTenantDetails = false"
|
||||
[expanded]="tenant.id == 0">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title *ngIf="!collapseTenantDetails">
|
||||
Details
|
||||
@ -68,18 +69,18 @@
|
||||
<input matInput name="iban" [(ngModel)]="tenant.iban"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!--
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-form-field appearance="outline" *ngIf="tenant.account">
|
||||
<mat-label>Account ID</mat-label>
|
||||
<input matInput name="account_id" [readonly]="true" [ngModel]="account.id"/>
|
||||
<input matInput name="account_id" [readonly]="true" [ngModel]="tenant.account"/>
|
||||
</mat-form-field>
|
||||
<!--
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Account Description</mat-label>
|
||||
<input matInput name="account_desc" [readonly]="true" [ngModel]="account.description"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
-->
|
||||
-->
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user