Added Audit trail for Decision Tracking#5
Open
MaxMorais wants to merge 2 commits intoTencentBlueKing:mainfrom
Open
Added Audit trail for Decision Tracking#5MaxMorais wants to merge 2 commits intoTencentBlueKing:mainfrom
MaxMorais wants to merge 2 commits intoTencentBlueKing:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, I didn't know if is interesting for this project, but I did an small improvement on this library to include the full trace of an decision!
I'm using this project as part of https://github.com/techmaxsolucoes/motor_tributario_py
And I'm able to extract this kind of audit from each execution
{ "method_name": "calcula_icms", "inputs": { "tributavel": { "valor_produto": 100.0, "frete": 0.0, "seguro": 0.0, "outras_despesas": 0.0, "desconto": 0.0, "valor_ipi": 0.0, "quantidade_produto": 1.0, "is_servico": false, "is_ativo_imobilizado_ou_uso_consumo": false, "tipo_desconto": "Incondicional", "cst": "", "tipo_calculo_icms_desonerado": "", "crt": "", "tipo_operacao": "", "tipo_pessoa": "", "percentual_icms": 18.0, "percentual_reducao": 0.0, "percentual_ipi": 0.0, "percentual_pis": 1.65, "percentual_reducao_pis": 0.0, "percentual_cofins": 7.6, "percentual_reducao_cofins": 0.0, "percentual_icms_st": 0.0, "percentual_mva": 0.0, "percentual_reducao_st": 0.0, "percentual_fcp": 0.0, "percentual_fcp_st": 0.0, "percentual_credito": 0.0, "csosn": 0, "percentual_fcp_st_retido": 0.0, "valor_ultima_base_calculo_icms_st_retido": 0.0, "percentual_difal_interna": 0.0, "percentual_difal_interestadual": 0.0, "percentual_issqn": 0.0, "percentual_ret_pis": 0.0, "percentual_ret_cofins": 0.0, "percentual_ret_csll": 0.0, "percentual_ret_irrf": 0.0, "percentual_ret_inss": 0.0, "percentual_federal": 0.0, "percentual_estadual": 0.0, "percentual_municipal": 0.0, "percentual_federal_importados": 0.0, "percentual_ibs_uf": 0.0, "percentual_ibs_municipal": 0.0, "percentual_cbs": 0.0, "percentual_reducao_ibs_uf": 0.0, "percentual_reducao_ibs_municipal": 0.0, "percentual_reducao_cbs": 0.0, "documento": "", "percentual_icms_efetivo": 0.0, "percentual_reducao_icms_efetivo": 0.0, "quantidade_base_calculo_icms_monofasico": 0.0, "aliquota_ad_rem_icms": 0.0, "percentual_reducao_aliquota_ad_rem_icms": 0.0, "percentual_biodiesel": 0.0, "percentual_originario_uf": 0.0, "quantidade_base_calculo_icms_monofasico_retido_anteriormente": 0.0, "aliquota_ad_rem_icms_retido_anteriormente": 0.0, "somar_pis_na_base_ibs_cbs": false, "somar_cofins_na_base_ibs_cbs": false, "somar_icms_na_base_ibs_cbs": false, "somar_issqn_na_base_ibs_cbs": false, "percentual_diferimento": 0.0, "deduz_icms_da_base_de_pis_cofins": false }, "args": [], "kwargs": {} }, "result": { "base_calculo": 100.0, "valor": 18.0, "percentual_icms": 18.0, "percentual_reducao": 0.0, "percentual_icms_st": 0.0, "percentual_mva": 0.0, "base_calculo_st": null, "valor_icms_st": null, "percentual_reducao_st": 0.0, "percentual_diferimento": 0.0, "valor_icms_diferido": null, "valor_icms_operacao": null, "valor_bc_st_retido": 100.0, "base_calculo_icms_efetivo": null, "valor_icms_efetivo": null, "modalidade_determinacao_bc_icms": "ValorOperacao", "modalidade_determinacao_bc_icms_st": null }, "audit_trail": { "traces": [ { "table_title": "Full ICMS Calculation Rules", "facts": { "valor_produto": 100.0, "quantidade_produto": 1.0, "frete": 0.0, "seguro": 0.0, "outras_despesas": 0.0, "valor_ipi": 0.0, "is_ativo": false, "tipo_desconto": "Incondicional", "desconto": 0.0, "percentual_reducao": 0.0, "percentual_icms": 18.0 }, "matched_rules": [ 3 ], "rule_count": 4, "final_result": [ { "base_calculo": 100.0, "valor_final": 18.0 } ], "matched_rule_details": [ { "rule_number": 4, "input_conditions": { "is_ativo": "false", "tipo_desconto": "\"Incondicional\"" }, "output_calculations": { "base_calculo": { "expression": "( ( ( ( (valor_produto * quantidade_produto) + frete) + seguro) + outras_despesas) - desconto ) * (decimal(1) - (percentual_reducao / decimal(100)))", "evaluated": "( ( ( ( (100.00 * 1) + 0) + 0) + 0) - 0 ) * (decimal(1) - (0 / decimal(100)))", "result": 100.0 }, "valor_final": { "expression": "( ( ( ( ( ( (valor_produto * quantidade_produto) + frete) + seguro) + outras_despesas) - desconto ) * (decimal(1) - (percentual_reducao / decimal(100))) ) * percentual_icms) / decimal(100)", "evaluated": "( ( ( ( ( ( (100.00 * 1) + 0) + 0) + 0) - 0 ) * (decimal(1) - (0 / decimal(100))) ) * 18.0) / decimal(100)", "result": 18.0 } } } ] } ] } }