|
@@ -5,6 +5,12 @@ import {
|
|
|
formatPercent,
|
|
formatPercent,
|
|
|
} from "./utils";
|
|
} from "./utils";
|
|
|
|
|
|
|
|
|
|
+const capitalize = (text) => {
|
|
|
|
|
+ if (!text) return text;
|
|
|
|
|
+
|
|
|
|
|
+ return text.charAt(0).toLocaleUpperCase("pt-BR") + text.slice(1);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
export function buildMetricCards(summary, options = {}) {
|
|
export function buildMetricCards(summary, options = {}) {
|
|
|
const { isAllPropertiesSelected = false, referenceLabel = "" } = options;
|
|
const { isAllPropertiesSelected = false, referenceLabel = "" } = options;
|
|
|
|
|
|
|
@@ -25,47 +31,47 @@ export function buildMetricCards(summary, options = {}) {
|
|
|
? "percentual do período"
|
|
? "percentual do período"
|
|
|
: `${formatInteger(summary.occupied_nights_in_month)} de ${formatInteger(summary.days_in_month)} dias`;
|
|
: `${formatInteger(summary.occupied_nights_in_month)} de ${formatInteger(summary.days_in_month)} dias`;
|
|
|
|
|
|
|
|
- return [
|
|
|
|
|
|
|
+ const cards = [
|
|
|
// INDICADORES
|
|
// INDICADORES
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Ocupação",
|
|
|
|
|
|
|
+ label: "ocupação",
|
|
|
value: formatPercent(summary.occupancy_rate, 1),
|
|
value: formatPercent(summary.occupancy_rate, 1),
|
|
|
caption: occupancyCaption,
|
|
caption: occupancyCaption,
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Total de Reservas",
|
|
|
|
|
|
|
+ label: "total de reservas",
|
|
|
value: formatInteger(summary.reservations_count),
|
|
value: formatInteger(summary.reservations_count),
|
|
|
caption: "no período",
|
|
caption: "no período",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Dias por Reserva",
|
|
|
|
|
|
|
+ label: "dias por reserva",
|
|
|
value: formatDecimal(summary.average_nights_per_reservation),
|
|
value: formatDecimal(summary.average_nights_per_reservation),
|
|
|
caption: "média de permanência",
|
|
caption: "média de permanência",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Diária Média",
|
|
|
|
|
|
|
+ label: "diária média",
|
|
|
value: formatCurrency(summary.average_price_per_night),
|
|
value: formatCurrency(summary.average_price_per_night),
|
|
|
caption: "Bruto ÷ diárias",
|
|
caption: "Bruto ÷ diárias",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Limpezas",
|
|
|
|
|
|
|
+ label: "limpezas",
|
|
|
value: formatInteger(summary.cleanings_count),
|
|
value: formatInteger(summary.cleanings_count),
|
|
|
caption: "total no período",
|
|
caption: "total no período",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Manutenção",
|
|
|
|
|
|
|
+ label: "manutenção",
|
|
|
value: formatCurrency(maintenanceExpenseAmount),
|
|
value: formatCurrency(maintenanceExpenseAmount),
|
|
|
caption: "despesas manuais",
|
|
caption: "despesas manuais",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Ticket Médio/Reserva",
|
|
|
|
|
|
|
+ label: "ticket médio/reserva",
|
|
|
value: formatCurrency(summary.average_reservation_ticket),
|
|
value: formatCurrency(summary.average_reservation_ticket),
|
|
|
caption: isAllPropertiesSelected
|
|
caption: isAllPropertiesSelected
|
|
|
? "Todos apartamentos"
|
|
? "Todos apartamentos"
|
|
@@ -75,47 +81,53 @@ export function buildMetricCards(summary, options = {}) {
|
|
|
// FINANCEIRO
|
|
// FINANCEIRO
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Faturamento",
|
|
|
|
|
|
|
+ label: "faturamento bruto",
|
|
|
value: formatCurrency(summary.gross_revenue),
|
|
value: formatCurrency(summary.gross_revenue),
|
|
|
caption: referenceLabel || "Mês selecionado",
|
|
caption: referenceLabel || "Mês selecionado",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "OTA",
|
|
|
|
|
|
|
+ label: "ota",
|
|
|
value: formatCurrency(summary.ota_amount),
|
|
value: formatCurrency(summary.ota_amount),
|
|
|
caption: "taxas plataformas",
|
|
caption: "taxas plataformas",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Faturamento Líquido",
|
|
|
|
|
|
|
+ label: "faturamento líquido",
|
|
|
value: formatCurrency(summary.net_revenue_amount),
|
|
value: formatCurrency(summary.net_revenue_amount),
|
|
|
caption: "Bruto - OTA",
|
|
caption: "Bruto - OTA",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Total Limpeza",
|
|
|
|
|
|
|
+ label: "total limpeza",
|
|
|
value: formatCurrency(summary.cleaning_total_amount),
|
|
value: formatCurrency(summary.cleaning_total_amount),
|
|
|
caption: "taxa de limpeza",
|
|
caption: "taxa de limpeza",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Gestão Kizzo",
|
|
|
|
|
|
|
+ label: "gestão kizzo",
|
|
|
value: formatCurrency(summary.management_fee_amount),
|
|
value: formatCurrency(summary.management_fee_amount),
|
|
|
caption: "comissão gestão",
|
|
caption: "comissão gestão",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Despesas",
|
|
|
|
|
|
|
+ label: "despesas",
|
|
|
value: formatCurrency(displayedExpenses),
|
|
value: formatCurrency(displayedExpenses),
|
|
|
caption: "inclui OTA",
|
|
caption: "inclui OTA",
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- label: "Repasse",
|
|
|
|
|
|
|
+ label: "repasse",
|
|
|
value: formatCurrency(summary.payout_amount),
|
|
value: formatCurrency(summary.payout_amount),
|
|
|
caption: isAllPropertiesSelected
|
|
caption: isAllPropertiesSelected
|
|
|
? "Todos apartamentos"
|
|
? "Todos apartamentos"
|
|
|
: "No imóvel selecionado",
|
|
: "No imóvel selecionado",
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
|
|
+
|
|
|
|
|
+ return cards.map((card) => ({
|
|
|
|
|
+ ...card,
|
|
|
|
|
+ label: capitalize(card.label),
|
|
|
|
|
+ caption: capitalize(card.caption),
|
|
|
|
|
+ }));
|
|
|
}
|
|
}
|