Merge branch 'feature/#75_revisar_monto_descuento' into 'develop'
revisar monto descuento y filtros See merge request !69
Showing
5 changed files
with
38 additions
and
7 deletions
@@ -7,7 +7,7 @@ from rest_framework.decorators import action | @@ -7,7 +7,7 @@ from rest_framework.decorators import action | ||
7 | from core.serializers import ActionSerializer | 7 | from core.serializers import ActionSerializer |
8 | from rest_framework.response import Response | 8 | from rest_framework.response import Response |
9 | 9 | ||
10 | -from .filters import EdictoFilter, PrecioFilter | 10 | +from .filters import EdictoFilter, PrecioFilter, ComprobanteFilter |
11 | from .models import Edicto, Precio, ComprobantePago | 11 | from .models import Edicto, Precio, ComprobantePago |
12 | from .permissions import IsAdminOrAuthorized | 12 | from .permissions import IsAdminOrAuthorized |
13 | from .serializers import EdictoSerializer, PrecioSerializer, ComprobanteSerializer | 13 | from .serializers import EdictoSerializer, PrecioSerializer, ComprobanteSerializer |
@@ -63,7 +63,9 @@ class ComprobanteViewSet(mixins.UpdateModelMixin, | @@ -63,7 +63,9 @@ class ComprobanteViewSet(mixins.UpdateModelMixin, | ||
63 | serializer_class = ComprobanteSerializer | 63 | serializer_class = ComprobanteSerializer |
64 | permission_classes = [IsAuthenticated, ] | 64 | permission_classes = [IsAuthenticated, ] |
65 | queryset = ComprobantePago.objects.all() | 65 | queryset = ComprobantePago.objects.all() |
66 | - ordering_fields = ('edicto',) | 66 | + filter_backends = (DjangoFilterBackend, filters.OrderingFilter) |
67 | + filter_class = ComprobanteFilter | ||
68 | + ordering_fields = ('monto_descuento', 'monto_total', 'fecha_pago') | ||
67 | ordering = 'id' | 69 | ordering = 'id' |
68 | 70 | ||
69 | 71 |
1 | from django_filters import rest_framework as filters | 1 | from django_filters import rest_framework as filters |
2 | from django.db.models import Q | 2 | from django.db.models import Q |
3 | 3 | ||
4 | -from edicto.models import Edicto, Precio | 4 | +from edicto.models import Edicto, Precio, ComprobantePago |
5 | 5 | ||
6 | 6 | ||
7 | class EdictoFilter(filters.FilterSet): | 7 | class EdictoFilter(filters.FilterSet): |
@@ -38,5 +38,14 @@ class PrecioFilter(filters.FilterSet): | @@ -38,5 +38,14 @@ class PrecioFilter(filters.FilterSet): | ||
38 | } | 38 | } |
39 | 39 | ||
40 | 40 | ||
41 | +class ComprobanteFilter(filters.FilterSet): | ||
41 | 42 | ||
42 | - | 43 | + class Meta: |
44 | + model = ComprobantePago | ||
45 | + fields = { | ||
46 | + 'monto_descuento': ['contains'], | ||
47 | + 'monto_total': ['contains'], | ||
48 | + 'edicto': ['exact'], | ||
49 | + 'fecha_pago': ['exact'], | ||
50 | + 'numero_comprobante': ['exact'], | ||
51 | + } |
1 | +# Generated by Django 4.1.9 on 2023-10-06 12:45 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + dependencies = [ | ||
9 | + ('edicto', '0004_alter_precio_usuario'), | ||
10 | + ] | ||
11 | + | ||
12 | + operations = [ | ||
13 | + migrations.AlterField( | ||
14 | + model_name='edicto', | ||
15 | + name='estado', | ||
16 | + field=models.CharField(choices=[('iniciado', 'iniciado'), ('pendiente_de_pago', 'pendiente_de_pago'), ('pendiente_pago_revision', 'pendiente_pago_revision'), ('publicado', 'publicado'), ('aprobado', 'aprobado'), ('rechazado', 'rechazado')], default='iniciado', max_length=23), | ||
17 | + ), | ||
18 | + ] |
@@ -10,7 +10,7 @@ from .constants import STATUS_CHOICE, MONEDA | @@ -10,7 +10,7 @@ from .constants import STATUS_CHOICE, MONEDA | ||
10 | 10 | ||
11 | 11 | ||
12 | class Precio(models.Model): | 12 | class Precio(models.Model): |
13 | - precio = models.FloatField(max_length=50, blank=False, null=False) | 13 | + precio = models.FloatField(max_length=50, blank=False, null=False, editable=False) |
14 | vigencia_desde = models.DateField() | 14 | vigencia_desde = models.DateField() |
15 | vigencia_hasta = models.DateField(blank=True, null=True) | 15 | vigencia_hasta = models.DateField(blank=True, null=True) |
16 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE, editable=False) | 16 | usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE, editable=False) |
@@ -37,7 +37,7 @@ class Edicto(models.Model): | @@ -37,7 +37,7 @@ class Edicto(models.Model): | ||
37 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/") | 37 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/") |
38 | dias_publicar = models.PositiveIntegerField() | 38 | dias_publicar = models.PositiveIntegerField() |
39 | cantidad_sellos = models.PositiveIntegerField() | 39 | cantidad_sellos = models.PositiveIntegerField() |
40 | - estado = models.CharField(max_length=23, choices=STATUS_CHOICE, default='inciado') | 40 | + estado = models.CharField(max_length=23, choices=STATUS_CHOICE, default='iniciado') |
41 | cantidad_palabras = models.IntegerField(editable=False) | 41 | cantidad_palabras = models.IntegerField(editable=False) |
42 | cantidad_copias = models.PositiveIntegerField() | 42 | cantidad_copias = models.PositiveIntegerField() |
43 | observaciones = models.CharField(max_length=500, blank=True) | 43 | observaciones = models.CharField(max_length=500, blank=True) |
@@ -20,12 +20,14 @@ def calculadora(edicto, precio): | @@ -20,12 +20,14 @@ def calculadora(edicto, precio): | ||
20 | 20 | ||
21 | if descuento: | 21 | if descuento: |
22 | resultado = (50 * subtotal) / 100 | 22 | resultado = (50 * subtotal) / 100 |
23 | + monto_descuento = resultado | ||
23 | else: | 24 | else: |
24 | resultado = subtotal | 25 | resultado = subtotal |
26 | + monto_descuento = 0 | ||
25 | 27 | ||
26 | comprobante = ComprobantePago(monto_total=resultado, | 28 | comprobante = ComprobantePago(monto_total=resultado, |
27 | monto_subtotal=subtotal, | 29 | monto_subtotal=subtotal, |
28 | - monto_descuento=resultado, | 30 | + monto_descuento=monto_descuento, |
29 | edicto=edicto) | 31 | edicto=edicto) |
30 | comprobante.save() | 32 | comprobante.save() |
31 | 33 |
-
Please register or login to post a comment