瀏覽代碼

Merge branch 'development' of gogs.softpar.inf.br:Softpar/sfp_front_vue_diarista_cliente into development

Gustavo Zanatta 2 天之前
父節點
當前提交
2325254e2d

+ 17 - 1
src/components/dashboard/DashboardNextSchedules.vue

@@ -77,7 +77,7 @@
             <div class="column text-text schedule-price">
               <div class="column schedule-price-info">
                 <span class="text-price-main font16 fontbold">
-                  {{ item.total_amount && item.total_amount !== '0.00' ? formatCurrency(item.total_amount) : $t('dashboard_client.next_schedules.to_combine') }}
+                  {{ formatScheduleTotal(item) }}
                 </span>
 
                 <span class="text-price-label schedule-price-label font12 fontmedium">
@@ -107,6 +107,9 @@
 <script setup>
 import { formatCurrency } from 'src/helpers/utils';
 import { formatLabelByPeriodType } from 'src/helpers/utils';
+import { getSchedulePaymentType, getScheduleTotalWithPlatformFee } from 'src/helpers/paymentPlatformFees';
+import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees';
+import { onMounted } from 'vue';
 import { useI18n } from 'vue-i18n';
 
 defineProps({ data: { type: Array, default: () => [] } });
@@ -114,6 +117,7 @@ defineProps({ data: { type: Array, default: () => [] } });
 const emit = defineEmits(['view-details']);
 
 const { t } = useI18n();
