"""DDEX deal terms logic concept""" # use the existing territory_dates list and call get_deal_terms function # get_deal_terms can be called at either Product or Track # can attach any additional data (rights) to the object in the return list def get_deal_terms(preorder_date, sale_start_date, pricing, instant_grats): deal_terms = [] if preorder_date: deal_terms.extend( get_preorder_deal_terms( preorder_date, sale_start_date, pricing, instant_grats, ) ) deal_terms.extend(get_regular_deal_terms(sale_start_date, pricing)) return deal_terms def get_preorder_deal_terms(preorder_date, end_date, pricing, instant_grats): preorder_deal_terms = [preorder_date] if pricing and min(pricing.start_date) < end_date: # split deals preorder_deal_terms.extend( [start_date for start_date in pricing if star_date < end_date] ) if instant_grats: preorder_deal_terms.extend([grat for grat in instant_grats]) return preorder_deal_terms def get_regular_deal_terms(sale_start_date, pricing): regular_deal_terms = [sale_start_date] if pricing: regular_deal_terms.extend( [start_date for start_date in pricing if start_date >= sale_start_date] ) return regular_deal_terms