Commits

Mariano Falcón committed e2332f3

de katy

Comments (0)

Files changed (13)

cashflow/forms.py

 from django import forms
 from django.forms import ModelForm
 
-from cashflow.models import Transaccion, Cuenta
+from cashflow.models import Transaccion, Cuenta, User
 
 from datetime import date
 
                   'termina']
         exclude = ('tipo', 'activo',)
 
+    def __init__(self, *args, **kwargs):
+        user = kwargs.pop('user')
+        super(TransaccionForm, self).__init__(*args, **kwargs)
+        self.fields['cuenta'].queryset = Cuenta.objects.filter(usuario=user)
+
     def clean(self):
         cleaned_data = self.cleaned_data
         fechas = []

cashflow/migrations/0001_initial.py

 
     def forwards(self, orm):
         
+        # Adding model 'Cuenta'
+        db.create_table('cashflow_cuenta', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('nombre', self.gf('django.db.models.fields.CharField')(max_length=30)),
+            ('usuario', self.gf('django.db.models.fields.related.ForeignKey')(related_name='account_creator', to=orm['auth.User'])),
+        ))
+        db.send_create_signal('cashflow', ['Cuenta'])
+
         # Adding model 'Categoria'
         db.create_table('cashflow_categoria', (
             ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
             ('nombre', self.gf('django.db.models.fields.CharField')(max_length=30)),
+            ('cuenta', self.gf('django.db.models.fields.related.ForeignKey')(related_name='categorias', to=orm['cashflow.Cuenta'])),
         ))
         db.send_create_signal('cashflow', ['Categoria'])
 
         db.create_table('cashflow_transaccion', (
             ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
             ('nombre', self.gf('django.db.models.fields.CharField')(max_length=30)),
+            ('descripcion', self.gf('django.db.models.fields.TextField')(blank=True)),
             ('tipo', self.gf('django.db.models.fields.IntegerField')(max_length=1)),
             ('monto', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
-            ('fecha', self.gf('django.db.models.fields.DateField')()),
+            ('fecha', self.gf('django.db.models.fields.DateField')(default=datetime.date.today)),
             ('frecuencia', self.gf('django.db.models.fields.IntegerField')(max_length=2)),
-            ('activo', self.gf('django.db.models.fields.BooleanField')(default=True)),
-            ('categoria', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cashflow.Categoria'])),
+            ('termina', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
+            ('categoria', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='transacciones', null=True, to=orm['cashflow.Categoria'])),
+            ('cuenta', self.gf('django.db.models.fields.related.ForeignKey')(related_name='transacciones', to=orm['cashflow.Cuenta'])),
         ))
         db.send_create_signal('cashflow', ['Transaccion'])
 
 
     def backwards(self, orm):
         
+        # Deleting model 'Cuenta'
+        db.delete_table('cashflow_cuenta')
+
         # Deleting model 'Categoria'
         db.delete_table('cashflow_categoria')
 
 
 
     models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
         'cashflow.categoria': {
             'Meta': {'object_name': 'Categoria'},
+            'cuenta': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'categorias'", 'to': "orm['cashflow.Cuenta']"}),
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
             'nombre': ('django.db.models.fields.CharField', [], {'max_length': '30'})
         },
+        'cashflow.cuenta': {
+            'Meta': {'object_name': 'Cuenta'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'nombre': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+            'usuario': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'account_creator'", 'to': "orm['auth.User']"})
+        },
         'cashflow.transaccion': {
             'Meta': {'object_name': 'Transaccion'},
-            'activo': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
-            'categoria': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cashflow.Categoria']"}),
-            'fecha': ('django.db.models.fields.DateField', [], {}),
+            'categoria': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'transacciones'", 'null': 'True', 'to': "orm['cashflow.Categoria']"}),
+            'cuenta': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'transacciones'", 'to': "orm['cashflow.Cuenta']"}),
+            'descripcion': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'fecha': ('django.db.models.fields.DateField', [], {'default': 'datetime.date.today'}),
             'frecuencia': ('django.db.models.fields.IntegerField', [], {'max_length': '2'}),
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
             'monto': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'}),
             'nombre': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+            'termina': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
             'tipo': ('django.db.models.fields.IntegerField', [], {'max_length': '1'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
         }
     }
 

cashflow/migrations/__init__.py

File contents unchanged.

cashflow/models.py

 class Categoria(models.Model):
     nombre = models.CharField(max_length=30)
     cuenta = models.ForeignKey(Cuenta, related_name='categorias')
+    #ingreso o gasto? tipo = se puede hacer un uniquetogether(categoria,tipo)? 
     #de ingresos o de egresos - validar en form
+    # usuario?
     def __unicode__(self):
         return u'%s' % self.nombre
 
     url(r'^ingresos/(?P<nombre_cuenta>\w+)/$', views.ingreso, name='cs_ingreso'),
     url(r'^gastos/(?P<nombre_cuenta>\w+)/$', views.gasto, name='cs_gasto'),
     url(r'^nueva_cuenta/$', views.nueva_cuenta, name='cs_nueva_cuenta'),
-    url(r'^reportes/$', views.reportes, name='cs_reportes'),
+    url(r'^reportes/(?P<nombre_cuenta>\w+)/$', views.reportes, name='cs_reportes'),
 )

cashflow/views.py

     )
 '''
 @login_required
-def reportes(request):
-    lista = request.session['lista']
+def reportes(request, nombre_cuenta="Inicial"):
+    if nombre_cuenta == "Inicial":
+        uri = "/cashflow/nueva_cuenta"
+        return HttpResponseRedirect(uri)     
+    info_mes = {}
+    info_cat = {}
+    lista_m_a = []
+    transacs = []
+    #if cuenta == "principal" :
     """
-    [[9, 2010, 0, 0, 0], [10, 2010, Decimal('50.00'), Decimal('200.00'), 0], [11, 2010, 0, 0, Decimal('-150.00')], [12, 2010, 0, Decimal('200.00'), Decimal('-150.00')], [1, 2011, Decimal('50.00'), 0, Decimal('-350.00')], [2, 2011, 0, Decimal('200.00'), Decimal('-300.00')], [3, 2011, 0, 0, Decimal('-500.00')]]
+    try:
+        cuenta = Cuenta.objects.filter(usuario=request.user)[0]
+    except:
+        return HttpResponse('cashflow/prueba.html')
     """
-    lista_fechas = []
-    lista_ingresos = []
-    lista_gastos = []
-    lista_en_mano = []
-    min = date(2010,9,1)
-    max = date(2011,3,1)
-    for el in lista:
-        #fecha = date(el[1], el[0], 1)
-        fecha = [el[1],el[0]]
-        lista_fechas.append(fecha)
-        lista_ingresos.append(el[2])
-        lista_gastos.append(el[3])
-        lista_en_mano.append(el[4])
+    cuenta = Cuenta.objects.get(nombre=nombre_cuenta, usuario=request.user)
+    categorias = cuenta.categorias.all() 
+    #categorias = Categoria.objects.all()
+    for anio in range(2006,2017):
+        for mes in range(1,13):
+            info_mes[(mes,anio)] = [0, 0, 0]
+            for cat in categorias:
+                info_cat[(cat,mes,anio)] = 0
+    meses_ant = 1
+    meses_desp = 5
+    lista_fechas = lista_mes_anio(meses_ant, meses_desp)
+    lista_m_a = [(date.month, date.year) for date in lista_mes_anio(1,5)]
+    min, max = [] , []
+    min, max = lista_fechas[0], lista_fechas[len(lista_fechas)-1]
+    INGRESO = 0
+    GASTO = 1
+    ENMANO = 2
+    transacs_en_fechas = []
+    txs = cuenta.transacciones.order_by('fecha')
+    #txs = Transaccion.objects.order_by('fecha')
+    for tx in txs:
+        mesanio = ()
+        mesanio = (tx.fecha.month, tx.fecha.year)
+        if tx.frecuencia == 0:
+            if tx.tipo == 0:
+                info_mes[mesanio][INGRESO] += tx.monto
+                if tx.categoria:
+                    info_cat[(tx.categoria, mesanio[0], mesanio[1])] += tx.monto
+            else:
+                info_mes[mesanio][GASTO] += tx.monto
+                if tx.categoria:
+                    info_cat[(tx.categoria, mesanio[0], mesanio[1])] += tx.monto
+            if mesanio in lista_m_a:
+                if tx not in transacs_en_fechas:
+                    transacs_en_fechas.append(tx)
+        elif tx.frecuencia == 4:
+            meses_dif = relativedelta.relativedelta(tx.termina, tx.fecha).months
+            if tx.termina.day < tx.fecha.day:
+                meses_dif += 1
+            anios_dif = relativedelta.relativedelta(tx.termina, tx.fecha).years
+            dif = meses_dif + (anios_dif*12)
+            rango = dif + 1
+            #rango = dif + 2
+            for i in range(rango):
+                fch = tx.fecha+relativedelta.relativedelta(months=+i)
+                if (fch.month, fch.year) in lista_m_a:
+                    if tx not in transacs_en_fechas:
+                        transacs_en_fechas.append(tx)
+                if tx.tipo == 0:
+                    info_mes[(fch.month,fch.year)][INGRESO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+                else:
+                    info_mes[(fch.month,fch.year)][GASTO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+        elif tx.frecuencia == 5:
+            meses_dif = relativedelta.relativedelta(tx.termina, tx.fecha).months
+            if tx.termina.day < tx.fecha.day:
+                meses_dif += 1
+            anios_dif = relativedelta.relativedelta(tx.termina, tx.fecha).years
+            dif = meses_dif + (anios_dif*12)
+            rango = dif + 1
+            #rango = dif + 2
+            for i in range(0, rango, 2): # lo unico que cambia de 4 ?
+                fch = tx.fecha+relativedelta.relativedelta(months=+i)
+                if (fch.month, fch.year) in lista_m_a:
+                    if tx not in transacs_en_fechas:
+                        transacs_en_fechas.append(tx)
+                if tx.tipo == 0:
+                    info_mes[(fch.month,fch.year)][INGRESO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+                else:
+                    info_mes[(fch.month,fch.year)][GASTO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+        elif tx.frecuencia == 6:
+            meses_dif = relativedelta.relativedelta(tx.termina, tx.fecha).months
+            if tx.termina.day < tx.fecha.day:
+                meses_dif += 1
+            anios_dif = relativedelta.relativedelta(tx.termina, tx.fecha).years
+            dif = meses_dif + (anios_dif*12)
+            rango = dif + 1
+            #rango = dif + 2
+            for i in range(0, rango, 3): # lo unico que cambia de 4
+                fch = tx.fecha+relativedelta.relativedelta(months=+i)
+                if (fch.month, fch.year) in lista_m_a:
+                    if tx not in transacs_en_fechas:
+                        transacs_en_fechas.append(tx)
+                if tx.tipo == 0:
+                    info_mes[(fch.month,fch.year)][INGRESO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+                else:
+                    info_mes[(fch.month,fch.year)][GASTO] += tx.monto
+                    if tx.categoria:
+                        info_cat[(tx.categoria, fch.month, fch.year)] += tx.monto
+            
+    import operator
+    thelist = []
+    thelist = sorted((my + tuple(v) for my, v in info_mes.iteritems()),
+                 key = operator.itemgetter(1, 0))
+    thelistlist = []
+    for tupla in thelist:
+        thelistlist.append(list(tupla))
+    for i in range(len(thelistlist)):
+        if i != 0:
+            thelistlist[i][4] = thelistlist[i-1][2] - thelistlist[i-1][3] + thelistlist[i-1][4]
+    lista = []
+    for el in thelistlist:
+        if (el[0],el[1]) in lista_m_a:
+            lista.append(el)
+    
+    #lista es la lista final
+    transacciones = cuenta.transacciones.all()
+    #transacciones = Transaccion.objects.all()
+    cats_en_fechas_ing = []
+    cats_en_fechas_eg = []
+    for t in transacs_en_fechas:
+        if t.categoria and t.tipo == 0:
+            if t.categoria not in cats_en_fechas_ing:
+                cats_en_fechas_ing.append(t.categoria)
+        elif t.categoria and t.tipo == 1:
+            if t.categoria not in cats_en_fechas_eg:
+                cats_en_fechas_eg.append(t.categoria)
 
-        
-    context = { 
-        'lista_fechas': lista_fechas,
-        'lista_ingresos': lista_ingresos,
-        'lista_fechas': lista_gastos,
-        'lista_fechas': lista_en_mano,
-        'min': min,
+    info_cats = []
+    for k, v in info_cat.items():
+        info_cats.append((k[0], k[1], k[2], v))
+
+    cuentas = Cuenta.objects.filter(usuario=request.user)
+
+    request.session['lista'] = lista
+
+    context = {
+        'fechas': lista_fechas, # [datetime.date] fechas en el rango
+        'info_mes': lista, # [(mes,anio):[in,eg,enma]] todas las fechas ordenadas
+        'txs': transacciones,
+        'min': min, #datetime menor mes actual
         'max': max,
+        'currentmonth': date.today(),
+        'tx_en_fecha': transacs_en_fechas,
+        'mesanio': lista_m_a,
+        'meses_ant': meses_ant,
+        'meses_desp': meses_desp,
+        'cats': categorias,
+        'info_cat': info_cats,
+        'cats_ing': cats_en_fechas_ing,
+        'cats_eg': cats_en_fechas_eg,
+        'cuentas': cuentas,
+        'cuenta': cuenta,
     }
-
     return render_to_response(
         'cashflow/reportes.html',
         context,
 @login_required
 def ingreso(request, nombre_cuenta): #sacar nombre_cuenta
     if request.method == 'POST':
-        form = TransaccionForm(data=request.POST)
+        form = TransaccionForm(user=request.user, data=request.POST)
         if form.is_valid():
             ingreso = form.save(commit=False)
             ingreso.tipo = 0
             return HttpResponseRedirect(uri)
             #return HttpResponseRedirect("/cashflow/prueba/%s") % str(nombre_cuenta)
     else:
-        form = TransaccionForm()
+        form = TransaccionForm(user=request.user)
     
     context = {
           'TransaccionForm': form,
 @login_required
 def gasto(request, nombre_cuenta):
     if request.method == 'POST':
-        form = TransaccionForm(data=request.POST)
+        form = TransaccionForm(user=request.user, data=request.POST)
         if form.is_valid():
             gasto = form.save(commit=False)
             gasto.tipo = 1
             uri = ("/cashflow/prueba/%s") % str(nombre_cuenta)
             return HttpResponseRedirect(uri)
     else:
-        form = TransaccionForm()
+        form = TransaccionForm(user=request.user)
     
     context = {
           'TransaccionForm': form,
         context_instance = RequestContext(request),
     )
 
+'''
+@login_required
+def nueva_categoria(request, tipo):
+    if request.method == 'POST':
+        form = CategoriaForm(data=request.POST)
+        if form.is_valid():
+            nueva_cat = form.save(commit=False)
+            nueva_cat.nombre = form.cleaned_data['nombre']
+            nueva_cat.usuario = request.user
+            nueva_cat.tipo = tipo
+            uri = ("/cashflow/prueba/%s") % s
+            return HttpResponseRedirect(uri)
+    else:
+        form = CuentaForm()
+    
+    context = {
+          'CategoriaForm': form,
+     }
+    return render_to_response(
+        'cashflow/nueva_categoria.html',
+        context,
+        context_instance = RequestContext(request),
+    )
+'''
+
 def cashflow(request):
     info_mes = {}
     lista_m_a = []

media/css/style.css

 	padding: 0;
 	font-size: 12px;
 	font-family: "Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif;
-	background: url(../images/background.gif) repeat-x;
+	background: #e8fafa url(../images/fondo.gif) repeat-x;
 }
 #header {  
-	background: url(../images/blueheader.gif) repeat-x;
+	background: url(../images/blueheader2.gif) repeat-x;
 	color: white;
 	width: 100%;
 	height: 70px;
     font-weight: bold;
 }
 div.breadcrumbs {
-    background: #205CBA /*url(../images/brandingblue.gif) repeat-x*/;
+    background: #6eb3da /*url(../images/brandingblue.gif) repeat-x*/;
     height: 20px;
     padding: 3px 12px 3px 8px;
     font-size: 12px;
 #income, #expense {
     background: #FFFFFF;
 }
-#category {
+.category {
     background: #EFF4FB url(../images/category.gif) repeat-x;
 }
 #cuentas {
     width: 200px;
 }
 #main {
-    background-color: #EAF1F6;
-    background-image: url(../images/bg_main1.gif);
+    background-color: #e8fafa;
+    /*background-image: url(../images/fondo.gif);*/
     background-position: center top;
     background-repeat: repeat-x;
 }
 }
 #list li {
     margin-bottom: 10px; 
-}
+}
 
 DATABASES = {
     'default': {
-        'ENGINE': 'django.db.backends.postgresql_psycopg2', 
-        'NAME': 'pylsedb',                      # Or path to database file if using sqlite3.
-        'USER': 'mf',                      # Not used with sqlite3.
-        'PASSWORD': 'maf99cnea',                  # Not used with sqlite3.
+        'ENGINE': 'django.db.backends.sqlite3', 
+        'NAME': 'pylse',                      # Or path to database file if using sqlite3.
+        'USER': '',                      # Not used with sqlite3.
+        'PASSWORD': '',                  # Not used with sqlite3.
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
     }
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'es-ar'
 
 SITE_ID = 1
 
     'django.contrib.admin',
     'cashflow',
     'billable',
-    'GChartWrapper.charts',
     'registration', 
     'south',
 )

templates/cashflow/arrows.html

-<div id="cash_grid">
     <table  class="cash" cellspacing="0" cellpadding="0" width="100%">
         <thead id="month_row">
             <tr>
                     {{ min|date:"m Y" }} &ndash; {{ max|date:"m Y" }}
                 </td>
                 <td class="arrow" width="1%">
-                    <a title="Previous Month" id="dates_down" style="cursor: pointer"><</a>
+                    <a title="Mes anterior" id="dates_down" style="cursor: pointer"><</a>
                 </td>
                 {% for fch in fechas %}
                     {% if fch == currentmonth %}
-                         <th class="monthcurrent">{{ fch|date:"m" }}</th>
+                         <th class="monthcurrent">{{ fch|date:"F" }}</th>
                     {% else %}                        
-                        <th class="month">{{ fch|date:"m" }}</th>
+                        <th class="month">{{ fch|date:"F" }}</th>
                     {% endif %}
                 {% endfor %}
                 <td class="arrow" width="1%">
-                    <a title="Next Month" id="dates_up" style="cursor: pointer">></a>
+                    <a title="Mes siguiente" id="dates_up" style="cursor: pointer">></a>
                 </td>
             </tr>
         </thead>
         <tbody id="cash-on-hand">
             <tr>
                 <th colspan="2">
-                    Cash on hand
+                    DINERO (al inicio del mes)
                 </th>
                 {% for fecha in info_mes %} 
                     <td>{{ fecha.4 }}</td>
         <tbody id="income-header">
             <tr>
                 <th colspan="2">
-                    Ingresos
+                    INGRESOS
                 </th>
                 {% for fecha in info_mes %}
                     <td>{{ fecha.2 }}</td>
         <tbody id="income">                  
                 {% for cat in cats %}
                     {% if cat in cats_ing %}  
-                    <tr id="category">
+                    <tr class="category">
                         <th colspan="2">
                             {{ cat.nombre }}
                         </th>                                            
                              <td>&nbsp;</td>
                     </tr>
                         {% for tx in cat.transacciones.all %}
-                        <tr id="subitem">                        
+                        <tr class="subitem">                        
                             {% if tx in tx_en_fecha %}
                                 <th colspan="2">
                                     {{ tx.nombre }}
         <tbody id="expense-header">
             <tr>
                 <th colspan="2">
-                    Egresos
+                    GASTOS
                 </th>
                 {% for fecha in info_mes %}
                     <td>{{ fecha.3 }}</td>
                     </tr>
                 {% endfor %}
         </tbody>
-
     </table>
-</div>

templates/cashflow/cashflow2.html

 <div class="breadcrumbs">
     <a class="nav" href={% url cs_welcome %}>Home</a>
     <a class="nav" href={% url cs_cashflow2 cuenta.nombre %}>Cashflow</a>
-    <a class="nav" href={% url cs_reportes %}>Reportes</a>  		   	
+    <a class="nav" href={% url cs_reportes cuenta.nombre %}>Reportes</a>  		   	
 </div>
 <div id="main">
     <h1>Cashflow</h1>   
         <tbody id="income">                  
                 {% for cat in cats %}
                     {% if cat in cats_ing %}  
-                    <tr id="category">
+                    <tr class="category">
                         <th colspan="2">
                             {{ cat.nombre }}
                         </th>                                            
                              <td>&nbsp;</td>
                     </tr>
                         {% for tx in cat.transacciones.all %}
-                        <tr id="subitem">                        
+                        <tr class="subitem">                        
                             {% if tx in tx_en_fecha %}
                                 <th colspan="2">
                                     {{ tx.nombre }}

templates/cashflow/ingreso.html

 {% block title %}Pylse - {{ block.super }}{% endblock %}
 
 {% block extra_head %}
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>
 {% endblock %}
 
 {% block main_content %}
+<script>
+$(document).ready(function(){
+	$('#id_fecha').datepicker({
+  		showOn: 'button',
+  		buttonImage: '{{ MEDIA_ROOT }}media/images/calendar.gif',
+  		buttonImageOnly: true,
+  		numberOfMonths: 1,
+  		maxDate: new Date(2016, 1 -1, 1),
+  		minDate: new Date(2006, 1 -1, 1),
+        dateFormat: 'yy-mm-dd',
+        regional: 'es',
+	});
+    $('#id_termina').datepicker({
+  		showOn: 'button',
+  		buttonImage: '{{ MEDIA_ROOT }}media/images/calendar.gif',
+  		buttonImageOnly: true,
+  		numberOfMonths: 1,
+  		maxDate: new Date(2016, 1 -1, 1),
+  		minDate: new Date(2006, 1 -1, 1),
+        dateFormat: 'yy-mm-dd',
+	});
+    $('#id_frecuencia').change(onSelectChange);
+
+});
+
+function onSelectChange(){
+        var selected = $('#id_frecuencia option:selected');
+        if(selected.val() == 0){
+            $('#list li:last').hide()
+        }
+        else { $('#list li:last').show() }
+}
+
+</script>
     <div class="breadcrumbs">
         <a class="nav" href={% url cs_welcome %}>Home</a>
         <a class="nav" href="#">Cashflow</a>
-        <a class="nav" href={% url cs_reportes %}>Reportes</a>  		   	
+        <a class="nav" href="#">Reportes</a>  		   	
     </div>
     <div id="main">
         <h1>Agregar ingreso</h1>    
             </form>
         </div>
     </div>
-{% endblock %}
+{% endblock %}

templates/cashflow/reportes.html

     <script type="text/javascript" src="/media/js/jqplot.barRenderer.min.js"></script>
     
     <script class="code" type="text/javascript">$(document).ready(function(){
-    line1 = [[1,1], [4,2], [9,3], [16,4]];
-    line2 = [[25,1], [12.5,2], [6.25,3], [3.125,4]];
+    line1 = [1]; // 
+    line2 = [2];
     plot3 = $.jqplot('chart1', [line1, line2], {
     legend:{show:true, location:'ne'},
     title:'Ingresos',
         "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc"],
     seriesDefaults:{
         renderer:$.jqplot.BarRenderer, 
-        rendererOptions:{barDirection:'horizontal', barPadding: 6, barMargin:15}, 
+        rendererOptions:{barDirection:'horizontal', barPadding: 4, barMargin:12}, 
         shadowAngle:135},
     series:[
-        {label:'Cats'}, 
+        {label:'Cats'}, // Nombre ingreso (categoria o tx sinc cat)
         {label:'Dogs'}
     ],
     axes:{
         xaxis:{min:0}, 
-        yaxis:{
-            renderer:$.jqplot.CategoryAxisRenderer, 
-            ticks:['Once', 'Twice', 'Three Times', 'More']
-        }
+        //yaxis:{
+            //renderer:$.jqplot.CategoryAxisRenderer, 
+            //ticks:['Once', 'Twice', 'Three Times', 'More']
+        //}
     }
     });
 });
         rendererOptions:{barDirection:'horizontal', barPadding: 6, barMargin:15}, 
         shadowAngle:135},
     series:[
-        {label:'Cats'}, 
+        {label:'Cats'},  
         {label:'Dogs'}
     ],
     axes:{
 });
     </script>
     <script class="code" type="text/javascript">$(document).ready(function(){
-    line1 = [1,4, 9, 16];
-    line2 = [25, 12.5, 6.25, 3.125];
-    line3 = [2, 7, 15, 30];
+    var line1 = [];
+    var line2 = [];
+    var line3 = [];
+    var meses = [];
+    {% for fecha in info_mes %}
+        line1.push({{ fecha.2 }});
+        line2.push({{ fecha.3 }});
+        line3.push({{ fecha.4 }});
+    {% endfor %}
+    {% for fecha in fechas %}
+        meses.push("{{ fecha|date:"F" }}");
+    {% endfor %}
     plot2 = $.jqplot('chart3', [line1, line2, line3], {
     legend:{show:true, location:'ne', xoffset:55},
     title:'CashFlow',
         rendererOptions:{barPadding: 8, barMargin: 20}
     },
     series:[
-        {label:'Profits'}, 
-        {label:'Expenses'}, 
-        {label:'Sales'}
+        {label:'Ingresos'}, 
+        {label:'Gastos'}, 
+        {label:'Efectivo'}
     ],
     axes:{
         xaxis:{
             renderer:$.jqplot.CategoryAxisRenderer, 
-            ticks:['1st Qtr', '2nd Qtr', '3rd Qtr', '4th Qtr']
+            ticks: meses // Meses
         }, 
         yaxis:{min:0}
     }
 {% block main_content %}
     <div class="breadcrumbs">
         <a class="nav" href={% url cs_welcome %}>Home</a>
-        <a class="nav" href="#">Cashflow</a>
-        <a class="nav" href={% url cs_reportes %}>Reportes</a>  		   	
+        <a class="nav" href={% url cs_cashflow2 cuenta.nombre %}>Cashflow</a>
+        <a class="nav" href={% url cs_reportes cuenta.nombre %}>Reportes</a>  		   	
     </div>
     <div id="main">
         <h1>Reportes</h1>
                 <ul>
                 Cuentas:
                 {% for c in cuentas %}
-                    <li><a class="nav" href="#">Personal</a></li>
+                    <li><a class="nav" href={% url cs_reportes cuenta.nombre %}>{{ cuenta.nombre }}</a></li>
                 {% endfor %}
                 </ul>
             </div>

templates/cashflow/welcome.html

     <div class="breadcrumbs">
         <a class="nav" href={% url cs_welcome %}>Home</a>
         <a class="nav" href={% url cs_cashflow2 cuenta %}>Cashflow</a>
-        <a class="nav" href={% url cs_reportes %}>Reportes</a>  		   	
+        <a class="nav" href={% url cs_reportes cuenta %}>Reportes</a>  		   	
     </div>
     <div id="main">
 	<h2>Bienvenido {{ user.username }}</h2>