Subversion Repositories SmartDukaan

Rev

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

Rev 17500 Rev 17526
Line 727... Line 727...
727
    saddress = ""
727
    saddress = ""
728
    
728
    
729
    for order in orders:
729
    for order in orders:
730
        if order.pickupStoreId:
730
        if order.pickupStoreId:
731
            sendSms= False
731
            sendSms= False
732
        transactionAmount = transactionAmount + order.total_amount
732
        transactionAmount = transactionAmount + order.total_amount + order.shippingCost
733
        for lineitem in order.lineitems:
733
        for lineitem in order.lineitems:
734
            if itemQuantityMap.has_key(lineitem.item_id):
734
            if itemQuantityMap.has_key(lineitem.item_id):
735
                quantity = itemQuantityMap.get(lineitem.item_id)
735
                quantity = itemQuantityMap.get(lineitem.item_id)
736
                quantity = quantity + lineitem.quantity
736
                quantity = quantity + lineitem.quantity
737
                itemQuantityMap[lineitem.item_id] = quantity
737
                itemQuantityMap[lineitem.item_id] = quantity
Line 805... Line 805...
805
            <th width="100">Amount</th>
805
            <th width="100">Amount</th>
806
        </tr>
806
        </tr>
807
    """
807
    """
808
    user_email = ""
808
    user_email = ""
809
    total_amount = 0.0
809
    total_amount = 0.0
-
 
810
    total_shipping = 0.0 
810
    html_table = ""
811
    html_table = ""
811
    order_date = datetime.datetime.now()
812
    order_date = datetime.datetime.now()
812
 
813
 
813
    html_pickup_text = ""
814
    html_pickup_text = ""
814
    random_text = ""
815
    random_text = ""
Line 830... Line 831...
830
            html_tr =  "<tr><td colspan=6>&nbsp;</td></tr>"
831
            html_tr =  "<tr><td colspan=6>&nbsp;</td></tr>"
831
        html_tr += "<tr><td align='center'>" + str(order.id) + "</td>"
832
        html_tr += "<tr><td align='center'>" + str(order.id) + "</td>"
832
 
833
 
833
        sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
834
        sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
834
        store_delivery_date = sdt.strftime("%d %B %Y")
835
        store_delivery_date = sdt.strftime("%d %B %Y")
835
    
836
        
-
 
837
        total_amount += order.shippingCost
-
 
838
        total_shipping += order.shippingCost
836
        if order.pickupStoreId:
839
        if order.pickupStoreId:
837
            attribute = Attribute()
840
            attribute = Attribute()
838
            attribute.orderId = order.id
841
            attribute.orderId = order.id
839
            attribute.name = "SECRET_CODE"
842
            attribute.name = "SECRET_CODE"
840
            attribute.value = random_text
843
            attribute.value = random_text
Line 885... Line 888...
885
        total_amount -= advance_amount
888
        total_amount -= advance_amount
886
        html_footer = html_footer + "<tr>\
889
        html_footer = html_footer + "<tr>\
887
                        <td colspan=5>Advance Paid</td>\
890
                        <td colspan=5>Advance Paid</td>\
888
                        <td> Rs. $advance_amount</td>\
891
                        <td> Rs. $advance_amount</td>\
889
                    </tr>"
892
                    </tr>"
-
 
893
    shipping_string = "Shipping Charges"
890
                
894
    if total_shipping > 0:
-
 
895
        html_footer = html_footer + "<tr>\
-
 
896
                            <td colspan=5>$shipping_string</td>\
-
 
897
                            <td> Rs. $total_shipping</td>\
-
 
898
                        </tr>"            
891
    html_footer = html_footer + "<tr>\
899
    html_footer = html_footer + "<tr>\
892
                <td colspan=5>$amount_string</td>\
900
                <td colspan=5>$amount_string</td>\
893
                <td> Rs. $total_amount</td>\
901
                <td> Rs. $total_amount</td>\
894
                </tr>\
902
                </tr>\
