| Line -... |
Line 1... |
| - |
|
1 |
from datetime import date, datetime, timedelta
|
| 1 |
from elixir import metadata, setup_all, session
|
2 |
from elixir import metadata, setup_all, session
|
| - |
|
3 |
from email import encoders
|
| - |
|
4 |
from email.mime.base import MIMEBase
|
| - |
|
5 |
from email.mime.multipart import MIMEMultipart
|
| - |
|
6 |
from email.mime.text import MIMEText
|
| 2 |
from shop2020.clients.CatalogClient import CatalogClient
|
7 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 3 |
from shop2020.clients.InventoryClient import InventoryClient
|
8 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 4 |
from shop2020.clients.TransactionClient import TransactionClient
|
9 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 5 |
from shop2020.purchase.main.model.Invoice import Invoice
|
10 |
from shop2020.purchase.main.model.Invoice import Invoice
|
| 6 |
from shop2020.purchase.main.model.LineItem import LineItem
|
11 |
from shop2020.purchase.main.model.LineItem import LineItem
|
| 7 |
from shop2020.purchase.main.model.Purchase import Purchase
|
12 |
from shop2020.purchase.main.model.Purchase import Purchase
|
| - |
|
13 |
from shop2020.purchase.main.model.PurchaseOrder import PurchaseOrder
|
| 8 |
from shop2020.purchase.main.model.PurchaseReturn import PurchaseReturn
|
14 |
from shop2020.purchase.main.model.PurchaseReturn import PurchaseReturn
|
| 9 |
from shop2020.purchase.main.model.PurchaseReturnSettlement import PurchaseReturnSettlement
|
15 |
from shop2020.purchase.main.model.PurchaseReturnSettlement import \
|
| - |
|
16 |
PurchaseReturnSettlement
|
| 10 |
from shop2020.purchase.main.model.RevisionedPurchaseOrder import \
|
17 |
from shop2020.purchase.main.model.RevisionedPurchaseOrder import \
|
| 11 |
RevisionedPurchaseOrder
|
18 |
RevisionedPurchaseOrder
|
| 12 |
from shop2020.purchase.main.model.Supplier import Supplier
|
19 |
from shop2020.purchase.main.model.Supplier import Supplier
|
| 13 |
from shop2020.purchase.main.model.PurchaseOrder import PurchaseOrder
|
- |
|
| 14 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
20 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
| 15 |
from shop2020.thriftpy.model.v1.inventory.ttypes import WarehouseType, \
|
21 |
from shop2020.thriftpy.model.v1.inventory.ttypes import WarehouseType, \
|
| 16 |
InventoryType, ItemStockPurchaseParams
|
22 |
InventoryType, ItemStockPurchaseParams
|
| 17 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
23 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus
|
| 18 |
from shop2020.thriftpy.purchase.ttypes import PurchaseServiceException, POStatus, \
|
24 |
from shop2020.thriftpy.purchase.ttypes import PurchaseServiceException, POStatus, \
|
| 19 |
PurchaseOrder as TPurchaseOrder, LineItem as TLineItem, POType,\
|
25 |
PurchaseOrder as TPurchaseOrder, LineItem as TLineItem, POType, \
|
| 20 |
PurchaseReturnType, PurchaseReturnInventoryType
|
26 |
PurchaseReturnType, PurchaseReturnInventoryType
|
| 21 |
from shop2020.utils.Utils import to_py_date
|
27 |
from shop2020.utils.Utils import to_py_date
|
| 22 |
from sqlalchemy import create_engine
|
28 |
from sqlalchemy import create_engine
|
| 23 |
from sqlalchemy.sql.expression import or_
|
29 |
from sqlalchemy.sql.expression import or_
|
| 24 |
from datetime import date, datetime, timedelta
|
- |
|
| 25 |
import logging
|
- |
|
| 26 |
import sys
|
- |
|
| 27 |
from xlrd import open_workbook
|
30 |
from xlrd import open_workbook
|
| 28 |
from xlwt.Workbook import Workbook
|
31 |
from xlwt.Workbook import Workbook
|
| - |
|
32 |
import logging
|
| 29 |
import smtplib
|
33 |
import smtplib
|
| - |
|
34 |
import sys
|
| 30 |
import time
|
35 |
import time
|
| - |
|
36 |
import traceback
|
| 31 |
import xlwt
|
37 |
import xlwt
|
| 32 |
from email import encoders
|
- |
|
| 33 |
from email.mime.base import MIMEBase
|
- |
|
| 34 |
from email.mime.multipart import MIMEMultipart
|
- |
|
| 35 |
from email.mime.text import MIMEText
|
- |
|
| 36 |
|
38 |
|
| 37 |
|
39 |
|
| 38 |
XLS_O_FILENAME = "allPendingPOs.xls"
|
40 |
XLS_O_FILENAME = "allPendingPOs.xls"
|
| 39 |
SENDER = "adwords@shop2020.in"
|
41 |
SENDER = "adwords@shop2020.in"
|
| 40 |
PASSWORD = "adwords_shop2020"
|
42 |
PASSWORD = "adwords_shop2020"
|
| Line 213... |
Line 215... |
| 213 |
if oosStatus.rto_orders:
|
215 |
if oosStatus.rto_orders:
|
| 214 |
rtoCount = oosStatus.rto_orders
|
216 |
rtoCount = oosStatus.rto_orders
|
| 215 |
if numDaysInStock>0:
|
217 |
if numDaysInStock>0:
|
| 216 |
avgSales = float(salesCount)/float(numDaysInStock)
|
218 |
avgSales = float(salesCount)/float(numDaysInStock)
|
| 217 |
itemStockPurchaseParam = ItemStockPurchaseParams()
|
219 |
itemStockPurchaseParam = ItemStockPurchaseParams()
|
| - |
|
220 |
itemStockPurchaseParam.minStockLevel = 0
|
| - |
|
221 |
itemStockPurchaseParam.numOfDaysStock = 0
|
| 218 |
try:
|
222 |
try:
|
| 219 |
itemStockPurchaseParam = inventory_client.getItemStockPurchaseParams(key)
|
223 |
itemStockPurchaseParam = inventory_client.getItemStockPurchaseParams(key)
|
| 220 |
except Exception as e:
|
224 |
except Exception as e:
|
| 221 |
if errorsMap.has_key(key):
|
225 |
if errorsMap.has_key(key):
|
| 222 |
errorsMap[key] = errorsMap.get(key) + "| Item Stock Purchase Param Missing"
|
226 |
errorsMap[key] = errorsMap.get(key) + "| Item Stock Purchase Param Missing"
|
| Line 345... |
Line 349... |
| 345 |
t_purchase_order['lineitems'].append(t_po_lineitem)
|
349 |
t_purchase_order['lineitems'].append(t_po_lineitem)
|
| 346 |
purchaseOrders.append(t_purchase_order)
|
350 |
purchaseOrders.append(t_purchase_order)
|
| 347 |
print errorsMap
|
351 |
print errorsMap
|
| 348 |
return purchaseOrders, errorsMap
|
352 |
return purchaseOrders, errorsMap
|
| 349 |
except Exception as e:
|
353 |
except Exception as e:
|
| 350 |
print e
|
- |
|
| 351 |
print sys.exc_info()[0]
|
354 |
traceback.print_exc()
|
| 352 |
finally:
|
355 |
finally:
|
| 353 |
self.close_session()
|
356 |
self.close_session()
|
| 354 |
|
357 |
|
| 355 |
def close_session(self):
|
358 |
def close_session(self):
|
| 356 |
if session.is_active:
|
359 |
if session.is_active:
|