import { CompanyDatabase } from './build/database/db.js';
import { readFileSync } from 'fs';
function populateTestData() {
console.log('📊 Populating database with test data...');
const db = new CompanyDatabase('./data/company.db');
const orgNr = '999059198';
// First ensure company exists
if (!db.getCompany(orgNr)) {
db.insertOrUpdateCompany({
org_nr: orgNr,
name: 'Test Company AS',
organization_form: 'AS',
nace_code: '123',
employees_count: 10,
last_updated: new Date().toISOString()
});
}
// Try to load existing JSON files
try {
const data2023 = JSON.parse(readFileSync('data/extracted/999059198/financial_data_2023.json', 'utf8'));
db.insertFinancialSnapshot({
org_nr: orgNr,
year: 2023,
revenue: data2023.revenue,
profit: data2023.profit,
assets: data2023.assets,
equity: data2023.equity,
employees: null,
source: 'openai_vision_extraction'
});
console.log('✅ Inserted 2023 data');
} catch (e) {
console.log('Could not load 2023 data:', e.message);
}
try {
const data2022 = JSON.parse(readFileSync('data/extracted/999059198/financial_data_2022.json', 'utf8'));
db.insertFinancialSnapshot({
org_nr: orgNr,
year: 2022,
revenue: data2022.revenue,
profit: data2022.profit,
assets: data2022.assets,
equity: data2022.equity,
employees: null,
source: 'openai_vision_extraction'
});
console.log('✅ Inserted 2022 data');
} catch (e) {
console.log('Could not load 2022 data:', e.message);
}
// Also add a 2024 entry for API data
db.insertFinancialSnapshot({
org_nr: orgNr,
year: 2024,
revenue: 350000000,
profit: 15000000,
assets: 400000000,
equity: 80000000,
employees: 25,
source: 'regnskapsregisteret_api'
});
console.log('✅ Inserted 2024 data');
// Check what we have
const history = db.getFinancialHistory(orgNr, 10);
console.log(`\n📊 Database now contains ${history.length} years of data`);
}
populateTestData();