895
            </table>\
903
            </table>\
Line 944... Line 952...
944
 
952
 
945
    sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
953
    sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
946
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
954
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
947
 
955
 
948
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, source_url = source_url, otgLink = otgLink, saddress = saddress))
956
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, source_url = source_url, otgLink = otgLink, saddress = saddress))
949
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, emi_amount = "%.2f" % emi_amount, advance_amount = "%.2f" % advance_amount, net_amount = "%.2f" % (total_amount-order.gvAmount), secret_code = random_text, store_address = store_address, store_delivery_date = store_delivery_date, source_url = source_url, source_name = source_name, amount_string = amount_string))
957
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, emi_amount = "%.2f" % emi_amount, advance_amount = "%.2f" % advance_amount, net_amount = "%.2f" % (total_amount-order.gvAmount), secret_code = random_text, store_address = store_address, store_delivery_date = store_delivery_date, source_url = source_url, source_name = source_name, amount_string = amount_string, shipping_string = shipping_string, total_shipping = "%.2f" % total_shipping))
950
 
958
 
951
    try:
959
    try:
952
        helper_client = HelperClient().get_client()
960
        helper_client = HelperClient().get_client()
953
        helper_client.saveUserEmailForSending([user_email], SaholicHelpEmailId, subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
961
        helper_client.saveUserEmailForSending([user_email], SaholicHelpEmailId, subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
954
        
962
        
Line 1151... Line 1159...
1151
                <th width="100">OTG Covered</th>
1159
                <th width="100">OTG Covered</th>
1152
                <th width="100">Freebie Item</th>
1160
                <th width="100">Freebie Item</th>
1153
            </tr>"""
1161
            </tr>"""
1154
            
1162
            
1155
    total_amount = 0.0
1163
    total_amount = 0.0
-
 
1164
    total_shipping = 0.0 
1156
    advanceAmount = 0.0
1165
    advanceAmount = 0.0
1157
    hasOtg = False
1166
    hasOtg = False
1158
    otgCount = 0
1167
    otgCount = 0
1159
    hasFreebie = False
1168
    hasFreebie = False
1160
    hasSplitOrder = False
1169
    hasSplitOrder = False
Line 1163... Line 1172...
1163
    splitOrdersMap = {}
1172
    splitOrdersMap = {}
1164
    totalUnitPrice = 0.0
1173
    totalUnitPrice = 0.0
1165
    for orderObj in orderList:
1174
    for orderObj in orderList:
1166
        lineitem = orderObj.lineitems[0]
1175
        lineitem = orderObj.lineitems[0]
1167
        lineitem_total_price = round(lineitem.total_price, 2)
1176
        lineitem_total_price = round(lineitem.total_price, 2)
1168
        total_amount += lineitem_total_price
1177
        total_amount += lineitem_total_price + orderObj.shippingCost
1169
        advanceAmount += orderObj.advanceAmount 
1178
        advanceAmount += orderObj.advanceAmount 
-
 
1179
        total_shipping += orderObj.shippingCost
1170
        html += """
1180
        html += """
1171
            <tr>
1181
            <tr>
1172
            <td align="center">"""+str(orderObj.id)+"""</td>
1182
            <td align="center">"""+str(orderObj.id)+"""</td>
1173
            <td>"""+str(lineitem)+"""</td>
1183
            <td>"""+str(lineitem)+"""</td>
1174
            <td align="center">"""+("%.0f" % lineitem.quantity)+"""</td>
1184
            <td align="center">"""+("%.0f" % lineitem.quantity)+"""</td>
Line 1215... Line 1225...
1215
                   <td>Rs."""+("%.2f" % advanceAmount)+"""
1225
                   <td>Rs."""+("%.2f" % advanceAmount)+"""
1216
                   </tr>
1226
                   </tr>
1217
            """
1227
            """
1218
        total_amount -= advanceAmount
1228
        total_amount -= advanceAmount
1219
        amount_string = "Balance Amount"
1229
        amount_string = "Balance Amount"
-
 
1230
    
-
 
1231
    shipping_string = "Shipping Charges"
-
 
1232
    if total_shipping > 0:
-
 
1233
        html = html + """"<tr>\
-
 
1234
                            <td colspan=7>"""+shipping_string+""""</td>\
-
 
1235
                            <td> Rs. """+("%.2f" % total_shipping)+"""</td>\
-
 
1236
                        </tr>"""
-
 
1237
    
1220
    html += """<tr>
1238
    html += """<tr>
1221
               <td colspan="7">"""+amount_string+"""</td>
1239
               <td colspan="7">"""+amount_string+"""</td>
1222
               <td>Rs."""+("%.2f" % total_amount)+"""
1240
               <td>Rs."""+("%.2f" % total_amount)+"""
1223
               </tr>
1241
               </tr>
1224
            """
1242
            """
Line 4720... Line 4738...
4720
                <th width="100">OTG Covered</th>
4738
                <th width="100">OTG Covered</th>
4721
                <th width="100">Freebie Item</th>
4739
                <th width="100">Freebie Item</th>
4722
            </tr>"""
4740
            </tr>"""
4723
            
4741
            
4724
    total_amount = 0.0
4742
    total_amount = 0.0
-
 
4743
    total_shipping = 0.0
4725
    advanceAmount = 0.0
4744
    advanceAmount = 0.0
4726
    hasOtg = False
4745
    hasOtg = False
4727
    hasFreebie = False
4746
    hasFreebie = False
4728
    hasSplitOrder = False
4747
    hasSplitOrder = False
4729
    hasInsurer = False
4748
    hasInsurer = False
4730
    splitOrdersMap = {}
4749
    splitOrdersMap = {}
4731
    for orderObj in orderList:
4750
    for orderObj in orderList:
4732
        lineitem = orderObj.lineitems[0]
4751
        lineitem = orderObj.lineitems[0]
4733
        lineitem_total_price = round(lineitem.total_price, 2)
4752
        lineitem_total_price = round(lineitem.total_price, 2)
4734
        total_amount += lineitem_total_price
4753
        total_amount += lineitem_total_price + orderObj.shippingCost
-
 
4754
        total_shipping += orderObj.shippingCost
4735
        advanceAmount += orderObj.advanceAmount
4755
        advanceAmount += orderObj.advanceAmount
4736
        html += """
4756
        html += """
4737
            <tr>
4757
            <tr>
4738
            <td align="center">"""+str(orderObj.id)+"""</td>
4758
            <td align="center">"""+str(orderObj.id)+"""</td>
4739
            <td>"""+str(lineitem)+"""</td>
4759
            <td>"""+str(lineitem)+"""</td>
Line 4775... Line 4795...
4775
                   <td>Rs."""+("%.2f" % advanceAmount)+"""
4795
                   <td>Rs."""+("%.2f" % advanceAmount)+"""
4776
                   </tr>
4796
                   </tr>
4777
            """
4797
            """
4778
        total_amount -= advanceAmount
4798
        total_amount -= advanceAmount
4779
        amount_string = "Balance Amount"
4799
        amount_string = "Balance Amount"
-
 
4800
    shipping_string = "Shipping Charges"
-
 
4801
    if total_shipping > 0:
-
 
4802
        html = html + """"<tr>\
-
 
4803
                            <td colspan=7>"""+shipping_string+""""</td>\
-
 
4804
                            <td> Rs. """+("%.2f" % total_shipping)+"""</td>\
-
 
4805
                        </tr>"""        
4780
    html += """<tr>
4806
    html += """<tr>
4781
               <td colspan="7">"""+amount_string+"""</td>
4807
               <td colspan="7">"""+amount_string+"""</td>
4782
               <td>Rs."""+("%.2f" % total_amount)+"""
4808
               <td>Rs."""+("%.2f" % total_amount)+"""
4783
               </tr>
4809
               </tr>
4784
            """
4810
            """