mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Merged PR 1789: #4687 WA, Abholfach, HSC - First and Lastname Update on Buyer just on Order
#4687 WA, Abholfach, HSC - First and Lastname Update on Buyer just on Order
This commit is contained in:
committed by
Lorenz Hilpert
parent
c3561339a9
commit
186afbc828
@@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
BranchService,
|
BranchService,
|
||||||
|
BuyerDTO,
|
||||||
ChangeStockStatusCodeValues,
|
ChangeStockStatusCodeValues,
|
||||||
HistoryDTO,
|
HistoryDTO,
|
||||||
NotificationChannel,
|
NotificationChannel,
|
||||||
@@ -29,7 +30,7 @@ export class DomainOmsService {
|
|||||||
private branchService: BranchService,
|
private branchService: BranchService,
|
||||||
private vatService: VATService,
|
private vatService: VATService,
|
||||||
private stockStatusCodeService: StockStatusCodeService,
|
private stockStatusCodeService: StockStatusCodeService,
|
||||||
private _orderCheckoutService: OrderCheckoutService
|
private _orderCheckoutService: OrderCheckoutService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getOrderItemsByCustomerNumber(customerNumber: string, skip: number): Observable<OrderListItemDTO[]> {
|
getOrderItemsByCustomerNumber(customerNumber: string, skip: number): Observable<OrderListItemDTO[]> {
|
||||||
@@ -54,7 +55,7 @@ export class DomainOmsService {
|
|||||||
return this.receiptService
|
return this.receiptService
|
||||||
.ReceiptGetReceiptsByOrderItemSubset({
|
.ReceiptGetReceiptsByOrderItemSubset({
|
||||||
payload: {
|
payload: {
|
||||||
receiptType: (65 as unknown) as any,
|
receiptType: 65 as unknown as any,
|
||||||
ids: orderItemSubsetIds,
|
ids: orderItemSubsetIds,
|
||||||
eagerLoading: 1,
|
eagerLoading: 1,
|
||||||
},
|
},
|
||||||
@@ -76,7 +77,7 @@ export class DomainOmsService {
|
|||||||
getStockStatusCodes({ supplierId, eagerLoading = 0 }: { supplierId: number; eagerLoading?: number }) {
|
getStockStatusCodes({ supplierId, eagerLoading = 0 }: { supplierId: number; eagerLoading?: number }) {
|
||||||
return this.stockStatusCodeService.StockStatusCodeGetStockStatusCodes({ supplierId, eagerLoading }).pipe(
|
return this.stockStatusCodeService.StockStatusCodeGetStockStatusCodes({ supplierId, eagerLoading }).pipe(
|
||||||
map((response) => response.result),
|
map((response) => response.result),
|
||||||
shareReplay()
|
shareReplay(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ export class DomainOmsService {
|
|||||||
orderId: number,
|
orderId: number,
|
||||||
orderItemId: number,
|
orderItemId: number,
|
||||||
orderItemSubsetId: number,
|
orderItemSubsetId: number,
|
||||||
data: StatusValues
|
data: StatusValues,
|
||||||
): Observable<ValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO> {
|
): Observable<ValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO> {
|
||||||
return this.orderService
|
return this.orderService
|
||||||
.OrderChangeStatus({
|
.OrderChangeStatus({
|
||||||
@@ -184,7 +185,7 @@ export class DomainOmsService {
|
|||||||
selected: order.notificationChannels,
|
selected: order.notificationChannels,
|
||||||
email: order.buyer?.communicationDetails?.email,
|
email: order.buyer?.communicationDetails?.email,
|
||||||
mobile: order.buyer?.communicationDetails?.mobile,
|
mobile: order.buyer?.communicationDetails?.mobile,
|
||||||
}))
|
})),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,12 +206,39 @@ export class DomainOmsService {
|
|||||||
delete communicationDetails.mobile;
|
delete communicationDetails.mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.updateOrder({ orderId, notificationChannels: changes.selected, communicationDetails });
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOrder({
|
||||||
|
orderId,
|
||||||
|
notificationChannels,
|
||||||
|
communicationDetails,
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
}: {
|
||||||
|
orderId: number;
|
||||||
|
notificationChannels?: NotificationChannel;
|
||||||
|
communicationDetails?: { email?: string; mobile?: string };
|
||||||
|
lastName?: string;
|
||||||
|
firstName?: string;
|
||||||
|
}) {
|
||||||
|
const buyer: BuyerDTO = {};
|
||||||
|
|
||||||
|
if (!!communicationDetails) {
|
||||||
|
buyer.communicationDetails = { ...communicationDetails };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!!lastName || !!firstName) {
|
||||||
|
buyer.firstName = firstName;
|
||||||
|
buyer.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
return this.orderService
|
return this.orderService
|
||||||
.OrderPatchOrder({
|
.OrderPatchOrder({
|
||||||
orderId: orderId,
|
orderId: orderId,
|
||||||
order: {
|
order: {
|
||||||
notificationChannels: changes.selected,
|
notificationChannels,
|
||||||
buyer: { communicationDetails },
|
buyer,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.pipe(map((res) => res.result));
|
.pipe(map((res) => res.result));
|
||||||
@@ -242,11 +270,14 @@ export class DomainOmsService {
|
|||||||
map((res) =>
|
map((res) =>
|
||||||
res.result
|
res.result
|
||||||
.sort((a, b) => new Date(b.completed).getTime() - new Date(a.completed).getTime())
|
.sort((a, b) => new Date(b.completed).getTime() - new Date(a.completed).getTime())
|
||||||
.reduce((data, result) => {
|
.reduce(
|
||||||
(data[result.name] = data[result.name] || []).push(new Date(result.completed));
|
(data, result) => {
|
||||||
return data;
|
(data[result.name] = data[result.name] || []).push(new Date(result.completed));
|
||||||
}, {} as Record<string, Date[]>)
|
return data;
|
||||||
)
|
},
|
||||||
|
{} as Record<string, Date[]>,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,14 @@
|
|||||||
<input uiInput formControlName="buyerNumber" />
|
<input uiInput formControlName="buyerNumber" />
|
||||||
</ui-form-control>
|
</ui-form-control>
|
||||||
|
|
||||||
|
<ui-form-control label="Name" variant="inline">
|
||||||
|
<input uiInput formControlName="firstName" />
|
||||||
|
</ui-form-control>
|
||||||
|
|
||||||
|
<ui-form-control label="Vorname" variant="inline">
|
||||||
|
<input uiInput formControlName="lastName" />
|
||||||
|
</ui-form-control>
|
||||||
|
|
||||||
<div formArrayName="items">
|
<div formArrayName="items">
|
||||||
<div *ngFor="let item of itemsControl.controls; index as i" [formGroupName]="i">
|
<div *ngFor="let item of itemsControl.controls; index as i" [formGroupName]="i">
|
||||||
<div class="item-header-wrapper">
|
<div class="item-header-wrapper">
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
private omsService: DomainOmsService,
|
private omsService: DomainOmsService,
|
||||||
private dateAdapter: DateAdapter,
|
private dateAdapter: DateAdapter,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private _modal: UiModalService
|
private _modal: UiModalService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
@@ -115,7 +115,6 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fb = this.fb;
|
const fb = this.fb;
|
||||||
this.control = fb.group({
|
this.control = fb.group({
|
||||||
orderId: fb.control({ value: items[0].orderId, disabled: true }),
|
orderId: fb.control({ value: items[0].orderId, disabled: true }),
|
||||||
@@ -123,6 +122,8 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
orderDate: fb.control({ value: this.datePipe.transform(items[0].orderDate), disabled: true }),
|
orderDate: fb.control({ value: this.datePipe.transform(items[0].orderDate), disabled: true }),
|
||||||
clientChannel: fb.control({ value: (await this.getOrderSource()) ?? items[0].features?.orderSource, disabled: true }),
|
clientChannel: fb.control({ value: (await this.getOrderSource()) ?? items[0].features?.orderSource, disabled: true }),
|
||||||
buyerNumber: fb.control({ value: items[0].buyerNumber, disabled: true }),
|
buyerNumber: fb.control({ value: items[0].buyerNumber, disabled: true }),
|
||||||
|
firstName: fb.control({ value: items[0].firstName, disabled: false }),
|
||||||
|
lastName: fb.control({ value: items[0].lastName, disabled: false }),
|
||||||
items: fb.array([]),
|
items: fb.array([]),
|
||||||
notificationChannel: this.notificationsGroup,
|
notificationChannel: this.notificationsGroup,
|
||||||
});
|
});
|
||||||
@@ -169,7 +170,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
fbItem.get('compartmentInfo').reset('');
|
fbItem.get('compartmentInfo').reset('');
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.itemsControl.push(fbItem);
|
this.itemsControl.push(fbItem);
|
||||||
@@ -246,10 +247,10 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
notificationChannels.length === 2
|
notificationChannels.length === 2
|
||||||
? ['email', 'sms']
|
? ['email', 'sms']
|
||||||
: notificationChannels[0] === 1
|
: notificationChannels[0] === 1
|
||||||
? ['email']
|
? ['email']
|
||||||
: notificationChannels[0] === 2
|
: notificationChannels[0] === 2
|
||||||
? ['sms']
|
? ['sms']
|
||||||
: [],
|
: [],
|
||||||
})
|
})
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.toPromise();
|
.toPromise();
|
||||||
@@ -270,6 +271,8 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
try {
|
try {
|
||||||
const control = this.control.getRawValue();
|
const control = this.control.getRawValue();
|
||||||
const orderId = control.orderId;
|
const orderId = control.orderId;
|
||||||
|
const firstName = control.firstName;
|
||||||
|
const lastName = control.lastName;
|
||||||
|
|
||||||
if (this.notificationsGroup.dirty) {
|
if (this.notificationsGroup.dirty) {
|
||||||
try {
|
try {
|
||||||
@@ -305,6 +308,19 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (this.firstOrLastNameChanged()) {
|
||||||
|
await this.omsService.updateOrder({ orderId, firstName, lastName }).pipe(first()).toPromise();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this._modal.open({
|
||||||
|
content: UiErrorModalComponent,
|
||||||
|
data: error,
|
||||||
|
title: 'Fehler beim Aktualisieren der Bestellung - Vorname und Name konnten nicht übernommen werden',
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.isOrderItemDirty(formGroup)) {
|
if (this.isOrderItemDirty(formGroup)) {
|
||||||
await this.omsService
|
await this.omsService
|
||||||
@@ -350,7 +366,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.toPromise()
|
.toPromise(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -382,6 +398,10 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstOrLastNameChanged() {
|
||||||
|
return this.control.get('firstName').dirty || this.control.get('lastName').dirty;
|
||||||
|
}
|
||||||
|
|
||||||
getFormGroupByOrderItemSubsetId(orderItemSubsetId: number): UntypedFormGroup {
|
getFormGroupByOrderItemSubsetId(orderItemSubsetId: number): UntypedFormGroup {
|
||||||
const arr = this.control.get('items') as UntypedFormArray;
|
const arr = this.control.get('items') as UntypedFormArray;
|
||||||
return arr.controls.find((c) => (c as UntypedFormGroup).controls.orderItemSubsetId.value === orderItemSubsetId) as UntypedFormGroup;
|
return arr.controls.find((c) => (c as UntypedFormGroup).controls.orderItemSubsetId.value === orderItemSubsetId) as UntypedFormGroup;
|
||||||
|
|||||||
Reference in New Issue
Block a user