add payment method field

This commit is contained in:
2024-11-15 11:05:52 +01:00
parent 033c5d5c76
commit 119650d518
12 changed files with 401 additions and 349 deletions
+2 -2
View File
@@ -14,7 +14,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<querydsl.version>5.1.0</querydsl.version>
<revision>0.5.1</revision>
<revision>0.6.0</revision>
</properties>
<parent>
@@ -102,7 +102,7 @@
<dependency>
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>
</dependency>
<!-- Datbase -->
@@ -35,6 +35,13 @@ public class TurnoverValidator implements Validator {
errors.rejectValue("price", "MIN");
}
if (turnover.getPaymentMethod() == null) {
errors.rejectValue("paymentMethod", "REQUIRED");
} else if (!turnover.getPaymentMethod().equals("card")
&& !turnover.getPaymentMethod().equals("cash")) {
errors.rejectValue("paymentMethod", "INVALID");
}
if (turnover.getGiftcardPrice() != null && turnover.getGiftcardPrice() < 0) {
errors.rejectValue("giftcardPrice", "MIN");
} else if (turnover.getGiftcardPrice() != null && turnover.getGiftcardPrice() > turnover.getPrice()) {
@@ -40,6 +40,9 @@ public class Turnover {
@Column(name = "price", nullable = false)
private float price;
@Column(name = "payment_method", nullable = true)
private String paymentMethod;
@Column(name = "time_investment", nullable = true)
private float timeInvestment;
@@ -121,6 +124,14 @@ public class Turnover {
this.price = price;
}
public String getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(String paymentMethod) {
this.paymentMethod = paymentMethod;
}
public float getTimeInvestment() {
return timeInvestment;
}
@@ -184,6 +195,9 @@ public class Turnover {
equals &= price == turnover.getPrice();
equals &= paymentMethod == null && turnover.getPaymentMethod() == null
|| paymentMethod != null && paymentMethod.equals(turnover.getPaymentMethod());
equals &= timeInvestment == turnover.getTimeInvestment();
equals &= remark == null && turnover.getRemark() == null
+299 -315
View File
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -1,6 +1,6 @@
{
"name": "buntspecht-web",
"version": "0.5.0",
"version": "0.6.0",
"license": "AGPL3",
"scripts": {
"ng": "ng",
@@ -12,28 +12,28 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.9",
"@angular/cdk": "^18.2.10",
"@angular/common": "^18.2.9",
"@angular/compiler": "^18.2.9",
"@angular/core": "^18.2.9",
"@angular/forms": "^18.2.9",
"@angular/material": "^18.2.10",
"@angular/material-moment-adapter": "^18.2.10",
"@angular/platform-browser": "^18.2.9",
"@angular/platform-browser-dynamic": "^18.2.9",
"@angular/router": "^18.2.9",
"@angular/service-worker": "^18.2.9",
"@angular/animations": "^18.2.12",
"@angular/cdk": "^18.2.13",
"@angular/common": "^18.2.12",
"@angular/compiler": "^18.2.12",
"@angular/core": "^18.2.12",
"@angular/forms": "^18.2.12",
"@angular/material": "^18.2.13",
"@angular/material-moment-adapter": "^18.2.13",
"@angular/platform-browser": "^18.2.12",
"@angular/platform-browser-dynamic": "^18.2.12",
"@angular/router": "^18.2.12",
"@angular/service-worker": "^18.2.12",
"moment": "^2.30.1",
"rxjs": "~7.8.1",
"tslib": "^2.8.0",
"tslib": "^2.8.1",
"zone.js": "~0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.10",
"@angular/cli": "^18.2.10",
"@angular/compiler-cli": "^18.2.9",
"@angular/localize": "^18.2.9",
"@angular-devkit/build-angular": "^18.2.12",
"@angular/cli": "^18.2.12",
"@angular/compiler-cli": "^18.2.12",
"@angular/localize": "^18.2.12",
"@types/jasmine": "^5.1.4",
"jasmine-core": "~5.4.0",
"karma": "^6.4.4",
@@ -46,6 +46,23 @@
</mat-error>
</mat-form-field>
<div class="form-field margin horizontal">
<mat-radio-group formControlName="paymentMethod" [required]="true">
<mat-radio-button value="card">
<span class="flex middle">
<mat-icon>credit_card</mat-icon>&nbsp;{{'turnover.paymentMethod.card' | i18n}}
</span>
</mat-radio-button>
<mat-radio-button value="cash">
<span class="flex middle">
<mat-icon>payments</mat-icon>&nbsp;{{'turnover.paymentMethod.cash' | i18n}}
</span></mat-radio-button>
</mat-radio-group>
<mat-error *ngFor="let error of form.get('paymentMethod').errors | keyvalue">
{{'turnover.paymentMethod.error.' + (error.key | errorCode) | i18n:error.value}}
</mat-error>
</div>
<mat-slide-toggle class="margin" [checked]="hasGiftcard" (change)="hasGiftcard=$event.checked">
{{'turnover.giftcard' | i18n}}
</mat-slide-toggle>
@@ -44,6 +44,7 @@ export class PageTurnover implements OnInit {
customer: ['', Validators.required],
motif: ['', Validators.required],
price: ['', Validators.required],
paymentMethod: ['', Validators.required],
giftcardNumber: ['', Validators.nullValidator],
giftcardPrice: ['', Validators.nullValidator],
timeInvestment: ['', Validators.nullValidator],
@@ -77,6 +78,7 @@ export class PageTurnover implements OnInit {
this.form.get("customer").setValue(this.turnover.customer);
this.form.get("motif").setValue(this.turnover.motif);
this.form.get("price").setValue(this.turnover.price);
this.form.get("paymentMethod").setValue(this.turnover.paymentMethod || 'card');
this.form.get("giftcardNumber").setValue(this.turnover.giftcardNumber);
this.form.get("giftcardPrice").setValue(this.turnover.giftcardPrice);
this.form.get("timeInvestment").setValue(this.turnover.timeInvestment);
@@ -118,6 +120,7 @@ export class PageTurnover implements OnInit {
this.turnover.customer = this.form.get("customer").value;
this.turnover.motif = this.form.get("motif").value;
this.turnover.price = this.form.get("price").value;
this.turnover.paymentMethod = this.form.get("paymentMethod").value;
this.turnover.timeInvestment = this.form.get("timeInvestment").value;
this.turnover.remark = this.form.get("remark").value;
this.turnover.materialConsumption = this.form.get("materialConsumption").value;
@@ -140,7 +143,7 @@ export class PageTurnover implements OnInit {
for (let errorObject of error.error) {
errors[errorObject.field] = errors[errorObject.field] || {};
errors[errorObject.field][errorObject.code] = errorObject.arguments || true;
}
}
for (let code in errors) {
this.form.get(code).setErrors(errors[code]);
@@ -161,6 +164,8 @@ export class PageTurnover implements OnInit {
this.turnover.customer = this.form.get("customer").value;
this.turnover.motif = this.form.get("motif").value;
this.turnover.price = this.form.get("price").value;
console.log(this.form.get("paymentMethod"));
this.turnover.paymentMethod = this.form.get("paymentMethod").value;
this.turnover.timeInvestment = this.form.get("timeInvestment").value;
this.turnover.remark = this.form.get("remark").value;
this.turnover.materialConsumption = this.form.get("materialConsumption").value;
@@ -191,7 +196,7 @@ export class PageTurnover implements OnInit {
for (let errorObject of error.error) {
errors[errorObject.field] = errors[errorObject.field] || {};
errors[errorObject.field][errorObject.code] = errorObject.arguments || true;
}
}
for (let code in errors) {
this.form.get(code).setErrors(errors[code]);
+1 -1
View File
@@ -65,7 +65,7 @@
<ng-container matColumnDef="about">
<th mat-header-cell *matHeaderCellDef>{{'profile.about' | i18n}}</th>
<td mat-cell *matCellDef="let user">
<span class="ellipsis" matTooltip="{{user.about}}">{{user.about}}</span>
<span class="ellipsis" [matTooltip]="user.about">{{user.about}}</span>
</td>
</ng-container>
@@ -40,7 +40,7 @@
<th mat-header-cell *matHeaderCellDef mat-sort-header [disableClear]="false">{{'turnover.dueDate' |
i18n}}
</th>
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.dueDate | datef:'LL'}}">
<td mat-cell *matCellDef="let turnover" [matTooltip]="turnover.dueDate | datef:'LL'">
<span class="nowrap">{{turnover.dueDate | datef:'L'}}</span>
</td>
</ng-container>
@@ -53,7 +53,7 @@
<ng-container matColumnDef="motif">
<th mat-header-cell *matHeaderCellDef>{{'turnover.motif' | i18n}}</th>
<td mat-cell *matCellDef="let turnover">
<span class="ellipsis" matTooltip="{{turnover.motif}}">{{turnover.motif}}</span>
<span class="ellipsis" [matTooltip]="turnover.motif">{{turnover.motif}}</span>
</td>
</ng-container>
@@ -63,8 +63,14 @@
<span>{{'turnover.price' | i18n}}</span>
</th>
<td mat-cell *matCellDef="let turnover">
<div class="flex">
<span class="spacer"></span>
<div class="flex middle">
@if (turnover.paymentMethod == 'card'){
<mat-icon [matTooltip]="'turnover.paymentMethod.card' | i18n">credit_card</mat-icon>
}
@if (turnover.paymentMethod == 'cash'){
<mat-icon [matTooltip]="'turnover.paymentMethod.cash' | i18n">payments</mat-icon>
}
<span class="spacer with-margin"></span>
<span>{{turnover.price | number: '1.2-2'}}</span>
<span>&nbsp;{{'turnover.price.suffix' | i18n}}</span>
</div>
@@ -77,7 +83,7 @@
<span>{{'turnover.giftcard.price' | i18n}}</span>
</th>
<td mat-cell *matCellDef="let turnover">
<div class="flex">
<div class="flex middle">
<span class="spacer"></span>
<span>{{turnover.giftcardPrice | number: '1.2-2'}}</span>
@if (turnover.giftcardPrice) {
@@ -106,7 +112,7 @@
<ng-container matColumnDef="remark">
<th mat-header-cell *matHeaderCellDef>{{'turnover.remark' | i18n}}</th>
<td mat-cell *matCellDef="let turnover">
<span class="ellipsis" matTooltip="{{turnover.remark}}">{{turnover.remark}}</span>
<span class="ellipsis" [matTooltip]="turnover.remark">{{turnover.remark}}</span>
</td>
</ng-container>
@@ -114,7 +120,7 @@
<th mat-header-cell *matHeaderCellDef>{{'turnover.materialConsumption' | i18n}}</th>
<td mat-cell *matCellDef="let turnover">
<span class="ellipsis"
matTooltip="{{turnover.materialConsumption}}">{{turnover.materialConsumption}}</span>
[matTooltip]="turnover.materialConsumption">{{turnover.materialConsumption}}</span>
</td>
</ng-container>
@@ -122,7 +128,7 @@
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{'turnover.created' |
i18n}}
</th>
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.created | datef:'LLLL'}}">
<td mat-cell *matCellDef="let turnover" [matTooltip]="turnover.created | datef:'LLLL'">
<span class="nowrap">{{turnover.created | datef}}</span>
</td>
</ng-container>
@@ -132,7 +138,7 @@
<span class="spacer"></span>
<span>{{'turnover.updated' | i18n}}</span>
</th>
<td mat-cell *matCellDef="let turnover" matTooltip="{{turnover.updated | datef:'LLLL'}}">
<td mat-cell *matCellDef="let turnover" [matTooltip]="turnover.updated | datef:'LLLL'">
<div class="flex">
<span class="spacer"></span>
@if(turnover.created != turnover.updated) {
@@ -62,6 +62,7 @@ export class UiTurnovers implements OnInit {
this.i18n.get('turnover.customer'),
this.i18n.get('turnover.motif'),
this.i18n.get('turnover.price'),
this.i18n.get('turnover.paymentMethod'),
this.i18n.get('turnover.giftcard.number'),
this.i18n.get('turnover.giftcard.price'),
this.i18n.get('turnover.timeInvestment'),
@@ -81,8 +82,9 @@ export class UiTurnovers implements OnInit {
turnover.customer,
turnover.motif,
turnover.price.toFixed(2),
turnover.paymentMethod ? this.i18n.get('turnover.paymentMethod.' + turnover.paymentMethod) : '',
turnover.giftcardNumber,
turnover.giftcardPrice && turnover.giftcardPrice.toFixed(2) || '',
turnover.giftcardPrice ? turnover.giftcardPrice.toFixed(2) : '',
turnover.timeInvestment.toFixed(1),
turnover.remark,
turnover.materialConsumption,
@@ -141,6 +141,15 @@
"REQUIRED": "Angabe von Motiv erforderlich"
}
},
"paymentMethod": {
".": "Zahlungsmethode",
"card":"Kartenzahlung",
"cash": "Barzahlung",
"error": {
"INVALID": "Üngültiger Wert",
"REQUIRED": "Angabe einer Zahlungsmethode erforderlich"
}
},
"price": {
".": "Preis",
"error": {
+9 -1
View File
@@ -210,10 +210,18 @@ qrcode canvas {
.spacer {
flex: 1 1 auto;
&.with-margin {
margin: 5px;
}
}
.margin {
margin: 0 15px;
&.horizontal {
margin: 15px 0;
}
}
.hint {
@@ -365,7 +373,7 @@ a[href*="//"]::after {
app-root {
background-color: #303030;
}
a {
color: $accent;
}