Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Marta Miranda
/
boletin_api
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Enzo Yair
2023-10-06 07:23:47 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
22aefb376aeb60103c1ac91d77a08d3f0d029f53
22aefb37
1 parent
7d1fb800
revisar monto descuento y filtros
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
project/apps/edicto/api.py
project/apps/edicto/filters.py
project/apps/edicto/precio.py
project/apps/edicto/api.py
View file @
22aefb3
...
...
@@ -7,7 +7,7 @@ from rest_framework.decorators import action
from
core.serializers
import
ActionSerializer
from
rest_framework.response
import
Response
from
.filters
import
EdictoFilter
,
PrecioFilter
from
.filters
import
EdictoFilter
,
PrecioFilter
,
ComprobanteFilter
from
.models
import
Edicto
,
Precio
,
ComprobantePago
from
.permissions
import
IsAdminOrAuthorized
from
.serializers
import
EdictoSerializer
,
PrecioSerializer
,
ComprobanteSerializer
...
...
@@ -63,7 +63,9 @@ class ComprobanteViewSet(mixins.UpdateModelMixin,
serializer_class
=
ComprobanteSerializer
permission_classes
=
[
IsAuthenticated
,
]
queryset
=
ComprobantePago
.
objects
.
all
()
ordering_fields
=
(
'edicto'
,)
filter_backends
=
(
DjangoFilterBackend
,
filters
.
OrderingFilter
)
filter_class
=
ComprobanteFilter
ordering_fields
=
(
'monto_descuento'
,
'monto_total'
,
'fecha_pago'
)
ordering
=
'id'
...
...
project/apps/edicto/filters.py
View file @
22aefb3
from
django_filters
import
rest_framework
as
filters
from
django.db.models
import
Q
from
edicto.models
import
Edicto
,
Precio
from
edicto.models
import
Edicto
,
Precio
,
ComprobantePago
class
EdictoFilter
(
filters
.
FilterSet
):
...
...
@@ -38,5 +38,14 @@ class PrecioFilter(filters.FilterSet):
}
class
ComprobanteFilter
(
filters
.
FilterSet
):
class
Meta
:
model
=
ComprobantePago
fields
=
{
'monto_descuento'
:
[
'contains'
],
'monto_total'
:
[
'contains'
],
'edicto'
:
[
'exact'
],
'fecha_pago'
:
[
'exact'
],
'numero_comprobante'
:
[
'exact'
],
}
...
...
project/apps/edicto/precio.py
View file @
22aefb3
...
...
@@ -20,12 +20,14 @@ def calculadora(edicto, precio):
if
descuento
:
resultado
=
(
50
*
subtotal
)
/
100
monto_descuento
=
resultado
else
:
resultado
=
subtotal
monto_descuento
=
0
comprobante
=
ComprobantePago
(
monto_total
=
resultado
,
monto_subtotal
=
subtotal
,
monto_descuento
=
resultad
o
,
monto_descuento
=
monto_descuent
o
,
edicto
=
edicto
)
comprobante
.
save
()
...
...
Please
register
or
login
to post a comment