Edits history of script submission #18873 for ' Create a subtotal template line object (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a subtotal template line object
     * Creates a new subtotal template line object.
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		description?: string
    		subtotalType?: 'discount' | 'charge'
    		lineNumber?: number
    		valueType?: 'amount' | 'percent'
    		defaultValue?: string
    		isApportioned?: false | true
    		txnType?: 'debit' | 'credit'
    		applyToLineNumber?: number
    		isTax?: false | true
    		isAvalaraTax?: false | true
    		glAccount?: { key?: string; id?: string; href?: string }
    		offsetGLAccount?: { key?: string; id?: string; href?: string }
    		href?: string
    		subtotalTemplate?: { key?: string; id?: string; href?: string }
    	} & { glAccount?: {}; offsetGLAccount?: {}; subtotalTemplate?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/purchasing/subtotal-template-line`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago