Compare commits

...

1 Commits

Author SHA1 Message Date
Lorenz Hilpert
445817c22f hotfix(checkout): Chaning the Quantity in the cart used a wrink branch for "Rücklage"
- When chaning the quantity, the current destination branch will be used to update the quantity in the cart
2025-04-09 12:05:15 +02:00

View File

@@ -25,7 +25,10 @@ import { DomainPrinterService } from '@domain/printer';
import { CheckoutDummyComponent } from '../checkout-dummy/checkout-dummy.component';
import { CheckoutDummyData } from '../checkout-dummy/checkout-dummy-data';
import { PurchaseOptionsModalService } from '@modal/purchase-options';
import { CheckoutNavigationService, ProductCatalogNavigationService } from '@shared/services/navigation';
import {
CheckoutNavigationService,
ProductCatalogNavigationService,
} from '@shared/services/navigation';
import { EnvironmentService } from '@core/environment';
import { CheckoutReviewStore } from './checkout-review.store';
import { ToasterService } from '@shared/shell';
@@ -59,8 +62,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
map((items) => items?.filter((item) => item?.features?.orderType === undefined)),
);
trackByGroupedItems: TrackByFunction<{ orderType: string; destination: DestinationDTO; items: ShoppingCartItemDTO[] }> = (_, item) =>
item?.orderType + item?.destination?.id;
trackByGroupedItems: TrackByFunction<{
orderType: string;
destination: DestinationDTO;
items: ShoppingCartItemDTO[];
}> = (_, item) => item?.orderType + item?.destination?.id;
groupedItems$ = this._store.shoppingCartItems$.pipe(
takeUntil(this._store.orderCompleted),
@@ -101,7 +107,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
grouped.push(group);
}
return [...grouped].sort((a, b) => (a?.orderType === undefined ? -1 : b?.orderType === undefined ? 1 : 0));
return [...grouped].sort((a, b) =>
a?.orderType === undefined ? -1 : b?.orderType === undefined ? 1 : 0,
);
},
[] as { orderType: string; destination: DestinationDTO; items: ShoppingCartItemDTO[] }[],
),
@@ -134,7 +142,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
.getPromotionPoints({
items,
})
.pipe(map((response) => Object.values(response.result).reduce((sum, points) => sum + points, 0)));
.pipe(
map((response) =>
Object.values(response.result).reduce((sum, points) => sum + points, 0),
),
);
} else {
return NEVER;
}
@@ -148,7 +160,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
showQuantityControlSpinnerItemId: number;
quantityError$ = new BehaviorSubject<{ [key: string]: string }>({});
primaryCtaLabel$ = combineLatest([this.payer$, this.buyer$, this.shoppingCartItemsWithoutOrderType$]).pipe(
primaryCtaLabel$ = combineLatest([
this.payer$,
this.buyer$,
this.shoppingCartItemsWithoutOrderType$,
]).pipe(
map(([payer, buyer, shoppingCartItemsWithoutOrderType]) => {
if (shoppingCartItemsWithoutOrderType?.length > 0) {
return 'Kaufoptionen';
@@ -182,7 +198,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
);
get productSearchBasePath() {
return this._productNavigationService.getArticleSearchBasePath(this.applicationService.activatedProcessId).path;
return this._productNavigationService.getArticleSearchBasePath(
this.applicationService.activatedProcessId,
).path;
}
get isDesktop$() {
@@ -258,8 +276,14 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
});
}
checkIfMultipleDestinationsForOrderTypeExist(targetBranch: BranchDTO, group: { items: ShoppingCartItemDTO[] }, i: number) {
return i === 0 ? false : targetBranch.id !== group.items[i - 1].destination?.data?.targetBranch?.data.id;
checkIfMultipleDestinationsForOrderTypeExist(
targetBranch: BranchDTO,
group: { items: ShoppingCartItemDTO[] },
i: number,
) {
return i === 0
? false
: targetBranch.id !== group.items[i - 1].destination?.data?.targetBranch?.data.id;
}
async refreshAvailabilities() {
@@ -276,7 +300,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
await this.breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: this.applicationService.activatedProcessId,
name: 'Warenkorb',
path: this._navigationService.getCheckoutReviewPath(this.applicationService.activatedProcessId).path,
path: this._navigationService.getCheckoutReviewPath(
this.applicationService.activatedProcessId,
).path,
tags: ['checkout', 'cart'],
section: 'customer',
});
@@ -284,7 +310,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
async removeBreadcrumbs() {
const checkoutDummyCrumbs = await this.breadcrumb
.getBreadcrumbsByKeyAndTags$(this.applicationService.activatedProcessId, ['checkout', 'cart', 'dummy'])
.getBreadcrumbsByKeyAndTags$(this.applicationService.activatedProcessId, [
'checkout',
'cart',
'dummy',
])
.pipe(first())
.toPromise();
checkoutDummyCrumbs.forEach(async (crumb) => {
@@ -296,7 +326,13 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
this._store.notificationsControl = undefined;
}
openDummyModal({ data, changeDataFromCart = false }: { data?: CheckoutDummyData; changeDataFromCart?: boolean }) {
openDummyModal({
data,
changeDataFromCart = false,
}: {
data?: CheckoutDummyData;
changeDataFromCart?: boolean;
}) {
this.uiModal.open({
content: CheckoutDummyComponent,
data: { ...data, changeDataFromCart },
@@ -321,7 +357,8 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
content: PrintModalComponent,
data: {
printerType: 'Label',
print: (printer) => this.domainPrinterService.printCart({ cartId: shoppingCart.id, printer }).toPromise(),
print: (printer) =>
this.domainPrinterService.printCart({ cartId: shoppingCart.id, printer }).toPromise(),
} as PrintModalData,
config: {
panelClass: [],
@@ -330,7 +367,13 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
});
}
async updateItemQuantity({ shoppingCartItem, quantity }: { shoppingCartItem: ShoppingCartItemDTO; quantity: number }) {
async updateItemQuantity({
shoppingCartItem,
quantity,
}: {
shoppingCartItem: ShoppingCartItemDTO;
quantity: number;
}) {
if (quantity === shoppingCartItem.quantity) {
return;
}
@@ -355,6 +398,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
price: shoppingCartItem.availability.price,
},
quantity,
branch,
})
.toPromise();
@@ -439,7 +483,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
} else if (availability) {
// Wenn das Ergebnis der Availability Abfrage keinen Preis zurückliefert (z.B. HFI Geschenkkarte), wird der Preis aus der
// Availability vor der Abfrage verwendet
const updateAvailability = availability?.price ? availability : { ...availability, price: shoppingCartItem.availability?.price };
const updateAvailability = availability?.price
? availability
: { ...availability, price: shoppingCartItem.availability?.price };
await this.domainCheckoutService
.updateItemInShoppingCart({
@@ -447,7 +493,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
shoppingCartItemId: shoppingCartItem.id,
update: {
quantity,
availability: this.compareDeliveryAndCatalogPrice(updateAvailability, orderType, shoppingCartItemPrice),
availability: this.compareDeliveryAndCatalogPrice(
updateAvailability,
orderType,
shoppingCartItemPrice,
),
},
})
.toPromise();
@@ -467,8 +517,15 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
}
// Bei unbekannten Kunden und DIG Bestellung findet ein Vergleich der Preise statt
compareDeliveryAndCatalogPrice(availability: AvailabilityDTO, orderType: string, shoppingCartItemPrice: number) {
if (['Versand', 'DIG-Versand'].includes(orderType) && shoppingCartItemPrice < availability?.price?.value?.value) {
compareDeliveryAndCatalogPrice(
availability: AvailabilityDTO,
orderType: string,
shoppingCartItemPrice: number,
) {
if (
['Versand', 'DIG-Versand'].includes(orderType) &&
shoppingCartItemPrice < availability?.price?.value?.value
) {
return {
...availability,
price: {
@@ -514,7 +571,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
async changeAddress() {
const processId = this.applicationService.activatedProcessId;
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
const customer = await this.domainCheckoutService
.getBuyer({ processId })
.pipe(first())
.toPromise();
if (!customer) {
this.navigateToCustomerSearch(processId);
return;
@@ -525,7 +585,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
}
async order() {
const shoppingCartItemsWithoutOrderType = await this.shoppingCartItemsWithoutOrderType$.pipe(first()).toPromise();
const shoppingCartItemsWithoutOrderType = await this.shoppingCartItemsWithoutOrderType$
.pipe(first())
.toPromise();
if (shoppingCartItemsWithoutOrderType?.length > 0) {
this.showPurchasingListModal(shoppingCartItemsWithoutOrderType);
@@ -533,7 +595,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
}
const processId = this.applicationService.activatedProcessId;
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
const customer = await this.domainCheckoutService
.getBuyer({ processId })
.pipe(first())
.toPromise();
if (!customer) {
this.navigateToCustomerSearch(processId);
} else {
@@ -577,7 +642,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
}
async patchProcess(processId: number) {
const process = await this.applicationService.getProcessById$(processId).pipe(first()).toPromise();
const process = await this.applicationService
.getProcessById$(processId)
.pipe(first())
.toPromise();
if (!!process) {
this.applicationService.patchProcess(process.id, {
name: `${process.name} Bestellbestätigung`,