-
Notifications
You must be signed in to change notification settings - Fork 15
Add CNPJ alphanumeric #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/bradesco
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
|
|
||
|
|
||
| numeric = "numeric" | ||
| alphaNumeric = "alphaNumeric" | ||
| alphaNumeric = "alphaNumeric" | ||
| alphaNumericRightAligned = "alphaNumericRightAligned" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| from ....row import Row | ||
| from ....characterType import numeric, alphaNumeric | ||
| from ....characterType import numeric, alphaNumeric, alphaNumericRightAligned | ||
|
|
||
|
|
||
| class SegmentQ: | ||
|
|
@@ -38,7 +38,7 @@ def setPositionInLot(self, index): | |
| def setPayer(self, user): | ||
| structs = [ | ||
| (17, 18, 1, numeric, "1" if len(user.identifier) == 11 else "2"), # 1 - CPF/ 2 - CNPJ | ||
| (18, 33, 15, numeric, user.identifier), # CPF/CNPJ do Pagador | ||
| (18, 33, 15, alphaNumericRightAligned, user.identifier), # CPF/CNPJ do Pagador | ||
| (33, 63, 30, alphaNumeric, user.name) # Nome do Pagador | ||
| ] | ||
| self.content = Row.setStructs(structs=structs, content=self.content) | ||
|
|
@@ -56,7 +56,7 @@ def setPayerAddress(self, address): | |
| def setGuarantor(self, user): | ||
| structs = [ | ||
| (153, 154, 1, numeric, "1" if len(user.identifier) == 11 else "2"), # 1 - CPF/ 2 - CNPJ | ||
| (154, 169, 15, numeric, user.identifier), # CPF/CNPJ do Sacador Avalista | ||
| (154, 169, 15, alphaNumericRightAligned, user.identifier), # CPF/CNPJ do Sacador Avalista | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alinhar o comentario |
||
| (169, 199, 30, alphaNumeric, user.name) # Nome do Sacador Avalista | ||
| ] | ||
| self.content = Row.setStructs(structs=structs, content=self.content) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| from .libs.middlewares.row import validateFormatter | ||
| from .characterType import numeric, alphaNumeric | ||
| from .characterType import numeric, alphaNumeric, alphaNumericRightAligned | ||
|
|
||
|
|
||
| class Row: | ||
|
|
@@ -11,7 +11,7 @@ def setStructs(cls, structs, content): | |
| string=str(value), | ||
| charactersType=type, | ||
| numberOfCharacters=len, | ||
| defaultCharacter={numeric: "0", alphaNumeric: " "}[type] | ||
| defaultCharacter={numeric: "0", alphaNumeric: " ", alphaNumericRightAligned: "0"}[type] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. para alfanumerico é para completar com espaço e não com zero. Zero é usado somente para o numerico |
||
| ) | ||
| content = content[:start] + replacement + content[start+len:] | ||
| return content | ||
|
|
@@ -25,14 +25,13 @@ def __formatted(cls, string, charactersType, numberOfCharacters, defaultCharacte | |
|
|
||
| Args: | ||
| string: String to be completed | ||
| charactersType: Can be .numeric or .alphaNumeric | ||
| charactersType: Can be .numeric, .alphaNumeric or .alphaNumericRightAligned | ||
| numberOfCharacters: Integer that represents the max string len | ||
| defaultCharacter: Single string with default character to be completed if string is short | ||
| Returns: | ||
| String formatted | ||
| """ | ||
| if type(string) != str: return defaultCharacter * numberOfCharacters | ||
| if len(string) > numberOfCharacters: return string[:numberOfCharacters] | ||
| if charactersType == numeric: return defaultCharacter * (numberOfCharacters - len(string)) + string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. porque foi removido essa condicional ? |
||
| if charactersType == alphaNumeric: return string + defaultCharacter * (numberOfCharacters - len(string)) | ||
| return string | ||
| if type(string) != str: return defaultCharacter * numberOfCharacters | ||
| if len(string) > numberOfCharacters: return string[:numberOfCharacters] | ||
| if charactersType == alphaNumeric: return string + defaultCharacter * (numberOfCharacters - len(string)) | ||
| return defaultCharacter * (numberOfCharacters - len(string)) + string | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comentario desalinhado