Conjunto de cambios c079de3 en seiven para economico/models.py


Ignorar:
Fecha y hora:
08/08/2017 13:58:38 (hace 7 años)
Autor:
Luis Barrios <nikeven@…>
Branches:
master
Children:
e214583
Parents:
40567da
Mensaje:

modificada descarga de archivo para precios

Fichero:
1 editado

Leyenda

No modificado
Añadido
Eliminado
  • economico/models.py

    r40567da rc079de3  
    1919from django.utils.translation import ugettext_lazy as _
    2020from django.db.models import Q
    21 from datetime import datetime, timedelta
     21from datetime import datetime, date, time, timedelta
    2222from itertools import islice , cycle
    2323
    2424from base.constant import (
    25     DOMINIO, PERIODICIDAD, TRIMESTRES, MESES, ECONOMICO_SUB_AREA, CONVERT_MES, EMAIL_SUBJECT_LOAD_DATA,
     25    DOMINIO, PERIODICIDAD, TRIMESTRES, MESES, ECONOMICO_SUB_AREA, CONVERT_MES, EMAIL_SUBJECT_LOAD_DATA,EMAIL_SUBJECT_CM_RESULT,
    2626    TIPO_BALANZA_COMERCIAL, DOMINIO_BALANZA_COMERCIAL, BALANZA_DATOS, INVERSION_CARTERA, SECTOR_DEUDA
    2727)
    2828from base.functions import enviar_correo, check_val_data
    2929from base.models import AnhoBase
     30
     31import calendar
    3032
    3133import pyexcel
     
    9193            [
    9294                {'tag': str(_('Año')), 'cabecera': True}, {'tag': str(_('Mes')), 'cabecera': True}, {'tag': str(_('INPC')), 'cabecera': True},
     95               
    9396                {'tag': str(_('(1) Alimentos y Bebidas no Alcoholicas')), 'cabecera': True},
    9497                {'tag': str(_('(2) Bebidas Alcoholicas y Tabaco')), 'cabecera': True},
     
    104107                {'tag': str(_('(12) Restaurant y Hotel')), 'cabecera': True},
    105108                {'tag': str(_('(13) Bienes y Servicios Diversos')), 'cabecera': True},
     109
    106110                {'tag': str(_('Bienes durables')), 'cabecera': True},
    107111                {'tag': str(_('Bienes semidurables')), 'cabecera': True},
    108112                {'tag': str(_('Bienes no durables')), 'cabecera': True},
     113
    109114                {'tag': str(_('Bienes')), 'cabecera': True},
    110115                {'tag': str(_('Agrícolas')), 'cabecera': True},
     
    112117                {'tag': str(_('Agroindustrial')), 'cabecera': True},
    113118                {'tag': str(_('Otros manufacturados')), 'cabecera': True},
     119
    114120                {'tag': str(_('Total Servicios')), 'cabecera': True},
    115121                {'tag': str(_('Servicios Básicos')), 'cabecera': True},
    116122                {'tag': str(_('Otros Servicios')), 'cabecera': True},
     123
    117124                {'tag': str(_('Núcleo Inflacionario (NI)')), 'cabecera': True},
    118125                {'tag': str(_('Alimentos Elaborados')), 'cabecera': True},
     
    120127                {'tag': str(_('Bienes industriales excepto alimentos y textiles')), 'cabecera': True},
    121128                {'tag': str(_('Servicios no administrados')), 'cabecera': True},
     129
    122130                {'tag': str(_('Controlados')), 'cabecera': True},
    123131                {'tag': str(_('No Controlados')), 'cabecera': True}
     
    133141                kwargs['dominio'] = None
    134142                kwargs['ciudad'] = kwargs.pop('dominio')
     143                lst=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']
     144                x = int (kwargs['fecha__month__lte']) - int (kwargs['fecha__month__gte']) + 1 +  12 * (int(kwargs['fecha__year__lte']) - int(kwargs['fecha__year__gte']))
     145                for i, val in enumerate(lst):
     146                    if lst[int(kwargs['fecha__month__gte'])-1] in val:
     147                        desired = list( islice( cycle( lst), i, i+x))
     148                        tmp=0
     149                        lolo=int (kwargs['fecha__year__gte'])
     150                        aux=1
     151                        for a in desired:
     152                            aux1=''
     153                            if a == 'Diciembre':
     154                                aux1=lolo+tmp
     155                                tmp=tmp+1
     156                            else:
     157                                aux1=lolo+tmp
     158                            aux=aux+1
     159                            fields.append([ {'tag': str(_(str(aux1)))}, {'tag': str(_(str(a)))}])
     160
    135161            else:
    136162                dominio, data_type = str(_('Ciudad')), 'C'
     
    140166                fields[0].insert(2, {'tag': '', 'cabecera': True})
    141167                fields[1].insert(2, {'tag': dominio, 'cabecera': True})
     168
     169                lst=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']
     170                lst1=['Caracas','Maracay','Ciudad Guayana','Barcelona -Pto la Cruz','Valencia','Barquisimeto','Maracaibo','Mérida','Maturín','San Cristóbal','Resto Nacional']
     171
     172                x = int (kwargs['fecha__month__lte']) - int (kwargs['fecha__month__gte']) + 1 +  12 * (int(kwargs['fecha__year__lte']) - int(kwargs['fecha__year__gte']))
     173                for i, val in enumerate(lst):
     174                    if lst[int(kwargs['fecha__month__gte'])-1] in val:
     175                        desired = list( islice( cycle( lst), i, i+x))
     176                        tmp=0
     177                        lolo=int (kwargs['fecha__year__gte'])
     178                        aux,aux2=1,0
     179                        for a in desired:
     180                            aux1=''
     181                            if a == 'Diciembre':
     182                                aux1=lolo+tmp
     183                                tmp=tmp+1
     184                            else:
     185                                aux1=lolo+tmp
     186                            aux=aux+1
     187                            for q in range(0,11):
     188                                if lst1[q] == 'Caracas':
     189                                    fields.append([ {'tag': str(_(str(aux1))),'combine_row':11 }, {'tag': str(_(str(a))), 'combine_row1':11},{'tag': str(_(str(lst1[q])))}])
     190                                else:
     191                                    fields.append([{'tag':''},{'tag':''},{'tag': str(_(str(lst1[q])))}])
     192
     193
    142194
    143195        elif not 'dominio' in kwargs or not kwargs['dominio'] == 'C':
     
    11711223        anho_base, errors, result, message = '', '', True, ''
    11721224        load_data_msg = str(_("Datos Cargados"))
     1225
     1226        self.anho_base=AnhoBase.objects.get(id=kwargs['anho_base'])
     1227       
    11731228        for row in range(1,len(load_file.row_range())):
    11741229           
    11751230            try:
    1176                 real_demanda , created = DemandaGlobal.objects.update_or_create(anho=load_file[row,0], anho_base=kwargs['anho_base'], trimestre=load_file[row,1], demanda_global= load_file[row,2]+load_file[row,7])
     1231                real_demanda , created = DemandaGlobal.objects.update_or_create(anho=load_file[row,0], anho_base=self.anho_base, trimestre=load_file[row,1], demanda_global= load_file[row,2]+load_file[row,7])
    11771232                ## Se crea  o actualiza el objeto de Demanda Agregada Interna luego de validar el valor en la hoja de calculo
    11781233
     
    12001255
    12011256        ## Envia correo electronico al usuario indicando el estatus de la carga de datos
    1202         enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_CM_RESULT, {
     1257        enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_LOAD_DATA, {
    12031258            'load_data_msg': load_data_msg, 'administrador': administrador, 'admin_email': admin_email,
    12041259            'errors': errors
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.