ng-easycommerce 0.0.691 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/assets/ec-i18n/ct.json +3 -0
- package/assets/ec-i18n/en.json +3 -0
- package/assets/ec-i18n/es.json +3 -0
- package/assets/ec-i18n/fr.json +3 -0
- package/assets/ec-i18n/gl.json +3 -0
- package/assets/ec-i18n/pr.json +3 -0
- package/bundles/ng-easycommerce.umd.js +1219 -653
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/ec-component/account-ec/order-ec/order-ec.component.js +103 -5
- package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +22 -8
- package/esm2015/lib/ec-component/checkout-ec/checkout-ec.component.js +34 -11
- package/esm2015/lib/ec-component/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.js +18 -7
- package/esm2015/lib/ec-component/sidebar-ec/sidebar-ec.component.js +12 -3
- package/esm2015/lib/interfaces/cart-item.js +1 -1
- package/esm2015/lib/interfaces/cart-totals.js +1 -0
- package/esm2015/lib/interfaces/channel.js +1 -0
- package/esm2015/lib/interfaces/checkout-data.js +1 -1
- package/esm2015/lib/interfaces/product.js +1 -1
- package/esm2015/lib/services/account/orders.service.js +18 -3
- package/esm2015/lib/services/cart.service.js +138 -23
- package/esm2015/lib/services/checkout/checkout.service.js +34 -4
- package/esm2015/lib/utils/order-util.service.js +99 -7
- package/esm2015/lib/utils/price-presentation.service.js +127 -0
- package/esm2015/public-api.js +2 -1
- package/esm5/lib/ec-component/account-ec/order-ec/order-ec.component.js +111 -5
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +35 -8
- package/esm5/lib/ec-component/checkout-ec/checkout-ec.component.js +36 -13
- package/esm5/lib/ec-component/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.js +18 -7
- package/esm5/lib/ec-component/sidebar-ec/sidebar-ec.component.js +12 -3
- package/esm5/lib/interfaces/cart-item.js +1 -1
- package/esm5/lib/interfaces/cart-totals.js +1 -0
- package/esm5/lib/interfaces/channel.js +1 -0
- package/esm5/lib/interfaces/checkout-data.js +1 -1
- package/esm5/lib/interfaces/product.js +1 -1
- package/esm5/lib/services/account/orders.service.js +18 -3
- package/esm5/lib/services/cart.service.js +154 -23
- package/esm5/lib/services/checkout/checkout.service.js +30 -4
- package/esm5/lib/utils/order-util.service.js +99 -7
- package/esm5/lib/utils/price-presentation.service.js +130 -0
- package/esm5/public-api.js +2 -1
- package/fesm2015/ng-easycommerce.js +1181 -652
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +1219 -654
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/account-ec/order-ec/order-ec.component.d.ts +15 -0
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +8 -1
- package/lib/ec-component/checkout-ec/checkout-ec.component.d.ts +1 -1
- package/lib/ec-component/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.d.ts +2 -2
- package/lib/interfaces/cart-item.d.ts +27 -2
- package/lib/interfaces/cart-totals.d.ts +19 -0
- package/lib/interfaces/channel.d.ts +15 -0
- package/lib/interfaces/checkout-data.d.ts +2 -1
- package/lib/interfaces/product.d.ts +48 -1
- package/lib/services/account/orders.service.d.ts +5 -0
- package/lib/services/cart.service.d.ts +26 -5
- package/lib/utils/order-util.service.d.ts +22 -0
- package/lib/utils/price-presentation.service.d.ts +56 -0
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
|
@@ -25,9 +25,24 @@ export declare class OrderEcComponent extends ComponentHelper implements OnInit
|
|
|
25
25
|
hideDiscounts: boolean;
|
|
26
26
|
hideTaxes: boolean;
|
|
27
27
|
enableFieldNotesInArticleFile: boolean;
|
|
28
|
+
showPriceWithTaxesWhileBrowsing: boolean;
|
|
28
29
|
constructor(ordersService: OrdersService, activedRoute: ActivatedRoute, router: Router, consts: Constants, cartService: CartService, channelConfigService: ChannelConfigService);
|
|
29
30
|
ngOnInit(): void;
|
|
30
31
|
toDate: (date: any, format: any) => string;
|
|
32
|
+
private getLinePricing;
|
|
33
|
+
private getHistoricalPricingKey;
|
|
34
|
+
getOrderLineValue: (item: any, section: "subtotal" | "discount" | "unit") => number;
|
|
35
|
+
hasOrderLineValue: (item: any, section: "subtotal" | "discount" | "unit") => boolean;
|
|
36
|
+
private getTotalsPricing;
|
|
37
|
+
private getSelectedTotalsPricing;
|
|
38
|
+
private hasHistoricalLinePricing;
|
|
39
|
+
getHistoricalProductsSubtotal: () => number;
|
|
40
|
+
getHistoricalOrderDiscount: () => number;
|
|
41
|
+
getHistoricalCouponDiscount: () => number;
|
|
42
|
+
getHistoricalShipping: () => number;
|
|
43
|
+
getHistoricalTaxes: () => number;
|
|
44
|
+
hasHistoricalTaxes: () => boolean;
|
|
45
|
+
getHistoricalTotal: () => number;
|
|
31
46
|
callError: () => void;
|
|
32
47
|
volver: () => Promise<boolean>;
|
|
33
48
|
repeatOrder(): void;
|
|
@@ -81,10 +81,17 @@ export declare class CartEcComponent extends ComponentHelper implements OnInit {
|
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
83
|
getItemEffectiveDiscount: (item: any) => number;
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Subtotal actual del renglón.
|
|
86
|
+
*
|
|
87
|
+
* El backend nuevo informa `item.subtotal` sin impuestos ni descuentos
|
|
88
|
+
* generales de orden. Las respuestas legacy continúan usando `item.total`.
|
|
89
|
+
*/
|
|
85
90
|
getDisplayedItemTotal: (item: any) => number;
|
|
86
91
|
/** @param item Ítem del carrito. @returns `true` si el backend informó promociones unitarias. */
|
|
87
92
|
hasUnitPromotions: (item: any) => boolean;
|
|
93
|
+
/** @param items Ítems del carrito. @returns `true` si al menos un ítem tiene promociones unitarias. */
|
|
94
|
+
hasAnyUnitPromotions: (items?: any[]) => boolean;
|
|
88
95
|
/** @param item Ítem del carrito. @returns `true` si el resumen activo pertenece a ese ítem. */
|
|
89
96
|
isUnitPromotionSummaryOpen: (item: any) => boolean;
|
|
90
97
|
/**
|
|
@@ -97,7 +97,7 @@ export declare class CheckoutEcComponent extends ComponentHelper implements OnIn
|
|
|
97
97
|
goToNextSection: (stepName: string) => void;
|
|
98
98
|
goToNextFromAddress: () => void;
|
|
99
99
|
isSectionOpen: (stepName: string) => boolean;
|
|
100
|
-
getSummaryLabel: (type: import("../../interfaces/checkout-data").CheckoutDataType) => "total" | "subtotal" | "shipment" | "coupon" | "discount" | "taxes" | "clientTaxes" | "national-taxes";
|
|
100
|
+
getSummaryLabel: (type: import("../../interfaces/checkout-data").CheckoutDataType, item?: CheckoutData) => "total" | "subtotal" | "shipment" | "coupon" | "discount" | "taxes" | "clientTaxes" | "products-before-discounts" | "line-discounts" | "taxes-included-in-total" | "national-taxes";
|
|
101
101
|
getSummaryData: (data: CheckoutData[]) => CheckoutData[];
|
|
102
102
|
getSummaryAmountView: (item: CheckoutData) => import("../../utils/shipping-price-display.service").ShippingPriceViewModel;
|
|
103
103
|
getTotalAmount: (data: CheckoutData[]) => number;
|
|
@@ -24,8 +24,8 @@ export declare class DetailCheckoutBlockEcComponent extends ComponentHelper impl
|
|
|
24
24
|
calcularTotales(): void;
|
|
25
25
|
getIcon: (data_item: CheckoutData) => "fas fa-ticket-alt fa-2x" | "fas fa-tags fa-2x" | "fas fa-shipping-fast fa-2x" | "fas fa-boxes fa-2x" | "fas fa-file-invoice-dollar fa-2x" | "fas fa-shopping-basket fa-2x";
|
|
26
26
|
getIcon2: (data_type: any) => "fas fa-ticket-alt fa-2x" | "fas fa-tags fa-2x" | "fas fa-percent fa-2x";
|
|
27
|
-
getTypeLabel(type: string): string;
|
|
28
|
-
shouldShowItem(type: string): boolean;
|
|
27
|
+
getTypeLabel(type: string, item?: CheckoutData): string;
|
|
28
|
+
shouldShowItem(type: string, item?: CheckoutData): boolean;
|
|
29
29
|
shouldHideSubtotal(item: any): boolean;
|
|
30
30
|
getAmountView(item: CheckoutData): import("../../../utils/shipping-price-display.service").ShippingPriceViewModel;
|
|
31
31
|
private getShipmentOriginalAmount;
|
|
@@ -14,14 +14,27 @@ export interface CartItemPromotion {
|
|
|
14
14
|
/** Nombre legible de la promoción o descuento. */
|
|
15
15
|
name: string;
|
|
16
16
|
}
|
|
17
|
+
/** Valor fiscal explícito de una parte de la línea del carrito. */
|
|
18
|
+
export interface CartLinePricingValue {
|
|
19
|
+
net: number;
|
|
20
|
+
tax: number;
|
|
21
|
+
gross: number;
|
|
22
|
+
}
|
|
23
|
+
/** Contrato aditivo de precios de línea informado por el backend. */
|
|
24
|
+
export interface CartLinePricing {
|
|
25
|
+
unit: CartLinePricingValue;
|
|
26
|
+
discount: CartLinePricingValue;
|
|
27
|
+
subtotal: CartLinePricingValue;
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* Precios del ítem normalizados por el core para evitar duplicar lógica en cada frontend.
|
|
19
31
|
*
|
|
20
32
|
* @remarks
|
|
21
33
|
* Esta estructura separa tres conceptos distintos:
|
|
22
|
-
* - `basePrice`: precio unitario
|
|
34
|
+
* - `basePrice`: precio unitario explícito del carrito cuando el backend lo informa;
|
|
35
|
+
* en respuestas legacy, `saleprice` si existe, si no `price`
|
|
23
36
|
* - `strikePrice`: precio tachado de la lógica legacy `price/saleprice`
|
|
24
|
-
* - `finalPrice`: precio unitario neto luego de aplicar
|
|
37
|
+
* - `finalPrice`: precio unitario neto luego de aplicar descuentos propios de la línea
|
|
25
38
|
*/
|
|
26
39
|
export interface CartItemPricing {
|
|
27
40
|
/** Precio unitario base que ya usaba el frontend antes de soportar promociones unitarias. */
|
|
@@ -55,8 +68,20 @@ export interface CartItem {
|
|
|
55
68
|
quantity: number;
|
|
56
69
|
variant_id: number;
|
|
57
70
|
total: number;
|
|
71
|
+
/** Precio unitario explícito del carrito, sin impuestos, cuando lo informa el backend. */
|
|
72
|
+
unitPrice?: number;
|
|
73
|
+
/** Descuento total propio de la línea, sin descuentos generales de orden. */
|
|
74
|
+
discount?: number;
|
|
75
|
+
/** Subtotal explícito de la línea, sin impuestos ni descuentos generales de orden. */
|
|
76
|
+
subtotal?: number;
|
|
77
|
+
/** Impuesto total de la línea, cuando lo informa el backend. */
|
|
78
|
+
taxTotal?: number;
|
|
58
79
|
/** Promociones unitarias crudas devueltas por backend. */
|
|
59
80
|
unitPromotions?: CartItemPromotion[];
|
|
81
|
+
/** Valores netos, fiscales y brutos explícitos de la línea del carrito. */
|
|
82
|
+
linePricing?: CartLinePricing;
|
|
83
|
+
/** Nombre real serializado por JMS; se normaliza una sola vez en CartService. */
|
|
84
|
+
line_pricing?: CartLinePricing;
|
|
60
85
|
/** Precios derivados listos para usar en la UI. */
|
|
61
86
|
pricing?: CartItemPricing;
|
|
62
87
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Valor fiscal explícito utilizado por los totales del carrito. */
|
|
2
|
+
export interface CartTotalPricingValue {
|
|
3
|
+
net: number;
|
|
4
|
+
tax: number;
|
|
5
|
+
gross: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Contratos aditivos serializados por el backend con nombres snake_case.
|
|
9
|
+
* Las variantes camelCase permiten consumir respuestas ya normalizadas por
|
|
10
|
+
* integraciones legacy sin crear una segunda transformación global.
|
|
11
|
+
*/
|
|
12
|
+
export interface CartTotalsPricing {
|
|
13
|
+
order_discount_pricing?: CartTotalPricingValue;
|
|
14
|
+
coupon_discount_pricing?: CartTotalPricingValue;
|
|
15
|
+
shipping_pricing?: CartTotalPricingValue;
|
|
16
|
+
orderDiscountPricing?: CartTotalPricingValue;
|
|
17
|
+
couponDiscountPricing?: CartTotalPricingValue;
|
|
18
|
+
shippingPricing?: CartTotalPricingValue;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuración de canal utilizada por el core.
|
|
3
|
+
*
|
|
4
|
+
* Las propiedades son opcionales para conservar compatibilidad con respuestas
|
|
5
|
+
* legacy y se mantiene una extensión abierta para el resto de la configuración.
|
|
6
|
+
*/
|
|
7
|
+
export interface Channel {
|
|
8
|
+
code?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
showPriceWithTaxesWhileBrowsing?: boolean;
|
|
11
|
+
showTaxLegend?: boolean;
|
|
12
|
+
hideTaxes?: boolean;
|
|
13
|
+
hideDiscounts?: boolean;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare type CheckoutDataType = 'total' | 'subtotal' | 'shipment' | 'coupon' | 'discount' | 'taxes' | 'clientTaxes';
|
|
1
|
+
export declare type CheckoutDataType = 'total' | 'subtotal' | 'productsBeforeDiscounts' | 'shipment' | 'coupon' | 'discount' | 'lineDiscount' | 'taxes' | 'clientTaxes';
|
|
2
2
|
export interface CheckoutData {
|
|
3
3
|
type: CheckoutDataType;
|
|
4
4
|
amount: number;
|
|
5
5
|
name: string;
|
|
6
|
+
taxesIncludedInTotal?: boolean;
|
|
6
7
|
}
|
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
export declare type ProductColor = 'white' | 'black' | 'red' | 'green' | 'purple' | 'yellow' | 'blue' | 'gray' | 'orange' | 'pink';
|
|
2
2
|
export declare type ProductSize = 'M' | 'L' | 'XL';
|
|
3
3
|
export declare type ProductTags = 'nike' | 'puma' | 'lifestyle' | 'caprese';
|
|
4
|
+
/** Valores fiscales explícitos de un precio de producto/variante. */
|
|
5
|
+
export interface ProductPricingValue {
|
|
6
|
+
net: number;
|
|
7
|
+
tax: number;
|
|
8
|
+
gross: number;
|
|
9
|
+
}
|
|
10
|
+
/** Metadatos fiscales del precio informado por el backend. */
|
|
11
|
+
export interface ProductPricingTax {
|
|
12
|
+
hasTax: boolean;
|
|
13
|
+
rate: number | null;
|
|
14
|
+
includedInPrice: boolean | null;
|
|
15
|
+
}
|
|
16
|
+
/** Contrato aditivo de pricing de ProductVariantView. */
|
|
17
|
+
export interface ProductVariantPricing {
|
|
18
|
+
current: ProductPricingValue;
|
|
19
|
+
previous: ProductPricingValue | null;
|
|
20
|
+
tax: ProductPricingTax;
|
|
21
|
+
}
|
|
22
|
+
/** Variante de producto, conservando los campos legacy consumidos por el core. */
|
|
23
|
+
export interface ProductVariant {
|
|
24
|
+
code?: any;
|
|
25
|
+
price?: any;
|
|
26
|
+
saleprice?: any;
|
|
27
|
+
priceWithoutTaxes?: any;
|
|
28
|
+
taxes?: any;
|
|
29
|
+
taxRate?: any;
|
|
30
|
+
taxIncluded?: any;
|
|
31
|
+
taxLegendInfo?: any;
|
|
32
|
+
cartAndSidebarPrices?: any;
|
|
33
|
+
final_consumer_price?: any;
|
|
34
|
+
original_final_consumer_price?: any;
|
|
35
|
+
discount?: any;
|
|
36
|
+
options?: any[];
|
|
37
|
+
images?: any[];
|
|
38
|
+
properties?: any;
|
|
39
|
+
stock?: number;
|
|
40
|
+
multipleQuantity?: number;
|
|
41
|
+
minimumItemsQuantity?: number;
|
|
42
|
+
maximumItemsQuantity?: number;
|
|
43
|
+
maximumAmount?: number;
|
|
44
|
+
minimumAmount?: number;
|
|
45
|
+
dateCreate?: any;
|
|
46
|
+
dateExpired?: any;
|
|
47
|
+
uniqueExternalCode?: any;
|
|
48
|
+
pricing?: ProductVariantPricing;
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
4
51
|
export interface Product {
|
|
5
52
|
id?: number;
|
|
6
53
|
category?: string;
|
|
@@ -16,7 +63,7 @@ export interface Product {
|
|
|
16
63
|
tag?: any[];
|
|
17
64
|
rating?: number | string;
|
|
18
65
|
special_mark?: any[];
|
|
19
|
-
variants?:
|
|
66
|
+
variants?: ProductVariant[];
|
|
20
67
|
productToCartItem?: ProductToCartItem;
|
|
21
68
|
currentOption?: CurrentOption;
|
|
22
69
|
productWithUniqueVariant?: Product[];
|
|
@@ -20,6 +20,11 @@ export declare class OrdersService {
|
|
|
20
20
|
constructor(connection: ConnectionService, cartService: CartService, router: Router, consts: Constants);
|
|
21
21
|
updateOrders: () => void;
|
|
22
22
|
mapOrdersAndAddInfo: (orders: any) => any;
|
|
23
|
+
/**
|
|
24
|
+
* Normaliza únicamente los aliases de los contratos históricos nuevos.
|
|
25
|
+
* La respuesta original se conserva para no afectar otros consumidores.
|
|
26
|
+
*/
|
|
27
|
+
private normalizeOrderPricing;
|
|
23
28
|
setSelectedOrder(order: any): void;
|
|
24
29
|
findOrder: (order_number: any) => any;
|
|
25
30
|
getOrderByNumber: (order_number: any) => any;
|
|
@@ -11,6 +11,8 @@ import { CartAffordable } from '../interfaces/cart/cart-affordable';
|
|
|
11
11
|
import { ChannelConfigService } from './channel-config.service';
|
|
12
12
|
import { AnalyticsService } from '../../public-api';
|
|
13
13
|
import { Router } from '@angular/router';
|
|
14
|
+
import { Channel } from '../interfaces/channel';
|
|
15
|
+
import { CartItemPricePresentation, CartSummaryPricePresentation, PricePresentationService } from '../utils/price-presentation.service';
|
|
14
16
|
export declare class CartService {
|
|
15
17
|
private connection;
|
|
16
18
|
private toastrService;
|
|
@@ -20,6 +22,7 @@ export declare class CartService {
|
|
|
20
22
|
private analyticsService;
|
|
21
23
|
private channelConfigService;
|
|
22
24
|
private router;
|
|
25
|
+
private pricePresentationService;
|
|
23
26
|
private cartItemsSubject;
|
|
24
27
|
private couponSubject;
|
|
25
28
|
private cartSubject;
|
|
@@ -63,7 +66,7 @@ export declare class CartService {
|
|
|
63
66
|
creditAmount$: Observable<number>;
|
|
64
67
|
showMax$: Observable<boolean>;
|
|
65
68
|
showPrice$: Observable<boolean>;
|
|
66
|
-
constructor(connection: ConnectionService, toastrService: ToastService, consts: Constants, authService: AuthService, orderUtils: OrderUtilityService, analyticsService: AnalyticsService, channelConfigService: ChannelConfigService, router: Router);
|
|
69
|
+
constructor(connection: ConnectionService, toastrService: ToastService, consts: Constants, authService: AuthService, orderUtils: OrderUtilityService, analyticsService: AnalyticsService, channelConfigService: ChannelConfigService, router: Router, pricePresentationService: PricePresentationService);
|
|
67
70
|
getCart2(): CartItem[];
|
|
68
71
|
getAddressBook: () => Promise<any>;
|
|
69
72
|
getTaxes: () => Promise<import("rxjs").Subscription>;
|
|
@@ -138,9 +141,13 @@ export declare class CartService {
|
|
|
138
141
|
getCartToken: () => any;
|
|
139
142
|
getLocale: () => string;
|
|
140
143
|
getTotalAmount: () => Observable<number>;
|
|
144
|
+
/** Total para carrito/sidebar, sin envío persistido ni recargos de checkout. */
|
|
145
|
+
getCartTotalAmount: () => Observable<number>;
|
|
141
146
|
getCountCartItems: () => Observable<number>;
|
|
142
147
|
getTaxesAmount: () => Observable<number>;
|
|
143
148
|
getSubTotalAmount: () => Observable<number>;
|
|
149
|
+
getCartTaxesAmount: () => Observable<number>;
|
|
150
|
+
getCartClientTaxesAmount: () => Observable<number>;
|
|
144
151
|
/**
|
|
145
152
|
* Devuelve el descuento que debe mostrarse en el resumen de compra.
|
|
146
153
|
*
|
|
@@ -152,10 +159,13 @@ export declare class CartService {
|
|
|
152
159
|
* ```
|
|
153
160
|
*
|
|
154
161
|
* @remarks
|
|
155
|
-
* Si el backend nuevo informa `totals.
|
|
156
|
-
*
|
|
162
|
+
* Si el backend nuevo informa `totals.orderDiscount`, se usa ese valor.
|
|
163
|
+
* En su ausencia, prioriza `totals.promotionBreakdown.orderPromotions` y
|
|
164
|
+
* luego hace fallback a `totals.promotion` para mantener compatibilidad.
|
|
157
165
|
*/
|
|
158
166
|
getSummaryPromotionAmount: () => Observable<number>;
|
|
167
|
+
/** Descuento específico del cupón, si el backend lo informa por separado. */
|
|
168
|
+
getCouponPromotionAmount: () => Observable<number>;
|
|
159
169
|
/**
|
|
160
170
|
* Indica si existe un cupón aplicado en el carrito actual.
|
|
161
171
|
*
|
|
@@ -182,6 +192,17 @@ export declare class CartService {
|
|
|
182
192
|
* ```
|
|
183
193
|
*/
|
|
184
194
|
getItemPricing: (item: CartItem) => CartItemPricing;
|
|
195
|
+
/** Resuelve la presentación nueva de una línea y conserva el fallback legacy. */
|
|
196
|
+
getCartItemPricePresentation: (item: CartItem, channel?: Channel) => CartItemPricePresentation;
|
|
197
|
+
/** Resuelve el resumen visible usando linePricing sin convertir importes fiscales. */
|
|
198
|
+
getCartSummaryPricePresentation: (cart?: any, channel?: Channel, includeShipping?: boolean) => CartSummaryPricePresentation;
|
|
199
|
+
/** Normaliza sólo el alias serializado del contrato de línea. */
|
|
200
|
+
private normalizeCartItemPricing;
|
|
201
|
+
/**
|
|
202
|
+
* Lee el contrato nuevo sin confundir un objeto válido con fallback legacy,
|
|
203
|
+
* incluso cuando todos sus importes son cero.
|
|
204
|
+
*/
|
|
205
|
+
private getTotalsPricing;
|
|
185
206
|
addCoupon: (code: any) => Promise<any>;
|
|
186
207
|
removeCoupon: () => Promise<boolean>;
|
|
187
208
|
formatCoupon: (cart: any) => void;
|
|
@@ -214,8 +235,8 @@ export declare class CartService {
|
|
|
214
235
|
* @example
|
|
215
236
|
* ```ts
|
|
216
237
|
* const pricing = this.buildCartItemPricing(item);
|
|
217
|
-
* // pricing.basePrice =>
|
|
218
|
-
* // pricing.finalPrice =>
|
|
238
|
+
* // pricing.basePrice => unitPrice del backend nuevo o fallback legacy
|
|
239
|
+
* // pricing.finalPrice => unitPrice del backend nuevo o cálculo legacy
|
|
219
240
|
* // pricing.effectiveDiscountPercent => % total contra el precio de referencia
|
|
220
241
|
* ```
|
|
221
242
|
*/
|
|
@@ -46,6 +46,28 @@ export declare class OrderUtilityService {
|
|
|
46
46
|
* Con backends viejos hace fallback a `totals.promotion` o `totals.discount`.
|
|
47
47
|
*/
|
|
48
48
|
getSummaryPromotionAmount: (cart: any) => number;
|
|
49
|
+
/** Descuento de orden separado de cupones y descuentos de envío. */
|
|
50
|
+
getOrderPromotionAmount: (cart: any) => number;
|
|
51
|
+
/**
|
|
52
|
+
* Obtiene únicamente el descuento aplicado por el cupón.
|
|
53
|
+
*
|
|
54
|
+
* Devuelve `null` cuando la respuesta no permite identificar su importe,
|
|
55
|
+
* para que el frontend pueda mostrar solamente el código.
|
|
56
|
+
*/
|
|
57
|
+
getCouponPromotionAmount: (cart: any) => number;
|
|
58
|
+
/**
|
|
59
|
+
* Obtiene el subtotal compatible con backends nuevos y legacy.
|
|
60
|
+
*
|
|
61
|
+
* @param cart Carrito u orden con `totals`.
|
|
62
|
+
* @returns `totals.subtotal` cuando existe; en backends legacy usa `totals.items`.
|
|
63
|
+
*/
|
|
64
|
+
getSummarySubtotalAmount: (cart: any) => number;
|
|
65
|
+
/** Total que debe mostrar el carrito/sidebar, excluyendo envío persistido. */
|
|
66
|
+
getCartTotalAmount: (cart: any) => number;
|
|
67
|
+
/** Impuestos de productos para carrito/sidebar, con fallback legacy. */
|
|
68
|
+
getCartTaxesAmount: (cart: any) => number;
|
|
69
|
+
/** Impuestos específicos del cliente para carrito/sidebar, con fallback legacy. */
|
|
70
|
+
getCartClientTaxesAmount: (cart: any) => number;
|
|
49
71
|
/**
|
|
50
72
|
* Indica si el backend ya informa el desglose nuevo de promociones.
|
|
51
73
|
*
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Channel } from '../interfaces/channel';
|
|
2
|
+
import { ProductVariant } from '../interfaces/product';
|
|
3
|
+
import { CartItem, CartItemPricing } from '../interfaces/cart-item';
|
|
4
|
+
export declare type PricePresentationValue = number | string;
|
|
5
|
+
export interface PricePresentation {
|
|
6
|
+
primary: PricePresentationValue;
|
|
7
|
+
previous: PricePresentationValue | null;
|
|
8
|
+
secondary: number | null;
|
|
9
|
+
hasTax: boolean;
|
|
10
|
+
tax: number;
|
|
11
|
+
taxRate: number | null;
|
|
12
|
+
includedInPrice: boolean | null;
|
|
13
|
+
source: 'pricing' | 'legacy';
|
|
14
|
+
}
|
|
15
|
+
export interface CartItemPricePresentation {
|
|
16
|
+
unitPrice: number;
|
|
17
|
+
discount: number;
|
|
18
|
+
subtotal: number;
|
|
19
|
+
previous: number | null;
|
|
20
|
+
secondary: number | null;
|
|
21
|
+
hasTax: boolean;
|
|
22
|
+
tax: number;
|
|
23
|
+
taxRate: number | null;
|
|
24
|
+
includedInPrice: boolean | null;
|
|
25
|
+
source: 'linePricing' | 'legacy';
|
|
26
|
+
}
|
|
27
|
+
export interface CartSummaryPricePresentation {
|
|
28
|
+
productsBeforeDiscounts: number;
|
|
29
|
+
lineDiscounts: number;
|
|
30
|
+
subtotal: number;
|
|
31
|
+
orderDiscount: number;
|
|
32
|
+
couponDiscount: number | null;
|
|
33
|
+
taxes: number;
|
|
34
|
+
clientTaxes: number;
|
|
35
|
+
shipping: number | null;
|
|
36
|
+
total: number;
|
|
37
|
+
taxesIncludedInTotal: boolean;
|
|
38
|
+
source: 'linePricing' | 'legacy';
|
|
39
|
+
}
|
|
40
|
+
export declare class PricePresentationService {
|
|
41
|
+
/** Resuelve únicamente qué valor presentar; no calcula impuestos. */
|
|
42
|
+
getProductPricePresentation(variant: ProductVariant | any, channel?: Channel | any): PricePresentation;
|
|
43
|
+
/**
|
|
44
|
+
* Resuelve los importes visibles de una línea sin convertir ni recalcular
|
|
45
|
+
* valores fiscales. `legacyPricing` debe ser el resultado ya normalizado
|
|
46
|
+
* por CartService para conservar exactamente el fallback histórico.
|
|
47
|
+
*/
|
|
48
|
+
getCartItemPricePresentation(item: CartItem | any, channel?: Channel | any, legacyPricing?: CartItemPricing): CartItemPricePresentation;
|
|
49
|
+
private fromPricing;
|
|
50
|
+
private fromLegacy;
|
|
51
|
+
private legacyValue;
|
|
52
|
+
private isPricingContract;
|
|
53
|
+
private isValue;
|
|
54
|
+
private isFiniteNumber;
|
|
55
|
+
private isCartLinePricing;
|
|
56
|
+
}
|