Edits history of script submission #18848 for ' Create a project change order (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a project change order
     * Creates a new project change order. You must specify a unique ID when creating a project change order unless document sequencing is configured, in which case the ID is auto-generated.
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		project?: { key?: string; id?: string; name?: string; href?: string }
    		location?: { key?: string; id?: number; name?: string; href?: string }
    		projectChangeOrderDate?: string
    		state?: 'draft' | 'posted'
    		changeRequestStatus?: { key?: string; id?: string; href?: string }
    		description?: string
    		projectContract?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		projectContractLine?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		priceEffectiveDate?: string
    		totalCost?: string
    		totalPrice?: string
    		sendToContact?: { key?: string; id?: string; href?: string }
    		item?: { key?: string; id?: string; name?: string; href?: string }
    		customer?: { key?: string; id?: string; name?: string; href?: string }
    		scope?: string
    		inclusions?: string
    		exclusions?: string
    		terms?: string
    		schedule?: {
    			scheduledStartDate?: string
    			actualStartDate?: string
    			scheduledCompletionDate?: string
    			revisedCompletionDate?: string
    			substantialCompletionDate?: string
    			actualCompletionDate?: string
    			noticeToProceedDate?: string
    			responseDueDate?: string
    			executedOnDate?: string
    			scheduleImpact?: string
    		}
    		internalReference?: {
    			referenceNumber?: string
    			initiatedBy?: { key?: string; id?: string; name?: string; href?: string }
    			verbalApprovalBy?: {
    				key?: string
    				id?: string
    				name?: string
    				href?: string
    			}
    			issuedBy?: { key?: string; id?: string; name?: string; href?: string }
    			issuedOnDate?: string
    			approvedBy?: { key?: string; id?: string; name?: string; href?: string }
    			approvedOnDate?: string
    			signedBy?: { key?: string; id?: string; name?: string; href?: string }
    			signedOnDate?: string
    			source?: string
    			sourceReferenceNumber?: string
    		}
    		externalReference?: {
    			referenceNumber?: string
    			verbalApprovalBy?: { key?: string; id?: string; href?: string }
    			approvedBy?: { key?: string; id?: string; href?: string }
    			approvedOnDate?: string
    			signedBy?: { key?: string; id?: string; href?: string }
    			signedOnDate?: string
    		}
    		attachment?: { key?: string; id?: string; href?: string }
    		status?: 'active' | 'inactive'
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    		entity?: { key?: string; id?: string; name?: string; href?: string }
    	} & {}
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/project-change-order`)
    
    	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