@snabcentr/client-core 3.21.0 → 3.21.2
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/catalog/dto/sc-product.d.ts +8 -0
- package/catalog/interfaces/sc-i-product.d.ts +4 -0
- package/config/sc-i-company-base-info.d.ts +9 -0
- package/esm2022/catalog/dto/sc-product.mjs +12 -4
- package/esm2022/catalog/interfaces/sc-i-product.mjs +1 -1
- package/esm2022/config/sc-i-company-base-info.mjs +1 -1
- package/esm2022/helpers/index.mjs +2 -1
- package/esm2022/helpers/sc-number-helper.mjs +214 -0
- package/esm2022/order/classes/sc-delivery-cost.mjs +4 -3
- package/esm2022/order/classes/sc-order-base.mjs +3 -2
- package/esm2022/order/classes/sc-order-draft.mjs +3 -2
- package/esm2022/order/classes/sc-order-item.mjs +6 -5
- package/esm2022/order/services/sc-order-drafts.service.mjs +3 -2
- package/esm2022/seo/classes/schema-org-factory.mjs +59 -30
- package/esm2022/user/dto/sc-user.mjs +4 -3
- package/fesm2022/snabcentr-client-core.mjs +294 -45
- package/fesm2022/snabcentr-client-core.mjs.map +1 -1
- package/helpers/index.d.ts +1 -0
- package/helpers/sc-number-helper.d.ts +148 -0
- package/package.json +1 -1
- package/release_notes.tmp +2 -4
- package/seo/classes/schema-org-factory.d.ts +11 -0
- package/user/dto/sc-user.d.ts +1 -1
|
@@ -11,7 +11,8 @@ import { isPlatformBrowser, isPlatformServer, DOCUMENT, formatDate } from '@angu
|
|
|
11
11
|
import * as i1$1 from '@angular/common/http';
|
|
12
12
|
import { HttpContextToken, HttpContext, HttpHeaders, HttpClient, HttpParams, HttpErrorResponse, HttpResponse, FetchBackend, HttpXhrBackend, HttpStatusCode, HttpBackend } from '@angular/common/http';
|
|
13
13
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
14
|
-
import { tuiIsPresent, TuiDay, tuiPure, TUI_TRUE_HANDLER } from '@taiga-ui/cdk';
|
|
14
|
+
import { tuiRound, tuiIsPresent, TuiDay, tuiPure, TUI_TRUE_HANDLER } from '@taiga-ui/cdk';
|
|
15
|
+
import { tuiFormatNumber } from '@taiga-ui/core';
|
|
15
16
|
import { tuiCleanObject } from '@taiga-ui/addon-doc/utils';
|
|
16
17
|
import * as i2 from '@angular/router';
|
|
17
18
|
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
|
@@ -1214,6 +1215,218 @@ class ScBanner {
|
|
|
1214
1215
|
}
|
|
1215
1216
|
}
|
|
1216
1217
|
|
|
1218
|
+
/**
|
|
1219
|
+
* Класс-помощник для работы с дробными числами.
|
|
1220
|
+
*
|
|
1221
|
+
* Округляет с учётом погрешности дробной арифметики, считает кратность шагу и задаёт настройки вывода чисел.
|
|
1222
|
+
*/
|
|
1223
|
+
class ScNumberHelper {
|
|
1224
|
+
/**
|
|
1225
|
+
* Количество знаков после запятой в денежных суммах.
|
|
1226
|
+
*/
|
|
1227
|
+
static { this.moneyFractionDigits = 2; }
|
|
1228
|
+
/**
|
|
1229
|
+
* Наибольшее количество знаков после запятой в проценте на экране.
|
|
1230
|
+
*/
|
|
1231
|
+
static { this.percentDisplayFractionDigits = 2; }
|
|
1232
|
+
/**
|
|
1233
|
+
* Наибольшее количество знаков после запятой в площади, м².
|
|
1234
|
+
*/
|
|
1235
|
+
static { this.areaFractionDigits = 4; }
|
|
1236
|
+
/**
|
|
1237
|
+
* Количество знаков после запятой в географических координатах.
|
|
1238
|
+
*/
|
|
1239
|
+
static { this.coordinateFractionDigits = 6; }
|
|
1240
|
+
/**
|
|
1241
|
+
* Количество значащих цифр, до которого обрезается погрешность дробной арифметики.
|
|
1242
|
+
*/
|
|
1243
|
+
static { this.significantDigits = 12; }
|
|
1244
|
+
/**
|
|
1245
|
+
* Допустимая погрешность сравнения дробных чисел.
|
|
1246
|
+
*/
|
|
1247
|
+
static { this.epsilon = 0.000001; }
|
|
1248
|
+
/**
|
|
1249
|
+
* Настройки вывода денежных сумм.
|
|
1250
|
+
*/
|
|
1251
|
+
static { this.moneyFormat = {
|
|
1252
|
+
precision: ScNumberHelper.moneyFractionDigits,
|
|
1253
|
+
decimalSeparator: ',',
|
|
1254
|
+
decimalMode: 'always',
|
|
1255
|
+
rounding: 'round',
|
|
1256
|
+
}; }
|
|
1257
|
+
/**
|
|
1258
|
+
* Настройки вывода площади.
|
|
1259
|
+
*/
|
|
1260
|
+
static { this.areaFormat = {
|
|
1261
|
+
precision: ScNumberHelper.areaFractionDigits,
|
|
1262
|
+
decimalSeparator: ',',
|
|
1263
|
+
decimalMode: 'not-zero',
|
|
1264
|
+
rounding: 'round',
|
|
1265
|
+
}; }
|
|
1266
|
+
/**
|
|
1267
|
+
* Настройки вывода целых чисел.
|
|
1268
|
+
*/
|
|
1269
|
+
static { this.integerFormat = {
|
|
1270
|
+
precision: 0,
|
|
1271
|
+
rounding: 'round',
|
|
1272
|
+
}; }
|
|
1273
|
+
/**
|
|
1274
|
+
* Настройки вывода процентов.
|
|
1275
|
+
*/
|
|
1276
|
+
static { this.percentFormat = {
|
|
1277
|
+
precision: ScNumberHelper.percentDisplayFractionDigits,
|
|
1278
|
+
decimalSeparator: ',',
|
|
1279
|
+
decimalMode: 'not-zero',
|
|
1280
|
+
rounding: 'round',
|
|
1281
|
+
}; }
|
|
1282
|
+
/**
|
|
1283
|
+
* Настройки вывода денежных сумм в валютах с точностью больше двух знаков после запятой.
|
|
1284
|
+
*/
|
|
1285
|
+
static { this.moneyFormatsByPrecision = new Map(); }
|
|
1286
|
+
/**
|
|
1287
|
+
* Возвращает количество знаков после запятой в указанном числе с учётом экспоненциальной записи.
|
|
1288
|
+
*
|
|
1289
|
+
* @param value Число, для которого нужно определить количество знаков после запятой.
|
|
1290
|
+
*/
|
|
1291
|
+
static getDecimalsCount(value) {
|
|
1292
|
+
if (!Number.isFinite(value) || Number.isInteger(value)) {
|
|
1293
|
+
return 0;
|
|
1294
|
+
}
|
|
1295
|
+
const [mantissa, exponent] = value.toString().split('e');
|
|
1296
|
+
const mantissaParts = mantissa.split('.');
|
|
1297
|
+
const decimals = mantissaParts.length > 1 ? mantissaParts[1].length : 0;
|
|
1298
|
+
return Math.max(decimals - (Number(exponent) || 0), 0);
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Возвращает число без погрешности дробной арифметики.
|
|
1302
|
+
*
|
|
1303
|
+
* @param value Число с возможной погрешностью.
|
|
1304
|
+
*/
|
|
1305
|
+
static normalize(value) {
|
|
1306
|
+
return Number.isFinite(value) ? Number(value.toPrecision(ScNumberHelper.significantDigits)) : value;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Возвращает значение, округлённое до указанного количества знаков после запятой.
|
|
1310
|
+
*
|
|
1311
|
+
* @param value Округляемое значение.
|
|
1312
|
+
* @param fractionDigits Количество знаков после запятой.
|
|
1313
|
+
*/
|
|
1314
|
+
static round(value, fractionDigits) {
|
|
1315
|
+
return tuiRound(value, fractionDigits);
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Возвращает денежную сумму, округлённую до копеек.
|
|
1319
|
+
*
|
|
1320
|
+
* @param value Денежная сумма.
|
|
1321
|
+
*/
|
|
1322
|
+
static roundMoney(value) {
|
|
1323
|
+
return ScNumberHelper.round(value, ScNumberHelper.moneyFractionDigits);
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Возвращает географическую координату, округлённую до точности хранения.
|
|
1327
|
+
*
|
|
1328
|
+
* @param value Координата.
|
|
1329
|
+
*/
|
|
1330
|
+
static roundCoordinate(value) {
|
|
1331
|
+
return ScNumberHelper.round(value, ScNumberHelper.coordinateFractionDigits);
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Возвращает произведение значения на шаг, округлённое до точности множителей.
|
|
1335
|
+
*
|
|
1336
|
+
* @param value Множитель, обычно количество.
|
|
1337
|
+
* @param step Шаг.
|
|
1338
|
+
*/
|
|
1339
|
+
static multiplyByStep(value, step) {
|
|
1340
|
+
return ScNumberHelper.round(value * step, ScNumberHelper.getDecimalsCount(step) + ScNumberHelper.getDecimalsCount(value));
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Возвращает частное от деления значения на шаг без погрешности дробной арифметики.
|
|
1344
|
+
*
|
|
1345
|
+
* @param value Делимое, обычно длина или количество.
|
|
1346
|
+
* @param step Шаг.
|
|
1347
|
+
*/
|
|
1348
|
+
static divideByStep(value, step) {
|
|
1349
|
+
return ScNumberHelper.withoutNegativeZero(ScNumberHelper.normalize(value / step));
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Возвращает сумму значения и шага, округлённую до точности слагаемых.
|
|
1353
|
+
*
|
|
1354
|
+
* @param value Значение.
|
|
1355
|
+
* @param step Шаг.
|
|
1356
|
+
*/
|
|
1357
|
+
static addStep(value, step) {
|
|
1358
|
+
return ScNumberHelper.round(value + step, Math.max(ScNumberHelper.getDecimalsCount(value), ScNumberHelper.getDecimalsCount(step)));
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Возвращает остаток от деления значения на шаг без погрешности дробной арифметики.
|
|
1362
|
+
*
|
|
1363
|
+
* @param value Значение.
|
|
1364
|
+
* @param step Шаг.
|
|
1365
|
+
*/
|
|
1366
|
+
static remainder(value, step) {
|
|
1367
|
+
const quotient = Math.floor(ScNumberHelper.divideByStep(value, step));
|
|
1368
|
+
return ScNumberHelper.round(value - quotient * step, Math.max(ScNumberHelper.getDecimalsCount(value), ScNumberHelper.getDecimalsCount(step)));
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Возвращает значение, приведённое к ближайшему кратному шагу, с точностью шага.
|
|
1372
|
+
*
|
|
1373
|
+
* @param value Значение.
|
|
1374
|
+
* @param step Шаг.
|
|
1375
|
+
*/
|
|
1376
|
+
static snapToStep(value, step) {
|
|
1377
|
+
return ScNumberHelper.multiplyByStep(Math.round(ScNumberHelper.divideByStep(value, step)), step);
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Возвращает признак того, что значение кратно шагу с учётом погрешности дробной арифметики.
|
|
1381
|
+
*
|
|
1382
|
+
* @param value Значение.
|
|
1383
|
+
* @param step Шаг.
|
|
1384
|
+
*/
|
|
1385
|
+
static isMultipleOf(value, step) {
|
|
1386
|
+
const quotient = value / step;
|
|
1387
|
+
return Math.abs(quotient - Math.round(quotient)) < ScNumberHelper.epsilon;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Возвращает настройки вывода денежной суммы с учётом точности её валюты.
|
|
1391
|
+
*
|
|
1392
|
+
* @param precision Точность валюты суммы ({@link ScICurrency.precision}),
|
|
1393
|
+
* если она больше двух знаков после запятой.
|
|
1394
|
+
*/
|
|
1395
|
+
static getMoneyFormat(precision) {
|
|
1396
|
+
if (!precision || precision <= ScNumberHelper.moneyFractionDigits) {
|
|
1397
|
+
return ScNumberHelper.moneyFormat;
|
|
1398
|
+
}
|
|
1399
|
+
let format = ScNumberHelper.moneyFormatsByPrecision.get(precision);
|
|
1400
|
+
if (!format) {
|
|
1401
|
+
format = { ...ScNumberHelper.moneyFormat, precision };
|
|
1402
|
+
ScNumberHelper.moneyFormatsByPrecision.set(precision, format);
|
|
1403
|
+
}
|
|
1404
|
+
return format;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Возвращает денежную сумму в виде строки с разделителями разрядов.
|
|
1408
|
+
*
|
|
1409
|
+
* Знаков после запятой не меньше двух и не больше, чем задаёт точность валюты.
|
|
1410
|
+
*
|
|
1411
|
+
* @param value Денежная сумма.
|
|
1412
|
+
* @param precision Точность валюты суммы ({@link ScICurrency.precision}),
|
|
1413
|
+
* если она больше двух знаков после запятой.
|
|
1414
|
+
*/
|
|
1415
|
+
static formatMoney(value, precision) {
|
|
1416
|
+
const rounded = ScNumberHelper.round(value, Math.max(precision ?? 0, ScNumberHelper.moneyFractionDigits));
|
|
1417
|
+
const decimalsCount = ScNumberHelper.getDecimalsCount(rounded);
|
|
1418
|
+
return tuiFormatNumber(rounded, decimalsCount > ScNumberHelper.moneyFractionDigits ? { ...ScNumberHelper.moneyFormat, precision: decimalsCount } : ScNumberHelper.moneyFormat);
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Возвращает число, в котором отрицательный ноль заменён на ноль.
|
|
1422
|
+
*
|
|
1423
|
+
* @param value Число.
|
|
1424
|
+
*/
|
|
1425
|
+
static withoutNegativeZero(value) {
|
|
1426
|
+
return value === 0 ? 0 : value;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1217
1430
|
/**
|
|
1218
1431
|
* Перечисление типов клиента.
|
|
1219
1432
|
*/
|
|
@@ -1284,10 +1497,10 @@ class ScUser {
|
|
|
1284
1497
|
return this.userType === ScUserType.guest;
|
|
1285
1498
|
}
|
|
1286
1499
|
/**
|
|
1287
|
-
*
|
|
1500
|
+
* Задолженность по модулю, округлённая до копеек.
|
|
1288
1501
|
*/
|
|
1289
1502
|
get absDebt() {
|
|
1290
|
-
return Math.abs(this.debt ?? 0);
|
|
1503
|
+
return ScNumberHelper.roundMoney(Math.abs(this.debt ?? 0));
|
|
1291
1504
|
}
|
|
1292
1505
|
}
|
|
1293
1506
|
|
|
@@ -1748,6 +1961,7 @@ class ScProduct extends ScCatalogItem {
|
|
|
1748
1961
|
else {
|
|
1749
1962
|
this.image = data.images?.find((img) => img.isDefault)?.image ?? data.properties?.image;
|
|
1750
1963
|
this.supplierSku = data.supplierSku;
|
|
1964
|
+
this.brand = data.brand;
|
|
1751
1965
|
this.cost = data.cost;
|
|
1752
1966
|
this.costRub = data.costRub;
|
|
1753
1967
|
this.costDate = data.costDate;
|
|
@@ -1771,19 +1985,19 @@ class ScProduct extends ScCatalogItem {
|
|
|
1771
1985
|
* Стоимость товара или услуги с валютой и единицей измерения.
|
|
1772
1986
|
*/
|
|
1773
1987
|
get costString() {
|
|
1774
|
-
return this.cost ? `${this.cost.
|
|
1988
|
+
return this.cost ? `${ScNumberHelper.formatMoney(this.cost, this.currency.precision)} ${this.currency.symbol} / ${this.unit.name}` : '';
|
|
1775
1989
|
}
|
|
1776
1990
|
/**
|
|
1777
1991
|
* Стоимость товара или услуги в рублях и с единицей измерения.
|
|
1778
1992
|
*/
|
|
1779
1993
|
get costRubString() {
|
|
1780
|
-
return this.costRub ? `${this.costRub.
|
|
1994
|
+
return this.costRub ? `${ScNumberHelper.formatMoney(this.costRub, this.rubPrecision)} ₽ / ${this.unit.name}` : '';
|
|
1781
1995
|
}
|
|
1782
1996
|
/**
|
|
1783
1997
|
* Стоимость товара или услуги с валютой и единицей измерения до применения скидки.
|
|
1784
1998
|
*/
|
|
1785
1999
|
get discountCostString() {
|
|
1786
|
-
return this.discount?.oldCost ? `${this.discount.oldCost.
|
|
2000
|
+
return this.discount?.oldCost ? `${ScNumberHelper.formatMoney(this.discount.oldCost, this.currency.precision)} ${this.currency.symbol} / ${this.unit.name}` : '';
|
|
1787
2001
|
}
|
|
1788
2002
|
/**
|
|
1789
2003
|
* Признак, что товар продаётся в рублях.
|
|
@@ -1791,6 +2005,12 @@ class ScProduct extends ScCatalogItem {
|
|
|
1791
2005
|
get priceInRub() {
|
|
1792
2006
|
return this.currency.symbol === '₽';
|
|
1793
2007
|
}
|
|
2008
|
+
/**
|
|
2009
|
+
* Точность цены товара в рублях, если товар продаётся в рублях.
|
|
2010
|
+
*/
|
|
2011
|
+
get rubPrecision() {
|
|
2012
|
+
return this.priceInRub ? this.currency.precision : undefined;
|
|
2013
|
+
}
|
|
1794
2014
|
/**
|
|
1795
2015
|
* Возвращает первое изображение товара. Если изображений нет, то возвращает undefined.
|
|
1796
2016
|
*
|
|
@@ -1898,25 +2118,25 @@ class ScOrderItem {
|
|
|
1898
2118
|
* @inheritDoc
|
|
1899
2119
|
*/
|
|
1900
2120
|
getCostPerItem() {
|
|
1901
|
-
return this.costOne > 0 ? `${this.costOne.
|
|
2121
|
+
return this.costOne > 0 ? `${ScNumberHelper.formatMoney(this.costOne, this.product.currency.precision)} ${this.product.currency.symbol}` : '-';
|
|
1902
2122
|
}
|
|
1903
2123
|
/**
|
|
1904
2124
|
* @inheritDoc
|
|
1905
2125
|
*/
|
|
1906
2126
|
getCostInCurrencyDescPerItem() {
|
|
1907
|
-
return this.costOne > 0 ? `${this.costOne.
|
|
2127
|
+
return this.costOne > 0 ? `${ScNumberHelper.formatMoney(this.costOne, this.product.currency.precision)} ${this.product.currency.symbol} / ${this.product.unit.name}` : '-';
|
|
1908
2128
|
}
|
|
1909
2129
|
/**
|
|
1910
2130
|
* @inheritDoc
|
|
1911
2131
|
*/
|
|
1912
2132
|
getCostInRubDescPerItem() {
|
|
1913
|
-
return this.costOneRub > 0 ? `${this.costOneRub.
|
|
2133
|
+
return this.costOneRub > 0 ? `${ScNumberHelper.formatMoney(this.costOneRub, this.product.rubPrecision)} ₽ / ${this.product.unit.name}` : '-';
|
|
1914
2134
|
}
|
|
1915
2135
|
/**
|
|
1916
2136
|
* @inheritDoc
|
|
1917
2137
|
*/
|
|
1918
2138
|
getCostRubStr() {
|
|
1919
|
-
return this.costRub > 0 ? `${this.costRub
|
|
2139
|
+
return this.costRub > 0 ? `${ScNumberHelper.formatMoney(this.costRub)} ₽` : '-';
|
|
1920
2140
|
}
|
|
1921
2141
|
/**
|
|
1922
2142
|
* @inheritDoc
|
|
@@ -6775,8 +6995,8 @@ class ScDeliveryCost {
|
|
|
6775
6995
|
constructor(deliveryCost, deliveryDate) {
|
|
6776
6996
|
if (deliveryCost.freeShippingTerms?.minOrdersSum !== undefined && deliveryCost.freeShippingTerms.currentOrdersSum !== undefined) {
|
|
6777
6997
|
this.freeShippingTerms = { minOrdersSum: deliveryCost.freeShippingTerms.minOrdersSum, currentOrdersSum: deliveryCost.freeShippingTerms.currentOrdersSum };
|
|
6778
|
-
this.message = `Для оформления бесплатной доставки сумма заказов на ${deliveryDate} должна быть более ${this.freeShippingTerms.minOrdersSum
|
|
6779
|
-
Текущая сумма заказов составляет ${this.freeShippingTerms.currentOrdersSum
|
|
6998
|
+
this.message = `Для оформления бесплатной доставки сумма заказов на ${deliveryDate} должна быть более ${ScNumberHelper.formatMoney(this.freeShippingTerms.minOrdersSum)} руб.<br>
|
|
6999
|
+
Текущая сумма заказов составляет ${ScNumberHelper.formatMoney(this.freeShippingTerms.currentOrdersSum)} руб`;
|
|
6780
7000
|
}
|
|
6781
7001
|
}
|
|
6782
7002
|
}
|
|
@@ -6799,7 +7019,7 @@ class ScOrderBase {
|
|
|
6799
7019
|
* @inheritDoc
|
|
6800
7020
|
*/
|
|
6801
7021
|
getSumStr() {
|
|
6802
|
-
return this.sum && this.sum > 0 ? `${this.sum
|
|
7022
|
+
return this.sum && this.sum > 0 ? `${ScNumberHelper.formatMoney(this.sum)} ₽` : '-';
|
|
6803
7023
|
}
|
|
6804
7024
|
/**
|
|
6805
7025
|
* @inheritDoc
|
|
@@ -6834,7 +7054,7 @@ class ScOrderDraft {
|
|
|
6834
7054
|
* @inheritDoc
|
|
6835
7055
|
*/
|
|
6836
7056
|
getSumStr() {
|
|
6837
|
-
return this.sum > 0 ? `${this.sum
|
|
7057
|
+
return this.sum > 0 ? `${ScNumberHelper.formatMoney(this.sum)} ₽` : '-';
|
|
6838
7058
|
}
|
|
6839
7059
|
/**
|
|
6840
7060
|
* @inheritDoc
|
|
@@ -7238,7 +7458,7 @@ class ScOrderDraftsService {
|
|
|
7238
7458
|
}
|
|
7239
7459
|
const updatedDraft = new ScOrderDraft(currentDraft);
|
|
7240
7460
|
updatedDraft.products = remainingProducts;
|
|
7241
|
-
updatedDraft.sum = remainingProducts.reduce((sum, product) => sum + product.costRub, 0);
|
|
7461
|
+
updatedDraft.sum = ScNumberHelper.roundMoney(remainingProducts.reduce((sum, product) => sum + product.costRub, 0));
|
|
7242
7462
|
cachedItem.setValue(updatedDraft);
|
|
7243
7463
|
});
|
|
7244
7464
|
}
|
|
@@ -7991,7 +8211,6 @@ class SchemaOrgFactory {
|
|
|
7991
8211
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
7992
8212
|
const image = this.mediaImageTransformerPipe.transform(product?.getImagePreview?.() ?? product.image, true);
|
|
7993
8213
|
const description = product.properties?.description;
|
|
7994
|
-
const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
|
|
7995
8214
|
return {
|
|
7996
8215
|
'@context': 'https://schema.org',
|
|
7997
8216
|
'@type': 'Product',
|
|
@@ -7999,21 +8218,16 @@ class SchemaOrgFactory {
|
|
|
7999
8218
|
name: product.name,
|
|
8000
8219
|
...(image && { image }),
|
|
8001
8220
|
...(description && { description: this.stripHtml(description) }),
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
price: product.costRub,
|
|
8009
|
-
availability: this.getAvailability(product),
|
|
8010
|
-
itemCondition: 'https://schema.org/NewCondition',
|
|
8011
|
-
seller: {
|
|
8012
|
-
'@type': 'Organization',
|
|
8013
|
-
name: this.companyInfo.name,
|
|
8221
|
+
sku: product.code,
|
|
8222
|
+
...(product.supplierSku && { mpn: product.supplierSku }),
|
|
8223
|
+
...(product.brand && {
|
|
8224
|
+
brand: {
|
|
8225
|
+
'@type': 'Brand',
|
|
8226
|
+
name: product.brand,
|
|
8014
8227
|
},
|
|
8015
|
-
|
|
8016
|
-
|
|
8228
|
+
}),
|
|
8229
|
+
url: productUrl,
|
|
8230
|
+
offers: this.createOffer(product, productUrl),
|
|
8017
8231
|
};
|
|
8018
8232
|
}
|
|
8019
8233
|
/**
|
|
@@ -8097,6 +8311,7 @@ class SchemaOrgFactory {
|
|
|
8097
8311
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
8098
8312
|
generateForOrganization() {
|
|
8099
8313
|
const postalAddress = this.createPostalAddress(this.companyInfo.address);
|
|
8314
|
+
const merchantReturnPolicy = this.createMerchantReturnPolicy();
|
|
8100
8315
|
return {
|
|
8101
8316
|
'@context': 'https://schema.org',
|
|
8102
8317
|
'@type': 'OnlineStore',
|
|
@@ -8126,6 +8341,13 @@ class SchemaOrgFactory {
|
|
|
8126
8341
|
address: warehouseAddress,
|
|
8127
8342
|
})),
|
|
8128
8343
|
}),
|
|
8344
|
+
...(merchantReturnPolicy && {
|
|
8345
|
+
// Тип возмещения Google принимает только в политике организации, в предложениях его нет.
|
|
8346
|
+
hasMerchantReturnPolicy: {
|
|
8347
|
+
...merchantReturnPolicy,
|
|
8348
|
+
refundType: 'https://schema.org/FullRefund',
|
|
8349
|
+
},
|
|
8350
|
+
}),
|
|
8129
8351
|
};
|
|
8130
8352
|
}
|
|
8131
8353
|
/**
|
|
@@ -8261,6 +8483,22 @@ class SchemaOrgFactory {
|
|
|
8261
8483
|
}
|
|
8262
8484
|
return contactPoints;
|
|
8263
8485
|
}
|
|
8486
|
+
/**
|
|
8487
|
+
* Формирует MerchantReturnPolicy по условиям возврата из данных о компании.
|
|
8488
|
+
*/
|
|
8489
|
+
createMerchantReturnPolicy() {
|
|
8490
|
+
if (!this.companyInfo.returnPolicy) {
|
|
8491
|
+
return undefined;
|
|
8492
|
+
}
|
|
8493
|
+
return {
|
|
8494
|
+
'@type': 'MerchantReturnPolicy',
|
|
8495
|
+
applicableCountry: 'RU',
|
|
8496
|
+
returnPolicyCategory: 'https://schema.org/MerchantReturnFiniteReturnWindow',
|
|
8497
|
+
merchantReturnDays: this.companyInfo.returnPolicy.returnDays,
|
|
8498
|
+
returnMethod: 'https://schema.org/ReturnInStore',
|
|
8499
|
+
returnFees: 'https://schema.org/FreeReturn',
|
|
8500
|
+
};
|
|
8501
|
+
}
|
|
8264
8502
|
/**
|
|
8265
8503
|
* Удаляет HTML-разметку из текста.
|
|
8266
8504
|
*
|
|
@@ -8354,6 +8592,30 @@ class SchemaOrgFactory {
|
|
|
8354
8592
|
const path = categoryPath.replace(':id', id);
|
|
8355
8593
|
return `${this.urls.siteUrl}${path}`;
|
|
8356
8594
|
}
|
|
8595
|
+
/**
|
|
8596
|
+
* Создаёт Offer о продаже товара.
|
|
8597
|
+
*
|
|
8598
|
+
* @param product Данные о продукте.
|
|
8599
|
+
* @param productUrl Полный URL страницы товара.
|
|
8600
|
+
*/
|
|
8601
|
+
createOffer(product, productUrl) {
|
|
8602
|
+
const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
|
|
8603
|
+
const merchantReturnPolicy = this.createMerchantReturnPolicy();
|
|
8604
|
+
return {
|
|
8605
|
+
'@type': 'Offer',
|
|
8606
|
+
priceCurrency: 'RUB',
|
|
8607
|
+
...(priceValidUntil && { priceValidUntil }),
|
|
8608
|
+
price: product.costRub,
|
|
8609
|
+
availability: this.getAvailability(product),
|
|
8610
|
+
itemCondition: 'https://schema.org/NewCondition',
|
|
8611
|
+
seller: {
|
|
8612
|
+
'@type': 'Organization',
|
|
8613
|
+
name: this.companyInfo.name,
|
|
8614
|
+
},
|
|
8615
|
+
url: productUrl,
|
|
8616
|
+
...(merchantReturnPolicy && { hasMerchantReturnPolicy: merchantReturnPolicy }),
|
|
8617
|
+
};
|
|
8618
|
+
}
|
|
8357
8619
|
/**
|
|
8358
8620
|
* Создаёт элемент списка ItemList с кратким Product для страницы категории.
|
|
8359
8621
|
*
|
|
@@ -8366,7 +8628,6 @@ class SchemaOrgFactory {
|
|
|
8366
8628
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
8367
8629
|
const image = this.mediaImageTransformerPipe.transform(product?.getImagePreview?.() ?? product.image, true);
|
|
8368
8630
|
const description = product.seo?.description ?? product.properties?.description;
|
|
8369
|
-
const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
|
|
8370
8631
|
return {
|
|
8371
8632
|
'@type': 'ListItem',
|
|
8372
8633
|
position,
|
|
@@ -8376,19 +8637,7 @@ class SchemaOrgFactory {
|
|
|
8376
8637
|
url: productUrl,
|
|
8377
8638
|
...(image && { image }),
|
|
8378
8639
|
...(description && { description: this.stripHtml(description) }),
|
|
8379
|
-
offers:
|
|
8380
|
-
'@type': 'Offer',
|
|
8381
|
-
priceCurrency: 'RUB',
|
|
8382
|
-
...(priceValidUntil && { priceValidUntil }),
|
|
8383
|
-
price: product.costRub,
|
|
8384
|
-
availability: this.getAvailability(product),
|
|
8385
|
-
itemCondition: 'https://schema.org/NewCondition',
|
|
8386
|
-
seller: {
|
|
8387
|
-
'@type': 'Organization',
|
|
8388
|
-
name: this.companyInfo.name,
|
|
8389
|
-
},
|
|
8390
|
-
url: productUrl,
|
|
8391
|
-
},
|
|
8640
|
+
offers: this.createOffer(product, productUrl),
|
|
8392
8641
|
},
|
|
8393
8642
|
};
|
|
8394
8643
|
}
|
|
@@ -9308,5 +9557,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
9308
9557
|
* Generated bundle index. Do not edit.
|
|
9309
9558
|
*/
|
|
9310
9559
|
|
|
9311
|
-
export { CATEGORY_PROVIDERS, EMPTY_CART, IS_BROWSER, IS_RUNNING_ON_TERMINAL, IS_SERVER, RESPONSE, SC_ACCESS_AUTH_TOKEN_STORAGE_KEY, SC_API_KEYS, SC_AUTH_ADD_HEADER_REQUIRED, SC_AUTH_AS_CLIENT_DEFAULT_OPTIONS, SC_AUTH_AS_CLIENT_OPTIONS, SC_CACHE_LIFETIME, SC_CACHE_SETTINGS, SC_CANONICAL_REDIRECT_ENABLED, SC_CATALOG_ITEM_PAGE_META, SC_CATALOG_ROOT_PAGE_META, SC_CATEGORY_INFO, SC_CATEGORY_STATE, SC_COMPANY_INFO, SC_COMPANY_NAME, SC_CONFIGURATOR_COMPONENTS, SC_CONFIGURATOR_SETTINGS, SC_COUNT_FIRST_DISCOUNTED_PRODUCTS, SC_COUNT_LAST_NEWS, SC_DATE_FORMAT, SC_DEFAULT_PAGE_META, SC_FEEDBACK_API, SC_GUEST_ENDPOINTS_TOKEN, SC_GUEST_PARAMETER_NAME_TOKEN, SC_GUEST_TOKEN_STORAGE_KEY, SC_ID_OR_SLUG_IN_ROUTE, SC_IS_HEADER_REQUIRED, SC_IS_HIDDEN_ERROR_ALERT, SC_IS_HIDDEN_ERROR_ALERT_HTTP_CONTEXT, SC_IS_LOGOUT_REQUEST, SC_IS_REFRESH_REQUIRED, SC_LINEAR_VALUES, SC_LINEAR_VALUES_TOKEN, SC_MAX_LENGTH_SEARCH_TERM, SC_MIN_LENGTH_SEARCH_TERM, SC_NEXT_PAGE_PAGINATION_CLICK, SC_ORDER_LOADER, SC_ORDER_LOADING, SC_PAGE_QUERY_PARAM, SC_PATH_IMAGE_NOT_FOUND, SC_PRODUCTS_PAGINATION_LOADER, SC_PRODUCT_PAGINATION_DEFAULT_OPTIONS, SC_PRODUCT_PAGINATION_OPTIONS, SC_REFRESH_AUTH_TOKEN_STORAGE_KEY, SC_RELEASE, SC_SSR_RESPONSE_CACHE, SC_SSR_RESPONSE_CACHE_SETTINGS, SC_UPDATE_INTERVAL, SC_URLS, SC_USER_INFO, SC_VACANCIES_DATA_SOURCE, SC_VIRTUAL_CATEGORY_INFO, SC_VIRTUAL_CATEGORY_PROVIDERS, SEARCH_TERM, SEARCH_TERM_PROVIDERS, ScAuthAsClientGuard, ScAuthInterceptor, ScAuthService, ScBanner, ScBannerService, ScCacheInterceptor, ScCacheSettings, ScCachedData, ScCachedItem, ScCart, ScCartService, ScCatalogFilterService, ScCatalogFormat, ScCatalogItem, ScCatalogRedirectService, ScCatalogService, ScCatalogableItem, ScCategory, ScClientType, ScCodedIdentity, ScConfiguratorService, ScContactsService, ScContragentService, ScConvertInterceptor, ScConvertersService, ScDateFormatInterceptor, ScDeletableNamedIdentity, ScDeliveryAddressService, ScDeliveryCost, ScDeliveryType, ScDocumentInfoNode, ScDocumentInfoTypesEnum, ScErrorRequestState, ScErrorsInterceptor, ScFavoriteService, ScFeedbackForms, ScFeedbackService, ScFilesService, ScFrequentlyAskedQuestionsService, ScGuestInterceptor, ScHiddenCatalogableItem, ScIBreadcrumbItem, ScISuggestionType, ScIconTypesEnum, ScIdOrSlugGuard, ScIdOrSlugPipe, ScIdentity, ScImage, ScImageHelper, ScLoadingRequestState, ScLocationsService, ScMediaImageTransformerPipe, ScMimeTypes, ScNamedIdentity, ScNews, ScNewsService, ScNotificationActionTypes, ScNotificationLevelNames, ScNotificationsService, ScOpfList, ScOptionsInterceptor, ScOrder, ScOrderBase, ScOrderDraft, ScOrderDraftShort, ScOrderDraftType, ScOrderDraftsService, ScOrderItem, ScOrderShort, ScOrderStateStatus, ScOrdersService, ScPaginationPageQueryParamService, ScPaginationService, ScPaymentStatus, ScPaymentType, ScPhoneService, ScPrimaryCatalogableItem, ScProduct, ScProductTileType, ScQuestionnaireService, ScQuestionnaireStatusEnum, ScReclamationService, ScReclamationStatus, ScRecommendationService, ScRedirectStatusEnum, ScReference, ScReferenceName, ScReferencesService, ScRequestStateStatusEnum, ScRequisitesService, ScRouteKeys, ScSearchService, ScSeoService, ScSocialType, ScSsrResponseCache, ScSsrResponseCacheBackend, ScSuccessRequestState, ScSuggestionService, ScSum, ScTokenService, ScUIService, ScUTMService, ScUnitsHelper, ScUpdatableNamedIdentity, ScUploadedFile, ScUser, ScUserMetadata, ScUserMetrikaGoalsEnum, ScUserMetrikaService, ScUserService, ScUserType, ScVCardService, ScVacanciesList, ScVacanciesService, ScVacancy, ScVerificationService, ScVirtualCategory, ScWarehouseService, SchemaOrgFactory, TERMINAL_PROVIDERS, USER_AGENT_TERMINAL, filterChangedByKey, loadingPlaceholder, mapRequestStateToDataOrNull, mapToRequestState, provideSsrResponseCache, runningOnTerminalFactory, scGetCurrentRoute, scGetPageQueryParamChanges, scOrderIsLoaded, scParsePageQueryParam, searchTermFactory };
|
|
9560
|
+
export { CATEGORY_PROVIDERS, EMPTY_CART, IS_BROWSER, IS_RUNNING_ON_TERMINAL, IS_SERVER, RESPONSE, SC_ACCESS_AUTH_TOKEN_STORAGE_KEY, SC_API_KEYS, SC_AUTH_ADD_HEADER_REQUIRED, SC_AUTH_AS_CLIENT_DEFAULT_OPTIONS, SC_AUTH_AS_CLIENT_OPTIONS, SC_CACHE_LIFETIME, SC_CACHE_SETTINGS, SC_CANONICAL_REDIRECT_ENABLED, SC_CATALOG_ITEM_PAGE_META, SC_CATALOG_ROOT_PAGE_META, SC_CATEGORY_INFO, SC_CATEGORY_STATE, SC_COMPANY_INFO, SC_COMPANY_NAME, SC_CONFIGURATOR_COMPONENTS, SC_CONFIGURATOR_SETTINGS, SC_COUNT_FIRST_DISCOUNTED_PRODUCTS, SC_COUNT_LAST_NEWS, SC_DATE_FORMAT, SC_DEFAULT_PAGE_META, SC_FEEDBACK_API, SC_GUEST_ENDPOINTS_TOKEN, SC_GUEST_PARAMETER_NAME_TOKEN, SC_GUEST_TOKEN_STORAGE_KEY, SC_ID_OR_SLUG_IN_ROUTE, SC_IS_HEADER_REQUIRED, SC_IS_HIDDEN_ERROR_ALERT, SC_IS_HIDDEN_ERROR_ALERT_HTTP_CONTEXT, SC_IS_LOGOUT_REQUEST, SC_IS_REFRESH_REQUIRED, SC_LINEAR_VALUES, SC_LINEAR_VALUES_TOKEN, SC_MAX_LENGTH_SEARCH_TERM, SC_MIN_LENGTH_SEARCH_TERM, SC_NEXT_PAGE_PAGINATION_CLICK, SC_ORDER_LOADER, SC_ORDER_LOADING, SC_PAGE_QUERY_PARAM, SC_PATH_IMAGE_NOT_FOUND, SC_PRODUCTS_PAGINATION_LOADER, SC_PRODUCT_PAGINATION_DEFAULT_OPTIONS, SC_PRODUCT_PAGINATION_OPTIONS, SC_REFRESH_AUTH_TOKEN_STORAGE_KEY, SC_RELEASE, SC_SSR_RESPONSE_CACHE, SC_SSR_RESPONSE_CACHE_SETTINGS, SC_UPDATE_INTERVAL, SC_URLS, SC_USER_INFO, SC_VACANCIES_DATA_SOURCE, SC_VIRTUAL_CATEGORY_INFO, SC_VIRTUAL_CATEGORY_PROVIDERS, SEARCH_TERM, SEARCH_TERM_PROVIDERS, ScAuthAsClientGuard, ScAuthInterceptor, ScAuthService, ScBanner, ScBannerService, ScCacheInterceptor, ScCacheSettings, ScCachedData, ScCachedItem, ScCart, ScCartService, ScCatalogFilterService, ScCatalogFormat, ScCatalogItem, ScCatalogRedirectService, ScCatalogService, ScCatalogableItem, ScCategory, ScClientType, ScCodedIdentity, ScConfiguratorService, ScContactsService, ScContragentService, ScConvertInterceptor, ScConvertersService, ScDateFormatInterceptor, ScDeletableNamedIdentity, ScDeliveryAddressService, ScDeliveryCost, ScDeliveryType, ScDocumentInfoNode, ScDocumentInfoTypesEnum, ScErrorRequestState, ScErrorsInterceptor, ScFavoriteService, ScFeedbackForms, ScFeedbackService, ScFilesService, ScFrequentlyAskedQuestionsService, ScGuestInterceptor, ScHiddenCatalogableItem, ScIBreadcrumbItem, ScISuggestionType, ScIconTypesEnum, ScIdOrSlugGuard, ScIdOrSlugPipe, ScIdentity, ScImage, ScImageHelper, ScLoadingRequestState, ScLocationsService, ScMediaImageTransformerPipe, ScMimeTypes, ScNamedIdentity, ScNews, ScNewsService, ScNotificationActionTypes, ScNotificationLevelNames, ScNotificationsService, ScNumberHelper, ScOpfList, ScOptionsInterceptor, ScOrder, ScOrderBase, ScOrderDraft, ScOrderDraftShort, ScOrderDraftType, ScOrderDraftsService, ScOrderItem, ScOrderShort, ScOrderStateStatus, ScOrdersService, ScPaginationPageQueryParamService, ScPaginationService, ScPaymentStatus, ScPaymentType, ScPhoneService, ScPrimaryCatalogableItem, ScProduct, ScProductTileType, ScQuestionnaireService, ScQuestionnaireStatusEnum, ScReclamationService, ScReclamationStatus, ScRecommendationService, ScRedirectStatusEnum, ScReference, ScReferenceName, ScReferencesService, ScRequestStateStatusEnum, ScRequisitesService, ScRouteKeys, ScSearchService, ScSeoService, ScSocialType, ScSsrResponseCache, ScSsrResponseCacheBackend, ScSuccessRequestState, ScSuggestionService, ScSum, ScTokenService, ScUIService, ScUTMService, ScUnitsHelper, ScUpdatableNamedIdentity, ScUploadedFile, ScUser, ScUserMetadata, ScUserMetrikaGoalsEnum, ScUserMetrikaService, ScUserService, ScUserType, ScVCardService, ScVacanciesList, ScVacanciesService, ScVacancy, ScVerificationService, ScVirtualCategory, ScWarehouseService, SchemaOrgFactory, TERMINAL_PROVIDERS, USER_AGENT_TERMINAL, filterChangedByKey, loadingPlaceholder, mapRequestStateToDataOrNull, mapToRequestState, provideSsrResponseCache, runningOnTerminalFactory, scGetCurrentRoute, scGetPageQueryParamChanges, scOrderIsLoaded, scParsePageQueryParam, searchTermFactory };
|
|
9312
9561
|
//# sourceMappingURL=snabcentr-client-core.mjs.map
|