From 335bbc3bab4fdef34a6bdcc328cf92a421e26220 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 8 Jul 2025 13:18:04 +0200 Subject: [PATCH] Code format --- src/components/BatchTransactionForm.tsx | 6 ++--- src/components/JobCardDetails.tsx | 36 ++++++++++++------------- src/components/JobCardMetrics.tsx | 35 +++++++++++------------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/components/BatchTransactionForm.tsx b/src/components/BatchTransactionForm.tsx index f7a0c15..26229ef 100644 --- a/src/components/BatchTransactionForm.tsx +++ b/src/components/BatchTransactionForm.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; @@ -208,11 +208,11 @@ const BatchTransactionForm: React.FC = ({ onClose, on ); return ( -
- e.stopPropagation()} > diff --git a/src/components/JobCardDetails.tsx b/src/components/JobCardDetails.tsx index b659c77..1d8d6fe 100644 --- a/src/components/JobCardDetails.tsx +++ b/src/components/JobCardDetails.tsx @@ -202,7 +202,7 @@ interface PriceDisplayProps { const PriceDisplay: React.FC = ({ job }) => { const { copying, copyToClipboard } = useClipboard(); const [salesTax, setSalesTax] = useState(() => parseFloat(localStorage.getItem('salesTax') || '0') / 100); - + // Listen for storage changes to update tax rate useEffect(() => { const handleStorageChange = () => { @@ -218,35 +218,35 @@ const PriceDisplay: React.FC = ({ job }) => { const factor = Math.pow(10, digits - 1 - magnitude); return Math.round(num * factor) / factor; }; - + // Calculate total costs and income const totalCosts = job.expenditures?.reduce((sum, tx) => sum + tx.totalPrice, 0) || 0; const totalIncome = job.income?.reduce((sum, tx) => sum + tx.totalPrice, 0) || 0; const itemsSold = job.income?.reduce((sum, tx) => sum + tx.quantity, 0) || 0; const itemsRemaining = (job.produced || 0) - itemsSold; - + // Original calculations (based on full revenue and costs) const targetPricePerUnit = job.projectedRevenue / job.produced; const targetPriceWithTax = roundToSignificantDigits(targetPricePerUnit * (1 + salesTax)); - + const breakEvenPricePerUnit = totalCosts / job.produced; const breakEvenPriceWithTax = roundToSignificantDigits(breakEvenPricePerUnit * (1 + salesTax)); - + // Adjusted calculations (based on remaining revenue and uncovered costs) const remainingRevenue = job.projectedRevenue - totalIncome; const uncoveredCosts = totalCosts - totalIncome; - + const adjustedTargetPricePerUnit = itemsRemaining > 0 ? remainingRevenue / itemsRemaining : 0; const adjustedTargetPriceWithTax = roundToSignificantDigits(adjustedTargetPricePerUnit * (1 + salesTax)); - + const adjustedBreakEvenPricePerUnit = itemsRemaining > 0 ? Math.max(0, uncoveredCosts / itemsRemaining) : 0; const adjustedBreakEvenPriceWithTax = roundToSignificantDigits(adjustedBreakEvenPricePerUnit * (1 + salesTax)); - + const handleCopyTargetPrice = async (e: React.MouseEvent) => { e.stopPropagation(); await copyToClipboard( - targetPriceWithTax.toString(), - 'targetPrice', + targetPriceWithTax.toString(), + 'targetPrice', 'Target price copied to clipboard' ); }; @@ -254,8 +254,8 @@ const PriceDisplay: React.FC = ({ job }) => { const handleCopyBreakEvenPrice = async (e: React.MouseEvent) => { e.stopPropagation(); await copyToClipboard( - breakEvenPriceWithTax.toString(), - 'breakEvenPrice', + breakEvenPriceWithTax.toString(), + 'breakEvenPrice', 'Break-even price copied to clipboard' ); }; @@ -263,8 +263,8 @@ const PriceDisplay: React.FC = ({ job }) => { const handleCopyAdjustedTargetPrice = async (e: React.MouseEvent) => { e.stopPropagation(); await copyToClipboard( - adjustedTargetPriceWithTax.toString(), - 'adjustedTargetPrice', + adjustedTargetPriceWithTax.toString(), + 'adjustedTargetPrice', 'Adjusted target price copied to clipboard' ); }; @@ -272,8 +272,8 @@ const PriceDisplay: React.FC = ({ job }) => { const handleCopyAdjustedBreakEvenPrice = async (e: React.MouseEvent) => { e.stopPropagation(); await copyToClipboard( - adjustedBreakEvenPriceWithTax.toString(), - 'adjustedBreakEvenPrice', + adjustedBreakEvenPriceWithTax.toString(), + 'adjustedBreakEvenPrice', 'Adjusted break-even price copied to clipboard' ); }; @@ -290,7 +290,7 @@ const PriceDisplay: React.FC = ({ job }) => { Break-even{taxSuffix}:
- +
= ({ job }) => { Adjusted Break-even{taxSuffix}:
- +
= ({ job }) => { // Calculate performance metrics - Simple price per unit comparison const itemsSold = sortedIncome.reduce((sum, tx) => sum + tx.quantity, 0); const produced = job.produced || 0; - + // Only show performance if we have produced items and sold items const showPerformanceIndicator = produced > 0 && itemsSold > 0 && job.projectedRevenue > 0; - + let performancePercentage = 0; if (showPerformanceIndicator) { const expectedPPU = job.projectedRevenue / produced; @@ -108,12 +108,11 @@ const JobCardMetrics: React.FC = ({ job }) => { {formatISK(job.projectedCost)} )}
-
{totalExpenditure <= job.projectedCost ? '✅' : '⚠️'} {((totalExpenditure / job.projectedCost) * 100).toFixed(0)}% @@ -151,25 +150,23 @@ const JobCardMetrics: React.FC = ({ job }) => { )}
-
= job.projectedRevenue - ? 'bg-green-900/50 text-green-400' +
= job.projectedRevenue + ? 'bg-green-900/50 text-green-400' : 'bg-yellow-900/50 text-yellow-400' - }`} + }`} title={`Revenue progress: ${((totalIncome / job.projectedRevenue) * 100).toFixed(1)}% of projected revenue`} > {totalIncome >= job.projectedRevenue ? '🎯' : '📊'} {((totalIncome / job.projectedRevenue) * 100).toFixed(0)}%
{showPerformanceIndicator && ( -
= 100 - ? 'bg-green-900/50 text-green-400' - : performancePercentage >= 90 - ? 'bg-yellow-900/50 text-yellow-400' +
= 100 + ? 'bg-green-900/50 text-green-400' + : performancePercentage >= 90 + ? 'bg-yellow-900/50 text-yellow-400' : 'bg-red-900/50 text-red-400' - }`} + }`} title={`Price performance: ${formatISK(totalIncome / itemsSold)}/unit vs ${formatISK(job.projectedRevenue / produced)}/unit expected (${performancePercentage.toFixed(1)}%)`} > {performancePercentage >= 100 ? '📈' : performancePercentage >= 90 ? '⚠️' : '📉'} {performancePercentage.toFixed(0)}%