Add support for change time zone
This commit is contained in:
parent
6d4023bb17
commit
bd1699d082
|
@ -772,7 +772,8 @@ def db_backup_local():
|
|||
|
||||
|
||||
def now():
|
||||
return datetime.datetime.now().replace(microsecond=0)
|
||||
n = datetime.datetime.now().replace(microsecond=0)
|
||||
return n
|
||||
|
||||
|
||||
def get_days(date):
|
||||
|
@ -1114,3 +1115,10 @@ def to_date(value):
|
|||
dt = datetime.datetime.combine(d, t)
|
||||
return dt
|
||||
|
||||
|
||||
def adjust_time(date_invoice, hours):
|
||||
new_date = date_invoice
|
||||
if hours:
|
||||
time_change = datetime.timedelta(hours=hours)
|
||||
new_date = date_invoice + time_change
|
||||
return new_date
|
||||
|
|
|
@ -1017,6 +1017,7 @@ class Emisor(BaseModel):
|
|||
logo = TextField(default='')
|
||||
registro_patronal = TextField(default='')
|
||||
regimenes = ManyToManyField(SATRegimenes, related_name='emisores')
|
||||
hours = IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
order_by = ('nombre',)
|
||||
|
@ -1077,7 +1078,8 @@ class Emisor(BaseModel):
|
|||
'ong_fecha_dof': obj.fecha_dof,
|
||||
'token_soporte': obj.token_soporte,
|
||||
'emisor_registro_patronal': obj.registro_patronal,
|
||||
'regimenes': [row.id for row in obj.regimenes]
|
||||
'regimenes': [row.id for row in obj.regimenes],
|
||||
'emisor_hours': obj.hours
|
||||
}
|
||||
else:
|
||||
row['emisor'] = {'emisor_rfc': rfc}
|
||||
|
@ -1156,6 +1158,8 @@ class Emisor(BaseModel):
|
|||
fields['registro_patronal'] = fields.pop('emisor_registro_patronal', '')
|
||||
fields['regimenes'] = SATRegimenes.get_(
|
||||
util.loads(fields['regimenes']))
|
||||
fields['hours'] = int(fields.pop('emisor_hours', 0))
|
||||
|
||||
return fields
|
||||
|
||||
@classmethod
|
||||
|
@ -4526,7 +4530,7 @@ class Facturas(BaseModel):
|
|||
version = TextField(default=PRE_DEFAULT['CFDI']['VERSION'])
|
||||
serie = TextField(default='')
|
||||
folio = BigIntegerField(default=0)
|
||||
fecha = DateTimeField(default=util.now, formats=['%Y-%m-%d %H:%M:%S'])
|
||||
fecha = DateTimeField(default=utils.now, formats=['%Y-%m-%d %H:%M:%S'])
|
||||
fecha_timbrado = DateTimeField(null=True)
|
||||
forma_pago = TextField(default='')
|
||||
condiciones_pago = TextField(default='')
|
||||
|
@ -5636,6 +5640,7 @@ class Facturas(BaseModel):
|
|||
|
||||
leyendas_fiscales = utils.loads(values.pop('leyendas_fiscales', '[]'))
|
||||
|
||||
values['fecha'] = utils.now()
|
||||
date_invoice = values.pop('date')
|
||||
if Configuracion.get_bool('chk_config_change_date_invoice'):
|
||||
values['fecha'] = utils.to_date(date_invoice)
|
||||
|
@ -5646,6 +5651,8 @@ class Facturas(BaseModel):
|
|||
return data
|
||||
|
||||
emisor = Emisor.select()[0]
|
||||
values['fecha'] = utils.adjust_time(values['fecha'], emisor.hours)
|
||||
|
||||
values['serie'] = cls._get_serie(cls, user, values['serie'])
|
||||
if Configuracion.get_bool('chk_folio_custom') and folio_custom:
|
||||
fc = {'folio': folio_custom, 'serie': values['serie']}
|
||||
|
@ -11116,8 +11123,10 @@ def _migrate_tables(rfc=''):
|
|||
'emisor', 'registro_patronal', registro_patronal))
|
||||
if not 'curp' in columns:
|
||||
curp = TextField(default='')
|
||||
migrations.append(
|
||||
migrator.add_column('emisor', 'curp', curp))
|
||||
migrations.append(migrator.add_column('emisor', 'curp', curp))
|
||||
if not 'hours' in columns:
|
||||
hours = IntegerField(default=0)
|
||||
migrations.append(migrator.add_column('emisor', 'hours', hours))
|
||||
|
||||
columns = [c.name for c in database_proxy.get_columns('socios')]
|
||||
if not 'id_fiscal' in columns:
|
||||
|
|
|
@ -534,9 +534,8 @@ function validate_invoice(values){
|
|||
}
|
||||
|
||||
var is_global = $$('cmd_show_global_information').isVisible()
|
||||
|
||||
if(is_global){
|
||||
if(values_global==''){
|
||||
if(values_global=='' && tipo_comprobante=='I'){
|
||||
msg = 'Captura los datos de la Factura Global'
|
||||
msg_error(msg)
|
||||
return false
|
||||
|
|
|
@ -176,7 +176,9 @@ var emisor_datos_fiscales = [
|
|||
invalidMessage: 'El C.P. es requerido'},
|
||||
{view: 'text', id: 'emisor_cp2', name: 'emisor_cp2', width: 300,
|
||||
label: 'C.P. de Expedición: ', attributes: {maxlength: 5}},
|
||||
{}]},
|
||||
{view: 'counter', id: 'emisor_hours', name: 'emisor_hours', value: 0,
|
||||
required: false, label: 'Horas Dif.: ', step: 1, min: -1, max: 3}
|
||||
]},
|
||||
{cols: [
|
||||
{view: 'label', label: 'Regimenes Fiscales *', required: true}, {}]},
|
||||
{cols: [{view: 'list', id: 'lst_emisor_regimen', select: 'multiselect',
|
||||
|
|
Loading…
Reference in New Issue