b2m-utils 0.0.301 → 0.0.302

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/build/index.js CHANGED
@@ -7993,7 +7993,9 @@ var normalizeString = function (str) {
7993
7993
  * ```
7994
7994
  */
7995
7995
  var renderChargedValue = function (value, cte, feeName) {
7996
+ var _a;
7996
7997
  var numericValue = typeof value === 'string' ? parseFloat(value) : value;
7998
+ console.log('🔍 renderChargedValue - feeName:', feeName, 'value:', numericValue);
7997
7999
  if (isNaN(numericValue)) {
7998
8000
  return 'R$ 0,00';
7999
8001
  }
@@ -8001,30 +8003,46 @@ var renderChargedValue = function (value, cte, feeName) {
8001
8003
  var formattedValue = convertNumberToCurrency(numericValue, 'pt-br');
8002
8004
  // Se não houver CTE ou ratecard, retornar apenas o valor formatado
8003
8005
  if (!cte) {
8006
+ console.log('⚠️ CTE não fornecido');
8004
8007
  return formattedValue;
8005
8008
  }
8006
8009
  // Buscar ratecard (pode estar em Ratecard ou ratecard)
8007
8010
  var ratecard = getRatecardFromCte(cte);
8011
+ console.log('🔍 Ratecard encontrado:', ratecard ? 'SIM' : 'NÃO');
8008
8012
  if (!ratecard || !ratecard.ratecard_config_values) {
8013
+ console.log('⚠️ Ratecard ou ratecard_config_values não encontrado');
8014
+ console.log(' - ratecard:', !!ratecard);
8015
+ console.log(' - ratecard_config_values:', ratecard === null || ratecard === void 0 ? void 0 : ratecard.ratecard_config_values);
8009
8016
  return formattedValue;
8010
8017
  }
8011
8018
  // Buscar configurações do ratecard
8012
8019
  var configs = ratecard.ratecard_config_values;
8020
+ console.log('✅ Configurações encontradas:', configs.length);
8013
8021
  // Verificar se o rateio de ICMS está habilitado
8014
8022
  var icmsApportionmentConfig = configs.find(function (config) { var _a; return ((_a = config.ratecard_configs) === null || _a === void 0 ? void 0 : _a.configKey) === exports.RatecardConfigKeyEnum.ICMS_APPORTIONMENT_ENABLED; });
8023
+ console.log('🔍 Config ICMS encontrada:', icmsApportionmentConfig);
8024
+ console.log(' - configKey:', (_a = icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.ratecard_configs) === null || _a === void 0 ? void 0 : _a.configKey);
8025
+ console.log(' - configValue:', icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.configValue);
8015
8026
  var isIcmsApportionmentEnabled = (icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.configValue) === 'true';
8027
+ console.log('🔍 ICMS rateio habilitado:', isIcmsApportionmentEnabled);
8028
+ console.log('🔍 feeName contém ICMS:', feeName === null || feeName === void 0 ? void 0 : feeName.toUpperCase().includes('ICMS'));
8016
8029
  // Se for ICMS e o rateio estiver habilitado, calcular e mostrar o rateio
8017
8030
  if (isIcmsApportionmentEnabled && (feeName === null || feeName === void 0 ? void 0 : feeName.toUpperCase().includes('ICMS'))) {
8031
+ console.log('✅ Aplicando rateio de ICMS');
8018
8032
  // Obter a alíquota de ICMS do CTE (icmsIncidence já vem em decimal, ex: 0.12 para 12%)
8019
8033
  var icmsRate = cte.icmsIncidence ? Number(cte.icmsIncidence) : 0.12; // Default 12%
8034
+ console.log(' - icmsRate:', icmsRate);
8020
8035
  // Calcular o ICMS baseado no valor cobrado
8021
8036
  // A função calculateIcms espera um array de valores e a alíquota
8022
8037
  var icmsResult = calculateIcms([numericValue], icmsRate);
8038
+ console.log(' - icmsResult.total:', icmsResult.total);
8023
8039
  // Valor cobrado menos o ICMS calculado
8024
8040
  var valueAfterIcms = numericValue - icmsResult.total;
8025
8041
  var formattedValueAfterIcms = convertNumberToCurrency(valueAfterIcms, 'pt-br');
8026
8042
  var formattedIcms = convertNumberToCurrency(icmsResult.total, 'pt-br');
8027
- return "".concat(formattedValue, " - ").concat(formattedIcms, " = ").concat(formattedValueAfterIcms, " (rateado)");
8043
+ var result = "".concat(formattedValue, " - ").concat(formattedIcms, " = ").concat(formattedValueAfterIcms, " (rateado)");
8044
+ console.log(' - resultado:', result);
8045
+ return result;
8028
8046
  }
8029
8047
  // Aqui você pode adicionar outras lógicas baseadas em outras configurações
8030
8048
  // Por exemplo, se houver configuração de arredondamento, aplicar aqui
package/build/index.js.gz CHANGED
Binary file