-
-
Notifications
You must be signed in to change notification settings - Fork 30
Add CondicionIVAReceptorId field #230
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: main
Are you sure you want to change the base?
Conversation
6f325ad to
2d6b590
Compare
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.
We need to add values for client_vat_condition to receipts created via factories. Once that is done, we can run tests on the testing environemnt with tox -e live.
| from __future__ import annotations | ||
|
|
||
| from django.core.management.base import BaseCommand | ||
| from django.utils.translation import gettext as _ | ||
|
|
||
| from django_afip import clients, models, serializers | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
| help = _( | ||
| "Retrieves all the ClientVatConditions from the AFIP server and updates it in the DB." | ||
| ) | ||
| requires_migrations_checks = True | ||
|
|
||
| def add_arguments(self, parser): | ||
| parser.add_argument( | ||
| "cuit", | ||
| type=int, | ||
| help=_("CUIT of the tax payer to be used to authenticate."), | ||
| ) | ||
|
|
||
| def handle(self, *args, **options) -> None: | ||
| from django_afip.models import TaxPayer | ||
|
|
||
| tax_payer = TaxPayer.objects.get(cuit=options["cuit"]) | ||
| ticket = tax_payer.get_or_create_ticket("wsfe") | ||
|
|
||
| client = clients.get_client("wsfe", sandbox=tax_payer.is_sandboxed) | ||
| response = client.service.FEParamGetCondicionIvaReceptor( | ||
| serializers.serialize_ticket(ticket), | ||
| ) | ||
|
|
||
| for condition in response.ResultGet.CondicionIvaReceptor: | ||
| models.ClientVatCondition.objects.get_or_create( | ||
| code=condition.Id, | ||
| defaults={ | ||
| "description": condition.Desc, | ||
| "cmp_clase": condition.Cmp_Clase, | ||
| }, | ||
| ) | ||
| self.stdout.write(self.style.SUCCESS(f"Loaded {condition.Desc}")) | ||
| self.stdout.write(self.style.SUCCESS("All done!")) |
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.
Esto debería ir en scripts/dump_metadata.py.
| ImpTrib=sum(tax.amount for tax in taxes), | ||
| MonId=receipt.currency.code, | ||
| MonCotiz=receipt.currency_quote, | ||
| CondicionIVAReceptorId=receipt.client_vat_condition.code, |
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.
Crashes if receipt.client_vat_condition is None.
Changes:
Receipt.client_vat_conditionFK to ClientVatCondition.CondicionIVAReceptorId=receipt.client_vat_condition.codetoserialize_receipt.load_client_vat_conditionscommand to retrieve ClientVatConditions from FEParamGetCondicionIvaReceptor and sync them.Potential improvements
I think that there are some improvements that could be made to this implementation:
cmp_clasefield of ClientVatCondition to ReceiptTypes.This implementation has an Issue
When serializing a Receipt in the
serialize_receiptfunction theFECAEDetRequestmethod will return this error:This is because the
Clientcreated asf = _LazyFactory()and used by the serializer is being created with the default parametersandbox=False. This causes the error because the parameterCondicionIVAReceptorIdis currently only available on Sandbox mode only.Related to: