| Line 15... |
Line 15... |
| 15 |
from shop2020.model.v1.catalog.impl.DataService import Item, Warehouse, \
|
15 |
from shop2020.model.v1.catalog.impl.DataService import Item, Warehouse, \
|
| 16 |
ItemInventoryHistory, CurrentInventorySnapshot, ItemChangeLog, Category, \
|
16 |
ItemInventoryHistory, CurrentInventorySnapshot, ItemChangeLog, Category, \
|
| 17 |
EntityIDGenerator, VendorItemPricing, VendorItemMapping, Vendor, SimilarItems, \
|
17 |
EntityIDGenerator, VendorItemPricing, VendorItemMapping, Vendor, SimilarItems, \
|
| 18 |
ProductNotification, Source, SourceItemPricing, AuthorizationLog, \
|
18 |
ProductNotification, Source, SourceItemPricing, AuthorizationLog, \
|
| 19 |
MissedInventoryUpdate, BadInventorySnapshot, VendorItemProcurementDelay, \
|
19 |
MissedInventoryUpdate, BadInventorySnapshot, VendorItemProcurementDelay, \
|
| 20 |
VendorHolidays, ItemAvailabilityCache
|
20 |
VendorHolidays, ItemAvailabilityCache, VoucherItemMapping
|
| 21 |
from shop2020.thriftpy.model.v1.catalog.ttypes import InventoryServiceException, \
|
21 |
from shop2020.thriftpy.model.v1.catalog.ttypes import InventoryServiceException, \
|
| 22 |
status, ItemShippingInfo, HolidayType, InventoryType, WarehouseType, ItemType
|
22 |
status, ItemShippingInfo, HolidayType, InventoryType, WarehouseType, ItemType
|
| 23 |
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
|
23 |
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
|
| 24 |
from shop2020.utils import EmailAttachmentSender
|
24 |
from shop2020.utils import EmailAttachmentSender
|
| 25 |
from shop2020.utils.EmailAttachmentSender import mail
|
25 |
from shop2020.utils.EmailAttachmentSender import mail
|
| Line 1513... |
Line 1513... |
| 1513 |
similar_item = SimilarItems.query.filter_by(item_id=itemId, catalog_item_id=catalog_item_id).all()
|
1513 |
similar_item = SimilarItems.query.filter_by(item_id=itemId, catalog_item_id=catalog_item_id).all()
|
| 1514 |
if len(similar_item):
|
1514 |
if len(similar_item):
|
| 1515 |
similar_item[0].delete()
|
1515 |
similar_item[0].delete()
|
| 1516 |
session.commit()
|
1516 |
session.commit()
|
| 1517 |
return True
|
1517 |
return True
|
| - |
|
1518 |
|
| - |
|
1519 |
def get_all_vouchers_for_item(itemId):
|
| - |
|
1520 |
vouchers = VoucherItemMapping.query.filter_by(item_id=itemId).all()
|
| - |
|
1521 |
return vouchers
|
| - |
|
1522 |
|
| - |
|
1523 |
def get_voucher_amount(itemId, voucher_type):
|
| - |
|
1524 |
voucher = VoucherItemMapping.query.filter_by(item_id=itemId, voucherType=voucher_type).all()
|
| - |
|
1525 |
if len(voucher):
|
| - |
|
1526 |
return voucher[0].amount
|
| - |
|
1527 |
else:
|
| - |
|
1528 |
return None
|
| - |
|
1529 |
|
| - |
|
1530 |
def add_update_voucher_for_item(catalog_item_id, voucher_type, voucher_amount):
|
| - |
|
1531 |
if not catalog_item_id or not voucher_type or not voucher_amount:
|
| - |
|
1532 |
raise InventoryServiceException(101, "Bad catalogItemId or voucherType or voucherAmount in request")
|
| - |
|
1533 |
|
| - |
|
1534 |
items_for_entity = get_items_by_catalog_id(catalog_item_id)
|
| - |
|
1535 |
if not len(items_for_entity):
|
| - |
|
1536 |
raise InventoryServiceException(101, "catalogItemId does not exists in database")
|
| - |
|
1537 |
|
| - |
|
1538 |
for item in items_for_entity:
|
| - |
|
1539 |
itemId = item.id
|
| - |
|
1540 |
voucher = VoucherItemMapping.query.filter_by(item_id=itemId, voucherType=voucher_type).all()
|
| - |
|
1541 |
if not len(voucher):
|
| - |
|
1542 |
voucher = VoucherItemMapping()
|
| - |
|
1543 |
voucher.item_id=itemId
|
| - |
|
1544 |
voucher.voucherType=voucher_type
|
| - |
|
1545 |
voucher.amount=voucher_amount
|
| - |
|
1546 |
else:
|
| - |
|
1547 |
voucher[0].amount=voucher_amount
|
| - |
|
1548 |
session.commit()
|
| - |
|
1549 |
return True
|
| 1518 |
|
1550 |
|
| - |
|
1551 |
def delete_voucher_for_item(catalog_item_id, voucher_type):
|
| - |
|
1552 |
if not catalog_item_id or not voucher_type:
|
| - |
|
1553 |
raise InventoryServiceException(101, "Bad catalogItemId or voucherType in request")
|
| - |
|
1554 |
|
| - |
|
1555 |
items_for_entity = get_items_by_catalog_id(catalog_item_id)
|
| - |
|
1556 |
if not len(items_for_entity):
|
| - |
|
1557 |
raise InventoryServiceException(101, "catalogItemId does not exists in database")
|
| - |
|
1558 |
|
| - |
|
1559 |
for item in items_for_entity:
|
| - |
|
1560 |
itemId = item.id
|
| - |
|
1561 |
voucher = VoucherItemMapping.query.filter_by(item_id=itemId, voucherType=voucher_type).all()
|
| - |
|
1562 |
if len(voucher):
|
| - |
|
1563 |
voucher[0].delete()
|
| - |
|
1564 |
session.commit()
|
| - |
|
1565 |
return True
|
| - |
|
1566 |
|
| 1519 |
def add_product_notification(itemId, email):
|
1567 |
def add_product_notification(itemId, email):
|
| 1520 |
try:
|
1568 |
try:
|
| 1521 |
try:
|
1569 |
try:
|
| 1522 |
product_notification = ProductNotification.query.filter_by(item_id=itemId, email=email).one()
|
1570 |
product_notification = ProductNotification.query.filter_by(item_id=itemId, email=email).one()
|
| 1523 |
except:
|
1571 |
except:
|