Features: - React + TypeScript frontend with Tailwind CSS - Node.js + Express backend with TypeScript - Comprehensive order tracking and management - Product catalog with inventory tracking - Customer data management - Expense tracking and categorization - Advanced Profit Analysis Dashboard with: - Real-time profit metrics and KPI visualization - Detailed order-level profit breakdown - Product performance analysis - Enhanced time range filtering (monthly, quarterly, yearly) - Interactive expandable order analysis - Performance categorization and color coding - CSV import functionality for Etsy statements - PDF parsing capabilities - Redux state management with persistence - Responsive design with mobile support - Australian date formatting and currency display
54 lines
No EOL
1.9 KiB
TypeScript
54 lines
No EOL
1.9 KiB
TypeScript
// Quick test for date parsing from packing slip text
|
|
export function testDateParsing() {
|
|
// Sample text from actual packing slip
|
|
const sampleText = `
|
|
Packing slip for order #3748364725
|
|
Order date 21 Jul, 2025
|
|
Ship to:
|
|
David L
|
|
`;
|
|
|
|
// Test the regex pattern (same as in pdfParser.ts)
|
|
const datePattern = /Order [Dd]ate:?\s*(\d{1,2} [A-Z][a-z]{2}, \d{4})/i;
|
|
const dateMatch = sampleText.match(datePattern);
|
|
|
|
console.log('=== TESTING DATE EXTRACTION ===');
|
|
console.log('Sample text contains:', sampleText.trim());
|
|
console.log('Date pattern:', datePattern.toString());
|
|
console.log('Match found:', dateMatch);
|
|
|
|
if (dateMatch && dateMatch[1]) {
|
|
const extractedDate = dateMatch[1];
|
|
console.log('Extracted date string:', extractedDate);
|
|
|
|
// Test parsing to Date object
|
|
try {
|
|
const parsedDate = new Date(extractedDate);
|
|
console.log('Parsed Date object:', parsedDate);
|
|
console.log('Is valid date:', !isNaN(parsedDate.getTime()));
|
|
console.log('ISO string:', parsedDate.toISOString());
|
|
|
|
// Test today's date for comparison
|
|
const today = new Date();
|
|
console.log('Today for comparison:', today.toISOString());
|
|
console.log('Are dates different?', parsedDate.toDateString() !== today.toDateString());
|
|
|
|
return {
|
|
success: true,
|
|
extractedDate,
|
|
parsedDate: parsedDate.toISOString(),
|
|
isValidDate: !isNaN(parsedDate.getTime()),
|
|
isDifferentFromToday: parsedDate.toDateString() !== today.toDateString()
|
|
};
|
|
} catch (error) {
|
|
console.error('Date parsing error:', error);
|
|
return { success: false, error };
|
|
}
|
|
} else {
|
|
console.log('No date match found - this is the problem!');
|
|
return { success: false, error: 'No date match found' };
|
|
}
|
|
}
|
|
|
|
// Export for use in components
|
|
export const dateTestResults = testDateParsing(); |