Pārlūkot izejas kodu

feat(packages): show punctuality discount on commercial proposal

alvesantos 1 nedēļu atpakaļ
vecāks
revīzija
88079138bf

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

@@ -16,16 +16,34 @@
           <div class="text-caption text-weight-bold text-primary q-mb-xs">PAVÃO</div>
           <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">Matrícula: {{ formatToBRLCurrency(pkg.pavao.registration_value) }}</div>
           <div class="text-caption text-grey-8">Aulas: {{ formatToBRLCurrency(pkg.pavao.classes_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-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>
 
 
         <div v-if="pkg.irrecusavel" class="col-12 col-md-6">
         <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-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">Matrícula: {{ formatToBRLCurrency(pkg.irrecusavel.registration_value) }}</div>
           <div class="text-caption text-grey-8">Aulas: {{ formatToBRLCurrency(pkg.irrecusavel.classes_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-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>
         </div>
 
 
         <span v-if="!pkg.pavao && !pkg.irrecusavel" class="col-12 text-caption text-grey-5">
         <span v-if="!pkg.pavao && !pkg.irrecusavel" class="col-12 text-caption text-grey-5">
@@ -39,6 +57,14 @@
 <script setup>
 <script setup>
 import { formatToBRLCurrency } from "src/helpers/utils";
 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({
 defineProps({
   pkg: {
   pkg: {
     type: Object,
     type: Object,

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

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