Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
test-correct-values.jsβ€’4.36 kB
import dotenv from 'dotenv'; dotenv.config(); import { OpenAIVisionParser } from './build/scraper/openai_vision_parser.js'; import { existsSync } from 'fs'; async function testCorrectValues() { console.log('πŸ§ͺ Testing Correct Value Extraction (No TNOK Multiplication)'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); const apiKey = process.env.OPENAI_API_KEY; if (!apiKey) { console.error('❌ OPENAI_API_KEY not found!'); process.exit(1); } const parser = new OpenAIVisionParser(apiKey); // Test with the PDF that had issues const testPdf = 'data/pdfs/928102939/aarsregnskap_928102939-2023.pdf'; if (!existsSync(testPdf)) { console.error(`❌ Test PDF not found: ${testPdf}`); console.error(' Please download it first using browser scraper'); process.exit(1); } console.log(`πŸ“„ Testing with: ${testPdf}`); console.log('πŸ’‘ Norwegian Γ₯rsregnskap show FULL values in NOK'); console.log(' Example: "20 623" = 20,623 NOK (not 20.6M)'); console.log('\nπŸ”„ Starting extraction...\n'); try { const startTime = Date.now(); const result = await parser.parseFinancialPDF(testPdf); const duration = Math.round((Date.now() - startTime) / 1000); console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log('πŸ“Š EXTRACTION RESULTS'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); console.log(`⏱️ Time: ${duration} seconds\n`); // Expected values for company 928102939 year 2023: // Profit: -20,623 NOK (loss of twenty thousand) // Assets: 48,000 NOK // Equity: 30,001 NOK const formatValue = (name, value, expectedRange) => { if (value === null) { console.log(`${name}: Not found`); return; } // Format based on size if (Math.abs(value) < 1000) { console.log(`${name}: ${value.toLocaleString('no-NO')} NOK`); } else if (Math.abs(value) < 1000000) { const thousands = value / 1000; console.log(`${name}: ${value.toLocaleString('no-NO')} NOK (${thousands.toFixed(1)}K)`); } else { const millions = value / 1000000; console.log(`${name}: ${value.toLocaleString('no-NO')} NOK (${millions.toFixed(1)}M)`); } // Check if in expected range if (expectedRange && (value < expectedRange.min || value > expectedRange.max)) { console.log(` ⚠️ WARNING: Value outside expected range ${expectedRange.min}-${expectedRange.max}`); } else if (expectedRange) { console.log(` βœ… Value in expected range`); } }; // Based on the JSON you showed, expected values (in NOK): formatValue('πŸ’° Revenue', result.revenue, null); formatValue('πŸ“ˆ Profit', result.profit, { min: -30000, max: -10000 }); // Expecting around -20K formatValue('🏒 Assets', result.assets, { min: 40000, max: 60000 }); // Expecting around 48K formatValue('πŸ’Ž Equity', result.equity, { min: 25000, max: 35000 }); // Expecting around 30K console.log('\nπŸ” Analysis:'); // Check if values look correct for a small company const seemsCorrect = (!result.profit || (result.profit > -1000000 && result.profit < 1000000)) && (!result.assets || (result.assets > 10000 && result.assets < 10000000)) && (!result.equity || (result.equity > 10000 && result.equity < 10000000)); if (seemsCorrect) { console.log('βœ… Values appear correct for a small Norwegian company!'); console.log(' No unnecessary multiplication detected.'); } else { console.log('❌ Some values still seem too large!'); console.log(' There may still be an issue with value extraction.'); } // Save corrected data console.log('\nπŸ’Ύ Corrected data ready for database:'); console.log(JSON.stringify({ year: 2023, revenue: result.revenue, profit: result.profit, assets: result.assets, equity: result.equity, source: 'openai_vision_extraction_fixed' }, null, 2)); } catch (error) { console.error('❌ Extraction failed:', error.message); } } testCorrectValues();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josuekongolo/companyiq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server