mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
fix #10: custom fields are empty on export
This commit is contained in:
@@ -39,13 +39,19 @@ export async function GET(request: Request) {
|
|||||||
// CSV rows
|
// CSV rows
|
||||||
for (const transaction of transactions) {
|
for (const transaction of transactions) {
|
||||||
const row: Record<string, any> = {}
|
const row: Record<string, any> = {}
|
||||||
for (const key of fieldKeys) {
|
for (const field of existingFields) {
|
||||||
const value = transaction[key as keyof typeof transaction] ?? ""
|
let value
|
||||||
const exportFieldSettings = EXPORT_AND_IMPORT_FIELD_MAP[key]
|
if (field.isExtra) {
|
||||||
if (exportFieldSettings && exportFieldSettings.export) {
|
value = transaction.extra?.[field.code as keyof typeof transaction.extra] ?? ""
|
||||||
row[key] = await exportFieldSettings.export(user.id, value)
|
|
||||||
} else {
|
} else {
|
||||||
row[key] = value
|
value = transaction[field.code as keyof typeof transaction] ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportFieldSettings = EXPORT_AND_IMPORT_FIELD_MAP[field.code]
|
||||||
|
if (exportFieldSettings && exportFieldSettings.export) {
|
||||||
|
row[field.code] = await exportFieldSettings.export(user.id, value)
|
||||||
|
} else {
|
||||||
|
row[field.code] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user