Ejemplo n.º 1
0
def serializeBuyerPayment(BuyerPaymentEntry, parameters= {}):
	buyerPayment = {}
	buyerPayment["orderID"] = BuyerPaymentEntry.order_id
	buyerPayment["buyerpaymentID"] = BuyerPaymentEntry.id
	buyerPayment["reference_number"] = BuyerPaymentEntry.reference_number
	buyerPayment["payment_time"] = BuyerPaymentEntry.payment_time
	buyerPayment["details"] = BuyerPaymentEntry.details
	buyerPayment["payment_value"] = '{0:.0f}'.format(float(BuyerPaymentEntry.payment_value))
	buyerPayment["created_at"] = BuyerPaymentEntry.created_at
	buyerPayment["updated_at"] = BuyerPaymentEntry.updated_at

	if "buyer_details" in parameters and parameters["buyer_details"] == 1:
		buyerPayment["buyer"] = serialize_buyer(BuyerPaymentEntry.order.buyer, parameters)
	else:
		buyer = {}
		buyer["buyerID"] = BuyerPaymentEntry.order.buyer.id
		buyer["name"] = BuyerPaymentEntry.order.buyer.name
		buyerPayment["buyer"] = buyer

	buyerPayment["buyer_payment_status"] = {
		"value": BuyerPaymentEntry.payment_status,
		"display_value":BuyerPaymentStatus[BuyerPaymentEntry.payment_status]["display_value"]
	}

	buyerPayment["buyer_payment_method"] = {
		"value": BuyerPaymentEntry.payment_method,
		"display_value":BuyerPaymentMethod[BuyerPaymentEntry.payment_method]["display_value"]
	}

	if BuyerPaymentEntry.order_shipment != None:
		buyerPayment["ordershipmentID"] = BuyerPaymentEntry.order_shipment_id

	return buyerPayment
Ejemplo n.º 2
0
def serializeCart(cartEntry, parameters={}):
    cart = {}
    cart["cartID"] = cartEntry.id

    cart["pieces"] = cartEntry.pieces
    cart["product_count"] = cartEntry.product_count
    cart["retail_price"] = cartEntry.retail_price
    cart["calculated_price"] = cartEntry.calculated_price
    cart["shipping_charge"] = cartEntry.shipping_charge
    cart["final_price"] = cartEntry.final_price
    cart["remarks"] = cartEntry.remarks

    cart["created_at"] = cartEntry.created_at
    cart["updated_at"] = cartEntry.updated_at

    if "buyer_details" in parameters and parameters["buyer_details"] == 1:
        cart["buyer"] = serialize_buyer(cartEntry.buyer, parameters)
    else:
        buyer = {}
        buyer["buyerID"] = cartEntry.buyer.id
        buyer["name"] = cartEntry.buyer.name
        cart["buyer"] = buyer

    if "sub_cart_details" in parameters and parameters["sub_cart_details"] == 1:
        subCarts = filterSubCarts(parameters)
        subCarts = subCarts.filter(cart_id=cartEntry.id)
        cart["sub_carts"] = parseSubCart(subCarts, parameters)

    return cart
Ejemplo n.º 3
0
    def sendCustomerMail(self, parameters={}):

        buyerPtr = self.buyer

        if self.email == None or self.email == "":
            return

        from_email = "Wholdus Info <*****@*****.**>"
        mail_template_file = "buyer_store/customer_store_lead.html"

        if len(buyerPtr.company_name) > 0:
            subject = buyerPtr.company_name
        else:
            subject = buyerPtr.name

        subject += " has received you request"
        to_email = [self.email]

        from users.serializers.buyer import serialize_buyer, serialize_buyer_store_lead, serialize_buyer_address

        mail_dict = {}
        mail_dict["buyer"] = serialize_buyer(buyerPtr)
        buyerAddressHistory = buyerPtr.latest_buyer_address_history()
        if buyerAddressHistory != None:
            mail_dict["buyer_address"] = serialize_buyer_address(
                buyerAddressHistory)

        productParameters = {}
        productParameters["product_image_details"] = 1
        mail_dict["buyer_store_lead"] = serialize_buyer_store_lead(
            self, productParameters)

        bcc = ["*****@*****.**", "*****@*****.**"]
        #bcc = []

        create_email(mail_template_file,
                     mail_dict,
                     subject,
                     from_email,
                     to_email,
                     bcc=bcc)
