Subversion Repositories SmartDukaan

Rev

Rev 16979 | Rev 17500 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16979 Rev 17487
Line 99... Line 99...
99
import sys
99
import sys
100
import time
100
import time
101
import traceback
101
import traceback
102
import urllib
102
import urllib
103
import MySQLdb
103
import MySQLdb
-
 
104
import math
104
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
105
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
105
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
106
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
106
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
107
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
107
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
108
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
108
 
109
 
Line 241... Line 242...
241
        order.dataProtectionAmount = t_order.dataProtectionAmount
242
        order.dataProtectionAmount = t_order.dataProtectionAmount
242
    if order.dataProtectionInsurer > 0:
243
    if order.dataProtectionInsurer > 0:
243
        dataInsuranceDetail = DataInsuranceDetailForOrder()
244
        dataInsuranceDetail = DataInsuranceDetailForOrder()
244
        dataInsuranceDetail.order = order
245
        dataInsuranceDetail.order = order
245
    if t_order.taxType:
246
    if t_order.taxType:
246
        order.taxType = t_order.taxType 
247
        order.taxType = t_order.taxType
-
 
248
    if t_order.shippingCost:
-
 
249
        order.shippingCost = t_order.shippingCost
-
 
250
    if t_order.codCharges:
-
 
251
        order.codCharges = t_order.codCharges
247
    return order
252
    return order
248
    
253
    
249
def create_transaction(t_transaction):
254
def create_transaction(t_transaction):
250
    t_orders = t_transaction.orders
255
    t_orders = t_transaction.orders
251
    if not t_orders:
256
    if not t_orders:
Line 256... Line 261...
256
    transaction.coupon_code = t_transaction.coupon_code
261
    transaction.coupon_code = t_transaction.coupon_code
257
    transaction.session_source = t_transaction.sessionSource
262
    transaction.session_source = t_transaction.sessionSource
258
    transaction.session_start_time = to_py_date(t_transaction.sessionStartTime)
263
    transaction.session_start_time = to_py_date(t_transaction.sessionStartTime)
259
    transaction.first_source = t_transaction.firstSource
264
    transaction.first_source = t_transaction.firstSource
260
    transaction.first_source_start_time = to_py_date(t_transaction.firstSourceTime)
265
    transaction.first_source_start_time = to_py_date(t_transaction.firstSourceTime)
-
 
266
    if t_transaction.totalShippingCost:
-
 
267
        transaction.totalShippingCost = t_transaction.totalShippingCost
-
 
268
    if t_transaction.totalCodCharges:
-
 
269
        transaction.totalCodCharges = t_transaction.totalCodCharges
261
 
270
 
262
    totalAmount = 0
271
    totalAmount = 0
263
    for t_order in t_orders:
272
    for t_order in t_orders:
264
        order = create_order(t_order)
273
        order = create_order(t_order)
265
        totalAmount = totalAmount + order.total_amount
274
        totalAmount = totalAmount + order.total_amount
Line 8628... Line 8637...
8628
    exists = HsOrder.query.filter_by(hsOrderNo=hs_OrderNo,hsSubOrderNo=hs_SubOrderNo).first()
8637
    exists = HsOrder.query.filter_by(hsOrderNo=hs_OrderNo,hsSubOrderNo=hs_SubOrderNo).first()
8629
    if exists is not None:
8638
    if exists is not None:
8630
        return True
8639
        return True
8631
    else:
8640
    else:
8632
        return False
8641
        return False
-
 
8642
    
-
 
8643
def split_bulk_order(order_id, split_order_quantity):
-
 
8644
    order = get_order(order_id)
-
 
8645
    order = get_order(order_id)
-
 
8646
    if split_order_quantity >=order.lineitems[0].quantity:
-
 
8647
        raise TransactionServiceException(115, "Split Quantity is greater than or equal to order quantity")
-
 
8648
    if order.status not in [OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT, OrderStatus.CAPTURE_IN_PROCESS, OrderStatus.REJECTED, OrderStatus.ACCEPTED]:
-
 
8649
        raise TransactionServiceException(115, "Order not allowed to be split")
-
 
8650
    
-
 
8651
    new_order = __clone_order(order, False, False)
-
 
8652
    new_order.expected_delivery_time = order.expected_delivery_time
-
 
8653
    new_order.promised_delivery_time = order.promised_delivery_time
-
 
8654
    new_order.expected_shipping_time = order.expected_shipping_time
-
 
8655
    new_order.promised_shipping_time = order.promised_shipping_time
-
 
8656
    
-
 
8657
    new_order.lineitems[0].quantity = split_order_quantity
-
 
8658
    new_order.lineitems[0].total_price = new_order.lineitems[0].unit_price*split_order_quantity
-
 
8659
    new_order.lineitems[0].total_weight = new_order.lineitems[0].unit_weight*split_order_quantity
