Repository URL to install this package:
|
Version:
0.4.200 ▾
|
lib-py-b2b
/
fulfillment_center.py
|
|---|
from datetime import datetime
from lib_b2b.address import Address
from lib_b2b.calendar import OperatingCalendar
from lib_b2b.customer import Customer
from lib_b2b.holidays import Holidays
from lib_b2b.profile import Profile
from lib_b2b.service_center import ServiceCenter
class FulfillmentCenter(ServiceCenter):
def operating_calendar(self, customer):
if customer in ['402100100554', '402100200002']:
return OperatingCalendar(work_days=list(range(1, 5)), holidays=self.holidays)
else:
return OperatingCalendar(work_days=self.workdays, holidays=self.holidays)
# TODO: - Ideally, the list of fulfillment centers should be pulled from the
# database. However, with only one fulfillment center it's unnecessary. If
# there is future expansion, this will need to be revisited.
class FulfillmentCenters:
fulfillment_centers = {
'MTAD': FulfillmentCenter(
center_id='MTAD',
name='Building D',
address=Address(
address1='199 Woltz St',
city='Mount Airy',
state='NC',
postalCode='27030',
country='US',
phone='(336)789-9161'
),
time_zone='US/Eastern',
workdays=[0, 1, 2, 3, 4],
holidays=Holidays.get('BarnhardtCalendar', years=[datetime.now().year])
)
}
@classmethod
def for_(cls, customer):
_profile = Profile.profile_for(customer)
_svc_ctr = cls.get(_profile.fulfillment_center)
return _svc_ctr
@classmethod
def get(cls, center_id):
return cls.fulfillment_centers.get(center_id, None)
@classmethod
def all(cls):
return cls.fulfillment_centers.values()