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