locale stuff

This commit is contained in:
2021-09-09 18:00:24 +02:00
parent 8276e39a7e
commit 6fcd785be0
16 changed files with 250 additions and 23 deletions

View File

@ -24,4 +24,8 @@ table {
.rightaligned {
justify-self: right;
}
.large {
font-size: large;
}

View File

@ -10,7 +10,7 @@
(closed)="collapse = false">
<mat-expansion-panel-header>
<mat-panel-title *ngIf="!collapse">
Kontoübersicht
Kontoübersicht, Saldo: {{saldo?.saldo | number:'1.2-2'}} €
</mat-panel-title>
<mat-panel-description>
</mat-panel-description>
@ -34,6 +34,9 @@
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
</form>
</div>
<div class="large">
Saldo: {{saldo?.saldo | number:'1.2-2'}} €
</div>
<div id="secondBlock">
<table mat-table [dataSource]="accountEntriesDataSource" #zftable>
<ng-container matColumnDef="description">

View File

@ -3,6 +3,8 @@ import { MatButton } from '@angular/material/button';
import { MatTableDataSource } from '@angular/material/table';
import { AccountEntryService, AccountService } from '../data-object-service';
import { Account, AccountEntry, NULL_AccountEntry } from '../data-objects';
import { ExtApiService } from '../ext-data-object-service';
import { Saldo } from '../ext-data-objects';
import { MessageService } from '../message.service';
@Component({
@ -21,6 +23,8 @@ export class AccountComponent implements OnInit {
accountEntries: AccountEntry[]
accountEntriesDataSource: MatTableDataSource<AccountEntry>
accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt" ]
saldo: Saldo
newAccountEntry: AccountEntry = NULL_AccountEntry
@ -28,6 +32,7 @@ export class AccountComponent implements OnInit {
constructor(
private accountService: AccountService,
private accountEntryService: AccountEntryService,
private extApiService: ExtApiService,
private messageService: MessageService
) { }
@ -47,8 +52,10 @@ export class AccountComponent implements OnInit {
async getAccountEntries(): Promise<void> {
try {
this.accountEntries = await this.accountEntryService.getAccountEntrysByAccount(this.selectedAccountId)
this.accountEntries.reverse()
this.messageService.add(`AccountEntries: ${JSON.stringify(this.accountEntries, undefined, 4)}`)
this.accountEntriesDataSource = new MatTableDataSource<AccountEntry>(this.accountEntries)
this.saldo = await this.extApiService.getAccountSaldo(this.selectedAccountId)
} catch (err) {
this.messageService.add(`Error in getAccountEntries: ${JSON.stringify(err, undefined, 4)}`)
}
@ -61,7 +68,7 @@ export class AccountComponent implements OnInit {
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': 0, 'created_at': '', 'description': '', 'id': 0 }
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0 }
this.getAccountEntries()
} catch (err) {
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)

View File

@ -1,5 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { LOCALE_ID, NgModule } from '@angular/core';
import localeDe from '@angular/common/locales/de';
import { registerLocaleData } from '@angular/common';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@ -43,6 +45,8 @@ import { FeeDetailsComponent } from './fee-details/fee-details.component';
import { MatExpansionModule } from '@angular/material/expansion';
import { AccountComponent } from './account/account.component'
registerLocaleData(localeDe)
@NgModule({
declarations: [
AppComponent,
@ -92,6 +96,7 @@ import { AccountComponent } from './account/account.component'
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: ErrorHandlerInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: AuthHandlerInterceptor, multi: true },
{ provide: LOCALE_ID, useValue: 'de' },
MatNativeDateModule
],
bootstrap: [AppComponent]

View File

@ -43,7 +43,7 @@ export const NULL_Tenant: Tenant = {
,phone1: ''
,phone2: ''
,iban: ''
,account: 0
,account: undefined
}
export interface Premise {
@ -71,9 +71,9 @@ export interface Flat {
export const NULL_Flat: Flat = {
id: 0
,description: ''
,premise: 0
,area: 0
,flat_no: 0
,premise: undefined
,area: undefined
,flat_no: undefined
}
export interface OverheadAdvance {
@ -86,7 +86,7 @@ export interface OverheadAdvance {
export const NULL_OverheadAdvance: OverheadAdvance = {
id: 0
,description: ''
,amount: 0
,amount: undefined
,startdate: ''
,enddate: ''
}
@ -98,8 +98,8 @@ export interface OverheadAdvanceFlatMapping {
}
export const NULL_OverheadAdvanceFlatMapping: OverheadAdvanceFlatMapping = {
id: 0
,overhead_advance: 0
,flat: 0
,overhead_advance: undefined
,flat: undefined
}
export interface Parking {
@ -110,7 +110,7 @@ export interface Parking {
export const NULL_Parking: Parking = {
id: 0
,description: ''
,premise: 0
,premise: undefined
}
export interface CommercialPremise {
@ -121,7 +121,7 @@ export interface CommercialPremise {
export const NULL_CommercialPremise: CommercialPremise = {
id: 0
,description: ''
,premise: 0
,premise: undefined
}
export interface Tenancy {
@ -137,10 +137,10 @@ export interface Tenancy {
export const NULL_Tenancy: Tenancy = {
id: 0
,description: ''
,tenant: 0
,flat: 0
,parking: 0
,commercial_premise: 0
,tenant: undefined
,flat: undefined
,parking: undefined
,commercial_premise: undefined
,startdate: ''
,enddate: ''
}
@ -156,7 +156,7 @@ export interface Fee {
export const NULL_Fee: Fee = {
id: 0
,description: ''
,amount: 0
,amount: undefined
,fee_type: ''
,startdate: ''
,enddate: ''
@ -169,8 +169,8 @@ export interface TenancyFeeMapping {
}
export const NULL_TenancyFeeMapping: TenancyFeeMapping = {
id: 0
,tenancy: 0
,fee: 0
,tenancy: undefined
,fee: undefined
}
export interface AccountEntry {
@ -183,9 +183,9 @@ export interface AccountEntry {
export const NULL_AccountEntry: AccountEntry = {
id: 0
,description: ''
,account: 0
,account: undefined
,created_at: ''
,amount: 0
,amount: undefined
}

View File

@ -16,7 +16,7 @@ export const NULL_$JsNameConverter($table.name): $JsNameConverter($table.name) =
#if $column.jstype == "string"
''
#else if $column.jstype == "number"
0
undefined
#end if
#end for
}

View File

@ -7,6 +7,7 @@ import { serviceBaseUrl } from './config';
import { Fee, OverheadAdvance } from './data-objects';
import { Saldo } from './ext-data-objects';
@Injectable({ providedIn: 'root' })
@ -22,4 +23,9 @@ export class ExtApiService {
this.messageService.add(`ExtApiService: get fees by flat ${id}`);
return this.http.get<Fee[]>(`${serviceBaseUrl}/v1/fees/tenancy/${id}`).toPromise()
}
async getAccountSaldo(id: number): Promise<Saldo> {
this.messageService.add(`ExtApiService: get saldo for account ${id}`);
return this.http.get<Saldo>(`${serviceBaseUrl}/v1/account/saldo/${id}`).toPromise()
}
}

View File

@ -0,0 +1,5 @@
export interface Saldo {
saldo: number
}