Example #1
0
def savesale():
	try:
		if session['logged_in']:
			today = datetime.date.today()
			codigocliente = request.form['codigocliente']
			client=Client(True)
			#busco al cliente en la db
			result = client.seek_client(request.form["identificacion"])
			if not result[0]: # si no lo encuentra creo uno
				client.save_client(request.form["identificacion"],str(today),request.form['nombre'],request.form['direccion'],request.form['telefonofijo'],"","", str(session['usuario_completo']['codigosucursal']))
				codigocliente = client.seek_client(request.form["identificacion"])[1][0]['codigocliente']

			if codigocliente == "":
				codigocliente = client.seek_client(request.form["identificacion"])[1][0]['codigocliente']

			inventory=Inventory(False)
			for key,value in session['shoppingcart'].items():
			    # los articulos a vender del inventario
			    article = inventory.seek_inventory_byVehicleid(session['shoppingcart'][key]['idarticulo'])
			    if article[0] and (int(article[1][0]['cantidad'])-int(value['cantarticulo'])) > -1:
			    	inventory.update_quantity_inventory( article[1][0]['codigoinventario'], str(int(article[1][0]['cantidad'])-int(value['cantarticulo'])) )
			    	# del session['shoppingcart'][key]
			    else:
			    	return jsonify(results= [False,"NO hay existencia, de uno o varios articulos a vender, no se puede continuar."])

			sale=Sales(True)
			result = sale.save_sale(request.form['qcode'],str(today),str(json.dumps(session['shoppingcart'])),request.form['valorcotizacion'],str(session['usuario_completo']['codigosucursal']),str(codigocliente),request.form['qcode'],str(session['usuario_completo']['idusuario']))
			if result[0]:
				session['shoppingcart'] = {}
				return jsonify(results= result)

	except:
		exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
		return render_template('index.html')
Example #2
0
def changeprice():
	try:
		if session['logged_in']:
			inventory=Inventory(True)
			return jsonify(results=inventory.update_quantity_inventory(request.form['codigoinventario'],request.form['precio']))
	except:
		exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
		return render_template('subsidiary/prices.html')
Example #3
0
def savevehicleinventory():
	if session['logged_in'] and request.method == 'POST':
		today = datetime.date.today()
		inventory=Inventory(True)
		if session['usuario_completo']['codigosucursal']:
			return jsonify(results=inventory.save_inventory(request.form['cantidadarticulo'],str(today),str (session['usuario_completo']['codigosucursal']),request.form['categoriaarticulo'],"-1"))
		else:
			return jsonify(results=[True,"Como usuario administador no puedes hacer esta operacion<br/> <a href='/configs'><b>Establecezca una sucursal</b></a>"])
	else:
		return render_template('subsidiary/inventory.html')
Example #4
0
def loadinventoryparts():
	if session['logged_in'] and request.method == 'POST':
		inventory=Inventory(True)
		# return jsonify(results=json.loads(json.dumps(inventory.all_inventoryparts(),default=json_serial)))
		if session['usuario_completo']['codigosucursal']:
			return jsonify(results=json.loads(json.dumps(inventory.all_inventoryparts("= '"+ str (session['usuario_completo']['codigosucursal']) +"' "),default=json_serial)))
		else:
			return jsonify(results=json.loads(json.dumps(inventory.all_inventoryparts(" notnull"),default=json_serial)))
	else:
		return render_template('index.html')
Example #5
0
def changequantity():
	if session['logged_in'] and request.method == 'POST':
		inventory=Inventory(True)
		return jsonify(results=inventory.update_quantity_inventory(request.form['codigoinventario'],request.form['cantidad']))
	else:
		return render_template('subsidiary/inventory.html')