+const { platformFees, loadPlatformFees } = usePaymentPlatformFees();
 
 const avatarColors = [
   { background: '#ffd5df', color: '#932e57' },
@@ -132,6 +136,14 @@ const addressLabel = (type) => {
   return t('dashboard_client.next_schedules.place_unknown');
 };
 
+const formatScheduleTotal = (item) => {
+  if (!item.total_amount || item.total_amount === '0.00') {
+    return t('dashboard_client.next_schedules.to_combine');
+  }
+
+  return formatCurrency(getScheduleTotalWithPlatformFee(item, getSchedulePaymentType(item), platformFees.value));
+};
+
 const formatDayMonth = (iso) => {
   if (!iso) return '';
 
@@ -147,6 +159,10 @@ const formatWeekday = (iso) => {
 
   return w.charAt(0).toUpperCase() + w.slice(1);
 };
+
+onMounted(() => {
+  loadPlatformFees().catch(() => {});
+});
 </script>
 
 <style scoped lang="scss">

+ 6 - 34
src/components/dashboard/NextSchedulesDetailsDialog.vue

@@ -91,26 +91,6 @@
           </span>
         </div>
 
-        <div class="detail-row">
-          <span class="detail-label text-primary q-pr-sm">
-            {{ $t('dashboard_client.pending_schedules.detail_value') }}
-          </span>
-
-          <span class="detail-value">
-            {{ formatCurrency(schedule.total_amount) }}
-          </span>
-        </div>
-
-        <div class="detail-row">
-          <span class="detail-label text-primary q-pr-sm">
-            {{ $t('dashboard_client.pending_schedules.detail_service_fee') }}
-          </span>
-
-          <span class="detail-value">
-            {{ formatCurrency(serviceFee) }}
-          </span>
-        </div>
-
         <div class="detail-row-total font16 fontbold">
           <span class="detail-label text-primary q-pr-sm">
             {{ $t('dashboard_client.pending_schedules.detail_total') }}
@@ -166,7 +146,7 @@ import { computed, onMounted, ref } from 'vue'
 import { formatAddress } from 'src/helpers/utils';
 import { formatCurrency } from 'src/helpers/utils'
 import { getScheduleClienteDetails } from 'src/api/dashboard'
-import { getSchedulePlatformFeeRate } from 'src/helpers/paymentPlatformFees'
+import { getSchedulePaymentType, getScheduleTotalWithPlatformFee } from 'src/helpers/paymentPlatformFees'
 import { useDialogPluginComponent, useQuasar } from 'quasar'
 import { useI18n } from 'vue-i18n'
 import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees'
@@ -232,19 +212,11 @@ const providerAge = computed(() => {
   return age
 })
 
-const serviceFee = computed(() => {
-  const base = parseFloat(props.schedule.total_amount) || 0
-
-  const feeRate = getSchedulePlatformFeeRate(props.schedule, 'pix', platformFees.value)
-
-  return parseFloat((base * (feeRate ?? 0)).toFixed(2))
-})
-
-const total = computed(() => {
-  const base = parseFloat(props.schedule.total_amount) || 0
-
-  return parseFloat((base + serviceFee.value).toFixed(2))
-})
+const total = computed(() => getScheduleTotalWithPlatformFee(
+  props.schedule,
+  getSchedulePaymentType(props.schedule),
+  platformFees.value
+))
 
 const avatarColors = [
   { background: '#ffd5df', color: '#932e57' },

+ 10 - 10
src/components/dashboard/ScheduleAcceptedDialog.vue

@@ -44,19 +44,17 @@
           </span>
         </div>
 
-        <div class="detail-row">
+        <div v-if="hasCartDiscount" class="detail-row">
           <span class="text-primary font14 fontmedium">
-            {{ $t('dashboard_client.pending_schedules.detail_value') }}
+            {{ $t('dashboard_client.pending_schedules.detail_total') }}
           </span>
 
-          <span class="detail-value">
-            {{ formatCurrency(baseAmount) }}
+          <span class="total-value font14 fontbold">
+            {{ formatCurrency(pixTotal) }}
           </span>
         </div>
 
-        <q-separator class="q-my-sm" />
-
-        <div class="detail-row">
+        <div v-if="!hasCartDiscount" class="detail-row">
           <span class="text-primary font14 fontmedium">
             {{ $t('dashboard_client.pending_schedules.detail_pix_total') }}
           </span>
@@ -66,7 +64,7 @@
           </span>
         </div>
 
-        <div v-if="pixDiscount > 0" class="detail-row discount-row">
+        <div v-if="!hasCartDiscount && pixDiscount > 0" class="detail-row discount-row">
           <span class="font13 fontmedium">
             {{ $t('dashboard_client.pending_schedules.detail_pix_discount') }}
           </span>
@@ -76,7 +74,7 @@
           </span>
         </div>
 
-        <div class="detail-row">
+        <div v-if="!hasCartDiscount" class="detail-row">
           <span class="text-primary font14 fontmedium">
             {{ $t('dashboard_client.pending_schedules.detail_credit_card_total') }}
           </span>
@@ -115,7 +113,7 @@
 <script setup>
 import { computed, onMounted } from 'vue'
 import { formatCurrency } from 'src/helpers/utils'
-import { getSchedulePlatformFeeRate } from 'src/helpers/paymentPlatformFees'
+import { getSchedulePlatformFeeRate, scheduleUsesCartDiscount } from 'src/helpers/paymentPlatformFees'
 import { useDialogPluginComponent, useQuasar } from 'quasar'
 import { usePaymentStore } from 'src/stores/payment'
 import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees'
@@ -140,6 +138,8 @@ const baseAmount = computed(() => Number(props.schedule.total_amount) || 0)
 
 const creditCardTotal = computed(() => parseFloat((baseAmount.value + platformFee('credit_card')).toFixed(2)))
 
+const hasCartDiscount = computed(() => scheduleUsesCartDiscount(props.schedule))
+
 const formattedDate = computed(() => {
   if (props.schedule.formatted_date) return props.schedule.formatted_date
 

+ 2 - 14
src/components/dashboard/SchedulePaymentDialog.vue

@@ -74,15 +74,6 @@
         <q-separator class="q-my-lg" />
 
         <div class="payment-summary q-mb-lg">
-          <div class="row items-center justify-between q-mb-xs">
-            <span class="summary-label">{{ $t('dashboard_client.pending_schedules.detail_value') }}</span>
-            <span class="summary-value">{{ formatCurrency(baseAmount) }}</span>
-          </div>
-          <div class="row items-center justify-between q-mb-xs">
-            <span class="summary-label">{{ $t('dashboard_client.pending_schedules.detail_service_fee') }}</span>
-            <span class="summary-value">{{ formatCurrency(selectedPlatformFee) }}</span>
-          </div>
-          <q-separator class="q-my-sm" />
           <div class="row items-center justify-between">
             <span class="summary-total-label">{{ $t('dashboard_client.pending_schedules.detail_total') }}</span>
             <span class="summary-total-value">{{ formatCurrency(selectedTotal) }}</span>
@@ -122,7 +113,7 @@ import { userStore } from 'src/stores/user'
 import { usePaymentStore } from 'src/stores/payment'
 import { getClientPaymentMethods } from 'src/api/clientPaymentMethod'
 import { formatCurrency } from 'src/helpers/utils'
-import { getSchedulePlatformFeeRate } from 'src/helpers/paymentPlatformFees'
+import { getScheduleTotalWithPlatformFee } from 'src/helpers/paymentPlatformFees'
 import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees'
 import ProfilePaymentAddDialog from 'src/components/profile/ProfilePaymentAddDialog.vue'
 import SchedulePaymentPixDialog from './SchedulePaymentPixDialog.vue'
@@ -149,11 +140,8 @@ const agreedToTerms = ref(false)
 const paymentMethods = ref([])
 const loadingCards = ref(false)
 
-const baseAmount = computed(() => Number(props.schedule.total_amount) || 0)
 const selectedPaymentType = computed(() => selectedMethod.value === 'pix' ? 'pix' : 'credit_card')
-const selectedPlatformFeeRate = computed(() => getSchedulePlatformFeeRate(props.schedule, selectedPaymentType.value, platformFees.value) ?? platformFees.value.pix)
-const selectedPlatformFee = computed(() => parseFloat((baseAmount.value * selectedPlatformFeeRate.value).toFixed(2)))
-const selectedTotal = computed(() => parseFloat((baseAmount.value + selectedPlatformFee.value).toFixed(2)))
+const selectedTotal = computed(() => getScheduleTotalWithPlatformFee(props.schedule, selectedPaymentType.value, platformFees.value))
 
 const addressTypeLabel = computed(() => {
   const type = props.schedule.address?.address_type

+ 22 - 0
src/helpers/paymentPlatformFees.js

@@ -10,3 +10,25 @@ export const getSchedulePlatformFeeRate = (schedule, paymentType, platformFees)
 
   return fees[paymentType]
 }
+
+export const getSchedulePaymentType = (schedule, fallback = 'pix') => {
+  const raw = schedule?.payment_method
+    ?? schedule?.paymentMethod
+    ?? schedule?.payment?.payment_method
+    ?? schedule?.payment?.method
+    ?? fallback
+
+  const value = String(raw ?? fallback).toLowerCase()
+
+  if (value.includes('credit') || value.includes('card')) return 'credit_card'
+  if (value.includes('pix')) return 'pix'
+
+  return fallback
+}
+
+export const getScheduleTotalWithPlatformFee = (schedule, paymentType, platformFees) => {
+  const base = Number(schedule?.total_amount) || 0
+  const feeRate = getSchedulePlatformFeeRate(schedule, paymentType, platformFees)
+
+  return parseFloat((base * (1 + (feeRate ?? 0))).toFixed(2))
+}

+ 5 - 5
src/i18n/locales/en.json

@@ -509,7 +509,7 @@
       "detail_date": "Date:",
       "detail_time": "Time:",
       "detail_value": "Amount:",
-      "detail_service_fee": "Service fee:",
+      "detail_service_fee": "Total:",
       "detail_total": "Total:",
       "detail_pix_total": "Pix total:",
       "detail_credit_card_total": "Credit card total:",
@@ -802,15 +802,15 @@
     "without_meal": "Without meal",
     "summary": "Summary",
     "services_total": "Services total",
-    "pix_fee": "Pix service fee ({percent})",
+    "pix_fee": "Pix total",
     "pix_total": "Pix total",
-    "credit_card_fee": "Card service fee ({percent})",
+    "credit_card_fee": "Card total",
     "credit_card_total": "Card total",
     "pix_discount": "Pix discount: save R$ {value}",
-    "cart_fee_discount": "Cart fee discount: R$ {value}",
+    "cart_fee_discount": "Cart total discount: R$ {value}",
     "cart_discount_hint": "Add {count} more time slot(s) to get the cart discount.",
     "cart_discount_applied": "Discount applied: 3 or more time slots in the cart.",
-    "cart_discount_total": "With discount",
+    "cart_discount_total": "Total",
     "provider": "Professional",
     "address": "Address",
     "quantity": "Quantity",

+ 5 - 5
src/i18n/locales/es.json

@@ -505,7 +505,7 @@
       "detail_date": "Fecha:",
       "detail_time": "Horario:",
       "detail_value": "Valor:",
-      "detail_service_fee": "Tasa de servicio:",
+      "detail_service_fee": "Total:",
       "detail_total": "Total:",
       "detail_pix_total": "Total en Pix:",
       "detail_credit_card_total": "Total en tarjeta de crédito:",
@@ -798,15 +798,15 @@
     "without_meal": "Sin comida",
     "summary": "Resumen",
     "services_total": "Valor de los servicios",
-    "pix_fee": "Tarifa de servicio Pix ({percent})",
+    "pix_fee": "Total con Pix",
     "pix_total": "Total con Pix",
-    "credit_card_fee": "Tarifa de servicio tarjeta ({percent})",
+    "credit_card_fee": "Total con tarjeta",
     "credit_card_total": "Total con tarjeta",
     "pix_discount": "Descuento con Pix: ahorre R$ {value}",
-    "cart_fee_discount": "Descuento de la tarifa del carrito: R$ {value}",
+    "cart_fee_discount": "Descuento en el total del carrito: R$ {value}",
     "cart_discount_hint": "Agregue {count} horario(s) más para recibir descuento en el carrito.",
     "cart_discount_applied": "Descuento aplicado: 3 o más horarios en el carrito.",
-    "cart_discount_total": "Con descuento",
+    "cart_discount_total": "Total",
     "provider": "Profesional",
     "address": "Dirección",
     "quantity": "Cantidad",

+ 5 - 5
src/i18n/locales/pt.json

@@ -509,7 +509,7 @@
       "detail_date": "Data:",
       "detail_time": "Horário:",
       "detail_value": "Valor:",
-      "detail_service_fee": "Taxa de serviço:",
+      "detail_service_fee": "Total:",
       "detail_total": "Total:",
       "detail_pix_total": "Total no Pix:",
       "detail_credit_card_total": "Total no cartão de crédito:",
@@ -810,15 +810,15 @@
     "without_meal": "Sem refeição",
     "summary": "Resumo",
     "services_total": "Valor dos serviços",
-    "pix_fee": "Taxa de serviço Pix ({percent})",
+    "pix_fee": "Total com Pix",
     "pix_total": "Total com Pix",
-    "credit_card_fee": "Taxa de serviço cartão ({percent})",
+    "credit_card_fee": "Total no cartão",
     "credit_card_total": "Total no cartão",
     "pix_discount": "Desconto no Pix: economize R$ {value}",
-    "cart_fee_discount": "Desconto da taxa do carrinho: R$ {value}",
+    "cart_fee_discount": "Desconto no total do carrinho: R$ {value}",
     "cart_discount_hint": "Adicione mais {count} horário(s) para receber desconto no carrinho.",
     "cart_discount_applied": "Desconto aplicado: 3 ou mais horários no carrinho.",
-    "cart_discount_total": "Com desconto",
+    "cart_discount_total": "Total",
     "provider": "Profissional",
     "address": "Endereço",
     "quantity": "Quantidade",

+ 13 - 3
src/pages/agenda/CalendarPage.vue

@@ -57,7 +57,7 @@
                     :label="statusLabel(item.status)"
                     class="font10"
                   />
-                  <span class="text-price font12 fontbold">{{ formatCurrency(item.total_amount) }}</span>
+                  <span class="text-price font12 fontbold">{{ formatScheduleTotal(item) }}</span>
                   <span class="text-period font10 fontmedium">{{ periodLabel(item.period_type) }}</span>
                 </div>
               </div>
@@ -131,7 +131,7 @@
                     :label="statusLabel(item.status)"
                     class="font10"
                   />
-                  <span class="text-price font12 fontbold">{{ formatCurrency(item.total_amount) }}</span>
+                  <span class="text-price font12 fontbold">{{ formatScheduleTotal(item) }}</span>
                   <span class="text-period font10 fontmedium">{{ periodLabel(item.period_type) }}</span>
                 </div>
               </div>
@@ -194,6 +194,8 @@ import { useQuasar } from 'quasar';
 import { useI18n } from 'vue-i18n';
 import { getClientCalendar } from 'src/api/clientCalendar';
 import { formatCurrency } from 'src/helpers/utils';
+import { getSchedulePaymentType, getScheduleTotalWithPlatformFee } from 'src/helpers/paymentPlatformFees';
+import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees';
 import NextSchedulesDetailsDialog from 'src/components/dashboard/NextSchedulesDetailsDialog.vue';
 import ScheduleRatingDialog from 'src/components/dashboard/ScheduleRatingDialog.vue';
 import SchedulingDialog from 'src/pages/search/components/SchedulingDialog.vue';
@@ -202,6 +204,7 @@ import { useRouter } from 'vue-router';
 const $q = useQuasar();
 const { t } = useI18n();
 const router = useRouter();
+const { platformFees, loadPlatformFees } = usePaymentPlatformFees();
 
 const avatarColors = [
   { background: '#ffd5df', color: '#932e57' },
@@ -242,6 +245,10 @@ const periodLabel = (periodType) => {
   return translated !== key ? translated : '';
 };
 
+const formatScheduleTotal = (item) => (
+  formatCurrency(getScheduleTotalWithPlatformFee(item, getSchedulePaymentType(item), platformFees.value))
+);
+
 const statusLabel = (status) => {
   const map = {
     pending: t('dashboard_client.agenda.status_pending'),
@@ -322,7 +329,10 @@ const openSchedulingDialog = (item) => {
 };
 
 onMounted(async () => {
-  await loadCalendar();
+  await Promise.all([
+    loadCalendar(),
+    loadPlatformFees().catch(() => {}),
+  ]);
   loading.value = false;
 });
 </script>

+ 3 - 3
src/pages/schedule-cart/ScheduleCartPage.vue

@@ -126,7 +126,7 @@
               </div>
 
               <div class="item-prices q-mt-sm">
-                <div class="row items-center no-wrap">
+                <div v-if="!hasCartDiscount" class="row items-center no-wrap">
                   <span class="font11 fontbold text-primary">{{ $t('schedule_cart.pix_total') }}</span>
 
                   <q-space />
@@ -136,7 +136,7 @@
                   </span>
                 </div>
 
-                <div class="row items-center no-wrap q-mt-xs">
+                <div v-if="!hasCartDiscount" class="row items-center no-wrap q-mt-xs">
                   <span class="font11 text-grey-7">
                     {{ $t('schedule_cart.credit_card_total') }}
                   </span>
@@ -221,7 +221,7 @@
               </span>
             </div>
 
-            <div class="summary-row row items-center no-wrap q-py-xs">
+            <div v-if="!hasCartDiscount" class="summary-row row items-center no-wrap q-py-xs">
               <span class="font12 fontbold text-primary">
                 {{ $t('schedule_cart.pix_total') }}
               </span>