-
 
8660
    new_order.total_amount = new_order.lineitems[0].total_price
-
 
8661
    new_order.total_weight = new_order.lineitems[0].total_weight
-
 
8662
    new_order.shippingCost = math.floor((order.shippingCost/order.lineitems[0].quantity)*split_order_quantity)
-
 
8663
    
-
 
8664
    order.lineitems[0].quantity = order.lineitems[0].quantity - split_order_quantity
-
 
8665
    order.lineitems[0].total_price = order.lineitems[0].unit_price * order.lineitems[0].quantity
-
 
8666
    order.lineitems[0].total_weight = order.lineitems[0].unit_weight*order.lineitems[0].quantity
-
 
8667
    order.total_amount = order.lineitems[0].total_price
-
 
8668
    order.total_weight = order.lineitems[0].total_weight
-
 
8669
    order.shippingCost = order.shippingCost - new_order.shippingCost
-
 
8670
    
-
 
8671
    session.commit()
-
 
8672
    html = """
-
 
8673
    <html>
-
 
8674
    <body>
-
 
8675
    <div>
-
 
8676
        <p>Dear Customer,</p>
-
 
8677
        <p>
-
 
8678
            Your order: """+str(order.id)+""" have been splitted into following orders:-
-
 
8679
            <br>
-
 
8680
            <br>
-
 
8681
            <div>
-
 
8682
                <table>
-
 
8683
                <tr><td colspan="8"><hr /></td></tr>
-
 
8684
                <tr><td colspan="8" align="left"><b>Order Details</b></td></tr>
-
 
8685
                <tr><td colspan="8"><hr /></td></tr>
-
 
8686
                <tr>
-
 
8687
                    <th width="100">Order Id</th>
-
 
8688
                    <th>Product Name</th>
-
 
8689
                    <th width="100">Quantity</th>
-
 
8690
                    <th width="100">Unit Price</th>
-
 
8691
                    <th width="100">Amount</th>
-
 
8692
                </tr>"""
-
 
8693
    html += """
-
 
8694
            <tr>
-
 
8695
            <td align="center">"""+str(order.id)+"""</td>
-
 
8696
            <td>"""+str(order.lineitems[0])+"""</td>
-
 
8697
            <td align="center">"""+("%.0f" % order.lineitems[0].quantity)+"""</td>
-
 
8698
            <td align="center">"""+("%.2f" % order.lineitems[0].unit_price)+"""</td>
-
 
8699
            <td align="center">"""+("%.2f" % round(order.lineitems[0].total_price,2))+"""</td>
-
 
8700
            </tr>"""
-
 
8701
    html += """
-
 
8702
            <tr>
-
 
8703
            <td align="center">"""+str(new_order.id)+"""</td>
-
 
8704
            <td>"""+str(new_order.lineitems[0])+"""</td>
-
 
8705
            <td align="center">"""+("%.0f" % new_order.lineitems[0].quantity)+"""</td>
-
 
8706
            <td align="center">"""+("%.2f" % new_order.lineitems[0].unit_price)+"""</td>
-
 
8707
            <td align="center">"""+("%.2f" % round(new_order.lineitems[0].total_price,2))+"""</td>
-
 
8708
            </tr>"""
-
 
8709
            
-
 
8710
    html += """
-
 
8711
            </table>
-
 
8712
            <p>
-
 
8713
                For any queries please call +919811247808.
-
 
8714
            </p>
-
 
8715
            <p>
-
 
8716
                Warm Regards,<br />
-
 
8717
                Saholic Team
-
 
8718
            </p>
-
 
8719
            </div>
-
 
8720
            </body>
-
 
8721
            </html>
-
 
8722
            """
-
 
8723
    subject = "Saholic Order: "+str(order.id) + " have been splitted"
-
 
8724
    bcc = ["backup@saholic.com"]
-
 
8725
    try:
-
 
8726
        helper_client = HelperClient().get_client()
-
 
8727
        helper_client.saveUserEmailForSending(order.customer_email, SaholicHelpEmailId, subject, html, str(order.id), "TransactionInfo", [], bcc, order.source)
-
 
8728
        if order.customer_mobilenumber is not None:
-
 
8729
            smsText = "Your Order "+ str(order.id) + " have been splitted into two orders. Please check your account or email. For any queries please call +919811247808."
-
 
8730
            send_transaction_sms(order.customer_id, order.customer_mobilenumber, smsText, SmsType.TRANSACTIONAL, False)
-
 
8731
            
-
 
8732
    except Exception as e:
-
 
8733
        print e
-
 
8734
    
-
 
8735
    return new_order
-
 
8736
    
8633
        
8737
        
8634
if __name__ == '__main__':
8738
if __name__ == '__main__':
8635
    print get_orders_by_mobile_number("9650889334")
8739
    print get_orders_by_mobile_number("9650889334")