mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +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 {
|
||||
BranchService,
|
||||
BuyerDTO,
|
||||
ChangeStockStatusCodeValues,
|
||||
HistoryDTO,
|
||||
NotificationChannel,
|
||||
@@ -29,7 +30,7 @@ export class DomainOmsService {
|
||||
private branchService: BranchService,
|
||||
private vatService: VATService,
|
||||
private stockStatusCodeService: StockStatusCodeService,
|
||||
private _orderCheckoutService: OrderCheckoutService
|
||||
private _orderCheckoutService: OrderCheckoutService,
|
||||
) {}
|
||||
|
||||
getOrderItemsByCustomerNumber(customerNumber: string, skip: number): Observable<OrderListItemDTO[]> {
|
||||
@@ -54,7 +55,7 @@ export class DomainOmsService {
|
||||
return this.receiptService
|
||||
.ReceiptGetReceiptsByOrderItemSubset({
|
||||
payload: {
|
||||
receiptType: (65 as unknown) as any,
|
||||
receiptType: 65 as unknown as any,
|
||||
ids: orderItemSubsetIds,
|
||||
eagerLoading: 1,
|
||||
},
|
||||
@@ -76,7 +77,7 @@ export class DomainOmsService {
|
||||
getStockStatusCodes({ supplierId, eagerLoading = 0 }: { supplierId: number; eagerLoading?: number }) {
|
||||
return this.stockStatusCodeService.StockStatusCodeGetStockStatusCodes({ supplierId, eagerLoading }).pipe(
|
||||
map((response) => response.result),
|
||||
shareReplay()
|
||||
shareReplay(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ export class DomainOmsService {
|
||||
orderId: number,
|
||||
orderItemId: number,
|
||||
orderItemSubsetId: number,
|
||||
data: StatusValues
|
||||
data: StatusValues,
|
||||
): Observable<ValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO> {
|
||||
return this.orderService
|
||||
.OrderChangeStatus({
|
||||
@@ -184,7 +185,7 @@ export class DomainOmsService {
|
||||
selected: order.notificationChannels,
|
||||
email: order.buyer?.communicationDetails?.email,
|
||||
mobile: order.buyer?.communicationDetails?.mobile,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,12 +206,39 @@ export class DomainOmsService {
|
||||
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
|
||||
.OrderPatchOrder({
|
||||
orderId: orderId,
|
||||
order: {
|
||||
notificationChannels: changes.selected,
|
||||
buyer: { communicationDetails },
|
||||
notificationChannels,
|
||||
buyer,
|
||||
},
|
||||
})
|
||||
.pipe(map((res) => res.result));
|
||||
@@ -242,11 +270,14 @@ export class DomainOmsService {
|
||||
map((res) =>
|
||||
res.result
|
||||
.sort((a, b) => new Date(b.completed).getTime() - new Date(a.completed).getTime())
|
||||
.reduce((data, result) => {
|
||||
(data[result.name] = data[result.name] || []).push(new Date(result.completed));
|
||||
return data;
|
||||
}, {} as Record<string, Date[]>)
|
||||
)
|
||||
.reduce(
|
||||
(data, result) => {
|
||||
(data[result.name] = data[result.name] || []).push(new Date(result.completed));
|
||||
return data;
|
||||
},
|
||||
{} as Record<string, Date[]>,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@
|
||||
<input uiInput formControlName="buyerNumber" />
|
||||
</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 *ngFor="let item of itemsControl.controls; index as i" [formGroupName]="i">
|
||||
<div class="item-header-wrapper">
|
||||
|
||||
@@ -89,7 +89,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
private omsService: DomainOmsService,
|
||||
private dateAdapter: DateAdapter,
|
||||
private cdr: ChangeDetectorRef,
|
||||
private _modal: UiModalService
|
||||
private _modal: UiModalService,
|
||||
) {}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -115,7 +115,6 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
if (items.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fb = this.fb;
|
||||
this.control = fb.group({
|
||||
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 }),
|
||||
clientChannel: fb.control({ value: (await this.getOrderSource()) ?? items[0].features?.orderSource, 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([]),
|
||||
notificationChannel: this.notificationsGroup,
|
||||
});
|
||||
@@ -169,7 +170,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
if (!value) {
|
||||
fbItem.get('compartmentInfo').reset('');
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
this.itemsControl.push(fbItem);
|
||||
@@ -246,10 +247,10 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
notificationChannels.length === 2
|
||||
? ['email', 'sms']
|
||||
: notificationChannels[0] === 1
|
||||
? ['email']
|
||||
: notificationChannels[0] === 2
|
||||
? ['sms']
|
||||
: [],
|
||||
? ['email']
|
||||
: notificationChannels[0] === 2
|
||||
? ['sms']
|
||||
: [],
|
||||
})
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
@@ -270,6 +271,8 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
try {
|
||||
const control = this.control.getRawValue();
|
||||
const orderId = control.orderId;
|
||||
const firstName = control.firstName;
|
||||
const lastName = control.lastName;
|
||||
|
||||
if (this.notificationsGroup.dirty) {
|
||||
try {
|
||||
@@ -305,6 +308,19 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
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 {
|
||||
if (this.isOrderItemDirty(formGroup)) {
|
||||
await this.omsService
|
||||
@@ -350,7 +366,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
},
|
||||
})
|
||||
.pipe(first())
|
||||
.toPromise()
|
||||
.toPromise(),
|
||||
);
|
||||
}
|
||||
} 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 {
|
||||
const arr = this.control.get('items') as UntypedFormArray;
|
||||
return arr.controls.find((c) => (c as UntypedFormGroup).controls.orderItemSubsetId.value === orderItemSubsetId) as UntypedFormGroup;
|
||||
|
||||
Reference in New Issue
Block a user