-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
293f098
commit e85cc30
Showing
10 changed files
with
569 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# About | ||
|
||
## Credits 🙌 | ||
This is a fork of the [nfe_utils](https://github.com/edsonbernar/nfe_utils) project, originally created by [Edson Bernardino](https://github.com/edsonbernar). | ||
|
||
## Feedback and Support 📬 | ||
For questions or support, feel free to open an issue or join the discussions in the repository. | ||
|
||
## Maintainer 🛠️ | ||
[![Engenere](https://storage.googleapis.com/eng-imagens/logo-fundo-preto.webp)]([#](https://engenere.one/)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
Generate DACTE, DANFE, and DACCE documents directly from the terminal. The PDF will be saved in the current directory, and you'll need to create a config.yaml file with issuer details and other configurations. | ||
|
||
#### Example of `config.yaml` ⚙️ | ||
|
||
```yaml | ||
ISSUER: | ||
name: "EMPRESA LTDA" | ||
address: "AV. TEST, 100" | ||
city: "SÃO PAULO" | ||
state: "SP" | ||
phone: "(11) 1234-5678" | ||
|
||
LOGO: "/path/to/logo.jpg" | ||
TOP_MARGIN: 5.0 | ||
RIGHT_MARGIN: 5.0 | ||
BOTTOM_MARGIN: 5.0 | ||
LEFT_MARGIN: 5.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# DACCe | ||
|
||
## Using in Python Code 🐍 | ||
|
||
```python | ||
from brazilfiscalreport.dacce import DaCCe | ||
|
||
# Path to the XML file | ||
xml_file_path = 'cce.xml' | ||
|
||
# Load XML Content | ||
with open(xml_file_path, "r", encoding="utf8") as file: | ||
xml_content = file.read() | ||
|
||
# Instantiate the CC-e PDF object with the loaded XML content | ||
cce = DaCCe(xml=xml_content) | ||
|
||
# Save the generated PDF to a file | ||
cce.output('cce.pdf') | ||
``` | ||
|
||
## Using in CLI 💻 | ||
|
||
``` | ||
bfrep dacce /path/to/cce_1.xml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
## Customizing DACTE 🎨 | ||
|
||
This section describes how to customize the PDF output of the DACTE using the `DacteConfig` class. You can adjust various settings such as margins, fonts, and tax configurations according to your needs. | ||
|
||
### Usage Example with Customization | ||
|
||
Here’s how to set up a DacteConfig object with a full set of customizations: | ||
|
||
```python | ||
from brazilfiscalreport.dacte import ( | ||
Dacte, | ||
DacteConfig, | ||
FontType, | ||
Margins, | ||
) | ||
|
||
# Path to the XML file | ||
xml_file_path = 'cte.xml' | ||
|
||
# Load XML Content | ||
with open(xml_file_path, "r", encoding="utf8") as file: | ||
xml_content = file.read() | ||
|
||
# Create a configuration instance | ||
config = DacteConfig( | ||
logo='path/to/logo.png', | ||
margins=Margins(top=10, right=10, bottom=10, left=10), | ||
font_type=FontType.TIMES | ||
) | ||
|
||
# Use this config when creating a Dacte instance | ||
dacte = Dacte(xml_content, config=config) | ||
dacte.output('output_dacte.pdf') | ||
``` | ||
## Using in Python Code 🐍 | ||
|
||
```python | ||
from brazilfiscalreport.dacte import ( | ||
Dacte, | ||
DacteConfig, | ||
FontType, | ||
Margins, | ||
) | ||
|
||
# Path to the XML file | ||
xml_file_path = 'cte.xml' | ||
|
||
# Load XML Content | ||
with open(xml_file_path, "r", encoding="utf8") as file: | ||
xml_content = file.read() | ||
|
||
# Create a configuration instance | ||
config = DacteConfig( | ||
logo='path/to/logo.png', | ||
margins=Margins(top=10, right=10, bottom=10, left=10), | ||
font_type=FontType.TIMES | ||
) | ||
|
||
# Use this config when creating a Dacte instance | ||
dacte = Dacte(xml_content, config=config) | ||
dacte.output('output_dacte.pdf') | ||
``` | ||
|
||
## Using in CLI 💻 | ||
|
||
``` | ||
bfrep dacte /path/to/dacte.xml | ||
``` | ||
|
||
### Configuration Options ⚙️ | ||
|
||
Here is a breakdown of all the configuration options available in `DacteConfig`: | ||
|
||
--- | ||
|
||
**Logo** | ||
|
||
- **Type**: `str`, `BytesIO`, or `bytes` | ||
- **Description**: Path to the logo file or binary image data to be included in the PDF. You can use a file path string or pass image data directly. | ||
- **Example**: | ||
```python | ||
config.logo = "path/to/logo.jpg" # Using a file path | ||
``` | ||
- **Default**: No logo. | ||
|
||
--- | ||
|
||
**Margins** | ||
|
||
- **Type**: `Margins` | ||
- **Fields**: `top`, `right`, `bottom`, `left` (all of type `Number`) | ||
- **Description**: Sets the page margins for the PDF document. | ||
- **Example**: | ||
```python | ||
config.margins = Margins(top=5, right=5, bottom=5, left=5) | ||
``` | ||
- **Default**: top, right, bottom, and left are set to 5 mm. | ||
|
||
--- | ||
|
||
**Font Type** | ||
|
||
- **Type**: `FontType` (Enum) | ||
- **Values**: `COURIER`, `TIMES` | ||
- **Description**: Font style used throughout the PDF document. | ||
- **Example**: | ||
```python | ||
config.font_type = FontType.COURIER | ||
``` | ||
- **Default**: `TIMES` | ||
|
||
--- | ||
|
||
**Display PIS COFINS** | ||
|
||
- **Type**: `Bool` | ||
- **Values**: `True`, `False` | ||
- **Description**: Whether or not to display PIS and COFINS taxes in the DACTE totals. | ||
- **Example**: | ||
```python | ||
config.display_pis_cofins = True | ||
``` | ||
- **Default**: `False` | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
## Customizing DAMDFE 🎨 | ||
|
||
This section describes how to customize the PDF output of the DAMDFE using the `DamdfeConfig` class. You can adjust various settings such as margins, fonts, and tax configurations according to your needs. | ||
|
||
### Usage Example with Customization | ||
|
||
Here’s how to set up a DamdfeConfig object with a full set of customizations: | ||
|
||
```python | ||
from brazilfiscalreport.damdfe import ( | ||
Damdfe, | ||
DacteConfig, | ||
FontType, | ||
Margins, | ||
) | ||
|
||
# Path to the XML file | ||
xml_file_path = 'mdf-e.xml' | ||
|
||
# Load XML Content | ||
with open(xml_file_path, "r", encoding="utf8") as file: | ||
xml_content = file.read() | ||
|
||
# Create a configuration instance | ||
config = DamdfeConfig( | ||
logo='path/to/logo.png', | ||
margins=Margins(top=10, right=10, bottom=10, left=10), | ||
font_type=FontType.TIMES | ||
) | ||
|
||
# Use this config when creating a Damdfe instance | ||
damdfe = Damdfe(xml_content, config=config) | ||
damdfe.output('output_dacte.pdf') | ||
``` | ||
## Using in Python Code 🐍 | ||
|
||
```python | ||
from brazilfiscalreport.damdfe import Damdfe | ||
|
||
# Path to the XML file | ||
xml_file_path = 'damdfe.xml' | ||
|
||
# Load XML Content | ||
with open(xml_file_path, "r", encoding="utf8") as file: | ||
xml_content = file.read() | ||
|
||
# Instantiate the DAMDFE object with the loaded XML content | ||
damdfe = Damdfe(xml=xml_content) | ||
|
||
# Save the generated PDF to a file | ||
damdfe.output('damdfe.pdf') | ||
``` | ||
|
||
### Configuration Options ⚙️ | ||
|
||
Here is a breakdown of all the configuration options available in `DamdfeConfig`: | ||
|
||
--- | ||
|
||
**Logo** | ||
|
||
- **Type**: `str`, `BytesIO`, or `bytes` | ||
- **Description**: Path to the logo file or binary image data to be included in the PDF. You can use a file path string or pass image data directly. | ||
- **Example**: | ||
```python | ||
config.logo = "path/to/logo.jpg" # Using a file path | ||
``` | ||
- **Default**: No logo. | ||
|
||
--- | ||
|
||
**Margins** | ||
|
||
- **Type**: `Margins` | ||
- **Fields**: `top`, `right`, `bottom`, `left` (all of type `Number`) | ||
- **Description**: Sets the page margins for the PDF document. | ||
- **Example**: | ||
```python | ||
config.margins = Margins(top=10, right=10, bottom=10, left=10) | ||
``` | ||
- **Default**: top, right, bottom, and left are set to 5 mm. | ||
|
||
--- | ||
|
||
**Font Type** | ||
|
||
- **Type**: `FontType` (Enum) | ||
- **Values**: `COURIER`, `TIMES` | ||
- **Description**: Font style used throughout the PDF document. | ||
- **Example**: | ||
```python | ||
config.font_type = FontType.COURIER | ||
``` | ||
- **Default**: `TIMES` | ||
|
||
--- |
Oops, something went wrong.