@grupolapa/cotizador-sdk 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 +125 -0
- package/dist/bundle-payment-schedule.calc.d.ts +2 -0
- package/dist/bundle-payment-schedule.calc.js +160 -0
- package/dist/calculate-quote.d.ts +2 -0
- package/dist/calculate-quote.js +382 -0
- package/dist/corporate-actions.d.ts +95 -0
- package/dist/corporate-actions.js +87 -0
- package/dist/corporate-rent.d.ts +5 -0
- package/dist/corporate-rent.js +43 -0
- package/dist/delivery-date.d.ts +6 -0
- package/dist/delivery-date.js +22 -0
- package/dist/entrada.d.ts +111 -0
- package/dist/entrada.js +139 -0
- package/dist/format.d.ts +7 -0
- package/dist/format.js +37 -0
- package/dist/http.d.ts +28 -0
- package/dist/http.js +133 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +22 -0
- package/dist/installment-allocation.d.ts +30 -0
- package/dist/installment-allocation.js +69 -0
- package/dist/inventory-availability.d.ts +10 -0
- package/dist/inventory-availability.js +105 -0
- package/dist/live-inventory-availability.d.ts +16 -0
- package/dist/live-inventory-availability.js +88 -0
- package/dist/payment-schemes.d.ts +22 -0
- package/dist/payment-schemes.js +99 -0
- package/dist/post-delivery-value.d.ts +3 -0
- package/dist/post-delivery-value.js +61 -0
- package/dist/product-types.d.ts +16 -0
- package/dist/product-types.js +82 -0
- package/dist/query-state.d.ts +5 -0
- package/dist/query-state.js +157 -0
- package/dist/quote-outcome-graph.d.ts +31 -0
- package/dist/quote-outcome-graph.js +113 -0
- package/dist/quote.d.ts +19 -0
- package/dist/quote.js +18 -0
- package/dist/selection-state.d.ts +34 -0
- package/dist/selection-state.js +156 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.js +17 -0
- package/dist/sitemap.d.ts +22 -0
- package/dist/sitemap.js +45 -0
- package/dist/social-quote.d.ts +8 -0
- package/dist/social-quote.js +51 -0
- package/dist/tax.d.ts +5 -0
- package/dist/tax.js +11 -0
- package/dist/types.d.ts +502 -0
- package/dist/types.js +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { clampToRange, getDefaultDownPaymentPctForScheme, getPaymentSchemeById, getResolvedSchemeForUnit, } from "./payment-schemes.js";
|
|
2
|
+
import { clampUondrCashbackDownPaymentPct, getSocialDefaultDownPaymentPct, SOCIAL_INCLUDE_IVA, } from "./social-quote.js";
|
|
3
|
+
import { clampInstallmentDownPaymentPct, clampInstallmentMonthlyPct, INSTALLMENT_DEFAULT_DOWN_PAYMENT_PCT, INSTALLMENT_DEFAULT_MONTHLY_PCT, } from "./installment-allocation.js";
|
|
4
|
+
function isNonEmptyString(value) {
|
|
5
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
6
|
+
}
|
|
7
|
+
function getAvailableCategories(content) {
|
|
8
|
+
return Array.from(new Set([
|
|
9
|
+
...content.siteContent.categories.map((category) => category.id),
|
|
10
|
+
...content.inventory.map((unit) => unit.category),
|
|
11
|
+
].filter(isNonEmptyString)));
|
|
12
|
+
}
|
|
13
|
+
function getUnitById(units, unitId) {
|
|
14
|
+
return units.find((unit) => unit.id === unitId) ?? null;
|
|
15
|
+
}
|
|
16
|
+
function getDefaultCategory(content) {
|
|
17
|
+
const availableCategories = getAvailableCategories(content);
|
|
18
|
+
if (isNonEmptyString(content.financeRules.defaults.category) &&
|
|
19
|
+
availableCategories.includes(content.financeRules.defaults.category)) {
|
|
20
|
+
return content.financeRules.defaults.category;
|
|
21
|
+
}
|
|
22
|
+
return (availableCategories[0] ??
|
|
23
|
+
getUnitById(content.inventory, content.financeRules.defaults.unitId)
|
|
24
|
+
?.category ??
|
|
25
|
+
content.inventory[0]?.category ??
|
|
26
|
+
"");
|
|
27
|
+
}
|
|
28
|
+
function getDefaultUnitForCategory(units, defaultUnitId, category) {
|
|
29
|
+
return (units.find((unit) => unit.id === defaultUnitId && unit.category === category) ??
|
|
30
|
+
units.find((unit) => unit.category === category) ??
|
|
31
|
+
null);
|
|
32
|
+
}
|
|
33
|
+
function getFallbackScheme(content, requestedSchemeId, category) {
|
|
34
|
+
const defaultUnitForCategory = getDefaultUnitForCategory(content.inventory, content.financeRules.defaults.unitId, category);
|
|
35
|
+
if (defaultUnitForCategory) {
|
|
36
|
+
return getResolvedSchemeForUnit(defaultUnitForCategory, content.paymentSchemes, requestedSchemeId);
|
|
37
|
+
}
|
|
38
|
+
const defaultScheme = getPaymentSchemeById(content.paymentSchemes, content.financeRules.defaults.schemeId);
|
|
39
|
+
return (content.paymentSchemes.find((scheme) => scheme.id === requestedSchemeId && scheme.active) ??
|
|
40
|
+
(defaultScheme?.active ? defaultScheme : null) ??
|
|
41
|
+
content.paymentSchemes.find((scheme) => scheme.active) ??
|
|
42
|
+
null);
|
|
43
|
+
}
|
|
44
|
+
function resolveScheme(content, unit, requestedSchemeId, category) {
|
|
45
|
+
if (unit) {
|
|
46
|
+
return getResolvedSchemeForUnit(unit, content.paymentSchemes, requestedSchemeId);
|
|
47
|
+
}
|
|
48
|
+
return getFallbackScheme(content, requestedSchemeId, category);
|
|
49
|
+
}
|
|
50
|
+
function getResolvedDownPaymentPct(surface, requestedState, scheme, content) {
|
|
51
|
+
if (scheme?.type === "cashback" &&
|
|
52
|
+
(surface === "uondr" || surface === "a-uondr")) {
|
|
53
|
+
return clampUondrCashbackDownPaymentPct(scheme, requestedState.downPaymentPct);
|
|
54
|
+
}
|
|
55
|
+
if (scheme?.type === "cashback" && surface === "default") {
|
|
56
|
+
return clampToRange(requestedState.downPaymentPct, scheme.downPaymentRange);
|
|
57
|
+
}
|
|
58
|
+
if (surface !== "default") {
|
|
59
|
+
return getSocialDefaultDownPaymentPct(scheme, content.financeRules);
|
|
60
|
+
}
|
|
61
|
+
return getDefaultDownPaymentPctForScheme(scheme, content.financeRules);
|
|
62
|
+
}
|
|
63
|
+
export function normalizeSelectionState(requestedState, content, surface) {
|
|
64
|
+
const availableCategories = getAvailableCategories(content);
|
|
65
|
+
const requestedUnit = getUnitById(content.inventory, requestedState.unitId);
|
|
66
|
+
const resolvedCategory = availableCategories.includes(requestedState.category)
|
|
67
|
+
? requestedState.category
|
|
68
|
+
: (requestedUnit?.category ?? getDefaultCategory(content));
|
|
69
|
+
const resolvedUnit = requestedUnit && requestedUnit.category === resolvedCategory
|
|
70
|
+
? requestedUnit
|
|
71
|
+
: null;
|
|
72
|
+
const resolvedScheme = resolveScheme(content, resolvedUnit, requestedState.scheme, resolvedCategory);
|
|
73
|
+
const installmentDownPaymentPct = clampInstallmentDownPaymentPct(requestedState.installmentDownPaymentPct ??
|
|
74
|
+
INSTALLMENT_DEFAULT_DOWN_PAYMENT_PCT);
|
|
75
|
+
const installmentMonthlyPct = clampInstallmentMonthlyPct(requestedState.installmentMonthlyPct ?? INSTALLMENT_DEFAULT_MONTHLY_PCT, installmentDownPaymentPct);
|
|
76
|
+
return {
|
|
77
|
+
category: resolvedCategory,
|
|
78
|
+
unitId: resolvedUnit?.id ?? "",
|
|
79
|
+
scheme: resolvedScheme?.id ?? content.financeRules.defaults.schemeId,
|
|
80
|
+
postDeliveryYears: surface === "default"
|
|
81
|
+
? clampToRange(requestedState.postDeliveryYears, content.financeRules.ranges.postDeliveryYears)
|
|
82
|
+
: content.financeRules.defaults.postDeliveryYears,
|
|
83
|
+
downPaymentPct: getResolvedDownPaymentPct(surface, requestedState, resolvedScheme, content),
|
|
84
|
+
installmentDownPaymentPct,
|
|
85
|
+
installmentMonthlyPct,
|
|
86
|
+
includeIva: surface === "default" ? requestedState.includeIva : SOCIAL_INCLUDE_IVA,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function createInitialSelectionState(content, surface) {
|
|
90
|
+
return normalizeSelectionState({
|
|
91
|
+
category: content.financeRules.defaults.category,
|
|
92
|
+
unitId: content.financeRules.defaults.unitId,
|
|
93
|
+
scheme: content.financeRules.defaults.schemeId,
|
|
94
|
+
postDeliveryYears: content.financeRules.defaults.postDeliveryYears,
|
|
95
|
+
downPaymentPct: content.financeRules.defaults.downPaymentPct,
|
|
96
|
+
installmentDownPaymentPct: INSTALLMENT_DEFAULT_DOWN_PAYMENT_PCT,
|
|
97
|
+
installmentMonthlyPct: INSTALLMENT_DEFAULT_MONTHLY_PCT,
|
|
98
|
+
includeIva: false,
|
|
99
|
+
}, content, surface);
|
|
100
|
+
}
|
|
101
|
+
export function reduceSelectionState(state, action, content, surface) {
|
|
102
|
+
switch (action.type) {
|
|
103
|
+
case "reset":
|
|
104
|
+
return action.state;
|
|
105
|
+
case "selectCategory": {
|
|
106
|
+
const selectedUnit = getUnitById(content.inventory, state.unitId);
|
|
107
|
+
const nextUnitId = selectedUnit?.category === action.category ? selectedUnit.id : "";
|
|
108
|
+
return normalizeSelectionState({
|
|
109
|
+
...state,
|
|
110
|
+
category: action.category,
|
|
111
|
+
unitId: nextUnitId,
|
|
112
|
+
}, content, surface);
|
|
113
|
+
}
|
|
114
|
+
case "selectUnit": {
|
|
115
|
+
const selectedUnit = getUnitById(content.inventory, action.unitId);
|
|
116
|
+
if (!selectedUnit) {
|
|
117
|
+
return state;
|
|
118
|
+
}
|
|
119
|
+
return normalizeSelectionState({
|
|
120
|
+
...state,
|
|
121
|
+
category: selectedUnit.category,
|
|
122
|
+
unitId: selectedUnit.id,
|
|
123
|
+
}, content, surface);
|
|
124
|
+
}
|
|
125
|
+
case "selectScheme":
|
|
126
|
+
return normalizeSelectionState({
|
|
127
|
+
...state,
|
|
128
|
+
scheme: action.schemeId,
|
|
129
|
+
}, content, surface);
|
|
130
|
+
case "setPostDeliveryYears":
|
|
131
|
+
return normalizeSelectionState({
|
|
132
|
+
...state,
|
|
133
|
+
postDeliveryYears: action.value,
|
|
134
|
+
}, content, surface);
|
|
135
|
+
case "setDownPaymentPct":
|
|
136
|
+
return normalizeSelectionState({
|
|
137
|
+
...state,
|
|
138
|
+
downPaymentPct: action.value,
|
|
139
|
+
}, content, surface);
|
|
140
|
+
case "setInstallmentDownPaymentPct":
|
|
141
|
+
return normalizeSelectionState({
|
|
142
|
+
...state,
|
|
143
|
+
installmentDownPaymentPct: action.value,
|
|
144
|
+
}, content, surface);
|
|
145
|
+
case "setInstallmentMonthlyPct":
|
|
146
|
+
return normalizeSelectionState({
|
|
147
|
+
...state,
|
|
148
|
+
installmentMonthlyPct: action.value,
|
|
149
|
+
}, content, surface);
|
|
150
|
+
case "setIncludeIva":
|
|
151
|
+
return normalizeSelectionState({
|
|
152
|
+
...state,
|
|
153
|
+
includeIva: action.value,
|
|
154
|
+
}, content, surface);
|
|
155
|
+
}
|
|
156
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CotizadorApiBaseOptions, CreatePublicReservationRequest, CreatePublicSessionRequest, GetPublicReservationRequest } from "./types.js";
|
|
2
|
+
export interface CotizadorServerClientOptions extends CotizadorApiBaseOptions {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createCotizadorServerClient(options: CotizadorServerClientOptions): {
|
|
6
|
+
createBrowserSession: (args: CreatePublicSessionRequest) => Promise<import("./types.js").PublicSessionResponse>;
|
|
7
|
+
createReservation: (args: CreatePublicReservationRequest) => Promise<import("./types.js").PublicReservationStatus>;
|
|
8
|
+
getAgentGuide: () => Promise<Record<string, unknown>>;
|
|
9
|
+
getInventory: (args: import("./types.js").CotizadorInventoryRequest) => Promise<import("./types.js").PublicInventoryResponse>;
|
|
10
|
+
getOpenApi: () => Promise<Record<string, unknown>>;
|
|
11
|
+
getPaymentMethods: (args: import("./types.js").CotizadorSiteRequest) => Promise<import("./types.js").PublicPaymentMethodsResponse>;
|
|
12
|
+
getReservation: (args: GetPublicReservationRequest) => Promise<import("./types.js").PublicReservationStatus>;
|
|
13
|
+
getSitemap: (args: import("./types.js").CotizadorSitemapRequest) => Promise<import("./types.js").PublicSitemapResponse>;
|
|
14
|
+
getSnapshot: (args: import("./types.js").CotizadorSiteRequest) => Promise<import("./types.js").PublicSnapshotResponse>;
|
|
15
|
+
listInstances: (args: Pick<import("./types.js").CotizadorSiteRequest, "lookup" | "siteKey">) => Promise<import("./types.js").PublicInstancesResponse>;
|
|
16
|
+
};
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createCotizadorApiRequester } from "./http.js";
|
|
2
|
+
export function createCotizadorServerClient(options) {
|
|
3
|
+
const api = createCotizadorApiRequester(options);
|
|
4
|
+
const credential = { kind: "apiKey", value: options.apiKey };
|
|
5
|
+
return {
|
|
6
|
+
createBrowserSession: (args) => api.createSession(args, credential),
|
|
7
|
+
createReservation: (args) => api.createReservation(args, credential),
|
|
8
|
+
getAgentGuide: api.getAgentGuide,
|
|
9
|
+
getInventory: api.getInventory,
|
|
10
|
+
getOpenApi: api.getOpenApi,
|
|
11
|
+
getPaymentMethods: api.getPaymentMethods,
|
|
12
|
+
getReservation: (args) => api.getReservation(args, credential),
|
|
13
|
+
getSitemap: api.getSitemap,
|
|
14
|
+
getSnapshot: api.getSnapshot,
|
|
15
|
+
listInstances: api.listInstances,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PublicSitemapMap, PublicSitemapResponse, PublicSitemapShape, PublicSitemapUnitHotspot } from "./types.js";
|
|
2
|
+
export type SelectablePublicSitemapUnitHotspot = PublicSitemapUnitHotspot & {
|
|
3
|
+
unitId: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function getSitemapMapById(sitemap: PublicSitemapResponse, mapId: string): PublicSitemapMap | null;
|
|
6
|
+
export declare function getRootSitemapMap(sitemap: PublicSitemapResponse): PublicSitemapMap | null;
|
|
7
|
+
export declare function resolveInitialSitemapMap(sitemap: PublicSitemapResponse): PublicSitemapMap;
|
|
8
|
+
export declare function getChildSitemapMaps(sitemap: PublicSitemapResponse, parentMapId: string): PublicSitemapMap[];
|
|
9
|
+
export declare function getSelectableUnitHotspots(map: PublicSitemapMap): SelectablePublicSitemapUnitHotspot[];
|
|
10
|
+
export declare function getUnitHotspotByUnitId(map: PublicSitemapMap, unitId: string): SelectablePublicSitemapUnitHotspot | null;
|
|
11
|
+
export declare function getUnitHotspotsByUnitId(map: PublicSitemapMap): Map<string, SelectablePublicSitemapUnitHotspot>;
|
|
12
|
+
export declare function getShapeByElementId(map: PublicSitemapMap, svgElementId: string): PublicSitemapShape | null;
|
|
13
|
+
export declare function getShapesByElementId(map: PublicSitemapMap): Map<string, PublicSitemapShape>;
|
|
14
|
+
export declare function getShapeForUnit(map: PublicSitemapMap, unitId: string): PublicSitemapShape | null;
|
|
15
|
+
export declare function getShapeGeometryValue(shape: PublicSitemapShape | null | undefined, key: string): string | null;
|
|
16
|
+
export declare function getSitemapMapAssetPlan(map: PublicSitemapMap): {
|
|
17
|
+
imageHeight: number | null;
|
|
18
|
+
imageUrl: string;
|
|
19
|
+
imageWidth: number | null;
|
|
20
|
+
overlayUrl: string;
|
|
21
|
+
overlayViewBox: string | null;
|
|
22
|
+
};
|
package/dist/sitemap.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function isSelectableUnitHotspot(hotspot) {
|
|
2
|
+
return typeof hotspot.unitId === "string" && hotspot.unitId.trim().length > 0;
|
|
3
|
+
}
|
|
4
|
+
export function getSitemapMapById(sitemap, mapId) {
|
|
5
|
+
return sitemap.maps.find((map) => map.id === mapId) ?? null;
|
|
6
|
+
}
|
|
7
|
+
export function getRootSitemapMap(sitemap) {
|
|
8
|
+
return sitemap.maps.find((map) => map.kind === "root") ?? null;
|
|
9
|
+
}
|
|
10
|
+
export function resolveInitialSitemapMap(sitemap) {
|
|
11
|
+
return getRootSitemapMap(sitemap) ?? sitemap.maps[0] ?? null;
|
|
12
|
+
}
|
|
13
|
+
export function getChildSitemapMaps(sitemap, parentMapId) {
|
|
14
|
+
return sitemap.maps.filter((map) => map.parentMapId === parentMapId);
|
|
15
|
+
}
|
|
16
|
+
export function getSelectableUnitHotspots(map) {
|
|
17
|
+
return map.unitHotspots.filter(isSelectableUnitHotspot);
|
|
18
|
+
}
|
|
19
|
+
export function getUnitHotspotByUnitId(map, unitId) {
|
|
20
|
+
return (getSelectableUnitHotspots(map).find((hotspot) => hotspot.unitId === unitId) ?? null);
|
|
21
|
+
}
|
|
22
|
+
export function getUnitHotspotsByUnitId(map) {
|
|
23
|
+
return new Map(getSelectableUnitHotspots(map).map((hotspot) => [hotspot.unitId, hotspot]));
|
|
24
|
+
}
|
|
25
|
+
export function getShapeByElementId(map, svgElementId) {
|
|
26
|
+
return (map.shapes.find((shape) => shape.svgElementId === svgElementId) ?? null);
|
|
27
|
+
}
|
|
28
|
+
export function getShapesByElementId(map) {
|
|
29
|
+
return new Map(map.shapes.map((shape) => [shape.svgElementId, shape]));
|
|
30
|
+
}
|
|
31
|
+
export function getShapeForUnit(map, unitId) {
|
|
32
|
+
return getUnitHotspotByUnitId(map, unitId)?.shape ?? null;
|
|
33
|
+
}
|
|
34
|
+
export function getShapeGeometryValue(shape, key) {
|
|
35
|
+
return shape?.geometry[key] ?? null;
|
|
36
|
+
}
|
|
37
|
+
export function getSitemapMapAssetPlan(map) {
|
|
38
|
+
return {
|
|
39
|
+
imageHeight: map.assets.imageHeight ?? map.imageHeight,
|
|
40
|
+
imageUrl: map.assets.imageUrl || map.imageUrl,
|
|
41
|
+
imageWidth: map.assets.imageWidth ?? map.imageWidth,
|
|
42
|
+
overlayUrl: map.assets.overlayUrl || map.overlayUrl,
|
|
43
|
+
overlayViewBox: map.assets.overlayViewBox ?? map.overlayViewBox,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FinanceRules, InventoryUnit, PaymentSchemeDefinition, QuoteInput, QuoteUrlState } from "./types.js";
|
|
2
|
+
export declare const SOCIAL_INCLUDE_IVA = false;
|
|
3
|
+
export declare const UONDR_CASHBACK_MIN_DOWN_PAYMENT_PCT = 60;
|
|
4
|
+
export declare function isSameQuoteState(left: QuoteUrlState, right: QuoteUrlState): boolean;
|
|
5
|
+
export declare function getSocialDefaultDownPaymentPct(scheme: PaymentSchemeDefinition | null, financeRules: FinanceRules): number;
|
|
6
|
+
export declare function getSocialQuoteInput(unit: InventoryUnit, scheme: PaymentSchemeDefinition, financeRules: FinanceRules): QuoteInput;
|
|
7
|
+
export declare function getSocialQuoteInputWithCashbackDownPayment(unit: InventoryUnit, scheme: PaymentSchemeDefinition, financeRules: FinanceRules, downPaymentPct: number): QuoteInput;
|
|
8
|
+
export declare function clampUondrCashbackDownPaymentPct(scheme: PaymentSchemeDefinition | null, downPaymentPct: number): number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { clampToRange, getDefaultDownPaymentPctForScheme, isCashbackScheme, isInstallmentScheme, } from "./payment-schemes.js";
|
|
2
|
+
import { INSTALLMENT_DEFAULT_DOWN_PAYMENT_PCT, INSTALLMENT_DEFAULT_MONTHLY_PCT, } from "./installment-allocation.js";
|
|
3
|
+
export const SOCIAL_INCLUDE_IVA = false;
|
|
4
|
+
export const UONDR_CASHBACK_MIN_DOWN_PAYMENT_PCT = 60;
|
|
5
|
+
export function isSameQuoteState(left, right) {
|
|
6
|
+
return (left.category === right.category &&
|
|
7
|
+
left.unitId === right.unitId &&
|
|
8
|
+
left.scheme === right.scheme &&
|
|
9
|
+
left.postDeliveryYears === right.postDeliveryYears &&
|
|
10
|
+
left.downPaymentPct === right.downPaymentPct &&
|
|
11
|
+
left.installmentDownPaymentPct === right.installmentDownPaymentPct &&
|
|
12
|
+
left.installmentMonthlyPct === right.installmentMonthlyPct &&
|
|
13
|
+
left.includeIva === right.includeIva);
|
|
14
|
+
}
|
|
15
|
+
export function getSocialDefaultDownPaymentPct(scheme, financeRules) {
|
|
16
|
+
if (scheme && isInstallmentScheme(scheme)) {
|
|
17
|
+
return scheme.downPaymentPct;
|
|
18
|
+
}
|
|
19
|
+
return getDefaultDownPaymentPctForScheme(scheme, financeRules);
|
|
20
|
+
}
|
|
21
|
+
export function getSocialQuoteInput(unit, scheme, financeRules) {
|
|
22
|
+
return {
|
|
23
|
+
unitId: unit.id,
|
|
24
|
+
scheme: scheme.id,
|
|
25
|
+
plusvaliaAnnualPct: financeRules.defaults.plusvaliaAnnualPct,
|
|
26
|
+
postDeliveryYears: financeRules.defaults.postDeliveryYears,
|
|
27
|
+
downPaymentPct: getSocialDefaultDownPaymentPct(scheme, financeRules),
|
|
28
|
+
installmentDownPaymentPct: INSTALLMENT_DEFAULT_DOWN_PAYMENT_PCT,
|
|
29
|
+
installmentMonthlyPct: INSTALLMENT_DEFAULT_MONTHLY_PCT,
|
|
30
|
+
includeIva: SOCIAL_INCLUDE_IVA,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function getSocialQuoteInputWithCashbackDownPayment(unit, scheme, financeRules, downPaymentPct) {
|
|
34
|
+
const input = getSocialQuoteInput(unit, scheme, financeRules);
|
|
35
|
+
if (!isCashbackScheme(scheme)) {
|
|
36
|
+
return input;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...input,
|
|
40
|
+
downPaymentPct: clampToRange(downPaymentPct, scheme.downPaymentRange),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function clampUondrCashbackDownPaymentPct(scheme, downPaymentPct) {
|
|
44
|
+
if (!scheme || !isCashbackScheme(scheme)) {
|
|
45
|
+
return downPaymentPct;
|
|
46
|
+
}
|
|
47
|
+
return clampToRange(downPaymentPct, {
|
|
48
|
+
...scheme.downPaymentRange,
|
|
49
|
+
min: Math.max(scheme.downPaymentRange.min, UONDR_CASHBACK_MIN_DOWN_PAYMENT_PCT),
|
|
50
|
+
});
|
|
51
|
+
}
|
package/dist/tax.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const IVA_RATE = 0.13;
|
|
2
|
+
export declare const IVA_RATE_PERCENT: number;
|
|
3
|
+
export declare function applyIvaMXN(valueMXN: number): number;
|
|
4
|
+
export declare function applyIvaModeMXN(valueMXN: number, includeIva: boolean): number;
|
|
5
|
+
export declare function getIvaModeLabel(includeIva: boolean): "IVA incluido" | "+ IVA";
|
package/dist/tax.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const IVA_RATE = 0.13;
|
|
2
|
+
export const IVA_RATE_PERCENT = IVA_RATE * 100;
|
|
3
|
+
export function applyIvaMXN(valueMXN) {
|
|
4
|
+
return valueMXN * (1 + IVA_RATE);
|
|
5
|
+
}
|
|
6
|
+
export function applyIvaModeMXN(valueMXN, includeIva) {
|
|
7
|
+
return includeIva ? applyIvaMXN(valueMXN) : valueMXN;
|
|
8
|
+
}
|
|
9
|
+
export function getIvaModeLabel(includeIva) {
|
|
10
|
+
return includeIva ? "IVA incluido" : "+ IVA";
|
|
11
|
+
}
|