diff --git a/src/components/App/FinePaymentSummary.vue b/src/components/App/FinePaymentSummary.vue index ca4ecf2..49a3ec4 100644 --- a/src/components/App/FinePaymentSummary.vue +++ b/src/components/App/FinePaymentSummary.vue @@ -19,8 +19,11 @@ const paymentMethods = [ const hasSelection = computed(() => props.selectedFines.length > 0); const canPay = computed(() => hasSelection.value && selectedPaymentMethod.value !== null); +const effectiveAmount = (f) => + parseFloat(f._total_to_pay ?? f.discount ?? f.total_amount ?? 0); + const totalSelected = computed(() => - props.selectedFines.reduce((sum, f) => sum + parseFloat(f.discount ?? f.total_amount ?? 0), 0) + props.selectedFines.reduce((sum, f) => sum + effectiveAmount(f), 0) ); const originalTotal = computed(() => @@ -28,9 +31,21 @@ const originalTotal = computed(() => ); const hasAnyDiscount = computed(() => - props.selectedFines.some((f) => f.discount != null) + props.selectedFines.some((f) => f.discount != null || f._has_early_discount) ); +const hasEarlyDiscount = computed(() => + props.selectedFines.some((f) => f._has_early_discount) +); + +const earlyDiscountExpiresAt = computed(() => { + const fine = props.selectedFines.find((f) => f._early_discount_expires_at); + if (!fine) return null; + return new Date(fine._early_discount_expires_at).toLocaleDateString("es-MX", { + day: "numeric", month: "long", year: "numeric", + }); +}); + const totalSavings = computed(() => originalTotal.value - totalSelected.value); const getConcepts = (fine) => { @@ -83,17 +98,17 @@ const handlePay = () => { :key="fine.id" class="bg-white/10 rounded-xl p-3" > -
+
Folio: {{ fine.id }}
${{ parseFloat(fine.total_amount || 0).toFixed(2) }} - ${{ parseFloat(fine.discount ?? fine.total_amount ?? 0).toFixed(2) }} + ${{ effectiveAmount(fine).toFixed(2) }}
@@ -147,12 +162,24 @@ const handlePay = () => {