"""Logic for anything carvein related.""" from oto import response from ows_product_physical.constant import error from ows_product_physical.models import ows_carveouts US_STORE = 738 CA_STORE = 739 EU_STORE = 740 UK_STORE = 696 AU_STORE = 737 ALL_STORE_IDS = [US_STORE, CA_STORE, EU_STORE, UK_STORE, AU_STORE] def get_carveins_for_upc(upc): """Gets the carveins by getting the carveouts.""" carveout_ids_for_upc = ows_carveouts.get_release_carveouts_for_upc(upc) if not carveout_ids_for_upc: return carveout_ids_for_upc stores = list(map(int, dict(carveout_ids_for_upc.message).keys())) carveins = set(ALL_STORE_IDS) - set(stores) return response.Response(message=carveins, status=200) def get_days_required_for_carveins(carvein_ids): """Get days required before sales date by carvein ids.""" days = 35 if US_STORE in carvein_ids: days = 75 elif (AU_STORE in carvein_ids or CA_STORE in carvein_ids or EU_STORE in carvein_ids): days = 60 return days def get_days_message_required_for_carveins(carvein_ids): """Get days required error code before sales date by carvein ids.""" if US_STORE in carvein_ids: return error.RELEASE_STATUS_SALE_START_DATE_US_ERROR elif (AU_STORE in carvein_ids or CA_STORE in carvein_ids or EU_STORE in carvein_ids): return error.RELEASE_STATUS_SALE_START_DATE_AU_CA_EU_ERROR return error.RELEASE_STATUS_SALE_START_DATE_DEFAULT_ERROR