def post(self): id_list = [int(identifier) for identifier in self.get_argument("id_list", "").split(",")] cellar = Cellar() res_cellars = cellar.FindById(id_list) self.write(json_util.dumps(res_cellars))
def post(self): cellar_id = self.get_argument("cellar_id", "") cellar = Cellar() if cellar_id != "": res = cellar.SelectReservation(cellar_id) self.write(json_util.dumps(res)) else: self.write(json_util.dumps({"error": "Cellar id is not valid"}))
def get(self): # validate access token if not self.ValidateToken(): return idd = self.get_argument("id", "") cellar = Cellar() cellar.InitById(idd) self.write(json_util.dumps(cellar.Remove())) pass
def post(self): if not self.ValidateToken(): return cellar_id = self.get_argument("cellar_id", "") sku = self.get_argument("sku", "") size = self.get_argument("size", "") cellar = Cellar() self.write( json_util.dumps(cellar.FindProductKardex(sku, cellar_id, size)))
def get(self): # validate access token if not self.ValidateToken(): return idd = self.get_argument("id", "") product_list = self.get_argument("products", "") cellar = Cellar() cellar.InitWithId(idd) # self.write(cellar.RemoveProducts(product_list)) pass
def get(self): # validate access token if not self.ValidateToken(): return page = self.get_argument("page", 1) items = self.get_argument("items", 10) day = self.get_argument("day", "") fromm = self.get_argument("from", "") until = self.get_argument("until", "") cellar = Cellar() self.write( json_util.dumps(cellar.ListKardex(page, items, day, fromm, until))) pass
def addTesting(add_data): print "\nrunning /cellar/add testing" add_url = ws_url + "cellar/add?" + urllib.urlencode(add_data) add_results = urllib.urlopen(add_url).read() cellar = Cellar() cellar.InitWithId(add_results, db.cellar) #print "results : " + cellar.name if cellar.name == add_data["name"]: print "ok" else: print "failed" print "testing results: " + add_results return add_results
def get(self): # validate access token cellar_name = self.get_argument("cellar_name", "") cellar_exist = Cellar.CellarExists(cellar_name) self.write(json_util.dumps({"exists": cellar_exist})) pass
def get(self): # validate access token if not self.ValidateToken(): return idd = self.get_argument("id", "") page = self.get_argument("page", 1) items = self.get_argument("items", 10) cellar = Cellar() response_obj = cellar.InitById(idd) if "success" in response_obj: self.write(json_util.dumps(cellar.ListProducts(page, items))) else: self.write(response_obj["error"])
def get(self): # validate access token if not self.ValidateToken(): return page = self.get_argument("page", 1) items = self.get_argument("items", 10) self.write(Cellar().GetList(int(page), int(items)))
def get(self): # validate access token if not self.ValidateToken(): return idd = self.get_argument("id", "") name = self.get_argument("name", "") cellar = Cellar() if idd != "": res_id = cellar.InitById(idd) if "success" in res_id: self.write(json_util.dumps(cellar.Print())) else: self.write(json_util.dumps(res_id)) else: res_name = cellar.InitByName(name) if "success" in res_name: self.write(json_util.dumps(cellar.Print())) else: self.write(json_util.dumps(res_name))
def editTesting(add_results, edit_data): print "\nrunning /cellar/edit testing" edit_data["id"] = add_results print "edit id: " + edit_data["id"] edit_url = ws_url + "cellar/edit?" + urllib.urlencode(edit_data) edit_results = urllib.urlopen(edit_url).read() cellar = Cellar() cellar.InitWithId(edit_results, db.cellar) print "cellar id: " + str(cellar.identifier) #print "testing results : " + cellar.name if cellar.name == edit_data["name"] and cellar.identifier == edit_data[ "id"]: print "ok" else: print "failed" return edit_results
def get(self): # validate access token if not self.ValidateToken(): return cellar = Cellar() cellar.name = self.get_argument("name", "") cellar.description = self.get_argument("description", "") cellar.id = self.get_argument("id", "") cellar.city = self.get_argument("city", 0) self.write(json_util.dumps((cellar.Save())))
def post(self): if not self.ValidateToken(): self.write(json_util.dumps({"error": "invalid token"})) else: order_id = self.get_argument("order_id", "") tracking_code = self.get_argument("tracking_code", "") provider_id = self.get_argument("provider_id", "") new_cellar_id = self.get_argument("new_cellar_id", "") c = Cellar() res_reservation = c.GetReservationCellar() if "success" in res_reservation: new_cellar_id = res_reservation["success"] if order_id == "": self.write(json_util.dumps({"error": "invalid order_id"})) elif tracking_code == "": self.write(json_util.dumps({"error": "invalid tracking_code"})) elif provider_id == "": self.write(json_util.dumps({"error": "invalid provider_id"})) else: cellar = Cellar() order_detail = OrderDetail() details_res = order_detail.ListByOrderId(order_id) if "success" in details_res: details = details_res["success"] for detail in details: sku = detail["sku"] quantity = detail["quantity"] operation = Kardex.OPERATION_SELL sell_price = detail["price"] _size = Size() _size.name = detail["size"] res_name = _size.initByName() if "success" in res_name: size = _size.id else: print res_name["error"] color = detail["color"] user = '******' k = Kardex() find_kardex = k.FindKardex(sku, new_cellar_id, size) balance_price = 0 units = 0 if "success" in find_kardex: balance_price = k.balance_price units = k.balance_units if int(units) >= int(quantity): kardex = Kardex() kardex.product_sku = sku kardex.cellar_identifier = new_cellar_id kardex.date = str( datetime.datetime.now( pytz.timezone( 'Chile/Continental')).isoformat()) kardex.operation_type = operation kardex.units = quantity kardex.price = balance_price kardex.size_id = size kardex.sell_price = sell_price kardex.color = color kardex.user = user response_kardex = kardex.Insert() if "error" in response_kardex: self.write(json_util.dumps(response_kardex)) return else: self.write( json_util.dumps({ "error": "Stock insuficiente para realizar el movimiento" })) return shipping = Shipping() res = shipping.SaveTrackingCode(order_id, tracking_code, provider_id) self.write(json_util.dumps(res))
def post(self): cellar = Cellar() self.write(json_util.dumps(cellar.GetWebCellar()))
def post(self): #validate constrains if not self.ValidateToken(): return ids = self.get_argument("ids", "") cellar_id = None web_cellar = None cellar = Cellar() res_reservation_cellar = cellar.GetReservationCellar() if "success" in res_reservation_cellar: cellar_id = res_reservation_cellar["success"] else: self.write( json_util.dumps({"error": res_reservation_cellar["error"]})) if ids == "": self.write(json_util.dumps({"error": "ids viene vacio"})) else: identificadores = [] for identificador in ids.split(","): order = Order() res_order = order.GetOrderById(identificador) cancelable = True if "success" in res_order: o = res_order["success"] if o["state"] != Order.ESTADO_CANCELADO and o[ "state"] != Order.ESTADO_DESPACHADO: order_detail = OrderDetail() details_res = order_detail.ListByOrderId(identificador) if "success" in details_res: details = details_res["success"] # recorre cada producto del detalle de orden y determina si la orden es cancelable for d in details: k = Kardex() find_kardex = k.FindKardex( d["sku"], cellar_id, d['size_id']) units = 0 if "success" in find_kardex: units = k.balance_units if int(units) < int(d['quantity']): cancelable = False # end for # si no es cancelable la orden se guarda en el array identificadores para avisar al usuario if not cancelable: identificadores.append({ "identificador": identificador, "error": "no tiene stock suficiente" }) else: cellar = Cellar() res_web_cellar = cellar.GetWebCellar() if "success" in res_web_cellar: web_cellar = res_web_cellar["success"] # mueve c/u de los productos desde la bodega de reserva a la bodega web kardex = Kardex() res = kardex.moveOrder(details, web_cellar, cellar_id) if "error" in res: identificadores.append({ "identificador": identificador, "error": res["error"] }) else: if identificador not in identificadores: identificadores.append({ "identificador": identificador, "error": details_res["error"] }) elif o["state"] == Order.ESTADO_DESPACHADO: if identificador not in identificadores: identificadores.append( identificadores.append({ "identificador": identificador, "error": "Pedido no puede ser cancelado, ya que se encuentra despachado" })) else: if identificador not in identificadores: identificadores.append( identificadores.append({ "identificador": identificador, "error": "Pedido ya esta cancelado" })) else: if identificador not in identificadores: identificadores.append( identificadores.append({ "identificador": identificador, "error": res_order["error"] })) if len(identificadores) > 0: self.write(json_util.dumps({"error": identificadores})) else: self.write(json_util.dumps({"success": "ok"}))
def post(self): cellar = Cellar() self.write(json_util.dumps(cellar.GetReservationCellar()))