export type JournalEntryLine = {amount: number, account?: string | undefined, vatCode?: string | undefined, debitAccount?: string | undefined, debitVatCode?: number | undefined, creditAccount?: string | undefined, creditVatCode?: number | undefined, projectId?: Array | undefined, lastModifiedDate?: string | undefined}; export type Attachment = {uuid?: string | undefined, filename?: string | undefined, identifier?: string | undefined, downloadUrl?: string | undefined, downloadUrlWithFikenNormalUserCredentials?: string | undefined, comment?: string | undefined, type?: ('invoice' | 'reminder' | 'unspecified' | 'ocr' | 'bank_statement') | undefined}; export type JournalEntry = {journalEntryId?: number | undefined, createdDate?: string | undefined, lastModifiedDate?: string | undefined, transactionId?: number | undefined, offsetTransactionId?: number | undefined, transactionType?: string | undefined, journalEntryNumber?: number | undefined, description: string, date: string, lines: Array, attachments?: Array | undefined}; export type GeneralJournalEntryRequest = {description?: string | undefined, open?: boolean | undefined, journalEntries: Array}; export type CreateApiCompaniesCompanySlugGeneralJournalEntriesArgs = {body: GeneralJournalEntryRequest}; export type CreateApiCompaniesCompanySlugGeneralJournalEntriesOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new general journal entry (fri postering). * * POST /companies/{companySlug}/generalJournalEntries */ export const createApiCompaniesCompanySlugGeneralJournalEntries = async (args: CreateApiCompaniesCompanySlugGeneralJournalEntriesArgs, options?: CreateApiCompaniesCompanySlugGeneralJournalEntriesOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/generalJournalEntries${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };