b2m-utils 0.0.303 → 0.0.305
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.esm.js +8 -27
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +8 -27
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -7976,9 +7976,7 @@ var normalizeString = function (str) {
|
|
|
7976
7976
|
* ```
|
|
7977
7977
|
*/
|
|
7978
7978
|
var renderChargedValue = function (value, cte, feeName) {
|
|
7979
|
-
var _a;
|
|
7980
7979
|
var numericValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
7981
|
-
console.log('🔍 renderChargedValue - feeName:', feeName, 'value:', numericValue);
|
|
7982
7980
|
if (isNaN(numericValue)) {
|
|
7983
7981
|
return 'R$ 0,00';
|
|
7984
7982
|
}
|
|
@@ -7986,46 +7984,29 @@ var renderChargedValue = function (value, cte, feeName) {
|
|
|
7986
7984
|
var formattedValue = convertNumberToCurrency(numericValue, 'pt-br');
|
|
7987
7985
|
// Se não houver CTE ou ratecard, retornar apenas o valor formatado
|
|
7988
7986
|
if (!cte) {
|
|
7989
|
-
console.log('⚠️ CTE não fornecido');
|
|
7990
7987
|
return formattedValue;
|
|
7991
7988
|
}
|
|
7992
7989
|
// Buscar ratecard (pode estar em Ratecard ou ratecard)
|
|
7993
7990
|
var ratecard = getRatecardFromCte(cte);
|
|
7994
|
-
console.log('🔍 Ratecard encontrado:', ratecard ? 'SIM' : 'NÃO');
|
|
7995
7991
|
if (!ratecard || !ratecard.ratecard_config_values) {
|
|
7996
|
-
console.log('⚠️ Ratecard ou ratecard_config_values não encontrado');
|
|
7997
|
-
console.log(' - ratecard:', !!ratecard);
|
|
7998
|
-
console.log(' - ratecard_config_values:', ratecard === null || ratecard === void 0 ? void 0 : ratecard.ratecard_config_values);
|
|
7999
7992
|
return formattedValue;
|
|
8000
7993
|
}
|
|
8001
7994
|
// Buscar configurações do ratecard
|
|
8002
7995
|
var configs = ratecard.ratecard_config_values;
|
|
8003
|
-
console.log('✅ Configurações encontradas:', configs.length);
|
|
8004
7996
|
// Verificar se o rateio de ICMS está habilitado
|
|
8005
7997
|
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; });
|
|
8006
|
-
console.log('🔍 Config ICMS encontrada:', icmsApportionmentConfig);
|
|
8007
|
-
console.log(' - configKey:', (_a = icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.ratecard_configs) === null || _a === void 0 ? void 0 : _a.configKey);
|
|
8008
|
-
console.log(' - configValue:', icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.configValue);
|
|
8009
7998
|
var isIcmsApportionmentEnabled = (icmsApportionmentConfig === null || icmsApportionmentConfig === void 0 ? void 0 : icmsApportionmentConfig.configValue) === 'true';
|
|
8010
|
-
console.log('🔍 ICMS rateio habilitado:', isIcmsApportionmentEnabled);
|
|
8011
|
-
console.log('🔍 feeName contém ICMS:', feeName === null || feeName === void 0 ? void 0 : feeName.toUpperCase().includes('ICMS'));
|
|
8012
7999
|
// Se for ICMS e o rateio estiver habilitado, calcular e mostrar o rateio
|
|
8013
8000
|
if (isIcmsApportionmentEnabled) {
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
var icmsResult = calculateIcms([numericValue], icmsRate);
|
|
8021
|
-
console.log(' - icmsResult.total:', icmsResult.total);
|
|
8022
|
-
// Valor cobrado menos o ICMS calculado
|
|
8023
|
-
var valueAfterIcms = numericValue - icmsResult.total;
|
|
8001
|
+
// Obter a alíquota de ICMS do CTE (icmsIncidence vem como número, ex: 7 para 7%)
|
|
8002
|
+
var icmsIncidence = cte.icmsIncidence ? Number(cte.icmsIncidence) : 12; // Default 12%
|
|
8003
|
+
// Calcular: valor * (100 - icmsIncidence) / 100
|
|
8004
|
+
// Exemplo: 5,42 * (100 - 7) / 100 = 5,42 * 0,93 = 5,04
|
|
8005
|
+
var multiplier = (100 - icmsIncidence) / 100;
|
|
8006
|
+
var valueAfterIcms = numericValue * multiplier;
|
|
8024
8007
|
var formattedValueAfterIcms = convertNumberToCurrency(valueAfterIcms, 'pt-br');
|
|
8025
|
-
var
|
|
8026
|
-
|
|
8027
|
-
console.log(' - resultado:', result);
|
|
8028
|
-
return result;
|
|
8008
|
+
var percentageToShow = (100 - icmsIncidence);
|
|
8009
|
+
return "".concat(formattedValue, " x ").concat(percentageToShow, "% = ").concat(formattedValueAfterIcms);
|
|
8029
8010
|
}
|
|
8030
8011
|
// Aqui você pode adicionar outras lógicas baseadas em outras configurações
|
|
8031
8012
|
// Por exemplo, se houver configuração de arredondamento, aplicar aqui
|
package/build/index.js.gz
CHANGED
|
Binary file
|