mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms_l10n_es: INE adaptation groups
This commit is contained in:
@@ -658,139 +658,110 @@ class WizardIne(models.TransientModel):
|
||||
)
|
||||
)
|
||||
|
||||
# TODO:
|
||||
# Evaluate how to get occupation & ADR for:
|
||||
# -traditional/online tour-operator
|
||||
# -traditional/online agency
|
||||
# -companys
|
||||
total_groups_domains = {
|
||||
"tour_operator_offline": [
|
||||
("reservation_id.agency_id.sale_channel_id.name", "ilike", "Operator"),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", True),
|
||||
],
|
||||
"tour_operator_online": [
|
||||
("reservation_id.agency_id.sale_channel_id.name", "ilike", "Operator"),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", False),
|
||||
],
|
||||
"companies": [
|
||||
("reservation_id.partner_id", "!=", False),
|
||||
("reservation_id.partner_id.is_company", "=", True),
|
||||
],
|
||||
"agencies": [
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", False),
|
||||
],
|
||||
"percent_otas": [
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", True),
|
||||
],
|
||||
"persons": [
|
||||
"|",
|
||||
("reservation_id.partner_id", "=", False),
|
||||
("reservation_id.partner_id.is_company", "=", False),
|
||||
],
|
||||
"groups": [("reservation_id.folio_id.number_of_rooms", ">=", 4)],
|
||||
"internet": [("reservation_id.channel_type_id.is_on_line", "=", True)],
|
||||
"others": [
|
||||
"|",
|
||||
("reservation_id.channel_type_id.is_on_line", "!=", True),
|
||||
("reservation_id.channel_type_id", "=", False),
|
||||
],
|
||||
}
|
||||
|
||||
ET.SubElement(prices_tag, "ADR_TOUROPERADOR_TRADICIONAL").text = "0"
|
||||
percents = {}
|
||||
adrs = {}
|
||||
for group, domain in total_groups_domains.items():
|
||||
percents[group] = self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
domain,
|
||||
)
|
||||
adrs[group] = self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
domain,
|
||||
)
|
||||
|
||||
# In this point, the groups adrs and percents are well calculated.... but,
|
||||
# our statist friends want the total of the percentage groupings to add up = 100%,
|
||||
# without conceiving that the groupings overlap, so they cannot receive real data
|
||||
# and force us to pervert the original data so that it fits in their grid notebook.
|
||||
# The purpose of the following lines of code is only to show the inefficiency
|
||||
# of the state statistics,
|
||||
# so at least I will feel that the effort made some sense :)
|
||||
|
||||
total_percent = sum([val for val in percents.values()])
|
||||
for group in total_groups_domains.keys():
|
||||
percents[group] = round(percents[group] * 100 / total_percent, 2)
|
||||
|
||||
ET.SubElement(prices_tag, "ADR_TOUROPERADOR_TRADICIONAL").text = str(
|
||||
adrs["tour_operator_offline"]
|
||||
)
|
||||
ET.SubElement(
|
||||
prices_tag, "PCTN_HABITACIONES_OCUPADAS_TOUROPERADOR_TRADICIONAL"
|
||||
).text = "0"
|
||||
ET.SubElement(prices_tag, "ADR_TOUROPERADOR_ONLINE").text = "0"
|
||||
).text = str(percents["tour_operator_offline"])
|
||||
ET.SubElement(prices_tag, "ADR_TOUROPERADOR_ONLINE").text = str(
|
||||
adrs["tour_operator_online"]
|
||||
)
|
||||
ET.SubElement(
|
||||
prices_tag, "PCTN_HABITACIONES_OCUPADAS_TOUROPERADOR_ONLINE"
|
||||
).text = "0"
|
||||
ET.SubElement(prices_tag, "ADR_EMPRESAS").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.partner_id", "!=", False),
|
||||
("reservation_id.partner_id.is_company", "=", True),
|
||||
],
|
||||
)
|
||||
)
|
||||
).text = str(percents["tour_operator_online"])
|
||||
ET.SubElement(prices_tag, "ADR_EMPRESAS").text = str(adrs["companies"])
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_EMPRESAS").text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.partner_id", "!=", False),
|
||||
("reservation_id.partner_id.is_company", "=", True),
|
||||
],
|
||||
)
|
||||
percents["companies"]
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_AGENCIA_DE_VIAJE_TRADICIONAL").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", False),
|
||||
],
|
||||
)
|
||||
adrs["agencies"]
|
||||
)
|
||||
ET.SubElement(
|
||||
prices_tag, "PCTN_HABITACIONES_OCUPADAS_AGENCIA_TRADICIONAL"
|
||||
).text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", False),
|
||||
],
|
||||
)
|
||||
)
|
||||
).text = str(percents["agencies"])
|
||||
ET.SubElement(prices_tag, "ADR_AGENCIA_DE_VIAJE_ONLINE").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", True),
|
||||
],
|
||||
)
|
||||
adrs["otas"]
|
||||
)
|
||||
ET.SubElement(
|
||||
prices_tag, "PCTN_HABITACIONES_OCUPADAS_AGENCIA_ONLINE"
|
||||
).text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
("reservation_id.agency_id", "!=", False),
|
||||
("reservation_id.agency_id.sale_channel_id.is_on_line", "=", True),
|
||||
],
|
||||
)
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_PARTICULARES").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
"|",
|
||||
("reservation_id.partner_id", "=", False),
|
||||
("reservation_id.partner_id.is_company", "!=", False),
|
||||
],
|
||||
)
|
||||
)
|
||||
).text = str(percents["otas"])
|
||||
ET.SubElement(prices_tag, "ADR_PARTICULARES").text = str(adrs["persons"])
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_PARTICULARES").text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
"|",
|
||||
("reservation_id.partner_id", "=", False),
|
||||
("reservation_id.partner_id.is_company", "=", False),
|
||||
],
|
||||
)
|
||||
percents["persons"]
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_GRUPOS").text = "0"
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_GRUPOS").text = "0"
|
||||
ET.SubElement(prices_tag, "ADR_INTERNET").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[("reservation_id.channel_type_id.is_on_line", "=", True)],
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_GRUPOS").text = str(adrs["groups"])
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_GRUPOS").text = str(
|
||||
percents["groups"]
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_INTERNET").text = str(adrs["internet"])
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_INTERNET").text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[("reservation_id.channel_type_id.is_on_line", "=", True)],
|
||||
)
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_OTROS").text = str(
|
||||
self.ine_calculate_adr(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[("reservation_id.channel_type_id.is_on_line", "!=", True)],
|
||||
)
|
||||
percents["internet"]
|
||||
)
|
||||
ET.SubElement(prices_tag, "ADR_OTROS").text = str(adrs["others"])
|
||||
ET.SubElement(prices_tag, "PCTN_HABITACIONES_OCUPADAS_OTROS").text = str(
|
||||
self.ine_calculate_occupancy(
|
||||
self.start_date,
|
||||
self.end_date,
|
||||
[
|
||||
"|",
|
||||
("reservation_id.channel_type_id.is_on_line", "!=", True),
|
||||
("reservation_id.channel_type_id", "=", False),
|
||||
],
|
||||
)
|
||||
percents["others"]
|
||||
)
|
||||
|
||||
staff_tag = ET.SubElement(survey_tag, "PERSONAL_OCUPADO")
|
||||
|
||||
Reference in New Issue
Block a user