fix: explain IVA query conditions and distinguish integration failures
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export type IvaIssue = {
|
||||
category: 'missing_field' | 'invalid_value' | 'out_of_scope' | 'period_unavailable' | 'system_configuration';
|
||||
field: string | null;
|
||||
label: string;
|
||||
received: unknown;
|
||||
expected: string;
|
||||
message: string;
|
||||
};
|
||||
export type IvaDiagnostic = {
|
||||
label: string;
|
||||
rule_version: number;
|
||||
validity: { start: string; end: string | null };
|
||||
source: { title?: string; diploma?: string; article?: string; url?: string };
|
||||
issues: IvaIssue[];
|
||||
};
|
||||
export const ivaIssueCategories = {
|
||||
missing_field: 'Campo em falta', invalid_value: 'Valor inválido', out_of_scope: 'Fora do âmbito',
|
||||
period_unavailable: 'Regra indisponível para o período', system_configuration: 'Configuração do sistema',
|
||||
};
|
||||
export function ivaReceived(value: unknown): string {
|
||||
const labels: Record<string, string> = { domestic: 'Operação interna', internal_general_net: 'Operação interna à taxa geral, sobre base líquida', import: 'Importação', export: 'Exportação', refund: 'Reembolso', unknown: 'Não sei', non_resident: 'Operação com não residente', other: 'Outra operação' };
|
||||
return typeof value === 'string' && value !== '' ? (labels[value] ?? value) : 'Não recebido';
|
||||
}
|
||||
export function ivaIssueText(issue: IvaIssue): string {
|
||||
return `${issue.label}: ${ivaIssueCategories[issue.category]}. Recebido: ${ivaReceived(issue.received)}. Esperado: ${issue.expected}. ${issue.message}`;
|
||||
}
|
||||
@@ -965,6 +965,12 @@ export const simulationFieldGroups: Record<
|
||||
},
|
||||
],
|
||||
tax: [
|
||||
{
|
||||
key: 'fiscal_currency',
|
||||
label: 'Moeda da operação fiscal (sem conversão automática)',
|
||||
options: 'currency',
|
||||
showWhen: (d) => d.fiscal_component === 'iva' && d.fiscal_scenario_mode !== 'custom_planning',
|
||||
},
|
||||
{
|
||||
key: 'fiscal_period',
|
||||
label: 'Ano do período fiscal a simular',
|
||||
|
||||
Reference in New Issue
Block a user