def validateBuyerInterestData(buyer_interest, old_buyer_interest, is_new): flag = 0 if not "scale" in buyer_interest or not validate_buyer_interest_scale(buyer_interest["scale"]): buyer_interest["scale"] = old_buyer_interest.scale if not "min_price_per_unit" in buyer_interest or not validate_number(buyer_interest["min_price_per_unit"]) or not float(buyer_interest["min_price_per_unit"]) >= 0: buyer_interest["min_price_per_unit"] = old_buyer_interest.min_price_per_unit if not "max_price_per_unit" in buyer_interest or not validate_number(buyer_interest["max_price_per_unit"]) or not float(buyer_interest["max_price_per_unit"]) >= 0: buyer_interest["max_price_per_unit"] = old_buyer_interest.max_price_per_unit if not "fabric_filter_text" in buyer_interest or buyer_interest["fabric_filter_text"]==None: buyer_interest["fabric_filter_text"] = old_buyer_interest.fabric_filter_text if not "productid_filter_text" in buyer_interest or buyer_interest["productid_filter_text"]==None: buyer_interest["productid_filter_text"] = old_buyer_interest.productid_filter_text if not "is_active" in buyer_interest or not validate_bool(buyer_interest["is_active"]): buyer_interest["is_active"] = old_buyer_interest.is_active if float(buyer_interest["max_price_per_unit"]) > float(buyer_interest["min_price_per_unit"]): buyer_interest["price_filter_applied"] = True else: buyer_interest["price_filter_applied"] = False buyer_interest["min_price_per_unit"] = 0.0 buyer_interest["max_price_per_unit"] = 0.0 if is_new == 1 and flag == 1: return False return True
def validateProductData(product, oldproduct, is_new): flag = 0 if not "name" in product or product["name"] == None: flag = 1 product["name"] = oldproduct.name if not "price_per_unit" in product or not validate_number( product["price_per_unit"]): flag = 1 product["price_per_unit"] = oldproduct.price_per_unit if not "unit" in product or product["unit"] == None: product["unit"] = oldproduct.unit if not "tax" in product or not validate_number(product["tax"]): product["tax"] = oldproduct.tax if not "min_price_per_unit" in product or not validate_number( product["min_price_per_unit"]): product["min_price_per_unit"] = oldproduct.min_price_per_unit if not "lot_size" in product or not validate_integer(product["lot_size"]): flag = 1 product["lot_size"] = oldproduct.lot_size if not "price_per_lot" in product or not validate_number( product["price_per_lot"]): flag = 1 product["price_per_lot"] = oldproduct.price_per_lot if not "verification" in product or not validate_bool( product["verification"]): product["verification"] = oldproduct.verification if not "show_online" in product or not validate_bool( product["show_online"]): product["show_online"] = oldproduct.show_online if not "slug" in product or product["slug"] == None: product["slug"] = oldproduct.slug if not "display_name" in product or product["display_name"] == None: product["display_name"] = oldproduct.display_name if not "is_catalog" in product or not validate_bool(product["is_catalog"]): product["is_catalog"] = oldproduct.is_catalog if not "delete_status" in product or not validate_bool( product["delete_status"]): product["delete_status"] = oldproduct.delete_status if not float(product["min_price_per_unit"]) > 0 or not float( product["price_per_lot"]) > 0 or not float( product["price_per_unit"]) > 0: return False if not float(product["price_per_unit"]) >= float( product["min_price_per_unit"]) or not float( product["price_per_lot"]) >= float(product["price_per_unit"]): return False if is_new == 1 and flag == 1: return False return True
def populateProductFilterParameters(request, parameters={}, version="0"): productID = request.GET.get("productID", "") if productID != "" and productID != None: parameters["productsArr"] = getArrFromString(productID) categoryID = request.GET.get("categoryID", "") if categoryID != "" and categoryID != None: parameters["categoriesArr"] = getArrFromString(categoryID) fabric = request.GET.get("fabric", "") if fabric != "" and fabric != None: parameters["fabricArr"] = getStrArrFromString(fabric) colour = request.GET.get("colour", "") if colour != "" and colour != None: parameters["colourArr"] = getStrArrFromString(colour) sizes = request.GET.get("sizes", "") if sizes != "" and sizes != None: parameters["sizesArr"] = getStrArrFromString(sizes) productShowOnline = request.GET.get("product_show_online", "") if productShowOnline != "" and validate_bool(productShowOnline): parameters["product_show_online"] = int(productShowOnline) productVerification = request.GET.get("product_verification", "") if productVerification != "" and validate_bool(productVerification): parameters["product_verification"] = int(productVerification) min_price_per_unit = request.GET.get("min_price_per_unit", "") max_price_per_unit = request.GET.get("max_price_per_unit", "") if validate_number(min_price_per_unit) and validate_number( max_price_per_unit) and float(min_price_per_unit) >= 0 and float( max_price_per_unit) > float(min_price_per_unit): parameters["price_filter_applied"] = True parameters["min_price_per_unit"] = float(min_price_per_unit) parameters["max_price_per_unit"] = float(max_price_per_unit) productOrderBy = request.GET.get("product_order_by", "") if productOrderBy != "" and productOrderBy != None: parameters["product_order_by"] = productOrderBy productUpdatedAt = request.GET.get("product_updated_at", "") if productUpdatedAt != "" and productUpdatedAt != None: parameters["product_updated_at"] = productUpdatedAt return parameters
def validateProductLotData(product_lots): flag = 1 for i in range(len(product_lots)): product_lot = product_lots[i] if not "lot_size_from" in product_lot or not validate_integer( product_lot["lot_size_from"]): flag = 0 if not "lot_size_to" in product_lot or not validate_integer( product_lot["lot_size_to"]): flag = 0 if not "price_per_unit" in product_lot or not validate_number( product_lot["price_per_unit"]): flag = 0 return flag
def validateOrderShipmentData(orderShipment): flag = True if not "invoice_number" in orderShipment or orderShipment[ "invoice_number"] == None: orderShipment["invoice_number"] = "" if not "invoice_date" in orderShipment or orderShipment[ "invoice_date"] == None or not validate_date( orderShipment["invoice_date"]): return False if not "waybill_number" in orderShipment or orderShipment[ "waybill_number"] == None: orderShipment["waybill_number"] = "" if not "packaged_weight" in orderShipment or not validate_number( orderShipment["packaged_weight"]): return False if not "packaged_length" in orderShipment or not validate_number( orderShipment["packaged_length"]): return False if not "packaged_breadth" in orderShipment or not validate_number( orderShipment["packaged_breadth"]): return False if not "packaged_height" in orderShipment or not validate_number( orderShipment["packaged_height"]): return False if not "cod_charge" in orderShipment or not validate_number( orderShipment["cod_charge"]): return False if not "shipping_charge" in orderShipment or not validate_number( orderShipment["shipping_charge"]): return False if not "remarks" in orderShipment or orderShipment["remarks"] == None: orderShipment["remarks"] = "" if not "rto_remarks" in orderShipment or orderShipment[ "rto_remarks"] == None: orderShipment["rto_remarks"] = "" if not "tracking_url" in orderShipment or orderShipment[ "tracking_url"] == None: orderShipment["tracking_url"] = "" if not "all_items" in orderShipment or not validate_bool( orderShipment["all_items"]): return False if not "logistics_partner" in orderShipment or orderShipment[ "logistics_partner"] == None: return False else: try: logistics_partner = LogisticsPartner.objects.get( name=orderShipment["logistics_partner"]) except Exception as e: return False return flag
def validateOrderProductsData(orderProducts, productsHash, productIDarr): for orderProduct in orderProducts: if not "productID" in orderProduct or not validate_integer(orderProduct["productID"]): return False productID = int(orderProduct["productID"]) if not "pieces" in orderProduct or not validate_integer(orderProduct["pieces"]): return False if not "edited_price_per_piece" in orderProduct or not validate_number(orderProduct["edited_price_per_piece"]): return False if not "remarks" in orderProduct or orderProduct["remarks"]==None: orderProduct["remarks"] = "" productsHash[productID] = len(productsHash) productIDarr.append(productID) return True
def validateSellerPaymentData(sellerPayment): if not "payment_method" in sellerPayment or not validate_integer( sellerPayment["payment_method"]): return False if not "reference_number" in sellerPayment or sellerPayment[ "reference_number"] == None: return False if not "details" in sellerPayment or sellerPayment["details"] == None: sellerPayment["details"] = "" if not "payment_time" in sellerPayment or not validate_date_time( sellerPayment["payment_time"]): return False if not "payment_value" in sellerPayment or not validate_number( sellerPayment["payment_value"]): return False if not "fully_paid" in sellerPayment or not validate_bool( sellerPayment["fully_paid"]): return False return True
def validateProductDetailsData(productdetails, oldproductdetails): if not "seller_catalog_number" in productdetails or productdetails[ "seller_catalog_number"] == None: productdetails[ "seller_catalog_number"] = oldproductdetails.seller_catalog_number if not "brand" in productdetails or productdetails["brand"] == None: productdetails["brand"] = oldproductdetails.brand if not "description" in productdetails or productdetails[ "description"] == None: productdetails["description"] = oldproductdetails.description if not "gender" in productdetails or productdetails["gender"] == None: productdetails["gender"] = oldproductdetails.gender if not "pattern" in productdetails or productdetails["pattern"] == None: productdetails["pattern"] = oldproductdetails.pattern if not "style" in productdetails or productdetails["style"] == None: productdetails["style"] = oldproductdetails.style if not "sleeve" in productdetails or productdetails["sleeve"] == None: productdetails["sleeve"] = oldproductdetails.sleeve if not "fabric_gsm" in productdetails or productdetails[ "fabric_gsm"] == None: productdetails["fabric_gsm"] = oldproductdetails.fabric_gsm if not "neck_collar_type" in productdetails or productdetails[ "neck_collar_type"] == None: productdetails["neck_collar_type"] = oldproductdetails.neck_collar_type if not "length" in productdetails or productdetails["length"] == None: productdetails["length"] = oldproductdetails.length if not "work_decoration_type" in productdetails or productdetails[ "work_decoration_type"] == None: productdetails[ "work_decoration_type"] = oldproductdetails.work_decoration_type if not "colours" in productdetails or productdetails["colours"] == None: productdetails["colours"] = oldproductdetails.colours if not "sizes" in productdetails or productdetails["sizes"] == None: productdetails["sizes"] = oldproductdetails.sizes if not "special_feature" in productdetails or productdetails[ "special_feature"] == None: productdetails["special_feature"] = oldproductdetails.special_feature if not "manufactured_country" in productdetails or productdetails[ "manufactured_country"] == None: productdetails[ "manufactured_country"] = oldproductdetails.manufactured_country if not "warranty" in productdetails or productdetails["warranty"] == None: productdetails["warranty"] = oldproductdetails.warranty if not "remarks" in productdetails or productdetails["remarks"] == None: productdetails["remarks"] = oldproductdetails.remarks if not "packaging_details" in productdetails or productdetails[ "packaging_details"] == None: productdetails[ "packaging_details"] = oldproductdetails.packaging_details if not "availability" in productdetails or productdetails[ "availability"] == None: productdetails["availability"] = oldproductdetails.availability if not "dispatched_in" in productdetails or productdetails[ "dispatched_in"] == None: productdetails["dispatched_in"] = oldproductdetails.dispatched_in if not "manufactured_city" in productdetails or productdetails[ "manufactured_city"] == None: productdetails[ "manufactured_city"] = oldproductdetails.manufactured_city if not "lot_description" in productdetails or productdetails[ "lot_description"] == None: productdetails["lot_description"] = oldproductdetails.lot_description if not "weight_per_unit" in productdetails or not validate_number( productdetails["weight_per_unit"]): productdetails["weight_per_unit"] = oldproductdetails.weight_per_unit if not "sample_type" in productdetails or productdetails[ "sample_type"] == None: productdetails["sample_type"] = oldproductdetails.sample_type if not "sample_description" in productdetails or productdetails[ "sample_description"] == None: productdetails[ "sample_description"] = oldproductdetails.sample_description if not "sample_price" in productdetails or not validate_number( productdetails["sample_price"]): productdetails["sample_price"] = oldproductdetails.sample_price