Edits history of script submission #18787 for ' Create a WIP period (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a WIP period
     * Creates a new WIP period.
    
    
    Permissions and other requirements
    
    SubscriptionConstruction
    User typeBusiness, Project Manager
    PermissionsAdd WIP Periods
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		periodName?: string
    		periodStartDate?: string
    		periodEndDate?: string
    		fiscalYear?: string
    		state?: 'unposted' | 'posted'
    		notes?: string
    		isHistoricalImport?: false | true
    		lastRefreshDateTime?: string
    		createdFromEntity?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		assignedEntity?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		endOfPriorYearPeriod?: {
    			key?: string
    			id?: string
    			periodName?: string
    			href?: string
    		}
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    		wipProjects?: {
    			key?: string
    			id?: string
    			isFinalized?: false | true
    			glPostedDate?: string
    			estimatedCostToDateAmount?: string
    			jobToDateCosts?: string
    			estimatedCostToComplete?: string
    			estimatedCostAtCompletion?: string
    			pendingEstimatesAmount?: string
    			estimatedPercentComplete?: string
    			projectManagerForecast?: {
    				costToComplete?: string
    				costAtCompletion?: string
    				percentComplete?: string
    				contractValue?: string
    				lastUpdatedDate?: string
    			}
    			cfoForecast?: {
    				costToComplete?: string
    				costAtCompletion?: string
    				percentComplete?: string
    				contractValue?: string
    				lastUpdatedDate?: string
    			}
    			costAtCompletionVariance?: string
    			totalContractValue?: string
    			contractVarianceAmount?: string
    			jobToDateBillings?: string
    			earnedToDateAmount?: string
    			remainingBacklogAmount?: string
    			overUnderBillingAmount?: string
    			earnedProfitToDateAmount?: string
    			grossProfitPercentOfContract?: string
    			grossProfitPercentOfCost?: string
    			totalGrossProfitEstimatedAtCompletion?: string
    			cfoForecastGrossProfitAtCompletion?: string
    			grossProfitVarianceAmount?: string
    			cfoForecastGrossProfitMarginPercent?: string
    			priorYearsProfit?: string
    			endOfPriorYearEarnedToDateAmount?: string
    			endOfPriorYearEarnedProfit?: string
    			remainingProfit?: string
    			yearToDateCostAmount?: string
    			yearToDateBillingAmount?: string
    			yearToDateEarnedRevenueAmount?: string
    			jobToDateOverBillingAmount?: string
    			jobToDateUnderBillingAmount?: string
    			yearToDateEarnedProfitAmount?: string
    			currentPeriodBillingAmount?: string
    			currentPeriodCostAmount?: string
    			currentPeriodEarnedProfitAmount?: string
    			currentPeriodEarnedRevenueAmount?: string
    			notes?: string
    			forecastDetails?: {
    				key?: string
    				id?: string
    				wipPeriod?: {
    					key?: string
    					id?: string
    					periodName?: string
    					href?: string
    				}
    				assignedEntity?: {
    					key?: string
    					id?: string
    					name?: string
    					href?: string
    				}
    				wipProject?: { key?: string; id?: string; href?: string }
    				project?: { key?: string; id?: string; name?: string; href?: string }
    				costType?: { id?: string; key?: string; name?: string; href?: string }
    				task?: { id?: string; key?: string; name?: string; href?: string }
    				groupTask?: { id?: string; key?: string; name?: string; href?: string }
    				costAndEstimateDetail?: {
    					key?: string
    					jobToDateCosts?: string
    					estimatedCostToDateAmount?: string
    					estimatedCostAtCompletion?: string
    					pendingEstimatesAmount?: string
    					estimatedCostToComplete?: string
    					estimatedPercentComplete?: string
    					estimateVsForecastVariance?: string
    					href?: string
    				}
    				projectManagerForecast?: {
    					key?: string
    					costToComplete?: string
    					costAtCompletion?: string
    					percentComplete?: string
    					notes?: string
    					pmUserUpdatedDate?: string
    					costToCompleteVariance?: string
    					costAtCompletionVariance?: string
    					href?: string
    				}
    				priorPeriodProjectManagerForecast?: {
    					costToComplete?: string
    					costAtCompletion?: string
    					percentComplete?: string
    				}
    				href?: string
    			}[]
    			href?: string
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			project?: {
    				key?: string
    				id?: string
    				name?: string
    				description?: string
    				status?: 'active' | 'inactive'
    				startDate?: string
    				endDate?: string
    				href?: string
    			}
    			customer?: { key?: string; id?: string; name?: string; href?: string }
    			projectType?: { key?: string; id?: string; href?: string }
    			projectStatus?: { key?: string; id?: string; href?: string }
    			location?: { key?: string; id?: string; name?: string; href?: string }
    			class?: { key?: string; id?: string; name?: string; href?: string }
    			department?: { key?: string; id?: string; name?: string; href?: string }
    			manager?: { key?: string; id?: string; name?: string; href?: string }
    			wipPeriod?: {
    				key?: string
    				id?: string
    				periodName?: string
    				href?: string
    			}
    		}[]
    		href?: string
    	} & {}
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/construction-forecasting/wip-period`
    	)
    
    	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