-
-
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
Open
manusturla
wants to merge
2
commits into
WhyNotHugo:main
Choose a base branch
from
manusturla:client-vat-condition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -21,3 +21,6 @@ test2.csr | |
|
|
||
| # Created by tests: | ||
| /media/ | ||
|
|
||
| # venv | ||
| .venv/ | ||
This file contains hidden or 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 hidden or 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,65 @@ | ||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 16 | ||
| description: "Monotributo Trabajador Independiente Promovido" | ||
| cmp_clase: "A/M/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 15 | ||
| description: "IVA No Alcanzado" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 13 | ||
| description: "Monotributista Social" | ||
| cmp_clase: "A/M/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 10 | ||
| description: "IVA Liberado – Ley N° 19.640" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 9 | ||
| description: "Cliente del Exterior" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 8 | ||
| description: "Proveedor del Exterior" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 7 | ||
| description: "Sujeto No Categorizado" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 6 | ||
| description: "Responsable Monotributo" | ||
| cmp_clase: "A/M/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 5 | ||
| description: "Consumidor Final" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 4 | ||
| description: "IVA Sujeto Exento" | ||
| cmp_clase: "B/C" | ||
|
|
||
| - model: afip.clientvatcondition | ||
| fields: | ||
| code: 1 | ||
| description: "IVA Responsable Inscripto" | ||
| cmp_clase: "A/M/C" |
42 changes: 42 additions & 0 deletions
42
django_afip/management/commands/load_client_vat_conditions.py
This file contains hidden or 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,42 @@ | ||
| 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!")) | ||
32 changes: 32 additions & 0 deletions
32
django_afip/migrations/0016_clientvatcondition_receipt_client_vat_condition.py
This file contains hidden or 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,32 @@ | ||
| # Generated by Django 5.1.6 on 2025-02-26 14:09 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('afip', '0015_alter_taxpayer_logo'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='ClientVatCondition', | ||
| fields=[ | ||
| ('code', models.IntegerField(primary_key=True, serialize=False, verbose_name='code')), | ||
| ('description', models.CharField(max_length=48, verbose_name='description')), | ||
| ('cmp_clase', models.CharField(help_text='Receipt class this VAT condition applies to (A, B, C, or M).', max_length=5, verbose_name='cmp clase')), | ||
| ], | ||
| options={ | ||
| 'verbose_name': 'Client VAT condition', | ||
| 'verbose_name_plural': 'Client VAT conditions', | ||
| 'unique_together': {('code', 'cmp_clase')}, | ||
| }, | ||
| ), | ||
| migrations.AddField( | ||
| model_name='receipt', | ||
| name='client_vat_condition', | ||
| field=models.ForeignKey(help_text='The VAT condition of the recipient of this receipt. It should match the receipt type.', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='receipts', to='afip.clientvatcondition', verbose_name='client vat condition'), | ||
| ), | ||
| ] |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -94,6 +94,7 @@ def serialize_receipt(receipt: Receipt): # noqa: ANN201 | |
| ImpTrib=sum(tax.amount for tax in taxes), | ||
| MonId=receipt.currency.code, | ||
| MonCotiz=receipt.currency_quote, | ||
| CondicionIVAReceptorId=receipt.client_vat_condition.code, | ||
|
Owner
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. Crashes if |
||
| ) | ||
| if int(receipt.concept.code) in (2, 3): | ||
| serialized.FchServDesde = serialize_date(receipt.service_start) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.