Initial build: SimpleScan Solo v0.1.0 - Freelancer receipt capture Chrome extension
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { getCategoryLabel } from './categories.js';
|
||||
export function exportToCsv(receipts) {
|
||||
const headers = ['Date', 'Vendor', 'Title', 'Category', 'Amount', 'Currency', 'Notes', 'Source'];
|
||||
const rows = receipts.map((r) => [
|
||||
r.date,
|
||||
r.vendor,
|
||||
r.title,
|
||||
getCategoryLabel(r.category),
|
||||
r.amount.toFixed(2),
|
||||
r.currency,
|
||||
r.notes,
|
||||
r.source,
|
||||
]);
|
||||
const csv = [headers, ...rows]
|
||||
.map((row) => row
|
||||
.map((cell) => {
|
||||
const str = String(cell).replace(/"/g, '""');
|
||||
return `"${str}"`;
|
||||
})
|
||||
.join(','))
|
||||
.join('\n');
|
||||
return csv;
|
||||
}
|
||||
export function downloadBlob(content, filename, mimeType) {
|
||||
const blob = new Blob([content], { type: mimeType });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
Reference in New Issue
Block a user