Edits history of script submission #19843 for ' Update a timesheet line (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a timesheet line
     * Updates an existing timesheet line by setting field values. Any fields not provided remain unchanged. Whether approvals are turned on for a company, and where a timesheet is in the approval process determines if a timesheet line can be edited.
    
    
    Permissions and other requirements
    
    SubscriptionTime & Expenses
    User typeBusiness, Project Manager, or Employee
    PermissionsEdit timesheets
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		timesheet?: { key?: string; id?: string; href?: string }
    		entryDate?: string
    		quantity?: number
    		lineNumber?: number
    		description?: string
    		notes?: string
    		state?:
    			| 'submitted'
    			| 'approved'
    			| 'partiallyApproved'
    			| 'declined'
    			| 'draft'
    			| 'saved'
    			| 'readyForApproval'
    		timeType?: { key?: string; id?: string; href?: string }
    		isBillable?: false | true
    		isBilled?: 'true' | 'false' | 'partial'
    		statisticalJournal?: { key?: string; id?: string; href?: string }
    		billableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
    		nonBillableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
    		billableNonUtilizedGLAccount?: { key?: string; id?: string; href?: string }
    		nonBillableNonUtilizedGLAccount?: {
    			key?: string
    			id?: string
    			href?: string
    		}
    		hours?: {
    			billable?: number
    			nonBillable?: number
    			approved?: number
    			approvedBillable?: number
    			approvedNonBillable?: number
    			utilized?: number
    			nonUtilized?: number
    			approvedUtilized?: number
    			approvedNonUtilized?: number
    		}
    		externalPayroll?: {
    			costRate?: number
    			billingRate?: number
    			amount?: string
    			employerTaxes?: number
    			fringes?: number
    			cashFringes?: number
    		}
    		laborClass?: { key?: string; id?: string; name?: string; href?: string }
    		laborShift?: { key?: string; id?: string; name?: string; href?: string }
    		laborUnion?: { key?: string; id?: string; name?: string; href?: string }
    		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
    		}
    	}
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/time/timesheet-line/${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