Skip to content

Implement Alphanumeric CNPJ Generation Feature - #3

Merged
edenalencar merged 3 commits into
masterfrom
copilot/fix-2
Sep 4, 2025
Merged

Implement Alphanumeric CNPJ Generation Feature#3
edenalencar merged 3 commits into
masterfrom
copilot/fix-2

Conversation

Copilot AI commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

This PR implements the new Brazilian alphanumeric CNPJ generation feature, allowing users to generate both traditional numeric CNPJs and the new alphanumeric format that includes letters and numbers.

Changes Made

New Alphanumeric CNPJ Class

  • Created IdentificacaoCNPJAlfanumerico.cs that supports 33 valid characters (0-9, A-Z excluding I, O, U to avoid confusion with numbers)
  • Implements proper base-33 validation algorithm with correct check digit calculation
  • Maintains the same 14-character format as traditional CNPJs

Enhanced User Interface

  • Added radio button selection in the CNPJ page to choose between "Numérico" (traditional) and "Alfanumérico" (new format)
  • Updated the InfoBar to explain both CNPJ types
  • Enhanced accessibility with proper AutomationProperties for screen readers
  • Updated user feedback messages to indicate which type of CNPJ was generated

Updated Business Logic

  • Extended IdentificacaoFactory to support the new alphanumeric CNPJ type
  • Added CNPJ_ALFANUMERICO constant to Constantes.cs
  • Modified generation logic in CNPJPage.xaml.cs to handle both numeric and alphanumeric formats seamlessly
  • Maintained full backward compatibility with existing numeric CNPJ generation

Technical Implementation

The alphanumeric CNPJ uses a 33-character set excluding vowels I, O, U (standard practice to prevent confusion with digits 1, 0). The validation algorithm uses modular arithmetic with base-33 calculations for both check digits, following Brazilian alphanumeric CNPJ standards.

Example outputs:

Numeric:      12.345.678/0001-90
Alphanumeric: AB.C12.34D/0001-E5

Compatibility

  • ✅ Fully backward compatible with existing numeric CNPJ generation
  • ✅ Supports branch office generation for both formats
  • ✅ Maintains all existing formatting and quantity options
  • ✅ Preserves accessibility features

Fixes #2.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 4, 2025 20:12
Co-authored-by: edenalencar <7075481+edenalencar@users.noreply.github.com>
Co-authored-by: edenalencar <7075481+edenalencar@users.noreply.github.com>
Copilot AI changed the title [WIP] Nova Feature Implement Alphanumeric CNPJ Generation Feature Sep 4, 2025
Copilot AI requested a review from edenalencar September 4, 2025 20:15

@edenalencar edenalencar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementação do CNPJ Alfanumerico

@edenalencar
edenalencar marked this pull request as ready for review September 4, 2025 20:20
@edenalencar
edenalencar merged commit 1ef7b42 into master Sep 4, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nova Feature

2 participants