mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Refactor selectLatestCompartmentCodeAndInfoForOrder to enforce booking rules for paid and unpaid items
This commit is contained in:
@@ -131,23 +131,27 @@ export const selectSelectedCompartmentInfo = (s: PickupShelfDetailsState) =>
|
||||
s.selectedCompartmentInfo;
|
||||
|
||||
export const selectLatestCompartmentCodeAndInfoForOrder = (s: PickupShelfDetailsState) => {
|
||||
const coverItems = selectCoverOrderItems(s);
|
||||
let coverItems = selectCoverOrderItems(s);
|
||||
|
||||
const orderItems = selectedOrderItems(s);
|
||||
|
||||
const isPaid = orderItems?.some((item) => item.features?.paid);
|
||||
const isKulturPass = orderItems?.some((item) => item.features?.orderSource === 'KulturPass');
|
||||
/**
|
||||
* Ticket #5022 - AHF // Bezahlte und unbezahlte Ware werden auf dieselbe AHF-Nummer gebucht (Abholfach)
|
||||
* Fall 1: Wenn alle ausgewählte Order Items Bezahlt sind, darf man diese nur auf die AHF-Nummer buchen, die auch Bezahlt ist.
|
||||
* Fall 2: Wenn keines der ausgewählte Order Items Bezahlt sind, darf man nur auf die AHF-Nummer buchen, die auch nicht Bezahlt ist.
|
||||
*/
|
||||
const hasFeaturePaid = orderItems?.every((item) => item.features?.paid === 'Bezahlt');
|
||||
const hasSourceKulturPass = orderItems?.every(
|
||||
(item) => item.features?.orderSource === 'KulturPass',
|
||||
);
|
||||
if (hasFeaturePaid || hasSourceKulturPass) {
|
||||
coverItems = coverItems?.filter(
|
||||
(item) => item.features?.paid === 'Bezahlt' || item.features?.orderSource === 'KulturPass',
|
||||
);
|
||||
}
|
||||
|
||||
// Ticket #4397 - Sortieren und Filtern der angezeigten CoverItems nach latestCompartmentCode und Info
|
||||
const coverItem = coverItems
|
||||
?.filter((a) => {
|
||||
// #5022 - Bezahlte und unbezahlte Ware werden auf dieselbe AHF-Nummer gebucht (Abholfach)
|
||||
// Bezahlte und unbezahlte Ware dürfen nicht dem selben Abholfach zugeordnet werden (Warenausgabe)
|
||||
const isCurrentItemPaid = !!a.features?.paid;
|
||||
const isCurrentItemKulturPass = !!(a.features?.orderSource === 'KulturPass');
|
||||
|
||||
return isPaid === isCurrentItemPaid && isKulturPass === isCurrentItemKulturPass;
|
||||
})
|
||||
// Item should have the processing status 128 "eingetroffen"
|
||||
?.filter((a) => a.processingStatus === 128)
|
||||
// Items should be ready for pick up today
|
||||
|
||||
Reference in New Issue
Block a user