Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Django AFIP
https://github.com/whynothugo/django-afip
Admin
⚖️ AFIP invoice integration for django.
Tokens:
1,161
Snippets:
15
Trust Score:
8.1
License:
ISC
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install django-afip via pip Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Instructions for installing the django-afip Python package using the pip package installer. Mentions additional dependencies for PDF generation using weasyprint. ```sh pip install django-afip ``` -------------------------------- ### Specify django-afip version in requirements Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Example of how to pin the version of the django-afip dependency in a requirements file (like requirements.txt) using version constraints to follow semantic versioning. ```text django-afip>=8.0,< 9.0 ``` -------------------------------- ### Run django-afip database migrations Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Command to apply the necessary database schema changes for the django-afip application using Django's manage.py utility. This must be run in each environment. ```sh python manage.py migrate afip ``` -------------------------------- ### Add django-afip to INSTALLED_APPS Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Shows how to include the 'django_afip' application in the INSTALLED_APPS setting within a Django project's settings.py file to enable its functionality. ```python INSTALLED_APPS = ( ... 'django_afip', ... ) ``` -------------------------------- ### Load django-afip metadata fixtures Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Command to import essential metadata (like receipt and document types) required by django-afip from bundled fixtures into the database. This command is idempotent and should be run per database instance. ```sh python manage.py afipmetadata ``` -------------------------------- ### Accessing Package Version - Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet shows how to access the installed version of the django-afip package programmatically via a module attribute. ```Python django_afip.__version__ ``` -------------------------------- ### Configure django-afip storage settings Source: https://github.com/whynothugo/django-afip/blob/main/docs/installation.rst Lists optional Django settings for specifying custom storage backends for different types of files used by django-afip, such as keys, certificates, PDFs, and logos. Using custom storage is recommended for sensitive files like keys. ```python AFIP_KEY_STORAGE # Clave para autenticación con el AFIP. (TaxPayer.key) AFIP_CERT_STORAGE # Certificados para autenticación con el AFIP (TaxPayer.certificate) AFIP_PDF_STORAGE # PDFs generados para comprobantes (ReceiptPDF.pdf_file) AFIP_LOGO_STORAGE # Logos usados para comprobantes (TaxPayer.logo) ``` -------------------------------- ### Build Documentation using Tox (Shell) Source: https://github.com/whynothugo/django-afip/blob/main/README.rst This command uses the 'tox' automation tool to build the project's documentation. The '-e docs' flag specifies the 'docs' environment configured in the tox configuration file, which typically includes the necessary dependencies and steps to generate the documentation. ```sh tox -e docs ``` -------------------------------- ### Customizing Django AFIP PDF Download View (Python) Source: https://github.com/whynothugo/django-afip/blob/main/CHANGELOG.rst This Python class demonstrates how to create a custom view inheriting from `ReceiptPDFView` to force browsers to prompt for file download and customize the downloaded filename. This replaces the removed `ReceiptPDFDownloadView`. ```python class MyPDFReceiptView(ReceiptPDFView): """Indicates to browsers that they should prompt to download the file.""" prompt_download = True @property def download_name(self): # You can customise the filename here. # This is the default behaviour: return f"{self.receipt.formatted_number}.pdf" ``` -------------------------------- ### Creating Receipt PDF - Django/Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet refers to the ReceiptPDF.create_for_receipt method, indicating that the 'profile' parameter has been removed from its signature. ```Python ReceiptPDF.create_for_receipt ``` -------------------------------- ### Accessing AFIP Debug Setting - Django/Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet refers to the settings.AFIP_DEBUG setting, noting that it has been dropped and is no longer used. The is_sandboxed flag on the TaxPayer model should now be used instead, updated based on the setting's previous value. ```Python settings.AFIP_DEBUG ``` -------------------------------- ### Customizing Receipt PDF Download View in Django Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This Python snippet demonstrates how to create a custom Django view inheriting from `ReceiptPDFView` to control the download behavior of a receipt PDF. By setting `prompt_download = True`, the browser is instructed to prompt the user to download the file instead of displaying it inline. The `download_name` property can be overridden to customize the suggested filename for the downloaded PDF, defaulting to the formatted receipt number. ```python class MyPDFReceiptView(ReceiptPDFView): """Indicates to browsers that they should prompt to download the file.""" prompt_download = True @property def download_name(self): # You can customise the filename here. # This is the default behaviour: return f"{self.receipt.formatted_number}.pdf" ``` -------------------------------- ### Validating Multiple Receipts (Queryset) - Django/Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet demonstrates the new method for validating multiple Receipt instances by calling the validate() method directly on a filtered queryset. This replaces the old ReceiptBatch model validation process. ```Python Receipt.objects.filter(...).validate() ``` -------------------------------- ### Authorizing AuthTicket - Django/Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet refers to the AuthTicket.authorize method, noting that it no longer accepts a 'save' argument. Authorized tickets are now always saved immediately upon calling this method. ```Python AuthTicket.authorize ``` -------------------------------- ### Accessing Formatted Receipt Number - Django/Python Source: https://github.com/whynothugo/django-afip/blob/main/docs/changelog.rst This snippet shows how to access the formatted number for a Receipt instance using the formatted_number attribute. This attribute replaces the now deprecated receiptnumber template tag. ```Python Receipt.formatted_number ```