division by zero
This commit is contained in:
@@ -3,7 +3,7 @@ from .models import Timbres, saldoModel, Clientes,ErroresTimbres
|
||||
|
||||
|
||||
class TimbresAdmin(admin.ModelAdmin):
|
||||
list_display=['uuid','rfcc','rfcp','fecha','folio','serie','tipo','modo']
|
||||
list_display=['uuid','rfcc','rfcp','fecha','folio','serie','tipo','modo','created_at']
|
||||
|
||||
|
||||
class ClientesAdmin(admin.ModelAdmin):
|
||||
|
||||
@@ -14,7 +14,7 @@ class ClienteForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Clientes
|
||||
fields = ('RFC','Nombre','Activo','fecha_baja')
|
||||
fields = ('RFC','Nombre','Activo','fecha_baja', 'email',)
|
||||
|
||||
def clean(self):
|
||||
super(ClienteForm,self).clean()
|
||||
|
||||
18
Clientes/migrations/0012_clientes_email.py
Normal file
18
Clientes/migrations/0012_clientes_email.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.3 on 2022-12-06 17:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('Clientes', '0011_merge_0010_merge_20221205_1039_0010_timbres_modo'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='clientes',
|
||||
name='email',
|
||||
field=models.EmailField(blank=True, max_length=254),
|
||||
),
|
||||
]
|
||||
18
Clientes/migrations/0013_clientes_conteo_mes.py
Normal file
18
Clientes/migrations/0013_clientes_conteo_mes.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.3 on 2022-12-06 20:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('Clientes', '0012_clientes_email'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='clientes',
|
||||
name='conteo_mes',
|
||||
field=models.IntegerField(blank=True, default=0, null=True),
|
||||
),
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.db import models
|
||||
import datetime
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
class saldoModel(models.Model):
|
||||
saldo = models.IntegerField()
|
||||
@@ -38,9 +38,37 @@ class Clientes(models.Model):
|
||||
Nombre = models.CharField(max_length=100)
|
||||
Activo = models.BooleanField(default=False)
|
||||
fecha_baja = models.DateField(blank=True,null=True)
|
||||
email = models.EmailField(max_length=254, blank=True)
|
||||
conteo_mes = models.IntegerField(blank=True,null=True,default=0)
|
||||
def timbres_X_MES(self, mes):
|
||||
|
||||
today = datetime.date.today()
|
||||
year = today.year
|
||||
print('mesmesmesmesmes',mes)
|
||||
if mes==None:
|
||||
mes = today.month
|
||||
dat = datetime.datetime(int(year),int(mes),1)
|
||||
if dat.month in (1,3,5,7,8,10,12):#31
|
||||
|
||||
findate = dat + datetime.timedelta(days=30)
|
||||
findate += datetime.timedelta(days=0)
|
||||
elif dat.month in (4,6,9,11):#30
|
||||
|
||||
findate = dat + datetime.timedelta(days=29)
|
||||
findate += datetime.timedelta(days=0)
|
||||
else:#28 or 29
|
||||
|
||||
findate = dat + datetime.timedelta(days=28)
|
||||
findate += datetime.timedelta(days=0)
|
||||
print(f'dat {(dat)} fdate={findate}')
|
||||
cou = Timbres.objects.filter(rfcc=self.RFC, created_at__range=[dat,findate]).count()
|
||||
print(cou)
|
||||
self.conteo_mes =cou
|
||||
self.save()
|
||||
return cou
|
||||
@property
|
||||
def timbres_mes_count(self):
|
||||
|
||||
today = datetime.date.today()
|
||||
month = today.month
|
||||
year = today.year
|
||||
|
||||
@@ -16,17 +16,27 @@ from asgiref.sync import sync_to_async
|
||||
#EXCEL
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Alignment, Border, Font, PatternFill, Side
|
||||
|
||||
import json
|
||||
@login_required
|
||||
def index(request):
|
||||
|
||||
|
||||
clientes_list = Clientes.objects.all()
|
||||
mes = request.GET.get('mes', None)
|
||||
page = request.GET.get('page', 1)
|
||||
search = request.GET.get('search',None)
|
||||
rfcc = request.GET.get('rfcc', None)
|
||||
filters = {key:value[0] for (key,value) in dict(request.GET).items() if value !=[""]}
|
||||
filters.pop('page', '')
|
||||
filters.pop('datepicker','')
|
||||
filters.pop('datepickerFin','')
|
||||
print('filters------',filters)
|
||||
if rfcc:
|
||||
clientes_list = Clientes.objects.filter(Q(RFC__icontains=search))
|
||||
|
||||
for i,ii in enumerate(clientes_list):
|
||||
ii.timbres_X_MES(mes=mes)
|
||||
|
||||
paginator = Paginator(clientes_list, 5)
|
||||
|
||||
try:
|
||||
@@ -35,8 +45,11 @@ def index(request):
|
||||
lista = paginator.page(1)
|
||||
except EmptyPage:
|
||||
lista = paginator.page(paginator.num_pages)
|
||||
filters.pop('mes','')
|
||||
context = {
|
||||
'lista':lista,
|
||||
'mes':mes,
|
||||
'filters':filters
|
||||
|
||||
}
|
||||
return render(request,'Clientes/index.html',context)
|
||||
@@ -114,13 +127,15 @@ def timbres_cliente(request, RFC):
|
||||
end += datetime.timedelta(days=1)
|
||||
#datetime.date.today()
|
||||
#print('FECHA',datetime.datetime.today(), 'HORA')
|
||||
#print('start',start, 'end',end)
|
||||
print('start',start, 'end',end)
|
||||
lista = lista.filter(created_at__range=[start, end])
|
||||
|
||||
conteo = lista.count()
|
||||
perPage = conteo // 2
|
||||
if perPage == 0 :
|
||||
perPage = conteo
|
||||
print('conteo',conteo)
|
||||
if conteo !=0 :
|
||||
perPage = conteo // 2
|
||||
else:
|
||||
perPage = 1
|
||||
lista =pageFunc(page,lista,perPage)
|
||||
|
||||
context ={
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
<label for="{{form.Nombre.name}}"><strong> {{form.Nombre.label|capfirst}} </strong></label>
|
||||
{% render_field form.Nombre id+="add" id+=form.Nombre.name placeholder=form.Nombre.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{form.email.name}}"><strong> {{form.email.label|capfirst}} </strong></label>
|
||||
{% render_field form.email id+="add" id+=form.email.name placeholder=form.email.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
{% render_field form.Activo class+="form-checkbox" type="checkbox" %}
|
||||
<label class="form-check-label" for="{{form.Activo.label}}">Activo</label>
|
||||
|
||||
@@ -19,7 +19,34 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
||||
Cliente RFC
|
||||
</th>
|
||||
<th>Nombre</th>
|
||||
<th>Totales Mes {{fecha|date:"F"}}</th>
|
||||
<th>Totales Mes
|
||||
<select id="table_select" class="form-control form-control-sm">
|
||||
<option value="01">Enero
|
||||
</option>
|
||||
<option value="02">Febrero
|
||||
</option>
|
||||
<option value="03">Marzo
|
||||
</option>
|
||||
<option value="04">Abril
|
||||
</option>
|
||||
<option value="05">Mayo
|
||||
</option>
|
||||
<option value="06">Junio
|
||||
</option>
|
||||
<option value="07">Julio
|
||||
</option>
|
||||
<option value="08">Agosto
|
||||
</option>
|
||||
<option value="09">Septiembre
|
||||
</option>
|
||||
<option value="10">Octubre
|
||||
</option>
|
||||
<option value="11">Noviembre
|
||||
</option>
|
||||
<option value="12">Diciembre
|
||||
</option>
|
||||
</select>
|
||||
</th>
|
||||
<th>Estado</th>
|
||||
<th scope="col">actions</th>
|
||||
<th>
|
||||
@@ -34,7 +61,9 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
||||
<a href="{% url 'update_cliente' obj.pk %}">{{obj.RFC}}</a>
|
||||
</td>
|
||||
<td>{{obj.Nombre}} </td>
|
||||
<td>{{obj.timbres_mes_count}}</td>
|
||||
<td>
|
||||
{{obj.conteo_mes}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{% if obj.Activo %}
|
||||
@@ -57,10 +86,14 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div id='id_filters' style="display: none;">{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
let filters = document.getElementById('id_filters').textContent
|
||||
console.log(filters)
|
||||
function aclick(event,RFC ,cuantos){
|
||||
|
||||
if( parseInt(cuantos)===0){
|
||||
@@ -75,7 +108,25 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
||||
document.getElementById('rfcc').checked= table_rfcc.checked? true:false;
|
||||
})
|
||||
|
||||
window.addEventListener("load", (event)=>{
|
||||
let mes ='{{mes}}'
|
||||
|
||||
if(mes !="None"){
|
||||
document.getElementById('table_select').value='{{mes}}'
|
||||
mes_id.value='{{mes}}'
|
||||
}else{
|
||||
document.getElementById('table_select').value='{{fecha|date:"m"}}'
|
||||
mes_id.value='{{fecha|date:"m"}}'
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById('table_select').addEventListener('change',(event)=>{
|
||||
let anc = document.getElementById('home_id')
|
||||
anc.href=''
|
||||
let url = `?mes=${event.target.value}${filters}`
|
||||
anc.href=url
|
||||
anc.click()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
Fecha: <strong>{{fecha|date:"d F Y"}}</strong>
|
||||
</span>
|
||||
<form action="{{request.path}}" method="get" class="form-inline my-2 my-lg-0">
|
||||
<input id="search" class="form-control mr-sm-2" name="search" type="search" placeholder="Search" aria-label="Search">
|
||||
<input style="display:none" id="mes_id" class="form-control mr-sm-2" name="mes" type="input" placeholder="mes" aria-label="mes">
|
||||
<input id="search" class="form-control mr-sm-2" name="search" type="search" placeholder="Search" aria-label="Search">
|
||||
|
||||
<div class="form-group form-check">
|
||||
<input style="display:none" name="rfcc" type="checkbox" class="form-check-input" id="rfcc">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/"><img height="25px" class="center" src="https://aduanasoft.com/wp-content/uploads/2019/01/aslogo-1.png" id="icon" alt="User Icon" /></a>
|
||||
<a id="home_id" class="navbar-brand" href="/"><img height="25px" class="center" src="https://aduanasoft.com/wp-content/uploads/2019/01/aslogo-1.png" id="icon" alt="User Icon" /></a>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
||||
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
|
||||
|
||||
Reference in New Issue
Block a user