mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
#4397 Fix RD Abholfach Zubuchen mit Zusatz
This commit is contained in:
@@ -37,9 +37,11 @@ export abstract class PickupShelfDetailsBaseComponent {
|
||||
async execAction({
|
||||
action,
|
||||
latestCompartmentCode,
|
||||
latestCompartmentInfo,
|
||||
}: {
|
||||
action: KeyValueDTOOfStringAndString;
|
||||
latestCompartmentCode?: string;
|
||||
latestCompartmentInfo?: string;
|
||||
}): Promise<OrderItemsContext> {
|
||||
if (action.command.includes('FETCHED_PARTIAL')) {
|
||||
this.store.setFetchPartial(true);
|
||||
@@ -50,7 +52,7 @@ export abstract class PickupShelfDetailsBaseComponent {
|
||||
action,
|
||||
items: this.store.selectedOrderItems,
|
||||
compartmentCode: latestCompartmentCode ?? undefined, // Ticket #4391 - if undefined, assign new compartmentCode to item (bei eingetroffen und drucken)
|
||||
compartmentInfo: this.store.selectedCompartmentInfo || this.store.compartmentInfo,
|
||||
compartmentInfo: latestCompartmentInfo ?? (this.store.selectedCompartmentInfo || this.store.compartmentInfo), // Ticket #4397
|
||||
order: this.store.order,
|
||||
itemQuantity: this.store.selectedOrderItemQuantity,
|
||||
});
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
</div>
|
||||
|
||||
<div class="page-pickup-shelf-in-details__action-wrapper">
|
||||
<ng-container *ngIf="latestCompartmentCode$ | async; let latestCompartmentCode">
|
||||
<ng-container *ngIf="latestCompartmentInfos$ | async; let latestCompartmentInfos">
|
||||
<button
|
||||
[disabled]="addToPreviousCompartmentActionDisabled$ | async"
|
||||
*ngIf="addToPreviousCompartmentAction$ | async; let action"
|
||||
class="cta-action shadow-action"
|
||||
[class.cta-action-primary]="action.selected"
|
||||
[class.cta-action-secondary]="!action.selected"
|
||||
(click)="handleAction({action, latestCompartmentCode })"
|
||||
(click)="handleAction({action, latestCompartmentCode: latestCompartmentInfos?.latestCompartmentCode, latestCompartmentInfo: latestCompartmentInfos?.latestCompartmentInfo })"
|
||||
>
|
||||
<ui-spinner [show]="(changeActionLoader$ | async) === action.command"
|
||||
>{{ latestCompartmentCode | addToPreviousCompartmentCodeLabelPipe }} zubuchen</ui-spinner
|
||||
>{{ latestDisplayedCompartmentInfos$ | async | addToPreviousCompartmentCodeLabelPipe }} zubuchen</ui-spinner
|
||||
>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
@@ -65,11 +65,20 @@ export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseCompone
|
||||
|
||||
coverOrderItems$ = this.store.coverOrderItems$;
|
||||
|
||||
compartmentInfo$ = this.store.compartmentInfo$;
|
||||
displayedCompartmentInfo$ = this.store.compartmentInfo$;
|
||||
|
||||
latestCompartmentCode$ = this.store.latestCompartmentCodeForOrder$;
|
||||
latestCompartmentInfos$ = this.store.latestCompartmentCodeAndInfoForOrder$;
|
||||
|
||||
addToPreviousCompartmentActionDisabled$ = combineLatest([this.compartmentInfo$, this.changeActionDisabled$]).pipe(
|
||||
latestDisplayedCompartmentInfos$ = this.latestCompartmentInfos$.pipe(
|
||||
map((latestCompartmentInfos) => {
|
||||
if (!!latestCompartmentInfos?.latestCompartmentInfo) {
|
||||
return `${latestCompartmentInfos?.latestCompartmentCode}_${latestCompartmentInfos?.latestCompartmentInfo}`;
|
||||
}
|
||||
return latestCompartmentInfos?.latestCompartmentCode;
|
||||
})
|
||||
);
|
||||
|
||||
addToPreviousCompartmentActionDisabled$ = combineLatest([this.displayedCompartmentInfo$, this.changeActionDisabled$]).pipe(
|
||||
map(([compartmentInfo, changeActionDisabled]) => !!compartmentInfo || changeActionDisabled)
|
||||
);
|
||||
|
||||
@@ -101,16 +110,23 @@ export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseCompone
|
||||
|
||||
private _registerPickUpShelfDetailsTagsComponentChanges() {
|
||||
this.orderItems$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((_) => {
|
||||
this.pickUpShelfDetailsTags?.writeValue(this.store.selectedCompartmentInfo);
|
||||
this.pickUpShelfDetailsTags?.registerOnChange((compartmentInfo) => (this.store.selectedCompartmentInfo = compartmentInfo));
|
||||
});
|
||||
}
|
||||
|
||||
async handleAction({ action, latestCompartmentCode }: { action: KeyValueDTOOfStringAndString; latestCompartmentCode?: string }) {
|
||||
async handleAction({
|
||||
action,
|
||||
latestCompartmentCode,
|
||||
latestCompartmentInfo,
|
||||
}: {
|
||||
action: KeyValueDTOOfStringAndString;
|
||||
latestCompartmentCode?: string;
|
||||
latestCompartmentInfo?: string;
|
||||
}) {
|
||||
try {
|
||||
this.changeActionLoader$.next(action.command);
|
||||
this.store.setDisableHeaderStatusDropdown(true);
|
||||
const context = await this.execAction({ action, latestCompartmentCode });
|
||||
const context = await this.execAction({ action, latestCompartmentCode, latestCompartmentInfo });
|
||||
if (!!context) {
|
||||
if (action.command.includes('ARRIVED') || action.command.includes('PRINT_PRICEDIFFQRCODELABEL')) {
|
||||
await this.router.navigate(this._pickupShelfInNavigationService.defaultRoute().path);
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, OnInit, Output, inject } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, inject } from '@angular/core';
|
||||
import { PickupShelfDetailsStore } from '../../store';
|
||||
import { DateAdapter, Group, groupBy } from '@ui/common';
|
||||
import { Group, groupBy } from '@ui/common';
|
||||
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
|
||||
import { ProductImageModule } from '@cdn/product-image';
|
||||
import { UiSliderModule } from '@ui/slider';
|
||||
import { UiSpinnerModule } from '@ui/spinner';
|
||||
import { PickupShelfProcessingStatusPipe } from '../pipes/processing-status.pipe';
|
||||
import { DBHOrderItemListItemDTO } from '@swagger/oms';
|
||||
import { Subscription, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { PickupShelfCoverCompartmentCodePipe } from '../pipes/cover-compartment-code.pipe';
|
||||
import { PickupShelfShowCoverCompartmentCodePipe } from '../pipes/show-cover-compartment-code.pipe';
|
||||
|
||||
@@ -31,7 +29,7 @@ import { PickupShelfShowCoverCompartmentCodePipe } from '../pipes/show-cover-com
|
||||
PickupShelfShowCoverCompartmentCodePipe,
|
||||
],
|
||||
})
|
||||
export class PickUpShelfDetailsCoversComponent implements OnInit, OnDestroy {
|
||||
export class PickUpShelfDetailsCoversComponent {
|
||||
private _store = inject(PickupShelfDetailsStore);
|
||||
|
||||
@Input() selectedOrderItem: DBHOrderItemListItemDTO;
|
||||
@@ -63,39 +61,7 @@ export class PickUpShelfDetailsCoversComponent implements OnInit, OnDestroy {
|
||||
return groupedItems;
|
||||
}
|
||||
|
||||
private subscriptions = new Subscription();
|
||||
|
||||
constructor(private dateAdapter: DateAdapter) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.coverItems
|
||||
?.filter((a) => a.processingStatus === 128)
|
||||
?.filter((a) => {
|
||||
if (a.readyForPickUp) {
|
||||
const readyForPickUp = new Date(a.readyForPickUp);
|
||||
return this.dateAdapter.compareDate(readyForPickUp, this.dateAdapter.today()) === 0;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
?.filter((currentItem) => {
|
||||
const oderItemPaid = !!this.coverItems[0].features?.paid;
|
||||
const currentItemPaid = !!currentItem.features?.paid;
|
||||
return oderItemPaid === currentItemPaid;
|
||||
})
|
||||
?.sort((a, b) => new Date(b.readyForPickUp).getTime() - new Date(a.readyForPickUp).getTime())
|
||||
?.find((_) => true);
|
||||
|
||||
// .subscribe((orderItem) => {
|
||||
// // this.host.latestCompartmentCode = orderItem?.compartmentCode;
|
||||
// // this.host.latestCompartmentInfo = orderItem?.compartmentInfo;
|
||||
// })
|
||||
// );
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.unsubscribe();
|
||||
// this.host.latestCompartmentCode = undefined;
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
groupByProcessingStatus(item: DBHOrderItemListItemDTO) {
|
||||
// Eingetroffene anhand compartmentCode und EAN gruppieren
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { uniq } from 'lodash';
|
||||
import { PickupShelfDetailsState } from './pickup-shelf-details.state';
|
||||
import { DBHOrderItemListItemDTO } from '@swagger/oms';
|
||||
|
||||
@@ -113,23 +112,35 @@ export const selectSelectedOrderItemQuantity = (s: PickupShelfDetailsState) => {
|
||||
|
||||
export const selectSelectedCompartmentInfo = (s: PickupShelfDetailsState) => s.selectedCompartmentInfo;
|
||||
|
||||
export const selectLatestCompartmentCodeForOrder = (s: PickupShelfDetailsState) => {
|
||||
const items = selectOrderItemsRaw(s);
|
||||
const itemsWithCompartmentCodes = items?.filter((oi) => oi.compartmentCode);
|
||||
export const selectLatestCompartmentCodeAndInfoForOrder = (s: PickupShelfDetailsState) => {
|
||||
const coverItems = selectCoverOrderItems(s);
|
||||
|
||||
const code = itemsWithCompartmentCodes?.reduce<string>((acc, oi) => {
|
||||
if (!acc) {
|
||||
return oi.compartmentCode;
|
||||
}
|
||||
// Ticket #4397 - Sortieren und Filtern der angezeigten CoverItems nach latestCompartmentCode und Info
|
||||
const coverItem = coverItems
|
||||
?.filter((a) => a.processingStatus === 128)
|
||||
?.filter((a) => {
|
||||
if (a.readyForPickUp) {
|
||||
const readyForPickUp = new Date(a.readyForPickUp);
|
||||
const today = new Date(Date.now());
|
||||
|
||||
if (Number(acc?.split('_')[0]) < Number(oi?.compartmentCode?.split('_')[0])) {
|
||||
return oi.compartmentCode;
|
||||
}
|
||||
// May use dateAdapter utility functions here to check if the date is the same
|
||||
return (
|
||||
(readyForPickUp.getFullYear() - today.getFullYear() ||
|
||||
readyForPickUp.getMonth() - today.getMonth() ||
|
||||
readyForPickUp.getDate() - today.getDate()) === 0
|
||||
);
|
||||
}
|
||||
return false;
|
||||
})
|
||||
?.filter((currentItem) => {
|
||||
const oderItemPaid = !!coverItems[0].features?.paid;
|
||||
const currentItemPaid = !!currentItem.features?.paid;
|
||||
return oderItemPaid === currentItemPaid;
|
||||
})
|
||||
?.sort((a, b) => new Date(b.readyForPickUp).getTime() - new Date(a.readyForPickUp).getTime())
|
||||
?.find((_) => true);
|
||||
|
||||
return acc;
|
||||
}, undefined);
|
||||
|
||||
return code;
|
||||
return { latestCompartmentCode: coverItem?.compartmentCode, latestCompartmentInfo: coverItem?.compartmentInfo };
|
||||
};
|
||||
|
||||
export const selectFetchingOrderItemSubsetTasks = (orderItemSubsetId: number) => (s: PickupShelfDetailsState) =>
|
||||
@@ -194,10 +205,10 @@ export const selectShowTagsComponent = (s: PickupShelfDetailsState) => {
|
||||
|
||||
export const selectAddToPreviousCompartmentAction = (s: PickupShelfDetailsState) => {
|
||||
const items = selectOrderItems(s);
|
||||
const latestCompartmentCode = selectLatestCompartmentCodeForOrder(s);
|
||||
const latestCompartmentInfos = selectLatestCompartmentCodeAndInfoForOrder(s);
|
||||
const firstItem = items?.find((_) => true);
|
||||
|
||||
if ([16, 8192].includes(firstItem?.processingStatus) && latestCompartmentCode) {
|
||||
if ([16, 8192].includes(firstItem?.processingStatus) && latestCompartmentInfos?.latestCompartmentCode) {
|
||||
// Zubuchen von Bezahlte und unbezahlte Bestellungen nicht möglich
|
||||
// Zubuchen bei Pay&Collect nur innerhalb der gleichen Bestellung möglich
|
||||
|
||||
|
||||
@@ -148,10 +148,10 @@ export class PickupShelfDetailsStore extends ComponentStore<PickupShelfDetailsSt
|
||||
return this.get(Selectors.selectDisplayedCompartmentCode);
|
||||
}
|
||||
|
||||
latestCompartmentCodeForOrder$ = this.select(Selectors.selectLatestCompartmentCodeForOrder);
|
||||
latestCompartmentCodeAndInfoForOrder$ = this.select(Selectors.selectLatestCompartmentCodeAndInfoForOrder);
|
||||
|
||||
get latestCompartmentCodeForOrder() {
|
||||
return this.get(Selectors.selectLatestCompartmentCodeForOrder);
|
||||
return this.get(Selectors.selectLatestCompartmentCodeAndInfoForOrder);
|
||||
}
|
||||
|
||||
selectedOrderItems$ = this.select(Selectors.selectedOrderItems);
|
||||
|
||||
Reference in New Issue
Block a user