Showing
3 changed files
with
18 additions
and
5 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 | + } |
@@ -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