diff --git a/generated/swagger/oms-api/src/models/display-order-item-dto.ts b/generated/swagger/oms-api/src/models/display-order-item-dto.ts index e020ac4d6..fff420947 100644 --- a/generated/swagger/oms-api/src/models/display-order-item-dto.ts +++ b/generated/swagger/oms-api/src/models/display-order-item-dto.ts @@ -1,5 +1,6 @@ /* tslint:disable */ import { EntityDTOBaseOfDisplayOrderItemDTOAndIOrderItem } from './entity-dtobase-of-display-order-item-dtoand-iorder-item'; +import { KeyValueDTOOfStringAndString } from './key-value-dtoof-string-and-string'; import { LoyaltyDTO } from './loyalty-dto'; import { DisplayOrderDTO } from './display-order-dto'; import { PriceDTO } from './price-dto'; @@ -9,6 +10,11 @@ import { QuantityUnitType } from './quantity-unit-type'; import { DisplayOrderItemSubsetDTO } from './display-order-item-subset-dto'; export interface DisplayOrderItemDTO extends EntityDTOBaseOfDisplayOrderItemDTOAndIOrderItem{ + /** + * Mögliche Aktionen + */ + actions?: Array; + /** * Bemerkung des Auftraggebers */ diff --git a/generated/swagger/oms-api/src/models/display-order-item-subset-dto.ts b/generated/swagger/oms-api/src/models/display-order-item-subset-dto.ts index 7fad5c398..dcddfa27a 100644 --- a/generated/swagger/oms-api/src/models/display-order-item-subset-dto.ts +++ b/generated/swagger/oms-api/src/models/display-order-item-subset-dto.ts @@ -1,10 +1,16 @@ /* tslint:disable */ import { EntityDTOBaseOfDisplayOrderItemSubsetDTOAndIOrderItemStatus } from './entity-dtobase-of-display-order-item-subset-dtoand-iorder-item-status'; +import { KeyValueDTOOfStringAndString } from './key-value-dtoof-string-and-string'; import { DateRangeDTO } from './date-range-dto'; import { DisplayOrderItemDTO } from './display-order-item-dto'; import { OrderItemProcessingStatusValue } from './order-item-processing-status-value'; export interface DisplayOrderItemSubsetDTO extends EntityDTOBaseOfDisplayOrderItemSubsetDTOAndIOrderItemStatus{ + /** + * Mögliche Aktionen + */ + actions?: Array; + /** * Abholfachnummer */ @@ -40,6 +46,11 @@ export interface DisplayOrderItemSubsetDTO extends EntityDTOBaseOfDisplayOrderIt */ estimatedShippingDate?: string; + /** + * Zusätzliche Markierungen (z.B. Abo, ...) + */ + features?: {[key: string]: string}; + /** * Bestellposten */ diff --git a/generated/swagger/oms-api/src/models/receipt-dto.ts b/generated/swagger/oms-api/src/models/receipt-dto.ts index 31e7d3c72..9e6e7636f 100644 --- a/generated/swagger/oms-api/src/models/receipt-dto.ts +++ b/generated/swagger/oms-api/src/models/receipt-dto.ts @@ -118,6 +118,11 @@ export interface ReceiptDTO extends EntityDTOBaseOfReceiptDTOAndIReceipt{ */ receiptNumber?: string; + /** + * Subtype of the receipt / Beleg-Unterart + */ + receiptSubType?: string; + /** * Belegtext */ diff --git a/libs/oms/data-access/src/lib/helpers/return-process/index.ts b/libs/oms/data-access/src/lib/helpers/return-process/index.ts index e6c4a91c2..dab08fe50 100644 --- a/libs/oms/data-access/src/lib/helpers/return-process/index.ts +++ b/libs/oms/data-access/src/lib/helpers/return-process/index.ts @@ -10,6 +10,7 @@ export * from './get-receipt-item-quantity.helper'; export * from './get-return-info.helper'; export * from './get-return-process-questions.helper'; export * from './get-tolino-questions.helper'; +export * from './is-task-type.helper'; export * from './receipt-item-has-category.helper'; export * from './return-details-mapping.helper'; export * from './return-receipt-values-mapping.helper'; diff --git a/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.spec.ts b/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.spec.ts new file mode 100644 index 000000000..57849ef68 --- /dev/null +++ b/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.spec.ts @@ -0,0 +1,88 @@ +import { TaskActionTypes } from '../../models'; +import { isTaskType } from './is-task-type.helper'; + +describe('isTaskType', () => { + describe('OK type matching', () => { + it('should return true when comparing OK with OK', () => { + expect(isTaskType('OK', TaskActionTypes.OK)).toBe(true); + }); + + it('should return true when comparing RETOURE_OK with OK', () => { + expect(isTaskType('RETOURE_OK', TaskActionTypes.OK)).toBe(true); + }); + + it('should return true when comparing OK with RETOURE_OK', () => { + expect(isTaskType('OK', TaskActionTypes.RETOURE_OK)).toBe(true); + }); + + it('should return true when comparing RETOURE_OK with RETOURE_OK', () => { + expect(isTaskType('RETOURE_OK', TaskActionTypes.RETOURE_OK)).toBe(true); + }); + }); + + describe('NOK type matching', () => { + it('should return true when comparing NOK with NOK', () => { + expect(isTaskType('NOK', TaskActionTypes.NOK)).toBe(true); + }); + + it('should return true when comparing RETOURE_NOK with NOK', () => { + expect(isTaskType('RETOURE_NOK', TaskActionTypes.NOK)).toBe(true); + }); + + it('should return true when comparing NOK with RETOURE_NOK', () => { + expect(isTaskType('NOK', TaskActionTypes.RETOURE_NOK)).toBe(true); + }); + + it('should return true when comparing RETOURE_NOK with RETOURE_NOK', () => { + expect(isTaskType('RETOURE_NOK', TaskActionTypes.RETOURE_NOK)).toBe(true); + }); + }); + + describe('UNKNOWN type matching', () => { + it('should return true when comparing UNKNOWN with UNKNOWN', () => { + expect(isTaskType('UNKNOWN', TaskActionTypes.UNKNOWN)).toBe(true); + }); + + it('should return true when comparing RETOURE_UNKNOWN with UNKNOWN', () => { + expect(isTaskType('RETOURE_UNKNOWN', TaskActionTypes.UNKNOWN)).toBe(true); + }); + + it('should return true when comparing UNKNOWN with RETOURE_UNKNOWN', () => { + expect(isTaskType('UNKNOWN', TaskActionTypes.RETOURE_UNKNOWN)).toBe(true); + }); + + it('should return true when comparing RETOURE_UNKNOWN with RETOURE_UNKNOWN', () => { + expect( + isTaskType('RETOURE_UNKNOWN', TaskActionTypes.RETOURE_UNKNOWN), + ).toBe(true); + }); + }); + + describe('non-matching types', () => { + it('should return false when comparing OK with NOK', () => { + expect(isTaskType('OK', TaskActionTypes.NOK)).toBe(false); + }); + + it('should return false when comparing RETOURE_OK with UNKNOWN', () => { + expect(isTaskType('RETOURE_OK', TaskActionTypes.UNKNOWN)).toBe(false); + }); + + it('should return false when comparing NOK with OK', () => { + expect(isTaskType('NOK', TaskActionTypes.OK)).toBe(false); + }); + }); + + describe('falsy values', () => { + it('should return false when value is undefined', () => { + expect(isTaskType(undefined, TaskActionTypes.OK)).toBe(false); + }); + + it('should return false when value is null', () => { + expect(isTaskType(null, TaskActionTypes.OK)).toBe(false); + }); + + it('should return false when value is empty string', () => { + expect(isTaskType('', TaskActionTypes.OK)).toBe(false); + }); + }); +}); diff --git a/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.ts b/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.ts new file mode 100644 index 000000000..3a6d34755 --- /dev/null +++ b/libs/oms/data-access/src/lib/helpers/return-process/is-task-type.helper.ts @@ -0,0 +1,34 @@ +import { TaskActionTypeType } from '../../models'; + +/** + * Checks if a task action type value matches a given type, including its RETOURE_ variant. + * + * This helper normalizes both values by stripping the 'RETOURE_' prefix before comparison, + * allowing flexible matching between base types and their return variants. + * + * @param value - The task action type value to check (can be a base type or RETOURE_ variant) + * @param type - The task action type to compare against (can be a base type or RETOURE_ variant) + * @returns `true` if the normalized values match, `false` otherwise + * + * @example + * // All of these return true: + * isTaskType('OK', TaskActionTypes.OK) // 'OK' === 'OK' + * isTaskType('RETOURE_OK', TaskActionTypes.OK) // 'OK' === 'OK' + * isTaskType('OK', TaskActionTypes.RETOURE_OK) // 'OK' === 'OK' + * isTaskType('RETOURE_OK', TaskActionTypes.RETOURE_OK) // 'OK' === 'OK' + * + * @example + * // Returns false: + * isTaskType('OK', TaskActionTypes.NOK) // 'OK' !== 'NOK' + * isTaskType('RETOURE_OK', TaskActionTypes.UNKNOWN) // 'OK' !== 'UNKNOWN' + * isTaskType(undefined, TaskActionTypes.OK) // value is falsy + */ +export const isTaskType = ( + value: TaskActionTypeType | string | undefined | null, + type: TaskActionTypeType, +): boolean => { + if (!value) return false; + const normalizedValue = value.replace('RETOURE_', ''); + const normalizedType = type.replace('RETOURE_', ''); + return normalizedValue === normalizedType; +}; diff --git a/libs/oms/data-access/src/lib/models/task-action-type.ts b/libs/oms/data-access/src/lib/models/task-action-type.ts index 33212e3ec..d78972616 100644 --- a/libs/oms/data-access/src/lib/models/task-action-type.ts +++ b/libs/oms/data-access/src/lib/models/task-action-type.ts @@ -2,8 +2,11 @@ import { KeyValueDTOOfStringAndString } from '@generated/swagger/oms-api'; export const TaskActionTypes = { OK: 'OK', + RETOURE_OK: 'RETOURE_OK', NOK: 'NOK', + RETOURE_NOK: 'RETOURE_NOK', UNKNOWN: 'UNKNOWN', + RETOURE_UNKNOWN: 'RETOURE_UNKNOWN', } as const; export type TaskActionTypeType = @@ -13,6 +16,6 @@ export interface TaskActionType { type: TaskActionTypeType; taskId: number; receiptItemId?: number; - updateTo?: Exclude; + updateTo?: Exclude; actions?: Array; } diff --git a/libs/oms/data-access/src/lib/services/return-task-list.service.ts b/libs/oms/data-access/src/lib/services/return-task-list.service.ts index 838efff72..8ad396aa3 100644 --- a/libs/oms/data-access/src/lib/services/return-task-list.service.ts +++ b/libs/oms/data-access/src/lib/services/return-task-list.service.ts @@ -1,6 +1,11 @@ import { inject, Injectable } from '@angular/core'; import { map, Observable, throwError } from 'rxjs'; -import { ReceiptItemTaskListItem, TaskActionTypeType } from '../models'; +import { + ReceiptItemTaskListItem, + TaskActionTypes, + TaskActionTypeType, +} from '../models'; +import { isTaskType } from '../helpers'; import { QueryTokenInput, QueryTokenSchema } from '../schemas'; import { ZodError } from 'zod'; import { ReturnParseQueryTokenError } from '../errors'; @@ -98,7 +103,7 @@ export class ReturnTaskListService { * @throws Error when the update operation fails or returns an error */ updateTaskType(updateTask: { - type: Exclude; + type: Exclude; taskId: number; }) { try { @@ -127,18 +132,18 @@ export class ReturnTaskListService { * @private */ private _updateTaskRequestHelper(updateTask: { - type: Exclude; + type: Exclude; taskId: number; }): Observable { if (!updateTask?.taskId) { return throwError(() => new Error('Task ID missing')); } - if (updateTask.type === 'OK') { + if (isTaskType(updateTask.type, TaskActionTypes.OK)) { return this.#receiptService.ReceiptSetReceiptItemTaskToOK( updateTask.taskId, ); - } else if (updateTask.type === 'NOK') { + } else if (isTaskType(updateTask.type, TaskActionTypes.NOK)) { return this.#receiptService.ReceiptSetReceiptItemTaskToNOK( updateTask.taskId, ); diff --git a/libs/oms/shared/task-list/src/lib/return-task-list/return-task-list-item/return-task-list-item.component.html b/libs/oms/shared/task-list/src/lib/return-task-list/return-task-list-item/return-task-list-item.component.html index 1b5dfe5fc..6f4266b53 100644 --- a/libs/oms/shared/task-list/src/lib/return-task-list/return-task-list-item/return-task-list-item.component.html +++ b/libs/oms/shared/task-list/src/lib/return-task-list/return-task-list-item/return-task-list-item.component.html @@ -8,7 +8,7 @@ @let taskItem = item(); @let taskActionType = type(); -@if (taskActionType === 'UNKNOWN') { +@if (isTaskType(taskActionType, TaskActionTypes.UNKNOWN)) {
} -@if (taskActionType === 'UNKNOWN' && !taskItem?.completed) { +@if ( + isTaskType(taskActionType, TaskActionTypes.UNKNOWN) && !taskItem?.completed +) {