import {
    accounts,
    authProfiles,
    bankaccounts,
    bankrequisitions,
    bankstatements,
    branches,
    entitybankaccounts,
    events,
    contacts,
    contracts,
    contracttypes,
    costcentres,
    createddocuments,
    customerinventoryitems,
    customerspaces,
    customers,
    files,
    filetags,
    folders,
    hourrates,
    incominginvoices,
    inventoryitemgroups,
    inventoryitems,
    letterheads,
    memberrelations,
    ownaccounts,
    outgoingsepamandates,
    plants,
    productcategories,
    products,
    projects,
    projecttypes,
    serialExecutions,
    servicecategories,
    services,
    spaces,
    statementallocations,
    tasks,
    teams,
    texttemplates,
    units,
    vehicles,
    vendors
} from "../../db/schema";

export const resourceConfig = {
    projects: {
        searchColumns: ["name","customerRef","projectNumber","notes"],
        mtoLoad: ["customer","plant","contract","projecttype"],
        mtmLoad: ["tasks", "files","createddocuments"],
        table: projects,
        numberRangeHolder: "projectNumber"
    },
    customers: {
        searchColumns: ["name", "nameAddition", "customerNumber", "firstname", "lastname", "notes"],
        mtmLoad: ["contacts","projects","plants","createddocuments","contracts","outgoingsepamandates","customerinventoryitems","customerspaces"],
        table: customers,
        numberRangeHolder: "customerNumber",
    },
    members: {
        searchColumns: ["name", "nameAddition", "customerNumber", "firstname", "lastname", "notes"],
        mtmLoad: ["contacts","projects","plants","createddocuments","contracts"],
        table: customers,
        numberRangeHolder: "customerNumber",
        relationKey: "customer",
    },
    memberrelations: {
        table: memberrelations,
        searchColumns: ["type", "billingInterval"],
    },
    contacts: {
        searchColumns: ["firstName", "lastName", "email", "phone", "notes"],
        table: contacts,
        mtoLoad: ["customer","vendor"]
    },
    contracts: {
        table: contracts,
        searchColumns: ["name", "notes", "contractNumber", "paymentType", "billingInterval", "sepaRef", "bankingName"],
        numberRangeHolder: "contractNumber",
        mtoLoad: ["customer", "contracttype", "contact", "outgoingsepamandate"],
    },
    outgoingsepamandates: {
        table: outgoingsepamandates,
        searchColumns: ["reference", "status", "mandateType", "sequenceType", "notes"],
        numberRangeHolder: "reference",
        mtoLoad: ["customer", "bankaccount"],
    },
    contracttypes: {
        table: contracttypes,
        searchColumns: ["name", "description", "paymentType", "billingInterval"],
    },
    plants: {
        table: plants,
        searchColumns: ["name"],
        mtoLoad: ["customer"],
        mtmLoad: ["projects","tasks","files"],
    },
    projecttypes: {
        table: projecttypes
    },
    vendors: {
        table: vendors,
        searchColumns: ["name","vendorNumber","notes","defaultPaymentType"],
        numberRangeHolder: "vendorNumber",
    },
    files: {
        table: files,
        mtoLoad: [
            "project",
            "customer",
            "contract",
            "vendor",
            "incominginvoice",
            "plant",
            "createddocument",
            "vehicle",
            "product",
            "check",
            "inventoryitem",
            "authProfile",
            "type",
        ],
    },
    folders: {
        table: folders
    },
    filetags: {
        table: filetags
    },
    type: {
        table: filetags
    },
    inventoryitems: {
        table: inventoryitems,
        numberRangeHolder: "articleNumber",
    },
    customerinventoryitems: {
        table: customerinventoryitems,
        numberRangeHolder: "customerInventoryId",
        mtoLoad: ["customer", "customerspace", "product", "vendor"],
        searchColumns: ["name", "customerInventoryId", "serialNumber", "description", "manufacturer", "manufacturerNumber"],
    },
    inventoryitemgroups: {
        table: inventoryitemgroups
    },
    products: {
        table: products,
        searchColumns: ["name","manufacturer","ean","barcode","description","manfacturer_number","article_number"],
    },
    productcategories: {
        table: productcategories
    },
    services: {
        table: services,
        mtoLoad: ["unit"],
        searchColumns: ["name","description"],
    },
    servicecategories: {
        table: servicecategories
    },
    units: {
        table: units,
    },
    vehicles: {
        table: vehicles,
        searchColumns: ["name","license_plate","vin","color"],
    },
    hourrates: {
        table: hourrates,
        searchColumns: ["name"],
    },
    spaces: {
        table: spaces,
        searchColumns: ["name","space_number","type","info_data"],
        numberRangeHolder: "spaceNumber",
    },
    customerspaces: {
        table: customerspaces,
        searchColumns: ["name","space_number","type","info_data","description"],
        numberRangeHolder: "space_number",
        mtoLoad: ["customer"],
        mtmLoad: ["customerinventoryitems"],
    },
    ownaccounts: {
        table: ownaccounts,
        searchColumns: ["name","description","number"],
    },
    costcentres: {
        table: costcentres,
        searchColumns: ["name","number","description"],
        mtoLoad: ["parentCostcentre","vehicle","project","inventoryitem","branch"],
        numberRangeHolder: "number",
    },
    parentCostcentre: {
        table: costcentres,
        searchColumns: ["name", "number", "description"],
    },
    branches: {
        table: branches,
        searchColumns: ["name","number","description"],
        numberRangeHolder: "number",
    },
    teams: {
        table: teams,
        searchColumns: ["name", "description"],
        mtoLoad: ["branch"],
    },
    tasks: {
        table: tasks,
    },
    events: {
        table: events,
        mtoLoad: ["project", "customer"],
        searchColumns: ["name", "notes", "link", "eventtype"],
    },
    profiles: {
        table: authProfiles,
        tenantKey: "tenant_id",
        searchColumns: ["first_name", "last_name", "full_name", "email", "employee_number"],
    },
    authProfile: {
        table: authProfiles,
        tenantKey: "tenant_id",
        searchColumns: ["first_name", "last_name", "full_name", "email", "employee_number"],
    },
    letterheads: {
        table: letterheads,

    },
    createddocuments: {
        table: createddocuments,
        mtoLoad: ["customer", "project", "costcentre", "contact", "contract", "plant","letterhead","createddocument", "outgoingsepamandate"],
        mtmLoad: ["statementallocations","files","createddocuments"],
        mtmListLoad: ["statementallocations", "files"],
    },
    texttemplates: {
        table: texttemplates
    },
    incominginvoices: {
        table: incominginvoices,
        mtmLoad: ["statementallocations","files"],
        mtmListLoad: ["statementallocations"],
        mtoLoad: ["vendor"],
    },
    statementallocations: {
        table: statementallocations,
        mtoLoad: ["customer","vendor","incominginvoice","createddocument","ownaccount","bankstatement"]
    },
    accounts: {
        table: accounts,
    },
    bankstatements: {
        table: bankstatements,
        mtmListLoad: ["statementallocations"],
        mtmLoad: ["statementallocations"],
    },
    bankaccounts: {
        table: bankaccounts,
    },
    bankrequisitions: {
        table: bankrequisitions,
    },
    entitybankaccounts: {
        table: entitybankaccounts,
        searchColumns: ["description"],
    },
    bankaccount: {
        table: entitybankaccounts,
        searchColumns: ["description"],
    },
    serialexecutions: {
        table: serialExecutions
    }
}
