Skip to content

Commit

Permalink
Merge pull request #27 from Gepardec/feature/749
Browse files Browse the repository at this point in the history
Feature/749
  • Loading branch information
Ollitod authored Jun 7, 2024
2 parents 26d7bd9 + 8880b9b commit 3de68ff
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 139 deletions.
11 changes: 0 additions & 11 deletions src/app/domains/monthly-report/data-model/BillData.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/app/domains/monthly-report/data-model/BillInfoData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface BillInfoData {
description: string;
icon?: string;
value: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface MonthlyBillInfoData {
sumBills: number,
sumPrivateBills: number,
sumCompanyBills: string,
hasAttachmentWarnings: boolean,
employeeHasCreditCard: boolean
}
Original file line number Diff line number Diff line change
@@ -1,75 +1,60 @@
<mat-card appearance="raised" class="fill-parent">
<mat-card appearance="raised" class="fill-parent bills-card">
<mat-card-header>
<mat-card-title>
{{ 'monthly-report.title.bills' | translate }}
<ngx-skeleton-loader *ngIf="!billInfo else title"
[theme]="{ height: '30px', width: '250px' }"
appearance="line"></ngx-skeleton-loader>

<ng-template #title>
{{ 'monthly-report.title.bills' | translate }}
</ng-template>
</mat-card-title>
</mat-card-header>
<mat-card-content [class.no-warnings]="bills?.length === 0">
<ng-container *ngIf="!bills else billData">

<mat-card-content [class.no-warnings]="!billInfo?.hasAttachmentWarnings && billInfo?.sumBills === 0 && !billInfo.employeeHasCreditCard" >
<ng-container *ngIf="!billInfo">
<ngx-skeleton-loader [theme]="{ height: '56px' }"
appearance="line"></ngx-skeleton-loader>
<ngx-skeleton-loader [theme]="{ height: '75px' }"
<ngx-skeleton-loader [theme]="{ height: '56px' }"
appearance="line"></ngx-skeleton-loader>
</ng-container>

<ng-template #billData>
<ng-container *ngIf="!bills || bills?.length === 0; else billsTable">
<app-state-indicator [state]="State.DONE" size="large"></app-state-indicator>
<p>{{ 'monthly-report.bills.noBillsForThisMonthAvailable' | translate }}</p>
</ng-container>

<ng-template #billsTable>
<mat-table [dataSource]="bills" class="mat-elevation-z1">

<ng-container matColumnDef="billDate">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.billDate' | translate }}</mat-header-cell>
<mat-cell *matCellDef="let bill">{{ bill.billDate | date:'dd.MM.yyyy' }}</mat-cell>
</ng-container>


<ng-container matColumnDef="bruttoValue">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.bruttoValue' | translate }}</mat-header-cell>
<mat-cell *matCellDef="let bill">{{ bill.bruttoValue | currency: 'EUR' }}</mat-cell>
</ng-container>

<ng-container *ngIf="!billInfo?.employeeHasCreditCard && billInfo?.sumBills === 0">
<app-state-indicator [state]="State.DONE" size="large"></app-state-indicator>
<p>{{ 'monthly-report.bills.noBillsForThisMonthAvailable' | translate }}</p>
</ng-container>

<ng-container matColumnDef="billType">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.billType' | translate }}</mat-header-cell>
<mat-cell *matCellDef="let bill">{{ bill.billType }}</mat-cell>
<ng-container *ngIf="billInfo?.sumBills > 0 || billInfo?.employeeHasCreditCard">
<div *ngIf="billInfo">
<mat-table *ngIf="billInfo" [dataSource]="toBillsData(billInfo)" class="mat-elevation-z1">

<ng-container matColumnDef="icon">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let row">
<ng-container *ngIf="row.icon">
<app-state-indicator size="small"></app-state-indicator>
</ng-container>
</mat-cell>
</ng-container>


<ng-container matColumnDef="paymentMethodType">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.paymentMethodType' | translate }}
</mat-header-cell>
<mat-cell *matCellDef="let bill">{{ bill.paymentMethodType }}</mat-cell>
<ng-container matColumnDef="description">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.description }}</mat-cell>
</ng-container>