Ejemplo n.º 4
0
def serializeSubOrder(subOrderEntry, parameters={}):
    subOrder = {}
    subOrder["orderID"] = subOrderEntry.order_id
    subOrder["suborderID"] = subOrderEntry.id
    subOrder["product_count"] = subOrderEntry.product_count
    subOrder["pieces"] = subOrderEntry.pieces
    subOrder["retail_price"] = '{0:.0f}'.format(
        float(subOrderEntry.retail_price))
    subOrder["calculated_price"] = '{0:.0f}'.format(
        float(subOrderEntry.calculated_price))
    subOrder["edited_price"] = '{0:.0f}'.format(
        float(subOrderEntry.edited_price))
    subOrder["cod_charge"] = '{0:.0f}'.format(float(subOrderEntry.cod_charge))
    subOrder["shipping_charge"] = '{0:.0f}'.format(
        float(subOrderEntry.shipping_charge))
    subOrder["final_price"] = '{0:.0f}'.format(float(
        subOrderEntry.final_price))
    subOrder["display_number"] = subOrderEntry.display_number
    subOrder["created_at"] = subOrderEntry.created_at
    subOrder["updated_at"] = subOrderEntry.updated_at
    subOrder["merchant_notified_time"] = subOrderEntry.merchant_notified_time
    subOrder["completed_time"] = subOrderEntry.completed_time
    subOrder["closed_time"] = subOrderEntry.closed_time

    subOrder["sub_order_status"] = {
        "value":
        subOrderEntry.suborder_status,
        "display_value":
        SubOrderStatus[subOrderEntry.suborder_status]["display_value"]
    }

    subOrder["sub_order_payment_status"] = {
        "value":
        subOrderEntry.suborder_payment_status,
        "display_value":
        SubOrderPaymentStatus[subOrderEntry.suborder_payment_status]
        ["display_value"]
    }

    subOrder["seller_address"] = serialize_seller_address(
        subOrderEntry.seller_address_history)

    if "seller_details" in parameters and parameters["seller_details"] == 1:
        subOrder["seller"] = serialize_seller(subOrderEntry.seller, parameters)
    else:
        seller = {}
        seller["sellerID"] = subOrderEntry.seller.id
        seller["name"] = subOrderEntry.seller.name
        subOrder["seller"] = seller

    if "buyer_details" in parameters and parameters["buyer_details"] == 1:
        subOrder["buyer"] = serialize_buyer(subOrderEntry.order.buyer,
                                            parameters)
    else:
        buyer = {}
        buyer["buyerID"] = subOrderEntry.order.buyer.id
        buyer["name"] = subOrderEntry.order.buyer.name
        subOrder["buyer"] = buyer

    if "seller_payment_details" in parameters and parameters[
            "seller_payment_details"] == 1:
        sellerPaymentQuerySet = filterSellerPayment(parameters)
        sellerPaymentQuerySet = sellerPaymentQuerySet.filter(
            suborder_id=subOrderEntry.id)
        subOrder["seller_payments"] = parseSellerPayments(
            sellerPaymentQuerySet, parameters)

    if "order_shipment_details" in parameters and parameters[
            "order_shipment_details"] == 1:
        orderShipmentQuerySet = filterOrderShipment(parameters)
        orderShipmentQuerySet = orderShipmentQuerySet.filter(
            suborder_id=subOrderEntry.id)
        subOrder["order_shipments"] = parseOrderShipments(
            orderShipmentQuerySet, parameters)

    if "order_item_details" in parameters and parameters[
            "order_item_details"] == 1:
        orderItemQuerySet = filterOrderItem(parameters)
        orderItemQuerySet = orderItemQuerySet.filter(
            suborder_id=subOrderEntry.id)
        subOrder["order_items"] = parseOrderItem(orderItemQuerySet, parameters)

    return subOrder
