Эх сурвалжийг харах

feat(packages): show punctuality discount on commercial proposal

alvesantos 1 долоо хоног өмнө
parent
commit
2ad1100bcd

+ 28 - 2
src/pages/packages/components/PackageCard.vue

@@ -21,16 +21,34 @@
           <div class="text-caption text-weight-bold text-primary q-mb-xs">PAVÃO</div>
           <div class="text-caption text-grey-8">Matrícula: {{ formatToBRLCurrency(pkg.pavao.registration_value) }}</div>
           <div class="text-caption text-grey-8">Aulas: {{ formatToBRLCurrency(pkg.pavao.classes_value) }}</div>
+          <div v-if="pkg.pavao.classes_discount_percentage" class="text-caption text-negative q-ml-sm">
+            - Pontualidade ({{ pkg.pavao.classes_discount_percentage }}%): {{ formatToBRLCurrency(getDiscountValue(pkg.pavao)) }}
+          </div>
           <div class="text-caption text-grey-8">Materiais: {{ formatToBRLCurrency(pkg.pavao.materials_total_value) }}</div>
-          <div class="text-caption text-weight-bold q-mt-xs">Total: {{ formatToBRLCurrency(pkg.pavao.total_value) }}</div>
+          
+          <div class="text-caption text-weight-bold q-mt-xs">
+            Total (Normal): {{ formatToBRLCurrency(pkg.pavao.total_value) }}
+          </div>
+          <div v-if="pkg.pavao.classes_discount_percentage" class="text-caption text-weight-bold text-positive">
+            Total (c/ Pontualidade): {{ formatToBRLCurrency(getTotalWithDiscount(pkg.pavao)) }}
+          </div>
         </div>
 
         <div v-if="pkg.irrecusavel" class="col-12 col-md-6">
           <div class="text-caption text-weight-bold text-secondary q-mb-xs">IRRECUSÁVEL</div>
           <div class="text-caption text-grey-8">Matrícula: {{ formatToBRLCurrency(pkg.irrecusavel.registration_value) }}</div>
           <div class="text-caption text-grey-8">Aulas: {{ formatToBRLCurrency(pkg.irrecusavel.classes_value) }}</div>
+          <div v-if="pkg.irrecusavel.classes_discount_percentage" class="text-caption text-negative q-ml-sm">
+            - Pontualidade ({{ pkg.irrecusavel.classes_discount_percentage }}%): {{ formatToBRLCurrency(getDiscountValue(pkg.irrecusavel)) }}
+          </div>
           <div class="text-caption text-grey-8">Materiais: {{ formatToBRLCurrency(pkg.irrecusavel.materials_total_value) }}</div>
-          <div class="text-caption text-weight-bold q-mt-xs">Total: {{ formatToBRLCurrency(pkg.irrecusavel.total_value) }}</div>
+          
+          <div class="text-caption text-weight-bold q-mt-xs">
+            Total (Normal): {{ formatToBRLCurrency(pkg.irrecusavel.total_value) }}
+          </div>
+          <div v-if="pkg.irrecusavel.classes_discount_percentage" class="text-caption text-weight-bold text-positive">
+            Total (c/ Pontualidade): {{ formatToBRLCurrency(getTotalWithDiscount(pkg.irrecusavel)) }}
+          </div>
         </div>
 
         <span v-if="!pkg.pavao && !pkg.irrecusavel" class="col-12 text-caption text-grey-5">
@@ -44,6 +62,14 @@
 <script setup>
 import { formatToBRLCurrency } from "src/helpers/utils";
 
+const getDiscountValue = (block) => {
+  return (Number(block.classes_value) || 0) * (Number(block.classes_discount_percentage) || 0) / 100;
+};
+
+const getTotalWithDiscount = (block) => {
+  return (Number(block.total_value) || 0) - getDiscountValue(block);
+};
+
 defineProps({
   pkg: {
     type: Object,

+ 1 - 1
src/pages/packages/components/ProposalPricingTab.vue

@@ -28,7 +28,7 @@
     <DefaultInput
       v-model="modelValue.classes_discount_percentage"
       class="col-12"
-      label="Desconto (%)"
+      label="Desconto de Pontualidade (%)"
       max="100"
       min="0"
       type="number"

+ 10 - 5
src/pages/packages/components/ReadonlyPricingSection.vue

@@ -19,9 +19,10 @@
       </div>
       <div class="text-caption text-grey-6">
         {{ statusLabel(block.classes_included_in_course, block.classes_max_installments) }}
-        <template v-if="block.classes_discount_percentage">
-          — Desconto {{ block.classes_discount_percentage }}%
-        </template>
+      </div>
+      <div v-if="block.classes_discount_percentage" class="row items-center justify-between text-body2 text-negative q-pl-sm q-pt-xs">
+        <span>Desconto de Pontualidade ({{ block.classes_discount_percentage }}%)</span>
+        <span>- {{ formatToBRLCurrency((Number(block.classes_value) || 0) * (Number(block.classes_discount_percentage) || 0) / 100) }}</span>
       </div>
     </div>
 
@@ -50,10 +51,14 @@
 
     <div class="pricing-row">
       <div class="row items-center justify-between">
-        <span class="text-weight-bold">Valor Total do Curso</span>
+        <span class="text-weight-bold">Valor Total (Normal)</span>
         <span class="text-weight-bold">{{ formatToBRLCurrency(block.total_value) }}</span>
       </div>
-      <div class="text-caption text-grey-6">
+      <div v-if="block.classes_discount_percentage" class="row items-center justify-between text-weight-bold text-positive q-pt-xs">
+        <span>Valor Total (c/ Pontualidade)</span>
+        <span>{{ formatToBRLCurrency((Number(block.total_value) || 0) - ((Number(block.classes_value) || 0) * (Number(block.classes_discount_percentage) || 0) / 100)) }}</span>
+      </div>
+      <div class="text-caption text-grey-6 q-pt-xs">
         Em até {{ block.total_max_installments }}x
       </div>
     </div>