#4016 Kaufoptionen - Preis bei Versandbestellungen

This commit is contained in:
Lorenz Hilpert
2023-05-03 16:22:51 +02:00
parent 35068e23cd
commit 4c7b5eec38
7 changed files with 39 additions and 10 deletions

View File

@@ -561,7 +561,6 @@ export class DomainAvailabilityService {
private _mapToShippingAvailability(availabilities: SwaggerAvailabilityDTO[]) {
const preferred = availabilities.filter((f) => f.preferred === 1);
return preferred.map((p) => {
return {
availabilityType: p?.status,
@@ -575,6 +574,7 @@ export class DomainAvailabilityService {
supplierInfo: p?.requestStatusCode,
lastRequest: p?.requested,
itemId: p.itemId,
priceMaintained: p.priceMaintained,
};
});
}

View File

@@ -64,7 +64,14 @@
</div>
</div>
<div class="shared-purchase-options-list-item__price text-right ml-4 flex flex-col items-end">
<div class="shared-purchase-options-list-item__price-value font-bold text-xl" *ngIf="!(canEditPrice$ | async)">
<div
class="shared-purchase-options-list-item__price-value font-bold text-xl flex flex-row items-center"
*ngIf="!(canEditPrice$ | async)"
>
<ui-svg-icon class="mr-3" [uiOverlayTrigger]="tooltip" icon="mat-info" *ngIf="priceMaintained$ | async"></ui-svg-icon>
<ui-tooltip #tooltip yPosition="above" xPosition="after" [yOffset]="-8" [xOffset]="5" [closeable]="true">
Günstigerer Preis aus Hugendubel Katalog wird übernommen
</ui-tooltip>
{{ priceValue$ | async | currency: 'EUR':'code' }}
</div>
<div class="shared-purchase-options-list-item__price-value font-bold text-xl" *ngIf="canEditPrice$ | async">

View File

@@ -121,6 +121,8 @@ export class PurchaseOptionsListItemComponent implements OnInit, OnDestroy, OnCh
price$ = this.item$.pipe(switchMap((item) => this._store.getPrice$(item.id)));
priceMaintained$ = this.price$.pipe(map((price) => price?.fromCatalogue));
priceValue$ = this.price$.pipe(map((price) => price?.value?.value));
priceVat$ = this.price$.pipe(map((price) => price?.vat?.value));

View File

@@ -204,7 +204,10 @@ export function getCanEditPrice(itemId: number): (state: PurchaseOptionsState) =
};
}
export function getPriceForPurchaseOption(itemId: number, purchaseOption: PurchaseOption): (state: PurchaseOptionsState) => PriceDTO {
export function getPriceForPurchaseOption(
itemId: number,
purchaseOption: PurchaseOption
): (state: PurchaseOptionsState) => PriceDTO & { fromCatalogue?: boolean } {
return (state) => {
const price = getPrices(state)[itemId];
@@ -212,6 +215,10 @@ export function getPriceForPurchaseOption(itemId: number, purchaseOption: Purcha
return price;
}
const item = getItems(state).find((item) => item.id === itemId);
const type = getType(state);
let availabilities = getAvailabilitiesForItem(itemId)(state);
let availability = availabilities.find((availability) => availability.purchaseOption === purchaseOption);
@@ -227,15 +234,26 @@ export function getPriceForPurchaseOption(itemId: number, purchaseOption: Purcha
}
availability = availability || digAvailability || b2bAvailability;
if (!availability?.data?.priceMaintained) {
// if price is not maintained, use the cheaper price
if (isItemDTO(item, type)) {
const catalogAvailability = item?.catalogAvailability?.price;
if (
catalogAvailability?.value?.value &&
availability?.data?.price?.value?.value &&
catalogAvailability?.value?.value < availability?.data?.price?.value?.value
) {
return { ...catalogAvailability, fromCatalogue: true };
}
}
}
}
if (availability && availability.data.price?.value?.value) {
return availability.data.price ?? DEFAULT_PRICE_DTO;
if (availability && availability.data.price?.value?.value && availability.data.price) {
return availability.data.price;
}
const item = getItems(state).find((item) => item.id === itemId);
const type = getType(state);
if (isItemDTO(item, type)) {
return item?.catalogAvailability?.price ?? DEFAULT_PRICE_DTO;
} else {

View File

@@ -283,7 +283,7 @@ export class PurchaseOptionsStore extends ComponentStore<PurchaseOptionsState> {
try {
this.addFetchingAvailability({ id, itemId: itemData.sourceId, purchaseOption: 'delivery' });
const res = await this._service.fetchDeliveryAvailability(itemData, itemData.quantity).toPromise();
console.log('res', res);
const availability: Availability = {
itemId: itemData.sourceId,
purchaseOption: 'delivery',

View File

@@ -17,7 +17,7 @@ export type Branch = BranchDTO;
export type Availability = {
itemId: number;
purchaseOption: PurchaseOption;
data: AvailabilityDTO;
data: AvailabilityDTO & { priceMaintained?: boolean };
};
export type ItemData = AvailabilityItemData & { sourceId: number; quantity: number };

View File

@@ -14,9 +14,11 @@ export interface AvailabilityDTO {
itemId?: number;
logistician?: string;
logisticianId?: number;
orderDeadline?: string;
orderReference?: string;
preferred?: number;
price?: PriceDTO;
priceMaintained?: boolean;
qty?: number;
requestMessage?: string;
requestReference?: string;