Ejemplo n.º 5
0
def serializeOrderShipment(orderShipmentEntry, parameters={}):
    orderShipment = {}
    orderShipment["suborderID"] = orderShipmentEntry.suborder_id
    orderShipment[
        "suborder_display_number"] = orderShipmentEntry.suborder.display_number
    orderShipment["ordershipmentID"] = orderShipmentEntry.id
    orderShipment["pickup_address"] = serialize_seller_address(
        orderShipmentEntry.pickup_address)
    orderShipment["drop_address"] = serialize_buyer_address(
        orderShipmentEntry.drop_address)
    orderShipment["invoice_number"] = orderShipmentEntry.invoice_number
    orderShipment["invoice_date"] = orderShipmentEntry.invoice_date
    orderShipment[
        "logistics_partner"] = orderShipmentEntry.logistics_partner_name
    orderShipment["waybill_number"] = orderShipmentEntry.waybill_number
    orderShipment["packaged_weight"] = orderShipmentEntry.packaged_weight
    orderShipment["packaged_length"] = orderShipmentEntry.packaged_length
    orderShipment["packaged_breadth"] = orderShipmentEntry.packaged_breadth
    orderShipment["packaged_height"] = orderShipmentEntry.packaged_height
    orderShipment["cod_charge"] = '{0:.0f}'.format(
        float(orderShipmentEntry.cod_charge))
    orderShipment["shipping_charge"] = '{0:.0f}'.format(
        float(orderShipmentEntry.shipping_charge))
    orderShipment["pieces"] = orderShipmentEntry.pieces
    orderShipment["product_count"] = orderShipmentEntry.product_count
    orderShipment["remarks"] = orderShipmentEntry.remarks
    orderShipment[
        "tpl_manifested_time"] = orderShipmentEntry.tpl_manifested_time
    orderShipment[
        "tpl_in_transit_time"] = orderShipmentEntry.tpl_in_transit_time
    orderShipment[
        "tpl_stuck_in_transit_time"] = orderShipmentEntry.tpl_stuck_in_transit_time
    orderShipment["delivered_time"] = orderShipmentEntry.delivered_time
    orderShipment[
        "rto_in_transit_time"] = orderShipmentEntry.rto_in_transit_time
    orderShipment["rto_delivered_time"] = orderShipmentEntry.rto_delivered_time
    orderShipment[
        "sent_for_pickup_time"] = orderShipmentEntry.sent_for_pickup_time
    orderShipment["lost_time"] = orderShipmentEntry.lost_time
    orderShipment["tracking_url"] = orderShipmentEntry.tracking_url
    orderShipment["rto_remarks"] = orderShipmentEntry.rto_remarks
    orderShipment["created_at"] = orderShipmentEntry.created_at
    orderShipment["updated_at"] = orderShipmentEntry.updated_at
    orderShipment["manifest_link"] = orderShipmentEntry.manifest_link
    orderShipment["label_link"] = orderShipmentEntry.label_link
    orderShipment["soft_data_csv_link"] = orderShipmentEntry.soft_data_csv_link
    orderShipment[
        "vendor_pickup_csv_link"] = orderShipmentEntry.vendor_pickup_csv_link
    orderShipment["final_price"] = '{0:.0f}'.format(
        float(orderShipmentEntry.final_price))
    orderShipment["amount_to_collect"] = '{0:.0f}'.format(
        float(orderShipmentEntry.final_price) +
        float(orderShipmentEntry.cod_charge) +
        float(orderShipmentEntry.shipping_charge))

    if "buyer_details" in parameters and parameters["buyer_details"] == 1:
        orderShipment["buyer"] = serialize_buyer(
            orderShipmentEntry.suborder.order.buyer, parameters)
    else:
        buyer = {}
        buyer["buyerID"] = orderShipmentEntry.suborder.order.buyer.id
        buyer["name"] = orderShipmentEntry.suborder.order.buyer.name
        orderShipment["buyer"] = buyer

    if "seller_details" in parameters and parameters["seller_details"] == 1:
        orderShipment["seller"] = serialize_seller(
            orderShipmentEntry.suborder.seller, parameters)
    else:
        seller = {}
        seller["sellerID"] = orderShipmentEntry.suborder.seller.id
        seller["name"] = orderShipmentEntry.suborder.seller.name
        orderShipment["seller"] = seller

    if "order_item_details" in parameters and parameters[
            "order_item_details"] == 1:
        orderItemQuerySet = filterOrderItem(parameters)
        orderItemQuerySet = orderItemQuerySet.filter(
            order_shipment_id=orderShipmentEntry.id)
        orderShipment["order_items"] = parseOrderItem(orderItemQuerySet,
                                                      parameters)

    orderShipment["order_shipment_status"] = {
        "value":
        orderShipmentEntry.current_status,
        "display_value":
        OrderShipmentStatus[orderShipmentEntry.current_status]["display_value"]
    }

    try:
        orderShipment["order_shipment_status"]["display_time"] = getattr(
            orderShipmentEntry, OrderShipmentStatus[
                orderShipmentEntry.current_status]["display_time"])
        orderShipment["order_shipment_status"][
            "display_time_name"] = OrderShipmentStatus[
                orderShipmentEntry.current_status]["display_time"]
    except Exception, e:
        pass
