forked from elmau/empresa-libre
Evitar cancelar movimiento con factura de pago
This commit is contained in:
parent
0ec7989c75
commit
1ee3f81dcc
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -1,3 +1,20 @@
|
||||||
|
v 1.13.0 [10-sep-2018]
|
||||||
|
----------------------
|
||||||
|
- Plantilla para factura de pago
|
||||||
|
- Cancelar factura de pago
|
||||||
|
|
||||||
|
* IMPORTANTE: Es necesario realizar una migración, despues de actualizar la rama principal.
|
||||||
|
|
||||||
|
```
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
cd source/app/models
|
||||||
|
|
||||||
|
python main.py -bk
|
||||||
|
|
||||||
|
python main.py -m
|
||||||
|
```
|
||||||
|
|
||||||
v 1.12.0 [31-ago-2018]
|
v 1.12.0 [31-ago-2018]
|
||||||
----------------------
|
----------------------
|
||||||
- Soporte para facturas (complemento) de pago.
|
- Soporte para facturas (complemento) de pago.
|
||||||
|
|
|
@ -420,7 +420,8 @@ class AppMovimientosBanco(object):
|
||||||
|
|
||||||
def on_post(self, req, resp):
|
def on_post(self, req, resp):
|
||||||
values = req.params
|
values = req.params
|
||||||
req.context['result'] = self._db.add_movbanco(values)
|
# ~ req.context['result'] = self._db.add_movbanco(values)
|
||||||
|
req.context['result'] = self._db.bankmovement(values)
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
def on_delete(self, req, resp):
|
def on_delete(self, req, resp):
|
||||||
|
|
|
@ -389,8 +389,8 @@ class StorageEngine(object):
|
||||||
def cuentasbanco(self, values):
|
def cuentasbanco(self, values):
|
||||||
return main.CuentasBanco.add(values)
|
return main.CuentasBanco.add(values)
|
||||||
|
|
||||||
def add_movbanco(self, values):
|
# ~ def add_movbanco(self, values):
|
||||||
return main.MovimientosBanco.add(values)
|
# ~ return main.MovimientosBanco.add(values)
|
||||||
|
|
||||||
def get_cuentasbanco(self, values):
|
def get_cuentasbanco(self, values):
|
||||||
return main.CuentasBanco.get_(values)
|
return main.CuentasBanco.get_(values)
|
||||||
|
@ -422,3 +422,6 @@ class StorageEngine(object):
|
||||||
|
|
||||||
def cfdipay(self, values):
|
def cfdipay(self, values):
|
||||||
return main.CfdiPagos.post(values)
|
return main.CfdiPagos.post(values)
|
||||||
|
|
||||||
|
def bankmovement(self, values):
|
||||||
|
return main.MovimientosBanco.post(values)
|
||||||
|
|
|
@ -1856,7 +1856,11 @@ class MovimientosBanco(BaseModel):
|
||||||
return saldo
|
return saldo
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add(cls, values):
|
def post(cls, values):
|
||||||
|
opt = values.pop('opt')
|
||||||
|
return getattr(cls, '_{}'.format(opt))(cls, values)
|
||||||
|
|
||||||
|
def _add(self, values):
|
||||||
ids = values.pop('ids', '')
|
ids = values.pop('ids', '')
|
||||||
|
|
||||||
if ids and not Facturas.validate_count_partners(util.loads(ids)):
|
if ids and not Facturas.validate_count_partners(util.loads(ids)):
|
||||||
|
@ -1876,8 +1880,8 @@ class MovimientosBanco(BaseModel):
|
||||||
values['deposito'] = util.get_float(values['deposito'])
|
values['deposito'] = util.get_float(values['deposito'])
|
||||||
values['forma_pago'] = int(values['forma_pago'])
|
values['forma_pago'] = int(values['forma_pago'])
|
||||||
|
|
||||||
ultimo_saldo = cls._ultimo_saldo(
|
ultimo_saldo = self._ultimo_saldo(
|
||||||
cls, values['cuenta'], values['fecha'])
|
self, values['cuenta'], values['fecha'])
|
||||||
values['saldo'] = \
|
values['saldo'] = \
|
||||||
ultimo_saldo - values['retiro'] + values['deposito']
|
ultimo_saldo - values['retiro'] + values['deposito']
|
||||||
|
|
||||||
|
@ -1889,12 +1893,47 @@ class MovimientosBanco(BaseModel):
|
||||||
return {'ok': False, 'msg': msg}
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
if actualizar:
|
if actualizar:
|
||||||
saldo = cls._actualizar_saldos(cls, obj)
|
saldo = self._actualizar_saldos(self, obj)
|
||||||
if ids:
|
if ids:
|
||||||
FacturasPagos.add(obj, util.loads(ids))
|
FacturasPagos.add(obj, util.loads(ids))
|
||||||
|
|
||||||
return {'ok': True, 'saldo': saldo}
|
return {'ok': True, 'saldo': saldo}
|
||||||
|
|
||||||
|
def _cancel(self, values):
|
||||||
|
id = int(values['id'])
|
||||||
|
try:
|
||||||
|
obj = MovimientosBanco.get(MovimientosBanco.id==id)
|
||||||
|
except MovimientosBanco.DoesNotExist:
|
||||||
|
msg = 'No se encontró el movimiento'
|
||||||
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
if obj.cancelado:
|
||||||
|
msg = 'El movimiento ya esta cancelado'
|
||||||
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
if obj.conciliado:
|
||||||
|
msg = 'El movimiento esta conciliado, no se puede cancelar'
|
||||||
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
filters = (CfdiPagos.movimiento==obj)
|
||||||
|
cp = CfdiPagos.select().where(filters).count()
|
||||||
|
if cp > 0:
|
||||||
|
msg = 'El movimiento tiene Factura de Pago, no se puede cancelar'
|
||||||
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
with database_proxy.transaction():
|
||||||
|
obj.cancelado = True
|
||||||
|
obj.save()
|
||||||
|
FacturasPagos.cancelar(obj)
|
||||||
|
|
||||||
|
obj = self._movimiento_anterior(self, obj.cuenta, obj.fecha)
|
||||||
|
self._actualizar_saldos(self, obj)
|
||||||
|
|
||||||
|
balance = CuentasBanco.get_saldo(obj.cuenta.id)
|
||||||
|
|
||||||
|
msg = 'Movimiento cancelado correctamente'
|
||||||
|
return {'ok': False, 'msg': msg, 'balance': balance}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def remove(cls, id):
|
def remove(cls, id):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -47,7 +47,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.12.0'
|
VERSION = '1.13.0'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
|
|
@ -282,6 +282,7 @@ function guardar_retiro(values){
|
||||||
|
|
||||||
var importe = get_float(values.retiro_importe)
|
var importe = get_float(values.retiro_importe)
|
||||||
var data = new Object()
|
var data = new Object()
|
||||||
|
data['opt'] = 'add'
|
||||||
data['cuenta'] = $$('lst_cuentas_banco').getValue()
|
data['cuenta'] = $$('lst_cuentas_banco').getValue()
|
||||||
data['fecha'] = values.retiro_fecha
|
data['fecha'] = values.retiro_fecha
|
||||||
data['hora'] = $$('time_retiro').getText()
|
data['hora'] = $$('time_retiro').getText()
|
||||||
|
@ -519,6 +520,7 @@ function guardar_deposito(values){
|
||||||
var grid = $$('grid_cfdi_este_deposito')
|
var grid = $$('grid_cfdi_este_deposito')
|
||||||
|
|
||||||
var data = new Object()
|
var data = new Object()
|
||||||
|
data['opt'] = 'add'
|
||||||
data['cuenta'] = $$('lst_cuentas_banco').getValue()
|
data['cuenta'] = $$('lst_cuentas_banco').getValue()
|
||||||
data['fecha'] = values.deposito_fecha
|
data['fecha'] = values.deposito_fecha
|
||||||
data['hora'] = $$('time_deposito').getText()
|
data['hora'] = $$('time_deposito').getText()
|
||||||
|
@ -610,17 +612,36 @@ function cmd_guardar_deposito_click(){
|
||||||
|
|
||||||
|
|
||||||
function cancelar_movimiento(id){
|
function cancelar_movimiento(id){
|
||||||
var grid = $$('grid_cuentabanco')
|
//~ var grid = $$('grid_cuentabanco')
|
||||||
|
|
||||||
webix.ajax().del('/movbanco', {id: id}, function(text, xml, xhr){
|
//~ webix.ajax().del('/movbanco', {id: id}, function(text, xml, xhr){
|
||||||
if(xhr.status == 200){
|
//~ if(xhr.status == 200){
|
||||||
get_estado_cuenta()
|
//~ get_estado_cuenta()
|
||||||
get_saldo_cuenta()
|
//~ get_saldo_cuenta()
|
||||||
msg_ok('Movimiento cancelado correctamente')
|
//~ msg_ok('Movimiento cancelado correctamente')
|
||||||
}else{
|
//~ }else{
|
||||||
msg_error('No se pudo eliminar')
|
//~ msg_error('No se pudo eliminar')
|
||||||
|
//~ }
|
||||||
|
//~ })
|
||||||
|
|
||||||
|
var data = {'opt': 'cancel', 'id': id}
|
||||||
|
webix.ajax().post('/movbanco', data, {
|
||||||
|
error:function(text, data, XmlHttpRequest){
|
||||||
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success:function(text, data, XmlHttpRequest){
|
||||||
|
var values = data.json()
|
||||||
|
if(values.ok){
|
||||||
|
get_estado_cuenta()
|
||||||
|
$$('txt_cuenta_saldo').setValue(values.balance)
|
||||||
|
msg_ok(values.msg)
|
||||||
|
}else{
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -871,7 +892,7 @@ function save_cfdi_pay(form){
|
||||||
function cmd_pay_stamp_click(){
|
function cmd_pay_stamp_click(){
|
||||||
var form = $$('form_bank_pay')
|
var form = $$('form_bank_pay')
|
||||||
var title = 'Timbrar Factura de Pago'
|
var title = 'Timbrar Factura de Pago'
|
||||||
msg = '¿Estás seguro de enviar a timbrar este pago?'
|
msg = '¿Estás seguro de enviar a timbrar este pago?<BR><BR>EL MOVIMIENTO YA NO PODRÁ SER MODIFICADO'
|
||||||
|
|
||||||
if (!validate_cfdi_pay(form)){
|
if (!validate_cfdi_pay(form)){
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue