def execute(self, house_id: int, pk: int, contact_id: int, attribute: str, value: Any) -> ResultE['Reservation']: ctx = Context( house_id=house_id, pk=pk, contact_id=cf.get_int_or_none(contact_id) or 0, attribute=(attribute or '').strip().lower(), value=value, ) if ctx.contact_id <= 0: return self._error( f"Missed Contact ID for update Guest information in Reservation ID={ctx.pk}", ctx, self._case_errors.error, ) if ctx.attribute == '': return self._error( f"Missed attribute for update Guest information in Reservation ID={ctx.pk}", ctx, self._case_errors.error, ) if ctx.attribute not in ('name', 'email', 'phone'): return self._error( f"Unsupported attribute [{ctx.attribute}] for update Guest information in Reservation ID={ctx.pk}", ctx, self._case_errors.error, ) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.make_reservation_from_data), bind_result(self.save_reservation), bind_result(lambda x: Success(x.reservation)), )
def execute(self, house_id: int, pk: int, contact_id: int) -> ResultE[bool]: ctx = Context(house_id=house_id, pk=pk, contact_id=contact_id) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.add_contact), bind_result(self.save), bind_result(lambda x: Success(True)), )
def execute(self, house_id: int, pk: int, user: '******') -> ResultE['Reservation']: ctx = Context(house_id=house_id, pk=pk, user=user) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.cancel_reservation), bind_result(self.write_changelog), bind_result(lambda x: Success(ctx.reservation)), )
def execute(self, house_id: int, pk: int, user: '******') -> ResultE[ReservationVerifyContext]: ctx = Context(house_id=house_id, pk=pk, user=user) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.populate_with_plans), bind_result(self.populate_with_room_types), bind_result(self.make_result), )
def execute(self, pk: int, base_date: Optional[datetime.date], user: '******' = None) -> ResultE[OccupanciesContext]: ctx = Context(house_id=pk, base_date=base_date, user=user) return flow( ctx, self.select_house, bind_result(self.get_calendar_period), bind_result(self.select_roomtypes), bind_result(self.select_occupancies), bind_result(self.make_result), )
def execute( self, pk: str, reservation_id: int, house_id: int, roomtype_id: int = None, room_id: int = None, user: '******' = None, ) -> ResultE[None]: ctx = Context( pk=pk, reservation_id=reservation_id, house_id=house_id, roomtype_id=roomtype_id, room_id=room_id, user=user, ) return flow( ctx, self.select_house, bind_result(self.select_reservation_from_cache), bind_result(self.select_reservation_from_db), bind_result(self.select_room_type), bind_result(self.select_room), bind_result(self.update_reservation), bind_result(self.save), bind_result(self.write_changelog), bind_result(lambda x: Success(None)), )
def execute( self, pk: str, house_id: int, room_id: int, start_date: datetime.date, end_date: datetime.date, reason: RoomCloseReasons, user: '******', notes: str = '', ) -> ResultE[ReservationUpdateContext]: pk = cf.get_int_or_none((pk or '').split('-')[0]) or 0 ctx = Context( pk=pk, house_id=house_id, room_id=room_id, start_date=start_date, end_date=end_date, reason=reason, user=user, notes=notes, ) return flow( ctx, self.select_house, bind_result(self.select_room), bind_result(self.select_reservation), bind_result(self.check_room_is_free), bind_result(self.make_reservation_from_data), bind_result(self.save_reservation), bind_result(self.accept_reservation), bind_result(self.write_changelog), bind_result(self.make_result), )
def execute(self, house_id: int, pk: int, user_id: int = None) -> ResultE[bool]: ctx = Context(house_id=house_id, pk=pk, user_id=user_id) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.select_user), bind_result(self.update_opportunity), bind_result(self.check_need_update_quotation), bind_result(self.get_quotation_state), bind_result(self.unlock_quotation), bind_result(self.update_quotation), bind_result(self.lock_back_quotation), bind_result(lambda x: Success(True)), )
def execute( self, house_id: int, room_id: int, start_date: datetime.date, end_date: datetime.date, reason: RoomCloseReasons, user: '******', notes: str = '', ) -> ResultE[Reservation]: ctx = Context( house_id=house_id, room_id=room_id, start_date=start_date, end_date=end_date, reason=reason, user=user, notes=notes, ) return flow( ctx, self.select_house, bind_result(self.select_room), bind_result(self.check_room_is_free), bind_result(self.make_reservation_from_date), bind_result(self.save_reservation), bind_result(self.accept_reservation), bind_result(self.write_changelog), bind_result(lambda x: Success(x.reservation)), )
def execute(self, house_id: int, pk: int, user: '******', price_ids: List[int] = None) -> ResultE['Reservation']: ctx = Context(house_id=house_id, pk=pk, user=user, price_ids=price_ids or []) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.accept_changes), bind_result(self.write_changelog), bind_result(lambda x: Success(ctx.reservation)), )
def execute(self, house_id: int, pk: int, room_id: int, user: '******') -> ResultE[ReservationPricesUpdateContext]: ctx = Context(house_id=house_id, pk=pk, room_id=room_id, user=user) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.select_reservation_room), bind_result(self.select_rate_plans), bind_result(self.select_cancellation_policies), bind_result(self.select_room_types), bind_result(self.select_rooms), bind_result(self.make_result), )
def execute(self, house_id: int, request: ReservationRequest, user: '******') -> ResultE[Reservation]: ctx = Context(house_id=house_id, request=request, user=user) if not isinstance(ctx.request, ReservationRequest): return self._error('Missed Reservation data', ctx, self._case_errors.missed_reservation) return flow( ctx, self.select_house, bind_result(self.select_room_type), bind_result(self.select_rate_plan), bind_result(self.select_rate), bind_result(self.select_cancellation_policy), bind_result(self.make_reservation_from_date), bind_result(self.save_reservation), bind_result(self.accept_reservation), bind_result(self.write_changelog), bind_result(lambda x: Success(x.reservation)), )
def execute(self, house_id: int, pk: int, user_id: int = None) -> ResultE[bool]: ctx = Context(house_id=house_id, pk=pk, user_id=user_id) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.select_user), bind_result(self.check_reservation), bind_result(self.create_guest_contact), bind_result(self.create_opportunity), bind_result(self.create_quotation), bind_result(self.save_reservation), bind_result(lambda x: Success(True)), )
def execute(self, house_id: int, pk: int, user: '******') -> ResultE[bool]: ctx = Context(house_id=house_id, pk=pk, user=user) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.accept_reservation), bind_result(self.confirm_quotation), bind_result(self.write_changelog), bind_result(lambda x: Success(True)), )
def execute(self, house_id: int, pk: int = None, start_date: datetime.date = None, end_date: datetime.date = None) -> ResultE[None]: ctx = Context(house_id=house_id, pk=pk, start_date=start_date, end_date=end_date) return flow( ctx, self.select_house, bind_result(self.select_reservations), bind_result(self.select_bot_user), bind_result(self.select_rate_plans), bind_result(self.select_payed_amounts), bind_result(self.process_reservations), bind_result(self.remove_canceled_reservations), bind_result(self.save_cache), bind_result(lambda x: Success(None)), )
def execute(self, pk: str, house_id: int, user: '******') -> ResultE['Reservation']: pk = cf.get_int_or_none((pk or '').split('-')[0]) or 0 ctx = Context(pk=pk, house_id=house_id, user=user) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.make_reservation_from_data), bind_result(self.save_reservation), bind_result(self.write_changelog), bind_result(lambda x: Success(x.reservation)), )
def execute( self, house_id: int, roomtype_id: int, plan_id: int, start_date: datetime.date, end_date: datetime.date, guest_count: int, user: '******', rate_id: int = None, ) -> ResultE[ReservationCalcContext]: ctx = Context( house_id=house_id, roomtype_id=roomtype_id, plan_id=plan_id, start_date=start_date, end_date=end_date, guest_count=guest_count, user=user, rate_id=rate_id, ) return flow( ctx, self.select_house, bind_result(self.select_room_type), bind_result(self.select_rate_plan), bind_result(self.select_rates), bind_result(self.select_rate_by_id), bind_result(self.select_rate_by_guest_count), bind_result(self.select_price_restrictions), bind_result(self.select_daily_prices), bind_result(self.select_discounts), bind_result(self.select_occupancies), bind_result(self.check_last_minute_discounts), bind_result(self.check_availability_discounts), bind_result(self.check_los_discounts), bind_result(self.check_min_prices), bind_result(self.make_result), )
def execute( self, house_id: int, pk: int, room_id: int, plan_id: int, user: '******', prices: Dict[datetime.date, Dict[str, Any]] = None, ) -> ResultE['Reservation']: ctx = Context(house_id=house_id, pk=pk, room_id=room_id, user=user, plan_id=plan_id, prices=prices) return flow( ctx, self.select_house, bind_result(self.select_reservation), bind_result(self.check_reservation), bind_result(self.select_reservation_room), bind_result(self.is_allow_update_period), bind_result(self.select_rate_plan), bind_result(self.select_cancellation_policy), bind_result(self.select_room_types), bind_result(self.select_rooms), bind_result(self.make_reservation_from_data), bind_result(self.save_reservation), bind_result(self.write_changelog), bind_result(lambda x: Success(x.reservation)), )