Ejemplo n.º 6
0
    def create_label(self):
        subOrderPtr = self.suborder
        buyerPtr = subOrderPtr.order.buyer
        sellerPtr = subOrderPtr.seller
        sellerAddressPtr = subOrderPtr.seller_address_history
        buyerAddressPtr = subOrderPtr.order.buyer_address_history

        outputLink = "media/generateddocs/shipmentlabel/{}/{}/".format(
            sellerPtr.id, subOrderPtr.display_number)
        outputDirectory = settings.STATIC_ROOT + outputLink
        outputFileName = "WholdusLabel-{}-{}.pdf".format(
            self.id, subOrderPtr.display_number)

        barcodeObj = barcode.codex.Code39(code=self.waybill_number,
                                          add_checksum=False)
        barcodeFileName = "barcode-{}-{}".format(self.id,
                                                 subOrderPtr.display_number)
        barcodeOptions = {"module_width": 0.36, "font_size": 12}
        if not os.path.exists(outputDirectory):
            os.makedirs(outputDirectory)
        barcodeFullPath = barcodeObj.save(outputDirectory + barcodeFileName,
                                          barcodeOptions)

        self.label_link = outputLink + outputFileName
        self.save()

        manifest_dict = {}

        from orders.serializers.subOrder import serializeSubOrder
        manifest_dict["sub_order"] = serializeSubOrder(subOrderPtr)

        manifest_dict["buyer"] = serialize_buyer(buyerPtr)
        manifest_dict["buyer_address"] = serialize_buyer_address(
            buyerAddressPtr)

        manifest_dict["seller"] = serialize_seller(
            sellerPtr, {"seller_details_details": 1})
        manifest_dict["seller_address"] = serialize_seller_address(
            sellerAddressPtr)

        from orders.serializers.orderShipment import serializeOrderShipment
        manifest_dict["shipment"] = serializeOrderShipment(self)

        manifest_dict["barcode_full_path"] = barcodeFullPath

        manifest_dict["pageDataArr"] = []
        manifest_dict["pageDataArr"].append(
            {"page_copy_label": "Original Customer's Copy"})
        manifest_dict["pageDataArr"].append(
            {"page_copy_label": "Duplicate Copy"})
        manifest_dict["pageDataArr"].append(
            {"page_copy_label": "Triplicate Copy"})
        manifest_dict["total_pages"] = len(manifest_dict["pageDataArr"])

        pincodeServiceabilityPtr = PincodeServiceability.objects.filter(
            logistics_partner_id=self.logistics_partner_id,
            pincode=buyerAddressPtr.pincode_id)

        if len(pincodeServiceabilityPtr) > 0:
            pincodeServiceabilityPtr = pincodeServiceabilityPtr[0]
            manifest_dict["buyer_ou_code"] = pincodeServiceabilityPtr.ou_code

        pincodeServiceabilityPtr = PincodeServiceability.objects.filter(
            logistics_partner_id=self.logistics_partner_id,
            pincode=sellerAddressPtr.pincode_id)

        if len(pincodeServiceabilityPtr) > 0:
            pincodeServiceabilityPtr = pincodeServiceabilityPtr[0]
            manifest_dict["seller_ou_code"] = pincodeServiceabilityPtr.ou_code

        template_file = "shipment/shipment_label.html"

        generate_pdf(template_file,
                     manifest_dict,
                     outputDirectory,
                     outputFileName,
                     landscape=True)
Ejemplo n.º 7
0
    def create_manifest(self):

        manifest_dict = {}
        manifest_dict["orderItems"] = []
        manifest_dict["extra_order_items"] = 0
        maxOrderItems = 32

        subOrderPtr = self.suborder
        buyerPtr = subOrderPtr.order.buyer
        sellerPtr = subOrderPtr.seller
        sellerAddressPtr = subOrderPtr.seller_address_history
        buyerAddressPtr = subOrderPtr.order.buyer_address_history

        allOrderItems = OrderItem.objects.filter(order_shipment_id=self.id)

        orderItemCount = len(allOrderItems)

        extraOrderItems = orderItemCount - maxOrderItems

        if extraOrderItems > 0:
            manifest_dict["extra_order_items"] = extraOrderItems
            orderItemCount = maxOrderItems

        for i in range(orderItemCount):

            orderItemPtr = allOrderItems[i]
            manifestOrderItem = {
                "name": orderItemPtr.product.display_name,
                "pieces": orderItemPtr.pieces
            }

            manifest_dict["orderItems"].append(manifestOrderItem)

        from orders.serializers.subOrder import serializeSubOrder
        manifest_dict["sub_order"] = serializeSubOrder(subOrderPtr)

        manifest_dict["buyer"] = serialize_buyer(buyerPtr)
        manifest_dict["buyer_address"] = serialize_buyer_address(
            buyerAddressPtr)

        manifest_dict["seller"] = serialize_seller(
            sellerPtr, {"seller_details_details": 1})
        manifest_dict["seller_address"] = serialize_seller_address(
            sellerAddressPtr)

        from orders.serializers.orderShipment import serializeOrderShipment
        manifest_dict["shipment"] = serializeOrderShipment(self)

        template_file = "shipment/shipment_manifest.html"

        outputLink = "media/generateddocs/shipmentmanifest/{}/{}/".format(
            sellerPtr.id, subOrderPtr.display_number)
        outputDirectory = settings.STATIC_ROOT + outputLink
        outputFileName = "WholdusManifest-{}-{}.pdf".format(
            self.id, subOrderPtr.display_number)

        self.manifest_link = outputLink + outputFileName
        self.save()

        generate_pdf(template_file, manifest_dict, outputDirectory,
                     outputFileName)