mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
#4016 Kaufoptionen - Preis bei Versandbestellungen
This commit is contained in:
@@ -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,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user