mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
feat: select columns to show
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_fields" (
|
||||
"code" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL DEFAULT 'string',
|
||||
"llm_prompt" TEXT,
|
||||
"options" JSONB,
|
||||
"is_visible_in_list" BOOLEAN NOT NULL DEFAULT false,
|
||||
"is_visible_in_analysis" BOOLEAN NOT NULL DEFAULT false,
|
||||
"is_required" BOOLEAN NOT NULL DEFAULT false,
|
||||
"is_extra" BOOLEAN NOT NULL DEFAULT true
|
||||
);
|
||||
INSERT INTO "new_fields" ("code", "is_extra", "is_required", "llm_prompt", "name", "options", "type") SELECT "code", "is_extra", "is_required", "llm_prompt", "name", "options", "type" FROM "fields";
|
||||
DROP TABLE "fields";
|
||||
ALTER TABLE "new_fields" RENAME TO "fields";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
@@ -42,13 +42,15 @@ model Project {
|
||||
}
|
||||
|
||||
model Field {
|
||||
code String @id
|
||||
name String
|
||||
type String @default("string")
|
||||
llm_prompt String?
|
||||
options Json?
|
||||
isRequired Boolean @default(false) @map("is_required")
|
||||
isExtra Boolean @default(true) @map("is_extra")
|
||||
code String @id
|
||||
name String
|
||||
type String @default("string")
|
||||
llm_prompt String?
|
||||
options Json?
|
||||
isVisibleInList Boolean @default(false) @map("is_visible_in_list")
|
||||
isVisibleInAnalysis Boolean @default(false) @map("is_visible_in_analysis")
|
||||
isRequired Boolean @default(false) @map("is_required")
|
||||
isExtra Boolean @default(true) @map("is_extra")
|
||||
|
||||
@@map("fields")
|
||||
}
|
||||
|
||||
132
prisma/seed.js
132
prisma/seed.js
@@ -1,6 +1,6 @@
|
||||
import { PrismaClient } from "@prisma/client"
|
||||
|
||||
const DATABASE_URL = process.env.DATABASE_URL || "file:./db.sqlite"
|
||||
const DATABASE_URL = process.env.DATABASE_URL
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
@@ -306,6 +306,8 @@ const fields = [
|
||||
name: "Name",
|
||||
type: "string",
|
||||
llm_prompt: "human readable name, summarize what is bought in the invoice",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: true,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -314,6 +316,8 @@ const fields = [
|
||||
name: "Description",
|
||||
type: "string",
|
||||
llm_prompt: "description of the transaction",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -322,54 +326,8 @@ const fields = [
|
||||
name: "Merchant",
|
||||
type: "string",
|
||||
llm_prompt: "merchant name, use the original spelling and language",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "type",
|
||||
name: "Type",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "total",
|
||||
name: "Total",
|
||||
type: "number",
|
||||
llm_prompt: "total total of the transaction",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "currencyCode",
|
||||
name: "Currency",
|
||||
type: "string",
|
||||
llm_prompt: "currency code, ISO 4217 three letter code like USD, EUR, including crypto codes like BTC, ETH, etc",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "convertedTotal",
|
||||
name: "Converted Total",
|
||||
type: "number",
|
||||
llm_prompt: "",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "convertedCurrencyCode",
|
||||
name: "Converted Currency Code",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "note",
|
||||
name: "Note",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -378,6 +336,8 @@ const fields = [
|
||||
name: "Category",
|
||||
type: "string",
|
||||
llm_prompt: "category code, one of: {categories.code}",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -386,6 +346,8 @@ const fields = [
|
||||
name: "Project",
|
||||
type: "string",
|
||||
llm_prompt: "project code, one of: {projects.code}",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -394,14 +356,68 @@ const fields = [
|
||||
name: "Issued At",
|
||||
type: "string",
|
||||
llm_prompt: "issued at date (YYYY-MM-DD format)",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "text",
|
||||
name: "Extracted Text",
|
||||
code: "total",
|
||||
name: "Total",
|
||||
type: "number",
|
||||
llm_prompt: "total total of the transaction",
|
||||
isVisibleInList: true,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "currencyCode",
|
||||
name: "Currency",
|
||||
type: "string",
|
||||
llm_prompt: "extract all recognised text from the invoice",
|
||||
llm_prompt: "currency code, ISO 4217 three letter code like USD, EUR, including crypto codes like BTC, ETH, etc",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "convertedTotal",
|
||||
name: "Converted Total",
|
||||
type: "number",
|
||||
llm_prompt: "",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: false,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "convertedCurrencyCode",
|
||||
name: "Converted Currency Code",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: false,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "type",
|
||||
name: "Type",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: true,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
{
|
||||
code: "note",
|
||||
name: "Note",
|
||||
type: "string",
|
||||
llm_prompt: "",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: false,
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
@@ -410,9 +426,19 @@ const fields = [
|
||||
name: "VAT Amount",
|
||||
type: "number",
|
||||
llm_prompt: "total VAT total in currency of the invoice",
|
||||
isVisibleInList: false,
|
||||
isVisibleInAnalysis: false,
|
||||
isRequired: false,
|
||||
isExtra: true,
|
||||
},
|
||||
{
|
||||
code: "text",
|
||||
name: "Extracted Text",
|
||||
type: "string",
|
||||
llm_prompt: "extract all recognised text from the invoice",
|
||||
isRequired: false,
|
||||
isExtra: false,
|
||||
},
|
||||
]
|
||||
|
||||
async function isDatabaseEmpty() {
|
||||
@@ -464,6 +490,8 @@ async function main() {
|
||||
name: field.name,
|
||||
type: field.type,
|
||||
llm_prompt: field.llm_prompt,
|
||||
isVisibleInList: field.isVisibleInList,
|
||||
isVisibleInAnalysis: field.isVisibleInAnalysis,
|
||||
isRequired: field.isRequired,
|
||||
isExtra: field.isExtra,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user