<ng-container matColumnDef="projectName">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.projectName' | translate }}</mat-header-cell>
<mat-cell *matCellDef="let bill">{{ bill.projectName }}</mat-cell>
<ng-container matColumnDef="value">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.value }}</mat-cell>
</ng-container>

<ng-container matColumnDef="downloadButton">
<mat-header-cell *matHeaderCellDef>{{ 'monthly-report.bills.billAsFile' | translate }}</mat-header-cell>
<mat-cell *matCellDef="let bill">
<ng-container *ngIf="bill.attachmentBase64String">
<mat-icon class="downloadBtn" (click)="downloadPDF(bill)">get_app</mat-icon>
</ng-container>
<ng-container *ngIf="!bill.attachmentBase64String">
<app-state-indicator size="small"></app-state-indicator>
</ng-container>
</mat-cell>
</ng-container>

<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</ng-template>
</div>
</ng-container>

</ng-template>
<div *ngIf="billInfo?.employeeHasCreditCard" class="credit-card-warning">
<app-credit-card-warning></app-credit-card-warning>
</div>
</mat-card-content>
</mat-card>


Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
@import 'styles/colors';

.mat-card {
width: 100%;
border-radius: 0;

.mat-card-header {
background-color: #f0f0f0;
width: 100%;
border-top-left-radius: 0;
border-top-right-radius: 0;
.bills-card {
mat-card-content{
/* override default material padding */
padding-bottom: 0;
}
}

Expand All @@ -19,13 +14,59 @@
align-items: center;
}

.downloadBtn {
color: $gepardec-black;
.summary-container {
display: flex;
flex-direction: column;
}

.downloadBtn:hover {
cursor: pointer;
.summary-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
padding-right: 16px;
}

.summary-value {
display: flex;
align-items: center;
}

.summary-value {
display: flex;
align-items: center;
padding-right: 16px;
}

.mat-column-icon {
flex: 0 0 5%;
justify-content: right;
}

.mat-column-value {
flex: 0 0 10%;
justify-content: flex-start;
}

.credit-card-warning {
display: flex;
justify-content: flex-start;
}

@media screen and (min-width: 1664px){
.credit-card-warning {
margin-top: 30px;
}
}

@media (min-width: 1264px) and (max-width: 1664px) {
.credit-card-warning{
margin-top: 10px;
}
}

@media screen and (max-width: 1264px){
.credit-card-warning{
margin-top: 25px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import {Employee, State} from "@mega/shared/data-model";
import {BillService} from "../../../shared/data-service/bill/bill.service";
import {MatCardModule} from "@angular/material/card";
import {NgxSkeletonLoaderModule} from "ngx-skeleton-loader";
import {CurrencyPipe, DatePipe, NgIf} from "@angular/common";
import {CurrencyPipe, DatePipe, DecimalPipe, NgIf} from "@angular/common";
import {TranslateModule, TranslateService} from "@ngx-translate/core";
import {MatTableModule} from "@angular/material/table";
import {PaymentMethodType} from "../../../shared/data-model/PaymentMethodType";
import {MatButtonModule} from "@angular/material/button";
import {StateIndicatorComponent} from "@mega/shared/ui-common";
import {MonthlyReportService} from "@mega/monthly-report/data-service";
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
import {MatIconModule} from "@angular/material/icon";
import {BillData} from "../../data-model/BillData";
import {MonthlyBillInfoData} from "../../data-model/MonthlyBillInfoData";
import {BillInfoData} from "../../data-model/BillInfoData";
import {CreditCardWarningComponent} from "./credit-card-warning/credit-card-warning.component";

@Component({
selector: 'app-bills',
Expand All @@ -28,7 +29,9 @@ import {BillData} from "../../data-model/BillData";
DatePipe,
MatButtonModule,
StateIndicatorComponent,
MatIconModule
MatIconModule,
DecimalPipe,
CreditCardWarningComponent
],
standalone: true
})
Expand All @@ -37,15 +40,16 @@ export class BillsComponent implements OnChanges {
// to avoid calling REST before employeeId is present
@Input({required: true})
employee: Employee;
bills: Array<BillData>;
displayedColumns: string[];
protected readonly PaymentMethodType = PaymentMethodType;
billInfo: MonthlyBillInfoData;
displayedColumns = ['description', 'icon', 'value'];
billInfoData: BillInfoData[] = [];

constructor(private billService: BillService, private destroyRef: DestroyRef, private monthlyReportService: MonthlyReportService, private translateService: TranslateService) {
this.billInfo = null;
}

ngOnChanges(changes: SimpleChanges) {
this.bills = null;
this.billInfo = null;
const currentEmployee = changes.employee.currentValue as Employee;
if (currentEmployee?.userId) {
this.getBillsForEmployee(currentEmployee.userId, this.monthlyReportService.selectedYear.getValue(), this.monthlyReportService.selectedMonth.getValue());
Expand All @@ -58,36 +62,20 @@ export class BillsComponent implements OnChanges {
.pipe(
takeUntilDestroyed(this.destroyRef)
)
.subscribe(resultBillList => {
this.bills = resultBillList;
this.displayedColumns = ['billDate', 'bruttoValue', 'billType', 'paymentMethodType', 'projectName', 'downloadButton'];
}
.subscribe(monthlyBillInfo =>
this.billInfo = monthlyBillInfo
)
}


downloadPDF(bill: BillData) {
let base64String = bill.attachmentBase64String;

// check whether we need to prepend the data type or not for pdf
if (base64String.startsWith("JVB")) {
base64String = "data:application/pdf;base64," + base64String;
this.downloadFileObject(base64String, bill.attachmentFileName);
} else if (base64String.startsWith("data:application/pdf;base64")) {
this.downloadFileObject(base64String, bill.attachmentFileName);
} else {
this.translateService.get("notifications.errors.noValidBase64").subscribe(alertString =>
alert(alertString)
);
}
}

downloadFileObject(base64String: string, attachmentFilename: string) {
const downloadLink = document.createElement("a");
downloadLink.href = base64String;
// fileName for the pdf
downloadLink.download = attachmentFilename;
downloadLink.click();
toBillsData(billInfo: MonthlyBillInfoData): BillInfoData[] {
const icon = billInfo.hasAttachmentWarnings ? 'warning' : null;
this.translateService.get("billInfo").subscribe(translation => {
this.billInfoData = [
{ description: translation['zepEntriesWithBills'], icon: icon, value: billInfo.sumBills.toString() },
{ description: translation['privateCompanyBills'], icon: null, value: `${billInfo.sumPrivateBills} / ${billInfo.sumCompanyBills}` }
];
});
return this.billInfoData;
}

protected readonly State = State;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="credit-card-container">
<div class="icon-container">
<app-state-indicator size="small"></app-state-indicator>
</div>
<div class="text-container">
<p>{{'monthly-report.bills.hasCreditCard' | translate}}</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import 'styles/colors';

.credit-card-container {
background-color: $mega-warning-orange-transparent;
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
border-radius: 4px;
max-height: 50px;
}

.icon-container {
margin-right: 12px;
}

.credit-card-container .icon-container app-state-indicator::ng-deep mat-icon {
color: $mega-warning-orange;
}

.text-container {
color: $mega-warning-orange;
text-align: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CreditCardWarningComponent } from './credit-card-warning.component';

describe('CreditCardWarningComponent', () => {
let component: CreditCardWarningComponent;
let fixture: ComponentFixture<CreditCardWarningComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CreditCardWarningComponent]
});
fixture = TestBed.createComponent(CreditCardWarningComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Component} from '@angular/core';
import {StateIndicatorComponent} from "@mega/shared/ui-common";
import {TranslateModule} from "@ngx-translate/core";

@Component({
selector: 'app-credit-card-warning',
templateUrl: './credit-card-warning.component.html',
styleUrls: ['./credit-card-warning.component.scss'],
imports: [
StateIndicatorComponent,
TranslateModule
],
standalone: true
})
export class CreditCardWarningComponent {

constructor() { }

}
Loading

0 comments on commit 3de68ff

Please sign in to comment.