#1033 Remove Nachbestellen CtA on Status "Storniert Lieferant" (2048)

This commit is contained in:
Sebastian
2020-09-16 17:35:17 +02:00
parent edc3329f5a
commit 288737aed3

View File

@@ -1,6 +1,17 @@
import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { map, switchMap, first, filter, flatMap, distinctUntilChanged, shareReplay, take, takeUntil, withLatestFrom } from 'rxjs/operators';
import {
map,
switchMap,
first,
filter,
flatMap,
distinctUntilChanged,
shareReplay,
take,
takeUntil,
withLatestFrom,
} from 'rxjs/operators';
import {
OrderItemProcessingStatusValue,
OrderItemListItemDTO,
@@ -14,6 +25,7 @@ import { OMSPrintService, PrintService } from '@swagger/print';
import { PrinterSelectionComponent } from 'apps/sales/src/app/components/printer-selection/printer-selection.component';
import { OrderDetailsCardInput } from '../../components/order-details-card';
import { DetailsFacade } from '@shelf-store/details';
import { ProcessingStatusNameMap } from '../../constants';
@Component({
selector: 'app-shelf-order-details',
@@ -28,7 +40,9 @@ export class ShelfOrderDetailsComponent {
})
printerSlectionComponent: PrinterSelectionComponent;
processingStatus$ = this.activatedRoute.params.pipe(map((params) => params['processingStatus']));
processingStatus$ = this.activatedRoute.params.pipe(
map((params) => params['processingStatus'])
);
partialPickup = false;
@@ -49,14 +63,24 @@ export class ShelfOrderDetailsComponent {
);
orderItems$ = race(
this.orderNumber$.pipe(switchMap((orderNumber) => this.detailsFacade.getOrderItemsByOrderNumber$(orderNumber))),
this.compartmentCode$.pipe(switchMap((compartmentCode) => this.detailsFacade.getOrderItemsByCompartmentCode$(compartmentCode)))
this.orderNumber$.pipe(
switchMap((orderNumber) =>
this.detailsFacade.getOrderItemsByOrderNumber$(orderNumber)
)
),
this.compartmentCode$.pipe(
switchMap((compartmentCode) =>
this.detailsFacade.getOrderItemsByCompartmentCode$(compartmentCode)
)
)
).pipe(
flatMap((items) =>
this.processingStatus$.pipe(
map((processingStatus) => {
if (!!processingStatus) {
return items.filter((item) => item.processingStatus === +processingStatus);
return items.filter(
(item) => item.processingStatus === +processingStatus
);
}
return items;
})
@@ -73,7 +97,9 @@ export class ShelfOrderDetailsComponent {
firstName: item.firstName,
lastName: item.lastName,
customerNumber: item.buyerNumber,
estimatedShippingDate: item.estimatedShippingDate ? new Date(item.estimatedShippingDate) : undefined,
estimatedShippingDate: item.estimatedShippingDate
? new Date(item.estimatedShippingDate)
: undefined,
orderDate: new Date(item.orderDate),
orderNumber: item.orderNumber,
processingStatus: item.processingStatus,
@@ -90,30 +116,53 @@ export class ShelfOrderDetailsComponent {
);
showArrivedAndPrintCta$ = this.orderDetailsCard$.pipe(
map((details) => details.processingStatus === 16 || details.processingStatus === 8192) // wenn bestellt(=16) oder nachbestellt(=8192)
map(
(details) =>
details.processingStatus === 16 || details.processingStatus === 8192
) // wenn bestellt(=16) oder nachbestellt(=8192)
);
showArrivedCta$ = this.orderDetailsCard$.pipe(map((details) => details.processingStatus === 256)); // wenn abgeholt(=256)
showArrivedCta$ = this.orderDetailsCard$.pipe(
map((details) => details.processingStatus === 256)
); // wenn abgeholt(=256)
showPickUpCta$ = this.orderDetailsCard$.pipe(
map((details) => details.processingStatus === 128) // wenn eingetroffen(=128)
);
showPickUpPartialCollectCta$ = combineLatest([this.orderDetailsCard$, this.orderItems$]).pipe(
showPickUpPartialCollectCta$ = combineLatest([
this.orderDetailsCard$,
this.orderItems$,
]).pipe(
map(([details, items]) => {
return details.processingStatus === 128 && (items.length > 1 || items.some((i) => i.quantity > 1));
return (
details.processingStatus === 128 &&
(items.length > 1 || items.some((i) => i.quantity > 1))
);
}) // wenn eingetroffen(=128) und mehr als 1 Artikel
);
showBackToStoreCta$ = this.orderDetailsCard$.pipe(
map((details) => details.processingStatus === 1024 || details.processingStatus === 512)
map(
(details) =>
details.processingStatus === 1024 || details.processingStatus === 512
)
);
showAddToRemissionListCta$ = this.orderDetailsCard$.pipe(
map((details) => details.processingStatus === 1024 || details.processingStatus === 512)
map(
(details) =>
details.processingStatus === 1024 || details.processingStatus === 512
)
);
showReOrderCta$ = this.orderDetailsCard$.pipe(map((details) => details.processingStatus === 2048));
showReOrderCta$ = this.orderDetailsCard$.pipe(
map(
(details) =>
details.processingStatus === 2048 &&
!ProcessingStatusNameMap.get(8192).disabled
)
);
constructor(
private activatedRoute: ActivatedRoute,
@@ -143,15 +192,25 @@ export class ShelfOrderDetailsComponent {
});
}
async changeProcessingStatus(status: OrderItemProcessingStatusValue, data: { compartmentInfo?: string; shouldPrint?: boolean } = {}) {
async changeProcessingStatus(
status: OrderItemProcessingStatusValue,
data: { compartmentInfo?: string; shouldPrint?: boolean } = {}
) {
let items = await this.orderItems$.pipe(first()).toPromise();
let results: ResponseArgsOfValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO[];
const navigate = this.partialPickup ? items.length === this.selectedForPartialPickup.size : true;
const navigate = this.partialPickup
? items.length === this.selectedForPartialPickup.size
: true;
if (status === 256) {
if (this.partialPickup) {
items = items.filter(({ orderItemId }) => this.selectedForPartialPickup.has(orderItemId));
items = items.filter(({ orderItemId }) =>
this.selectedForPartialPickup.has(orderItemId)
);
}
results = await this.detailsFacade.pickedUp(items, this.quantityForPartialPickup);
results = await this.detailsFacade.pickedUp(
items,
this.quantityForPartialPickup
);
} else if (status === 262144) {
results = await this.detailsFacade.backToStock(items);
} else if (status === 8192) {
@@ -159,15 +218,19 @@ export class ShelfOrderDetailsComponent {
} else if (status === 128) {
results = await this.detailsFacade.arrived(items, data.compartmentInfo);
if (data.shouldPrint) {
await this.printAbholfachetikett(items.map(({ orderItemSubsetId }) => orderItemSubsetId));
await this.printAbholfachetikett(
items.map(({ orderItemSubsetId }) => orderItemSubsetId)
);
}
} else {
const payloads = items.map(({ orderId, orderItemId, orderItemSubsetId }) => ({
orderId,
orderItemId,
orderItemSubsetId,
data: { processingStatus: status } as StatusValues,
}));
const payloads = items.map(
({ orderId, orderItemId, orderItemSubsetId }) => ({
orderId,
orderItemId,
orderItemSubsetId,
data: { processingStatus: status } as StatusValues,
})
);
results = await this.detailsFacade.changeStatus(payloads);
}
@@ -222,7 +285,9 @@ export class ShelfOrderDetailsComponent {
if (this.appService.isIPadEnv()) {
this.printerSlectionComponent.openDialog();
printer = await this.printerSlectionComponent.print.pipe(takeUntil(this.printerSlectionComponent.closed), take(1)).toPromise();
printer = await this.printerSlectionComponent.print
.pipe(takeUntil(this.printerSlectionComponent.closed), take(1))
.toPromise();
this.printerSlectionComponent.closeModal();
}
@@ -255,7 +320,9 @@ export class ShelfOrderDetailsComponent {
async navigateToDetails() {
const data = await race(
this.orderNumber$.pipe(map((orderNumber) => ({ orderNumber }))),
this.compartmentCode$.pipe(map((compartmentCode) => ({ compartmentCode })))
this.compartmentCode$.pipe(
map((compartmentCode) => ({ compartmentCode }))
)
)
.pipe(
withLatestFrom(this.processingStatus$),