export RFC month timbres
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
from django.urls import path,include
|
from django.urls import path,include
|
||||||
from .views import index,add_timbre, timbres_cliente,saldo_funct,ClientesUpdateView
|
from .views import index,add_timbre, timbres_cliente,saldo_funct,ClientesUpdateView, export_Excel
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', index, name='index'),
|
path('', index, name='index'),
|
||||||
path('add_timbre/', add_timbre, name='add_timbre'),
|
path('add_timbre/', add_timbre, name='add_timbre'),
|
||||||
path('timbres_cliente/<str:RFC>/', timbres_cliente, name='timbres_cliente'),
|
path('timbres_cliente/<str:RFC>/', timbres_cliente, name='timbres_cliente'),
|
||||||
path('get_saldo/', saldo_funct, name='saldo_funct'),
|
path('get_saldo/', saldo_funct, name='saldo_funct'),
|
||||||
path('cliente/update/<int:pk>/',ClientesUpdateView.as_view(),name='update_cliente'),
|
path('cliente/update/<int:pk>/',ClientesUpdateView.as_view(),name='update_cliente'),
|
||||||
|
path('get_timbres_xls/', export_Excel, name='export_Excel'),
|
||||||
]
|
]
|
||||||
@@ -11,6 +11,11 @@ from .forms import ClienteForm
|
|||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||||
|
|
||||||
|
|
||||||
|
#EXCEL
|
||||||
|
from openpyxl import Workbook
|
||||||
|
from openpyxl.styles import Alignment, Border, Font, PatternFill, Side
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
||||||
@@ -148,4 +153,37 @@ class ClientesUpdateView(UserPassesTestMixin,LoginRequiredMixin,UpdateView):
|
|||||||
|
|
||||||
def test_func(self):
|
def test_func(self):
|
||||||
#self.request.user.groups.all()
|
#self.request.user.groups.all()
|
||||||
return self.request.user.groups.filter(name= 'admin_soft')
|
return self.request.user.groups.filter(name= 'admin_soft')
|
||||||
|
|
||||||
|
|
||||||
|
def export_Excel(request):
|
||||||
|
RFC = request.GET.get('RFC', '')
|
||||||
|
|
||||||
|
today = datetime.date.today()
|
||||||
|
month = today.month
|
||||||
|
year = today.year
|
||||||
|
|
||||||
|
objeto_a_trabajar = Timbres.objects.filter(rfcc=RFC, created_at__year=str(year),created_at__month=str(month))
|
||||||
|
wb = Workbook()
|
||||||
|
ws = wb.active
|
||||||
|
#contador = 1
|
||||||
|
ws['A1']='UUID'
|
||||||
|
ws['B1']='RFC_Cliente'
|
||||||
|
ws['C1']='Fecha'
|
||||||
|
contador =2
|
||||||
|
|
||||||
|
for q in objeto_a_trabajar:
|
||||||
|
column = str(contador)
|
||||||
|
|
||||||
|
ws['A' + column] = q.uuid
|
||||||
|
ws['B'+ column] = q.rfcc
|
||||||
|
ws['C'+ column] = q.fecha
|
||||||
|
contador += 1
|
||||||
|
|
||||||
|
|
||||||
|
nombre_archivo = "ListadoObjeto.xlsx"
|
||||||
|
response = HttpResponse(content_type="application/ms-excel")
|
||||||
|
contenido = "attachment; filename = {0}".format(nombre_archivo)
|
||||||
|
response["Content-Disposition"] = contenido
|
||||||
|
wb.save(response)
|
||||||
|
return response
|
||||||
@@ -46,6 +46,7 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
|||||||
<a href="{% url 'timbres_cliente' obj.RFC %}" class="btn btn-info">Ver Timbres</a>
|
<a href="{% url 'timbres_cliente' obj.RFC %}" class="btn btn-info">Ver Timbres</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<td><a href="{% url 'export_Excel' %}?RFC={{obj.RFC}}">Excel</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
{% if lista.has_previous %}
|
{% if lista.has_previous %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a class="page-link" href="?page={{ lista.previous_page_number }}" aria-label="Previous">
|
<a class="page-link" href="?page={{ lista.previous_page_number }}{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
{% if lista.has_next %}
|
{% if lista.has_next %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a class="page-link" href="?page={{ lista.next_page_number }}" aria-label="Next">
|
<a class="page-link" href="?page={{ lista.next_page_number }}{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}" aria-label="Next">
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
2
req.text
2
req.text
@@ -8,8 +8,10 @@ Django==4.1.3
|
|||||||
django-allauth==0.51.0
|
django-allauth==0.51.0
|
||||||
django-widget-tweaks==1.4.12
|
django-widget-tweaks==1.4.12
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.14.0
|
||||||
|
et-xmlfile==1.1.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
oauthlib==3.2.2
|
oauthlib==3.2.2
|
||||||
|
openpyxl==3.0.10
|
||||||
pycparser==2.21
|
pycparser==2.21
|
||||||
PyJWT==2.6.0
|
PyJWT==2.6.0
|
||||||
PyMySQL==1.0.2
|
PyMySQL==1.0.2
|
||||||
|
|||||||
22
req.txt
22
req.txt
@@ -1,22 +0,0 @@
|
|||||||
asgiref==3.5.2
|
|
||||||
certifi==2022.9.24
|
|
||||||
cffi==1.15.1
|
|
||||||
charset-normalizer==2.1.1
|
|
||||||
cryptography==38.0.3
|
|
||||||
defusedxml==0.7.1
|
|
||||||
Django==4.1.3
|
|
||||||
django-allauth==0.51.0
|
|
||||||
django-widget-tweaks==1.4.12
|
|
||||||
djangorestframework==3.14.0
|
|
||||||
idna==3.4
|
|
||||||
oauthlib==3.2.2
|
|
||||||
pycparser==2.21
|
|
||||||
PyJWT==2.6.0
|
|
||||||
PyMySQL==1.0.2
|
|
||||||
python3-openid==3.2.0
|
|
||||||
pytz==2022.6
|
|
||||||
requests==2.28.1
|
|
||||||
requests-oauthlib==1.3.1
|
|
||||||
sqlparse==0.4.3
|
|
||||||
tzdata==2022.6
|
|
||||||
urllib3==1.26.13
|
|
||||||
Reference in New Issue
Block a user