forked from elmau/empresa-libre
Get related invoice
This commit is contained in:
parent
7896d66448
commit
6339e11c37
|
@ -514,3 +514,16 @@ class AppDocumentos(object):
|
|||
'attachment; filename={}'.format(file_name))
|
||||
resp.content_type = content_type
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
# ~ Revisado
|
||||
class AppInvoicePay(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.get_invoicepay(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ from controllers.main import (AppEmpresas,
|
|||
AppLogin, AppLogout, AppAdmin, AppEmisor, AppConfig,
|
||||
AppMain, AppValues, AppPartners, AppProducts, AppInvoices, AppFolios,
|
||||
AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco,
|
||||
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina
|
||||
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina,
|
||||
AppInvoicePay
|
||||
)
|
||||
|
||||
|
||||
|
@ -55,6 +56,7 @@ api.add_route('/movbanco', AppMovimientosBanco(db))
|
|||
api.add_route('/students', AppStudents(db))
|
||||
api.add_route('/employees', AppEmployees(db))
|
||||
api.add_route('/nomina', AppNomina(db))
|
||||
api.add_route('/cfdipay', AppInvoicePay(db))
|
||||
|
||||
|
||||
# ~ Activa si usas waitress y NO estas usando servidor web
|
||||
|
|
|
@ -412,3 +412,7 @@ class StorageEngine(object):
|
|||
|
||||
def importar_bdfl(self):
|
||||
return main.importar_bdfl()
|
||||
|
||||
# ~ Revisado
|
||||
def get_invoicepay(self, values):
|
||||
return main.FacturasPagos.get_values(values)
|
||||
|
|
|
@ -5222,6 +5222,37 @@ class FacturasPagos(BaseModel):
|
|||
cls._actualizar_saldo_cliente(cls, fac.cliente, importe * -1)
|
||||
return
|
||||
|
||||
def _get_related(self, values):
|
||||
id = int(values['id'])
|
||||
filters = (FacturasPagos.movimiento==id)
|
||||
|
||||
rows = tuple(FacturasPagos
|
||||
.select(
|
||||
Facturas.id,
|
||||
Facturas.serie,
|
||||
Facturas.folio,
|
||||
Facturas.uuid,
|
||||
Facturas.fecha,
|
||||
Facturas.tipo_comprobante,
|
||||
Facturas.estatus,
|
||||
Socios.nombre.alias('cliente'),
|
||||
Facturas.total,
|
||||
FacturasPagos.saldo,
|
||||
FacturasPagos.importe,
|
||||
)
|
||||
.join(Facturas).switch(FacturasPagos)
|
||||
.join(Socios, on=(Facturas.cliente==Socios.id))
|
||||
.where(filters)
|
||||
.dicts()
|
||||
)
|
||||
|
||||
return {'ok': True, 'rows': rows}
|
||||
|
||||
@classmethod
|
||||
def get_values(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_get_{}'.format(opt))(cls, values)
|
||||
|
||||
|
||||
class PreFacturasImpuestos(BaseModel):
|
||||
factura = ForeignKeyField(PreFacturas)
|
||||
|
|
|
@ -695,6 +695,8 @@ function filter_cuenta_dates_change(range){
|
|||
function set_data_pay(row){
|
||||
var form = $$('form_banco_pagos')
|
||||
var dt = row.fecha.split(' ')
|
||||
var grid = $$('grid_pay_related')
|
||||
grid.clearAll()
|
||||
|
||||
set_way_payment('pay_way_payment')
|
||||
var wp = table_waypayment.findOne({'value': row.way_payment})
|
||||
|
@ -708,6 +710,20 @@ function set_data_pay(row){
|
|||
pay_import: row.deposito,
|
||||
pay_description: row.descripcion
|
||||
})
|
||||
|
||||
webix.ajax().get('/cfdipay', {'opt': 'related', 'id': row.id}, {
|
||||
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){
|
||||
grid.parse(values.rows, 'json')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ var grid_cfdi_pago_cols = [
|
|||
]
|
||||
|
||||
|
||||
var grid_pago_relacionadas_cols = [
|
||||
var grid_pay_related_cols = [
|
||||
{id: 'index', header: '#', adjust: 'data', css: 'right'},
|
||||
{id: 'id', header: 'ID', hidden: true},
|
||||
{id: 'serie', header: 'Serie', adjust: 'data'},
|
||||
|
@ -153,9 +153,11 @@ var grid_pago_relacionadas_cols = [
|
|||
{id: 'total', header: ['Total'], width: 125, sort: 'int',
|
||||
format: webix.i18n.priceFormat, css: 'right'},
|
||||
{id: 'saldo', header: ['Saldo'], width: 125, sort: 'int',
|
||||
format: webix.i18n.priceFormat, css: 'right'},
|
||||
format: webix.i18n.priceFormat, css: 'right', css: 'right',
|
||||
footer: 'Importe Depósito'},
|
||||
{id: 'importe', header: ['Este pago'], width: 125, sort: 'int',
|
||||
format: webix.i18n.priceFormat, css: 'right', editor: 'text'},
|
||||
format: webix.i18n.priceFormat, css: 'right',
|
||||
footer: {content: 'summColumn', css: 'right'}},
|
||||
]
|
||||
|
||||
|
||||
|
@ -223,16 +225,17 @@ var grid_cfdi_pago = {
|
|||
}
|
||||
|
||||
|
||||
var grid_pago_relacionadas = {
|
||||
var grid_pay_related = {
|
||||
view: 'datatable',
|
||||
id: 'grid_pago_relacionadas',
|
||||
id: 'grid_pay_related',
|
||||
select: 'row',
|
||||
autoConfig: false,
|
||||
adjust: true,
|
||||
autoheight: true,
|
||||
resizeColumn: true,
|
||||
headermenu: true,
|
||||
columns: grid_pago_relacionadas_cols,
|
||||
footer: true,
|
||||
columns: grid_pay_related_cols,
|
||||
on:{
|
||||
'data->onStoreUpdated':function(){
|
||||
this.data.each(function(obj, i){
|
||||
|
@ -362,7 +365,7 @@ var controls_banco_pagos = [
|
|||
label: 'Referencia', labelAlign: 'right', readonly: true},
|
||||
]},
|
||||
{cols: [
|
||||
{view: 'richselect', id: 'pay_way_payment', readonly: false,
|
||||
{view: 'richselect', id: 'pay_way_payment', readonly: true,
|
||||
name: 'pay_way_payment', label: 'Forma de Pago', required: true,
|
||||
options: [], labelWidth: 125, labelAlign: 'right'},
|
||||
{view: 'currency', type: 'text', id: 'pay_import', name: 'pay_import',
|
||||
|
@ -377,7 +380,7 @@ var controls_banco_pagos = [
|
|||
{view: 'label', label: '<b>Facturas de pago de este depósito: </b>'},
|
||||
grid_cfdi_pago,
|
||||
{view: 'label', label: '<b>Facturas relacionadas en este pago: </b>'},
|
||||
grid_pago_relacionadas
|
||||
grid_pay_related
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue