コード例 #1
0
ファイル: hotel.py プロジェクト: Crazy-Ideas/focus-solutions
 def __init__(self,
              name: str = None,
              ballrooms: List[str] = None,
              primary_hotels: List[str] = None,
              secondary_hotels: List[str] = None,
              city: str = None):
     super().__init__()
     self.name: str = name if name else str()
     self.ballroom_maps: List[dict] = [BallroomMap(room).to_dict() for room in ballrooms] if ballrooms \
         else [BallroomMap(Config.OTHER).to_dict()]
     self.city: str = city if city else str()
     self.primary_hotels: List[
         str] = primary_hotels[:9] if primary_hotels else list()
     self.secondary_hotels: List[
         str] = secondary_hotels[:9] if secondary_hotels else list()
     self.start_date: str = str()
     self.end_date: str = str()
     self.full_name: str = str()
     self.company: str = str()
     self.address: str = str()
     self.pin_code: str = str()
     self.banquet_area: int = int()
     self.star_category: str = str()
     self.pan: str = str()
     self.gst: str = str()
     self.set_contract(Date.today(), Date.today())
     self.last_date: str = str()
     self.last_timing: str = str()
     self.contract_file: str = str()
コード例 #2
0
ファイル: report.py プロジェクト: Crazy-Ideas/focus-solutions
 def __init__(self, *args, **kwargs) -> None:
     super().__init__(*args, **kwargs)
     self.error_message: str = str()
     hotels = Hotel.objects.filter_by(city=current_user.city).get()
     hotels.sort(key=lambda hotel: hotel.name)
     self.custom_hotels.choices.extend([(hotel.name, hotel.name)
                                        for hotel in hotels
                                        if hotel.name != current_user.hotel
                                        ])
     hotel: Hotel = next(
         (hotel for hotel in hotels if hotel.name == current_user.hotel),
         None)
     if not hotel:
         self.error_message = "Error in retrieving the hotel information"
         return
     if current_user.role == Config.HOTEL:
         date, _ = Usage.get_data_entry_date(hotel)
         if not date:
             self.error_message = "Error in retrieving last update date"
             return
         if date <= Date.previous_lock_in() and Date.today(
         ) <= hotel.contract.end_date:
             self.error_message = "There are pending data entry for previous lock in period"
             return
     self.primaries = hotel.primary_hotels if hotel else list()
     self.secondaries = hotel.secondary_hotels if hotel else list()
     self.usage_data: List[Usage] = list()
     self.hotel_counts: List[Tuple[Hotel, int]] = list()
     self.hotel_trends: List[Tuple[str, int, float]] = list()
     self.file_path: str = str()
コード例 #3
0
ファイル: report.py プロジェクト: Crazy-Ideas/focus-solutions
 def generate_header(self) -> List[Tuple[int, str, str, str]]:
     return [
         ((Date.next_lock_in() - dt.timedelta(days=day)).day,
          "d-none d-lg-table-cell" if day > 2 else str(),
          (Date.next_lock_in() - dt.timedelta(days=day)).strftime("%a")[:2],
          "bg-warning text-dark" if Date.next_lock_in() -
          dt.timedelta(days=day) == Date.today() else str())
         for day in range(self.PAST_DAYS, -1, -1)
     ]
コード例 #4
0
ファイル: report.py プロジェクト: Crazy-Ideas/focus-solutions
 def generate_hotel_status(self):
     hotels = Hotel.objects.filter_by(city=current_user.city).get()
     self.hotels = [(hotel.name, list()) for hotel in hotels]
     for index, hotel in enumerate(hotels):
         last_date = Date(hotel.last_date).date
         if last_date and (last_date < hotel.contract[0]
                           or last_date > Date.next_lock_in()):
             last_date = None
         for day in range(self.PAST_DAYS, -1, -1):
             date = Date.next_lock_in() - dt.timedelta(days=day)
             if not last_date:
                 self.add_status(
                     index, day, self.NOT_DONE
                     if hotel.is_contract_valid(date) else self.NA)
                 continue
             if date < last_date:
                 self.add_status(
                     index, day, self.DONE
                     if hotel.is_contract_valid(date) else self.NA)
             elif date > last_date:
                 self.add_status(
                     index, day, self.NOT_DONE
                     if hotel.is_contract_valid(date) else self.NA)
             else:
                 self.add_status(
                     index, day, self.DONE if hotel.last_timing
                     == Config.EVENING else self.PARTIAL)
         if current_user.hotel != hotel.name:
             continue
         end_date = min(Date.yesterday(), hotel.contract[1])
         last_date = last_date or hotel.contract[0]
         if hotel.contract[0] > Date.today():
             self.status = self.STATUS_NO_CONTRACT
             continue
         if last_date >= end_date:
             self.status = self.STATUS_ALL_DONE if last_date > end_date or hotel.last_timing == Config.EVENING \
                 else self.STATUS_PARTIAL
             continue
         days = (end_date - last_date).days
         self.status = (f"{days} days entry remaining",
                        "list-group-item-danger")
     self.hotels.sort(key=itemgetter(0))
     hotel = next(
         (hotel for hotel in self.hotels if hotel[0] == current_user.hotel))
     if hotel:
         self.hotels.remove(hotel)
         self.hotels.insert(0, hotel)
     return
コード例 #5
0
ファイル: hotel.py プロジェクト: Crazy-Ideas/focus-solutions
 def set_last_entry(self, input_date: Union[str, dt.date],
                    timing: str) -> bool:
     date = Date(input_date).date
     if not date:
         return False
     last_date = Date(self.last_date).date
     if last_date and last_date > Date.today():
         last_date = None
     if not last_date or date > last_date:
         self.last_date = Date(date).db_date
         self.last_timing = timing
         return True
     elif date == last_date and self.last_timing == Config.MORNING and timing == Config.EVENING:
         self.last_timing = timing
         return True
     return False