feat(bloco-c): motor fiscal com legal_basis obrigatorio, classificacao NCM, seguranca CEST/IPI e validador GTIN

This commit is contained in:
gti
2026-09-28 16:28:15 -03:00
parent cf5bb64d9b
commit d383332150
5 changed files with 322 additions and 12 deletions
+7 -1
View File
@@ -49,8 +49,14 @@ class Classifier:
status, candidate = "EXACT_NCM", exact
elif legacy:
status, candidate = "LEGACY_NCM", None
elif not code:
status, candidate = self._candidate(entries, product.get("description"))
elif len(set(code)) == 1 or code in ("00000000", "99999999", "11111111", "000000"):
status, candidate = "PLACEHOLDER_NCM", None
elif len(code) != 8 or code in ("12345678", "87654321"):
status, candidate = "INVALID_FORMAT_NCM", None
else:
status, candidate = ("INVALID_NCM", None) if code else self._candidate(entries, product.get("description"))
status, candidate = "OUT_OF_TABLE_NCM", None
matched_code = candidate.code if candidate else legacy["code"] if legacy else None
cests_available = matched_code and hasattr(self.repository, "cest_for_ncm")
cests = self.repository.cest_for_ncm(matched_code) if cests_available else None