Edits history of script submission #19147 for ' Delete budget (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Delete budget
     * Deletes a budget. You cannot delete the default budget or any budget that is being used by a financial report.
    
    Carefully consider the implications before you delete a budget. After you delete a budget, you will no longer be able to use its data to create future budgets and it can no longer be used in financial reports.
    
    
    Permissions and other requirements
    
    SubscriptionGeneral Ledger
    User typeBusiness User
    PermissionsDelete Budgets
    
    
    
    
     */
    export async function main(auth: SageIntacct, key: string) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/general-ledger/budget/${key}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago