fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
export type IvaIssue = {
|
||||
category: 'missing_field' | 'invalid_value' | 'out_of_scope' | 'period_unavailable' | 'system_configuration';
|
||||
category:
|
||||
| 'missing_field'
|
||||
| 'invalid_value'
|
||||
| 'out_of_scope'
|
||||
| 'period_unavailable'
|
||||
| 'system_configuration';
|
||||
field: string | null;
|
||||
label: string;
|
||||
received: unknown;
|
||||
@@ -10,16 +15,36 @@ export type IvaDiagnostic = {
|
||||
label: string;
|
||||
rule_version: number;
|
||||
validity: { start: string; end: string | null };
|
||||
source: { title?: string; diploma?: string; article?: string; url?: string };
|
||||
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',
|
||||
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';
|
||||
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}`;
|
||||
|
||||
Reference in New Issue
Block a user