mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]: added GET for res_users and is_board_service field in pms_service
This commit is contained in:
@@ -44,3 +44,4 @@ from . import pms_cancelation_rule
|
||||
from . import pms_agency
|
||||
from . import pms_service
|
||||
from . import pms_service_line
|
||||
from . import res_users
|
||||
|
||||
@@ -32,6 +32,7 @@ class PmsReservationInfo(Datamodel):
|
||||
boardServiceId = fields.Integer(required=False, allow_none=True)
|
||||
saleChannelId = fields.Integer(required=False, allow_none=True)
|
||||
agencyId = fields.Integer(required=False, allow_none=True)
|
||||
userId = fields.Integer(required=False, allow_none=True)
|
||||
|
||||
checkin = fields.String(required=False, allow_none=True)
|
||||
checkout = fields.String(required=False, allow_none=True)
|
||||
|
||||
@@ -12,3 +12,4 @@ class PmsServiceInfo(Datamodel):
|
||||
priceSubtotal = fields.Float(required=False, allow_none=True)
|
||||
priceTaxes = fields.Float(required=False, allow_none=True)
|
||||
discount = fields.Float(required=False, allow_none=True)
|
||||
isBoardService = fields.Boolean(required=False, allow_none=True)
|
||||
|
||||
9
pms_api_rest/datamodels/res_users.py
Normal file
9
pms_api_rest/datamodels/res_users.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from marshmallow import fields
|
||||
|
||||
from odoo.addons.datamodel.core import Datamodel
|
||||
|
||||
|
||||
class PmsResUsersInfo(Datamodel):
|
||||
_name = "res.users.info"
|
||||
id = fields.Integer(required=False, allow_none=True)
|
||||
name = fields.String(required=False, allow_none=True)
|
||||
@@ -47,7 +47,7 @@ class PmsBoardServiceService(Component):
|
||||
name=line.pms_board_service_room_type_id.display_name,
|
||||
boardServiceId=line.pms_board_service_room_type_id.id,
|
||||
productId=line.product_id.id,
|
||||
amount=round(line.amount,2),
|
||||
amount=round(line.amount, 2),
|
||||
)
|
||||
)
|
||||
return result_board_service_lines
|
||||
@@ -75,7 +75,7 @@ class PmsBoardServiceService(Component):
|
||||
name=board_service_line.pms_board_service_room_type_id.display_name,
|
||||
boardServiceId=board_service_line.pms_board_service_room_type_id.id,
|
||||
productId=board_service_line.product_id.id,
|
||||
amount=round(board_service_line.amount,2),
|
||||
amount=round(board_service_line.amount, 2),
|
||||
)
|
||||
else:
|
||||
raise MissingError(_("Board service line not found"))
|
||||
|
||||
@@ -56,7 +56,7 @@ class PmsBoardServiceService(Component):
|
||||
id=board_service.id,
|
||||
name=board_service.pms_board_service_id.display_name,
|
||||
roomTypeId=board_service.pms_room_type_id.id,
|
||||
amount=round(board_service.amount,2),
|
||||
amount=round(board_service.amount, 2),
|
||||
)
|
||||
)
|
||||
return result_board_services
|
||||
@@ -127,7 +127,7 @@ class PmsBoardServiceService(Component):
|
||||
name=line.pms_board_service_room_type_id.display_name,
|
||||
boardServiceId=line.pms_board_service_room_type_id.id,
|
||||
productId=line.product_id.id,
|
||||
amount=round(line.amount,2),
|
||||
amount=round(line.amount, 2),
|
||||
)
|
||||
)
|
||||
return result_board_service_lines
|
||||
|
||||
@@ -73,8 +73,8 @@ class PmsCalendarService(Component):
|
||||
isFirstNight=line.reservation_id.checkin == line.date,
|
||||
isLastNight=line.reservation_id.checkout + timedelta(days=-1)
|
||||
== line.date,
|
||||
totalPrice=round(line.reservation_id.price_total,2),
|
||||
pendingPayment=round(line.reservation_id.folio_pending_amount,2),
|
||||
totalPrice=round(line.reservation_id.price_total, 2),
|
||||
pendingPayment=round(line.reservation_id.folio_pending_amount, 2),
|
||||
numNotifications=line.reservation_id.message_needaction_counter,
|
||||
adults=line.reservation_id.adults,
|
||||
nextLineSplitted=next_line_splitted,
|
||||
@@ -176,8 +176,11 @@ class PmsCalendarService(Component):
|
||||
result.append(
|
||||
PmsCalendarDailyInvoicing(
|
||||
date=datetime.combine(day, datetime.min.time()).isoformat(),
|
||||
invoicingTotal=round(sum(reservation_lines_by_day.mapped("price"))
|
||||
+ sum(service_lines_by_day.mapped("price_day_total")),2)
|
||||
invoicingTotal=round(
|
||||
sum(reservation_lines_by_day.mapped("price"))
|
||||
+ sum(service_lines_by_day.mapped("price_day_total")),
|
||||
2,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class PmsFolioService(Component):
|
||||
state=dict(folio.fields_get(["state"])["state"]["selection"])[
|
||||
folio.state
|
||||
],
|
||||
amountTotal=round(folio.amount_total,2),
|
||||
amountTotal=round(folio.amount_total, 2),
|
||||
)
|
||||
else:
|
||||
raise MissingError(_("Folio not found"))
|
||||
@@ -148,7 +148,7 @@ class PmsFolioService(Component):
|
||||
partnerName=folio.partner_name if folio.partner_name else None,
|
||||
partnerPhone=folio.mobile if folio.mobile else None,
|
||||
partnerEmail=folio.email if folio.email else None,
|
||||
amountTotal=round(folio.amount_total,2),
|
||||
amountTotal=round(folio.amount_total, 2),
|
||||
reservations=[] if not reservations else reservations,
|
||||
paymentStateCode=folio.payment_state,
|
||||
paymentStateDescription=dict(
|
||||
@@ -193,7 +193,7 @@ class PmsFolioService(Component):
|
||||
payments.append(
|
||||
PmsPaymentInfo(
|
||||
id=payment.id,
|
||||
amount=round(payment.amount,2),
|
||||
amount=round(payment.amount, 2),
|
||||
journalId=payment.journal_id.id,
|
||||
date=datetime.combine(
|
||||
payment.date, datetime.min.time()
|
||||
@@ -206,7 +206,7 @@ class PmsFolioService(Component):
|
||||
payments.append(
|
||||
PmsPaymentInfo(
|
||||
id=payment.id,
|
||||
amount=round(payment.amount,2),
|
||||
amount=round(payment.amount, 2),
|
||||
journalId=payment.journal_id.id,
|
||||
date=datetime.combine(
|
||||
payment.date, datetime.min.time()
|
||||
@@ -265,13 +265,11 @@ class PmsFolioService(Component):
|
||||
readyForCheckin=reservation.ready_for_checkin,
|
||||
allowedCheckout=reservation.allowed_checkout,
|
||||
splitted=reservation.splitted,
|
||||
priceTotal=round(reservation.price_room_services_set,2),
|
||||
priceTotal=round(reservation.price_room_services_set, 2),
|
||||
servicesCount=sum(
|
||||
reservation.service_ids.filtered(
|
||||
|
||||
lambda x: not x.is_board_service
|
||||
)
|
||||
.mapped("product_qty")
|
||||
).mapped("product_qty")
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -64,8 +64,8 @@ class PmsPricelistService(Component):
|
||||
if pricelist.cancelation_rule_id
|
||||
else None,
|
||||
defaultAvailabilityPlanId=pricelist.availability_plan_id.id
|
||||
if pricelist.availability_plan_id else None
|
||||
,
|
||||
if pricelist.availability_plan_id
|
||||
else None,
|
||||
pmsPropertyIds=pricelist.pms_property_ids.mapped("id"),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -52,7 +52,9 @@ class PmsProductService(Component):
|
||||
PmsProductInfo(
|
||||
id=product.id,
|
||||
name=product.name,
|
||||
price=round(self._get_product_price(product, product_search_param),2),
|
||||
price=round(
|
||||
self._get_product_price(product, product_search_param), 2
|
||||
),
|
||||
perDay=product.per_day,
|
||||
perPerson=product.per_person,
|
||||
)
|
||||
@@ -79,7 +81,7 @@ class PmsProductService(Component):
|
||||
return PmsProductInfo(
|
||||
id=product.id,
|
||||
name=product.name,
|
||||
price=round(self._get_product_price(product, product_search_param),2),
|
||||
price=round(self._get_product_price(product, product_search_param), 2),
|
||||
perDay=product.per_day,
|
||||
perPerson=product.per_person,
|
||||
)
|
||||
|
||||
@@ -120,3 +120,25 @@ class PmsPropertyService(Component):
|
||||
)
|
||||
)
|
||||
return res
|
||||
|
||||
@restapi.method(
|
||||
[
|
||||
(
|
||||
[
|
||||
"/<int:property_id>/users",
|
||||
],
|
||||
"GET",
|
||||
)
|
||||
],
|
||||
output_param=Datamodel("res.users.info", is_list=True),
|
||||
auth="jwt_api_pms",
|
||||
)
|
||||
def get_users(self, pms_property_id):
|
||||
result_users = []
|
||||
ResUsersInfo = self.env.datamodels["res.users.info"]
|
||||
users = self.env["res.users"].search(
|
||||
[("pms_property_id", "=", pms_property_id)]
|
||||
)
|
||||
for user in users:
|
||||
result_users.append(ResUsersInfo(id=user.id, name=user.name))
|
||||
return result_users
|
||||
|
||||
@@ -37,9 +37,9 @@ class PmsReservationLineService(Component):
|
||||
date=datetime.combine(
|
||||
reservation_line.date, datetime.min.time()
|
||||
).isoformat(),
|
||||
price=round(reservation_line.price,2),
|
||||
discount=round(reservation_line.discount,2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
||||
price=round(reservation_line.price, 2),
|
||||
discount=round(reservation_line.discount, 2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||
roomId=reservation_line.room_id.id,
|
||||
reservationId=reservation_line.reservation_id.id,
|
||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||
@@ -90,9 +90,9 @@ class PmsReservationLineService(Component):
|
||||
date=datetime.combine(
|
||||
reservation_line.date, datetime.min.time()
|
||||
).isoformat(),
|
||||
price=round(reservation_line.price,2),
|
||||
discount=round(reservation_line.discount,2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
||||
price=round(reservation_line.price, 2),
|
||||
discount=round(reservation_line.discount, 2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||
roomId=reservation_line.room_id.id,
|
||||
reservationId=reservation_line.reservation_id.id,
|
||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||
|
||||
@@ -64,6 +64,7 @@ class PmsReservationService(Component):
|
||||
if reservation.channel_type_id
|
||||
else None,
|
||||
agencyId=reservation.agency_id.id if reservation.agency_id else None,
|
||||
userId=reservation.user_id.id,
|
||||
checkin=datetime.combine(
|
||||
reservation.checkin, datetime.min.time()
|
||||
).isoformat(),
|
||||
@@ -103,13 +104,13 @@ class PmsReservationService(Component):
|
||||
else None,
|
||||
toAssign=reservation.to_assign,
|
||||
reservationType=reservation.reservation_type,
|
||||
priceTotal=round(reservation.price_room_services_set,2),
|
||||
discount=round(reservation.discount,2),
|
||||
priceTotal=round(reservation.price_room_services_set, 2),
|
||||
discount=round(reservation.discount, 2),
|
||||
commissionAmount=round(reservation.commission_amount, 2)
|
||||
if reservation.commission_amount
|
||||
else None,
|
||||
priceOnlyServices=round(reservation.price_services,2),
|
||||
priceOnlyRoom=round(reservation.price_total,2),
|
||||
priceOnlyServices=round(reservation.price_services, 2),
|
||||
priceOnlyRoom=round(reservation.price_total, 2),
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -239,9 +240,9 @@ class PmsReservationService(Component):
|
||||
date=datetime.combine(
|
||||
reservation_line.date, datetime.min.time()
|
||||
).isoformat(),
|
||||
price=round(reservation_line.price,2),
|
||||
discount=round(reservation_line.discount,2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount,2),
|
||||
price=round(reservation_line.price, 2),
|
||||
discount=round(reservation_line.discount, 2),
|
||||
cancelDiscount=round(reservation_line.cancel_discount, 2),
|
||||
roomId=reservation_line.room_id.id,
|
||||
reservationId=reservation_line.reservation_id.id,
|
||||
pmsPropertyId=reservation_line.pms_property_id.id,
|
||||
@@ -273,10 +274,11 @@ class PmsReservationService(Component):
|
||||
id=service.id,
|
||||
name=service.name,
|
||||
quantity=service.product_qty,
|
||||
priceTotal=round(service.price_total,2),
|
||||
priceSubtotal=round(service.price_subtotal,2),
|
||||
priceTaxes=round(service.price_tax,2),
|
||||
discount=round(service.discount,2),
|
||||
priceTotal=round(service.price_total, 2),
|
||||
priceSubtotal=round(service.price_subtotal, 2),
|
||||
priceTaxes=round(service.price_tax, 2),
|
||||
discount=round(service.discount, 2),
|
||||
isBoardService=service.is_board_service,
|
||||
)
|
||||
)
|
||||
return result_services
|
||||
|
||||
@@ -59,7 +59,7 @@ class PmsRoomTypeService(Component):
|
||||
name=room.name,
|
||||
pmsPropertyIds=room.pms_property_ids.mapped("id"),
|
||||
defaultCode=room.default_code,
|
||||
price=round(room.list_price,2),
|
||||
price=round(room.list_price, 2),
|
||||
)
|
||||
)
|
||||
return result_rooms
|
||||
|
||||
@@ -41,9 +41,9 @@ class PmsServiceService(Component):
|
||||
date=datetime.combine(
|
||||
service_line.date, datetime.min.time()
|
||||
).isoformat(),
|
||||
priceUnit=round(service_line.price_unit,2),
|
||||
priceTotal=round(service_line.price_day_total,2),
|
||||
discount=round(service_line.discount,2),
|
||||
priceUnit=round(service_line.price_unit, 2),
|
||||
priceTotal=round(service_line.price_day_total, 2),
|
||||
discount=round(service_line.discount, 2),
|
||||
)
|
||||
)
|
||||
return result_service_lines
|
||||
|
||||
Reference in New Issue
Block a user