@infrab4a/connect-angular 4.12.1-beta.4 → 4.12.1-beta.6

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.
@@ -1093,8 +1093,12 @@ class CouponService {
1093
1093
  if (!hasProductCategories)
1094
1094
  throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1095
1095
  const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
1096
- if (!hasMinSubTotal)
1096
+ if (!hasMinSubTotal) {
1097
+ if (coupon.productsCategories?.length) {
1098
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido na(s) categoria(s)/marca(s) elegiveis para o desconto.`;
1099
+ }
1097
1100
  throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1101
+ }
1098
1102
  return coupon;
1099
1103
  }
1100
1104
  calcDiscountSubscription(coupon, checkout) {
@@ -1179,9 +1183,13 @@ class CouponService {
1179
1183
  async getCouponCategoriesId(productsCategories) {
1180
1184
  const couponCategories = [];
1181
1185
  for (let index = 0; index < productsCategories.length; index++) {
1182
- const category = await this.categoryRepository.get({
1183
- id: productsCategories[index],
1184
- });
1186
+ const category = await this.categoryRepository
1187
+ .find({
1188
+ filters: {
1189
+ id: productsCategories[index],
1190
+ },
1191
+ })
1192
+ .then((res) => res.data.at(0));
1185
1193
  if (category) {
1186
1194
  const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1187
1195
  couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
@@ -1415,7 +1423,7 @@ class CartService {
1415
1423
  quantity: (item.quantity || 0) + (quantity || 0),
1416
1424
  pricePaid,
1417
1425
  discount: 0,
1418
- categories: product.categories ?? [],
1426
+ categories: product.categories || product.category?.id ? [product.category?.id, ...product.categories] : [],
1419
1427
  isGift: isGift ?? null,
1420
1428
  costPrice: product.costPrice ?? 0,
1421
1429
  type,