Get details from ticket
This commit is contained in:
parent
98f091a347
commit
2e5f4ac27e
|
@ -726,6 +726,18 @@ class AppWareHouseProduct(object):
|
|||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppTicketsDetails(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp):
|
||||
values = req.params
|
||||
user = req.env['beaker.session']['userobj']
|
||||
req.context['result'] = self._db.ticketsdetails_get(values, user)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppUsers(object):
|
||||
|
||||
def __init__(self, db):
|
||||
|
|
|
@ -20,9 +20,10 @@ from controllers.main import (AppEmpresas,
|
|||
AppSATFormaPago, AppSATLeyendaFiscales, AppCert, AppSucursales,
|
||||
AppPartnerProducts,
|
||||
AppInventoryEntries,
|
||||
AppTicketsDetails,
|
||||
AppUsers,
|
||||
AppWareHouse,
|
||||
AppWareHouseProduct,
|
||||
AppUsers,
|
||||
)
|
||||
|
||||
|
||||
|
@ -73,6 +74,7 @@ api.add_route('/partnerproducts', AppPartnerProducts(db))
|
|||
api.add_route('/inventoryentries', AppInventoryEntries(db))
|
||||
api.add_route('/warehouse', AppWareHouse(db))
|
||||
api.add_route('/warehouseproduct', AppWareHouseProduct(db))
|
||||
api.add_route('/ticketsdetails', AppTicketsDetails(db))
|
||||
api.add_route('/users', AppUsers(db))
|
||||
|
||||
|
||||
|
|
|
@ -502,6 +502,9 @@ class StorageEngine(object):
|
|||
def users_post(self, args, user):
|
||||
return main.Usuarios.post(args, user)
|
||||
|
||||
def ticketsdetails_get(self, filters, user):
|
||||
return main.TicketsDetalle.get_data(filters, user)
|
||||
|
||||
# Companies only in MV
|
||||
def _get_empresas(self, values):
|
||||
return main.companies_get()
|
||||
|
|
|
@ -8211,6 +8211,37 @@ class TicketsDetalle(BaseModel):
|
|||
|
||||
return data
|
||||
|
||||
def _get_by_ticket_id(cls, args, user):
|
||||
products = []
|
||||
id = int(args['id'])
|
||||
rows = TicketsDetalle.select().where(TicketsDetalle.ticket==id)
|
||||
|
||||
for row in rows:
|
||||
# ~ descuento
|
||||
# ~ precio_final
|
||||
# ~ inventario
|
||||
# ~ existencia
|
||||
product = dict(
|
||||
id_product = row.producto.id,
|
||||
clave = row.producto.clave,
|
||||
clave_sat = row.producto.clave_sat,
|
||||
descripcion = row.descripcion,
|
||||
unidad = row.producto.unidad.id,
|
||||
cantidad = float(row.cantidad),
|
||||
valor_unitario = cls._with_tax(cls, row),
|
||||
)
|
||||
product['importe'] = round(
|
||||
product['valor_unitario'] * product['cantidad'], DECIMALES)
|
||||
products.append(product)
|
||||
|
||||
return tuple(products)
|
||||
|
||||
@classmethod
|
||||
def get_data(cls, values, user):
|
||||
opt = values.pop('opt')
|
||||
method = f'_get_{opt}'
|
||||
return getattr(cls, method)(cls, values, user)
|
||||
|
||||
|
||||
class TicketsImpuestos(BaseModel):
|
||||
ticket = ForeignKeyField(Tickets)
|
||||
|
|
|
@ -197,8 +197,9 @@ function cmd_ticket_from_ticket_click(){
|
|||
return
|
||||
}
|
||||
|
||||
id = row['id']
|
||||
|
||||
configuracion_inicial_nuevo_ticket()
|
||||
$$('multi_tickets').setValue('tickets_new')
|
||||
$$('grid_tdetails').load('ticketsdetails?opt=by_ticket_id&id=' + row.id)
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue