export type IntectWebAPIControllersSalaryBatchPrepareFinalizationRequest = {FinalizationGuid?: string | undefined}; export type CreateApiApiSalarybatchesBatchIdFinalizeArgs = {batchId: number, body: IntectWebAPIControllersSalaryBatchPrepareFinalizationRequest}; export type CreateApiApiSalarybatchesBatchIdFinalizeOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Finalizes a payroll batch. Note that you must first call the /preparefinalize route and submit the GUID you receive back from that request. * The function requires the permission salarybatch.canfinalize * * POST /api/salarybatches/{batchId}/finalize * * Also accepts auth: ApiKey */ export const createApiApiSalarybatchesBatchIdFinalize = async (args: CreateApiApiSalarybatchesBatchIdFinalizeArgs, options?: CreateApiApiSalarybatchesBatchIdFinalizeOptions) => { const {baseUrl = "https://api.intect.app", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/salarybatches/${encodeURIComponent(String(args.batchId))}/finalize${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 };