Exemplo n.º 1
0
def serializeCheckout(checkoutEntry, parameters={}):
    checkout = {}

    checkout["checkoutID"] = checkoutEntry.id

    checkout["cart"] = serializeCart(checkoutEntry.cart, parameters)

    if hasattr(checkoutEntry, "buyer_address_history"
               ) and checkoutEntry.buyer_address_history != None:
        checkout["buyer_address"] = serialize_buyer_address(
            checkoutEntry.buyer_address_history, parameters)

    checkout["status"] = {
        "value": checkoutEntry.status,
        "display_value": CheckoutStatus[checkoutEntry.status]["display_value"]
    }

    checkout["payment_method"] = checkoutEntry.payment_method

    checkout["created_at"] = checkoutEntry.created_at
    checkout["updated_at"] = checkoutEntry.updated_at
    checkout["address_given_time"] = checkoutEntry.address_given_time
    checkout["summary_confirmed_time"] = checkoutEntry.summary_confirmed_time
    checkout["payment_done_time"] = checkoutEntry.payment_done_time

    return checkout
Exemplo n.º 2
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)
Exemplo n.º 3
0
def populateSellerMailDict(SubOrderPtr, buyerPtr, buyerAddressPtr):
    seller_mail_dict = {}
    seller_mail_dict["suborder"] = {
        "suborderNumber": SubOrderPtr.display_number,
        "product_count": SubOrderPtr.product_count,
        "final_price": '{0:.0f}'.format(SubOrderPtr.final_price),
        "pieces": SubOrderPtr.pieces
    }
    seller_mail_dict["buyer"] = {
        "name": buyerPtr.name,
        "company_name": buyerPtr.company_name
    }
    seller_mail_dict["buyerAddress"] = serialize_buyer_address(buyerAddressPtr)

    seller_mail_dict["orderItems"] = []

    orderItems = OrderItem.objects.filter(suborder_id=SubOrderPtr.id)

    for OrderItemPtr in orderItems:
        mailOrderItem = populateMailOrderItem(OrderItemPtr)
        seller_mail_dict["orderItems"].append(mailOrderItem)
        seller_mail_dict["suborder"]["items_title"] = "Order Items"

    return seller_mail_dict
Exemplo n.º 4
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
Exemplo n.º 5
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)
Exemplo n.º 6
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)