| Line 28... |
Line 28... |
| 28 |
from shop2020.clients.UserClient import UserClient
|
28 |
from shop2020.clients.UserClient import UserClient
|
| 29 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
29 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
| 30 |
from shop2020.config.client.ConfigClient import ConfigClient
|
30 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 31 |
from shop2020.model.v1 import order
|
31 |
from shop2020.model.v1 import order
|
| 32 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
32 |
from shop2020.model.v1.order.impl import DataService, RechargeService
|
| 33 |
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme
|
33 |
from shop2020.model.v1.order.impl.Convertors import to_t_emi_scheme, to_t_order
|
| 34 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
34 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| 35 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
35 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
| 36 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
36 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
| 37 |
CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, MiscCharges, \
|
37 |
CodVerificationAgent, Attribute, RechargeVoucherTracker, EmiScheme, MiscCharges, \
|
| 38 |
BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder, DocumentStore, \
|
38 |
BlockedIpRange, DeniedIpAddress, InsuranceDetailForOrder, DocumentStore, \
|
| Line 825... |
Line 825... |
| 825 |
thank_you_html = thank_you_html + """If you are happy with our services please join us on <a href="http://www.facebook.com/mysaholic">Facebook</a>/<a href="https://twitter.com/saholic">Twitter</a> and help us spread the word."""
|
825 |
thank_you_html = thank_you_html + """If you are happy with our services please join us on <a href="http://www.facebook.com/mysaholic">Facebook</a>/<a href="https://twitter.com/saholic">Twitter</a> and help us spread the word."""
|
| 826 |
|
826 |
|
| 827 |
else :
|
827 |
else :
|
| 828 |
thank_you_html = str(order.lineitems[0]) + """ ordered by you has been delivered.
|
828 |
thank_you_html = str(order.lineitems[0]) + """ ordered by you has been delivered.
|
| 829 |
Thank you for shopping with us. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers. Following are the details of your order.<br>
|
829 |
Thank you for shopping with us. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers. Following are the details of your order.<br>
|
| 830 |
"""
|
830 |
"""
|
| - |
|
831 |
|
| - |
|
832 |
freebie_text = "<br/>"
|
| - |
|
833 |
if order.freebieItemId:
|
| - |
|
834 |
catalog_client = CatalogClient().get_client()
|
| - |
|
835 |
item = catalog_client.getItem(order.freebieItemId)
|
| - |
|
836 |
freebie_text = freebie_text = "We have also delivered " + item.brand + " " + item.modelName + "" + item.modelNumber +" as promised"
|
| - |
|
837 |
else:
|
| - |
|
838 |
freebie_orderId = get_order_attribute_value(order.id, "freebieOrderId")
|
| - |
|
839 |
if freebie_orderId != "":
|
| - |
|
840 |
line_items = get_line_items_for_order(int(freebie_orderId))
|
| - |
|
841 |
freebie_order = get_order(int(freebie_orderId))
|
| - |
|
842 |
freebie_text = freebie_text + " We wish to inform you that your freebie item " +line_items[0].brand + " " + line_items[0].model_name + " " + line_items[0].model_number + " will be sent as a separate order with OrderId : " + freebie_orderId + " and is expected to be delivered on " + freebie_order.expected_delivery_time.strftime("%A, %d %B %Y")+ "<br/>You can track the status of this order from My Orders section in saholic.com"
|
| 831 |
|
843 |
|
| 832 |
html_header = html_header + thank_you_html + """
|
844 |
html_header = html_header + thank_you_html + """
|
| 833 |
</p>
|
845 |
</p>
|
| 834 |
<div>
|
846 |
<div>
|
| 835 |
Order Date: $order_date <br>
|
847 |
Order Date: $order_date <br>
|
| Line 877... |
Line 889... |
| 877 |
<tr>
|
889 |
<tr>
|
| 878 |
<td colspan=4>Total Amount</td>
|
890 |
<td colspan=4>Total Amount</td>
|
| 879 |
<td> Rs. $total_amount</td>
|
891 |
<td> Rs. $total_amount</td>
|
| 880 |
</tr>
|
892 |
</tr>
|
| 881 |
</table>
|
893 |
</table>
|
| - |
|
894 |
$freebie_text
|
| 882 |
</div>
|
895 |
</div>
|
| 883 |
<p>
|
896 |
<p>
|
| 884 |
Best Wishes,<br />
|
897 |
Best Wishes,<br />
|
| 885 |
$source_name Team
|
898 |
$source_name Team
|
| 886 |
</p>
|
899 |
</p>
|
| Line 893... |
Line 906... |
| 893 |
dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
|
906 |
dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
|
| 894 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
907 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
| 895 |
|
908 |
|
| 896 |
|
909 |
|
| 897 |
email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, pickup_text = pickup_text, source_url = source_url))
|
910 |
email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, pickup_text = pickup_text, source_url = source_url))
|
| 898 |
email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, source_name = source_name))
|
911 |
email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, source_name = source_name, freebie_text = freebie_text))
|
| 899 |
|
912 |
|
| 900 |
try:
|
913 |
try:
|
| 901 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
914 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
| 902 |
if order.insurer:
|
915 |
if order.insurer:
|
| 903 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], ["pramit.singh@shop2020.in ","anupam.singh@shop2020.in","rajveer.singh@shop2020.in"])
|
916 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], ["pramit.singh@shop2020.in ","anupam.singh@shop2020.in","rajveer.singh@shop2020.in"])
|
| Line 1190... |
Line 1203... |
| 1190 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
1203 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
| 1191 |
|
1204 |
|
| 1192 |
'''
|
1205 |
'''
|
| 1193 |
First checking whether freebie can be billed or not otherwise wont proceed.
|
1206 |
First checking whether freebie can be billed or not otherwise wont proceed.
|
| 1194 |
'''
|
1207 |
'''
|
| 1195 |
if billingType == BillingType.OURS:
|
1208 |
if order.freebieItemId:
|
| 1196 |
if order.freebieItemId is not None or order.freebieItemId>0:
|
1209 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| 1197 |
if freebieWarehouseId is not None or freebieWarehouseId >0:
|
1210 |
if freebieWarehouseId:
|
| 1198 |
try:
|
1211 |
try:
|
| - |
|
1212 |
inventory_client = InventoryClient().get_client()
|
| - |
|
1213 |
warehouse = inventory_client.getWarehouse(freebieWarehouseId)
|
| - |
|
1214 |
|
| - |
|
1215 |
if warehouse.warehouseType!= 'OURS'or warehouse.inventoryType != 'GOOD':
|
| - |
|
1216 |
raise TransactionServiceException(110,'Billing of Freebie is only allowed from OURS_GOOD warehouses ')
|
| - |
|
1217 |
|
| 1199 |
warehouse_client = WarehouseClient().get_client()
|
1218 |
warehouse_client = WarehouseClient().get_client()
|
| 1200 |
inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
|
1219 |
inventoryItem = warehouse_client.scanfreebie(orderId, order.freebieItemId, freebieWarehouseId, ScanType.SALE);
|
| 1201 |
|
1220 |
|
| 1202 |
attr = Attribute()
|
1221 |
attr = Attribute()
|
| 1203 |
attr.orderId = orderId
|
1222 |
attr.orderId = orderId
|
| Line 1208... |
Line 1227... |
| 1208 |
attr1.orderId = orderId
|
1227 |
attr1.orderId = orderId
|
| 1209 |
attr1.name = "freebie_vendor"
|
1228 |
attr1.name = "freebie_vendor"
|
| 1210 |
attr1.value = str(inventoryItem.supplierId)
|
1229 |
attr1.value = str(inventoryItem.supplierId)
|
| 1211 |
|
1230 |
|
| 1212 |
inventory_client = InventoryClient().get_client()
|
1231 |
inventory_client = InventoryClient().get_client()
|
| 1213 |
warehouse = inventory_client.getWarehouse(freebieWarehouseId)
|
- |
|
| 1214 |
item_pricing = inventory_client.getItemPricing(order.freebieItemId, warehouse.vendor.id)
|
1232 |
item_pricing = inventory_client.getItemPricing(order.freebieItemId, warehouse.vendor.id)
|
| 1215 |
#lineitem.transfer_price = item_pricing.transferPrice
|
- |
|
| 1216 |
attr2 = Attribute()
|
1233 |
attr2 = Attribute()
|
| 1217 |
attr2.orderId = orderId
|
1234 |
attr2.orderId = orderId
|
| 1218 |
attr2.name = "freebie_nlc"
|
1235 |
attr2.name = "freebie_nlc"
|
| 1219 |
attr2.value = str(item_pricing.nlc)
|
1236 |
attr2.value = str(item_pricing.nlc)
|
| 1220 |
except Exception as e:
|
1237 |
except Exception as e:
|
| 1221 |
print sys.exc_info()[0]
|
1238 |
print sys.exc_info()[0]
|
| 1222 |
print e.message
|
1239 |
print e.message
|
| 1223 |
raise Exception('Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
|
1240 |
raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
|
| - |
|
1241 |
else:
|
| - |
|
1242 |
raise TransactionServiceException(110,'No warehouseId provided for billing of freebie ')
|
| 1224 |
|
1243 |
else:
|
| - |
|
1244 |
raise TransactionServiceException(110,'Order with freebies associated with it cant be billed from an external warehouse ')
|
| 1225 |
lineitem = order.lineitems[0]
|
1245 |
lineitem = order.lineitems[0]
|
| 1226 |
item_id = lineitem.item_id
|
1246 |
item_id = lineitem.item_id
|
| 1227 |
|
1247 |
|
| 1228 |
# inventoryClient = InventoryClient().get_client()
|
1248 |
# inventoryClient = InventoryClient().get_client()
|
| 1229 |
# if not inventoryClient.isOrderBillable(item_id, order.fulfilmentWarehouseId, sourceId, orderId):
|
1249 |
# if not inventoryClient.isOrderBillable(item_id, order.fulfilmentWarehouseId, sourceId, orderId):
|
| Line 3563... |
Line 3583... |
| 3563 |
<div>
|
3583 |
<div>
|
| 3564 |
<p>Dear Customer,</p>
|
3584 |
<p>Dear Customer,</p>
|
| 3565 |
<p>
|
3585 |
<p>
|
| 3566 |
We are pleased to inform that we have shipped the order: $order_id for your product $product_name on $shipping_datetime.
|
3586 |
We are pleased to inform that we have shipped the order: $order_id for your product $product_name on $shipping_datetime.
|
| 3567 |
The shipment will be delivered to you via $courier_name Courier Service vide AWB# $awb.
|
3587 |
The shipment will be delivered to you via $courier_name Courier Service vide AWB# $awb.
|
| 3568 |
$freebie_text
|
3588 |
|
| 3569 |
</p>
|
3589 |
</p>
|
| 3570 |
<p>
|
3590 |
<p>
|
| 3571 |
Expected delivery date for your order is $expected_delivery_date.
|
3591 |
Expected delivery date for your order is $expected_delivery_date.
|
| 3572 |
<br/>
|
3592 |
<br/>
|
| 3573 |
$otg_text
|
3593 |
$otg_text
|
| - |
|
3594 |
$freebie_text
|
| 3574 |
<br/>
|
3595 |
<br/>
|
| 3575 |
The product can be delivered to you between business hours of 10am to 6pm.
|
3596 |
The product can be delivered to you between business hours of 10am to 6pm.
|
| 3576 |
You can Check the current shipment updates for your product online at <a href="www.saholic.com/myaccount">Open Orders</a>.
|
3597 |
You can Check the current shipment updates for your product online at <a href="www.saholic.com/myaccount">Open Orders</a>.
|
| 3577 |
</p>
|
3598 |
</p>
|
| 3578 |
<p>
|
3599 |
<p>
|
| Line 3621... |
Line 3642... |
| 3621 |
|
3642 |
|
| 3622 |
freebie_text = "<br/>"
|
3643 |
freebie_text = "<br/>"
|
| 3623 |
if order.freebieItemId:
|
3644 |
if order.freebieItemId:
|
| 3624 |
catalog_client = CatalogClient().get_client()
|
3645 |
catalog_client = CatalogClient().get_client()
|
| 3625 |
item = catalog_client.getItem(order.freebieItemId)
|
3646 |
item = catalog_client.getItem(order.freebieItemId)
|
| 3626 |
freebie_text = freebie_text = "We have also sent you " + item.brand + " " + item.modelName + item.modelNumber +" as promised"
|
3647 |
freebie_text = freebie_text = "We have also shipped you " + item.brand + " " + item.modelName + "" + item.modelNumber +" as promised<br/>"
|
| 3627 |
else:
|
3648 |
else:
|
| 3628 |
freebie_orderId = get_order_attribute_value(order.id, "freebieOrderId")
|
3649 |
freebie_orderId = get_order_attribute_value(order.id, "freebieOrderId")
|
| 3629 |
if freebie_orderId != "":
|
3650 |
if freebie_orderId != "":
|
| 3630 |
line_items = get_line_items_for_order(int(freebie_orderId))
|
3651 |
line_items = get_line_items_for_order(int(freebie_orderId))
|
| 3631 |
freebie_text = freebie_text + "Due to some unavoidable issues in procuring " +line_items(0).brand + " " + line_items(0).model_name + " " + line_items(0).model_number
|
3652 |
freebie_order = get_order(int(freebie_orderId))
|
| 3632 |
freebie_text = freebie_text + " Your freebie will be sent as a separate order with OrderId : " + freebie_orderId + "<br/> You can track the status of this order from My Orders section in saholic.com"
|
3653 |
freebie_text = freebie_text + "We wish to inform you that your freebie item " +line_items[0].brand + " " + line_items[0].model_name + " " + line_items[0].model_number + " will be sent as a separate order with OrderId : " + freebie_orderId + " and is expected to be delivered on " + freebie_order.expected_delivery_time.strftime("%A, %d %B %Y")+ "<br/>"
|
| - |
|
3654 |
else:
|
| - |
|
3655 |
freebie_text = ""
|
| 3633 |
|
3656 |
|
| 3634 |
info = dict(order_id = order.id, product_name = product, shipping_datetime = shipping_date, awb = order.airwaybill_no, expected_delivery_date = new_expected_delivery_date, courier_name = provider_name, courier_phone = provider_phone, source_name = source_name, otg_text = otg_text, freebie_text = freebie_text)
|
3657 |
info = dict(order_id = order.id, product_name = product, shipping_datetime = shipping_date, awb = order.airwaybill_no, expected_delivery_date = new_expected_delivery_date, courier_name = provider_name, courier_phone = provider_phone, source_name = source_name, otg_text = otg_text, freebie_text = freebie_text)
|
| 3635 |
return Template(html).substitute(info)
|
3658 |
return Template(html).substitute(info)
|
| 3636 |
|
3659 |
|
| 3637 |
def enqueue_shipping_confirmation_email(order):
|
3660 |
def enqueue_shipping_confirmation_email(order):
|
| Line 4819... |
Line 4842... |
| 4819 |
freebie_order.promised_delivery_time = order.promised_delivery_time
|
4842 |
freebie_order.promised_delivery_time = order.promised_delivery_time
|
| 4820 |
freebie_order.expected_shipping_time = to_py_date(shippingDate)
|
4843 |
freebie_order.expected_shipping_time = to_py_date(shippingDate)
|
| 4821 |
freebie_order.promised_shipping_time = order.promised_shipping_time
|
4844 |
freebie_order.promised_shipping_time = order.promised_shipping_time
|
| 4822 |
|
4845 |
|
| 4823 |
inventory_client = InventoryClient().get_client()
|
4846 |
inventory_client = InventoryClient().get_client()
|
| 4824 |
item_availability = inventory_client.getItemAvailabilityAtLocation(freebie_order.lineitems[0].item_id,1)
|
4847 |
item_availability = inventory_client.getItemAvailabilityAtLocation(order.freebieItemId,1)
|
| 4825 |
freebie_order.warehouse_id = item_availability[2]
|
4848 |
freebie_order.warehouse_id = item_availability[2]
|
| 4826 |
freebie_order.fulfillmentWarehouseId = item_availability[0]
|
4849 |
freebie_order.fulfillmentWarehouseId = item_availability[0]
|
| 4827 |
|
4850 |
|
| 4828 |
catalog_client = CatalogClient().get_client()
|
4851 |
catalog_client = CatalogClient().get_client()
|
| 4829 |
item = catalog_client.getItem(order.freebieItemId)
|
4852 |
item = catalog_client.getItem(order.freebieItemId)
|
| Line 4843... |
Line 4866... |
| 4843 |
litem.total_price = 0.01
|
4866 |
litem.total_price = 0.01
|
| 4844 |
litem.total_weight = item.weight
|
4867 |
litem.total_weight = item.weight
|
| 4845 |
litem.vatRate = 5.0
|
4868 |
litem.vatRate = 5.0
|
| 4846 |
|
4869 |
|
| 4847 |
freebie_order.lineitems.append(litem)
|
4870 |
freebie_order.lineitems.append(litem)
|
| 4848 |
|
4871 |
order.freebieItemId = 0
|
| 4849 |
session.commit()
|
4872 |
session.commit()
|
| - |
|
4873 |
order.lineitems[0].extra_info = "Parent Order for Order ID " + str(freebie_order.id)
|
| 4850 |
|
4874 |
|
| - |
|
4875 |
inventory_client = InventoryClient().get_client()
|
| 4851 |
inventory_client.reserveItemInWarehouse(freebie_order.lineitems[0].item_id, item_availability[0], 1, freebie_order.id, datetime.datetime.now(), order.promised_shipping_time, 1)
|
4876 |
inventory_client.reserveItemInWarehouse(freebie_order.lineitems[0].item_id, item_availability[0], sourceId, freebie_order.id, to_java_date(freebie_order.created_timestamp), to_java_date(freebie_order.promised_shipping_time), 1)
|
| 4852 |
|
- |
|
| 4853 |
parentOrderAttribute = Attribute()
|
4877 |
parentOrderAttribute = Attribute()
|
| 4854 |
parentOrderAttribute.orderId = freebie_order.id
|
4878 |
parentOrderAttribute.orderId = freebie_order.id
|
| 4855 |
parentOrderAttribute.name = "parentOrderIdForFreebie"
|
4879 |
parentOrderAttribute.name = "parentOrderIdForFreebie"
|
| 4856 |
parentOrderAttribute.value = str(order.id)
|
4880 |
parentOrderAttribute.value = str(order.id)
|
| 4857 |
|
4881 |
|
| Line 4859... |
Line 4883... |
| 4859 |
freebieOrderAttribute.orderId = order.id
|
4883 |
freebieOrderAttribute.orderId = order.id
|
| 4860 |
freebieOrderAttribute.name = "freebieOrderId"
|
4884 |
freebieOrderAttribute.name = "freebieOrderId"
|
| 4861 |
freebieOrderAttribute.value = str(freebie_order.id)
|
4885 |
freebieOrderAttribute.value = str(freebie_order.id)
|
| 4862 |
session.commit()
|
4886 |
session.commit()
|
| 4863 |
|
4887 |
|
| 4864 |
return freebie_order
|
4888 |
return to_t_order(freebie_order)
|
| 4865 |
|
4889 |
|
| 4866 |
def __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime, payMethod):
|
4890 |
def __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime, payMethod):
|
| 4867 |
PAGE_HEIGHT=defaultPageSize[1];
|
4891 |
PAGE_HEIGHT=defaultPageSize[1];
|
| 4868 |
styles = getSampleStyleSheet()
|
4892 |
styles = getSampleStyleSheet()
|
| 4869 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
4893 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|