Conjunto de cambios c079de3 en seiven para economico/models.py
- Fecha y hora:
- 08/08/2017 13:58:38 (hace 7 años)
- Branches:
- master
- Children:
- e214583
- Parents:
- 40567da
- Fichero:
-
- 1 editado
Leyenda
- No modificado
- Añadido
- Eliminado
-
economico/models.py
r40567da rc079de3 19 19 from django.utils.translation import ugettext_lazy as _ 20 20 from django.db.models import Q 21 from datetime import datetime, timedelta21 from datetime import datetime, date, time, timedelta 22 22 from itertools import islice , cycle 23 23 24 24 from 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, 26 26 TIPO_BALANZA_COMERCIAL, DOMINIO_BALANZA_COMERCIAL, BALANZA_DATOS, INVERSION_CARTERA, SECTOR_DEUDA 27 27 ) 28 28 from base.functions import enviar_correo, check_val_data 29 29 from base.models import AnhoBase 30 31 import calendar 30 32 31 33 import pyexcel … … 91 93 [ 92 94 {'tag': str(_('Año')), 'cabecera': True}, {'tag': str(_('Mes')), 'cabecera': True}, {'tag': str(_('INPC')), 'cabecera': True}, 95 93 96 {'tag': str(_('(1) Alimentos y Bebidas no Alcoholicas')), 'cabecera': True}, 94 97 {'tag': str(_('(2) Bebidas Alcoholicas y Tabaco')), 'cabecera': True}, … … 104 107 {'tag': str(_('(12) Restaurant y Hotel')), 'cabecera': True}, 105 108 {'tag': str(_('(13) Bienes y Servicios Diversos')), 'cabecera': True}, 109 106 110 {'tag': str(_('Bienes durables')), 'cabecera': True}, 107 111 {'tag': str(_('Bienes semidurables')), 'cabecera': True}, 108 112 {'tag': str(_('Bienes no durables')), 'cabecera': True}, 113 109 114 {'tag': str(_('Bienes')), 'cabecera': True}, 110 115 {'tag': str(_('Agrícolas')), 'cabecera': True}, … … 112 117 {'tag': str(_('Agroindustrial')), 'cabecera': True}, 113 118 {'tag': str(_('Otros manufacturados')), 'cabecera': True}, 119 114 120 {'tag': str(_('Total Servicios')), 'cabecera': True}, 115 121 {'tag': str(_('Servicios Básicos')), 'cabecera': True}, 116 122 {'tag': str(_('Otros Servicios')), 'cabecera': True}, 123 117 124 {'tag': str(_('Núcleo Inflacionario (NI)')), 'cabecera': True}, 118 125 {'tag': str(_('Alimentos Elaborados')), 'cabecera': True}, … … 120 127 {'tag': str(_('Bienes industriales excepto alimentos y textiles')), 'cabecera': True}, 121 128 {'tag': str(_('Servicios no administrados')), 'cabecera': True}, 129 122 130 {'tag': str(_('Controlados')), 'cabecera': True}, 123 131 {'tag': str(_('No Controlados')), 'cabecera': True} … … 133 141 kwargs['dominio'] = None 134 142 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 135 161 else: 136 162 dominio, data_type = str(_('Ciudad')), 'C' … … 140 166 fields[0].insert(2, {'tag': '', 'cabecera': True}) 141 167 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 142 194 143 195 elif not 'dominio' in kwargs or not kwargs['dominio'] == 'C': … … 1171 1223 anho_base, errors, result, message = '', '', True, '' 1172 1224 load_data_msg = str(_("Datos Cargados")) 1225 1226 self.anho_base=AnhoBase.objects.get(id=kwargs['anho_base']) 1227 1173 1228 for row in range(1,len(load_file.row_range())): 1174 1229 1175 1230 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]) 1177 1232 ## Se crea o actualiza el objeto de Demanda Agregada Interna luego de validar el valor en la hoja de calculo 1178 1233 … … 1200 1255 1201 1256 ## 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, { 1203 1258 'load_data_msg': load_data_msg, 'administrador': administrador, 'admin_email': admin_email, 1204 1259 'errors': errors
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.