Edits history of script submission #19844 for ' Update a transaction allocation template (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a transaction allocation template
     * Updates an existing allocation template and template lines by setting field values. Any fields not provided remain unchanged.
    
    
    Permissions and other requirements
    
    SubscriptionCompany
    User typeBusiness user with admin privileges
    PermissionsEdit transaction allocations
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		description?: string
    		allocateBy?: 'percentage' | 'exactAmount' | 'fixedAmount'
    		documentNumber?: string
    		status?: 'active' | 'inactive'
    		attachment?: { key?: string; id?: string; href?: string }
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    		href?: string
    		lines?: {
    			key?: string
    			id?: string
    			value?: string
    			valueType?: 'amount' | 'percent'
    			lineNumber?: number
    			dimensions?: {
    				location?: { key?: string; id?: string; name?: string; href?: string }
    				department?: {
    					key?: string
    					id?: string
    					name?: string
    					href?: string
    				}
    				employee?: { key?: string; id?: string; name?: string; href?: string }
    				project?: { key?: string; id?: string; name?: string; href?: string }
    				customer?: { key?: string; id?: string; name?: string; href?: string }
    				vendor?: { key?: string; id?: string; name?: string; href?: string }
    				item?: { key?: string; id?: string; name?: string; href?: string }
    				warehouse?: { key?: string; id?: string; name?: string; href?: string }
    				class?: { key?: string; id?: string; name?: string; href?: string }
    				task?: { id?: string; key?: string; name?: string; href?: string }
    				costType?: { id?: string; key?: string; name?: string; href?: string }
    				asset?: { id?: string; key?: string; name?: string; href?: string }
    				contract?: { id?: string; key?: string; name?: string; href?: string }
    				affiliateEntity?: {
    					key?: string
    					id?: string
    					href?: string
    					name?: string
    				}
    			} & {
    				location?: { key?: string; id?: string; name?: string; href?: string }
    				department?: {
    					key?: string
    					id?: string
    					name?: string
    					href?: string
    				}
    			}
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			href?: string
    			txnAllocationTemplate?: { key?: string; id?: string; href?: string }
    		}[]
    	} & { id?: {} }
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/general-ledger/txn-allocation-template/${key}`
    	)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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