Edits history of script submission #18908 for ' Create an MEA price list entry (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create an MEA price list entry
     * Creates a new MEA price list entry.
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		meaPriceList?: { key?: string; id?: string; href?: string }
    		fairValueCategory?: { key?: string; id?: string; href?: string }
    		item?: { key?: string; id?: string; name?: string; href?: string }
    		currency?: {
    			exchangeRateDate?: string
    			exchangeRateTypeId?: string
    			exchangeRate?: number
    			baseCurrency?: string
    			txnCurrency?: string
    		}
    		priceType?: 'amount' | 'percent' | 'priceRange' | 'noFairValue'
    		calculatePercentageBasedOn?: 'extendedFairValuePrice' | 'extendedContractLinePrice'
    		usePriceRange?: false | true
    		priceRangeVarianceType?: 'amount' | 'percent'
    		priceRuleOutsideRange?: 'fairValue' | 'nearestBoundary'
    		lines?: {
    			key?: string
    			id?: string
    			href?: string
    			meaPriceListEntry?: { key?: string; id?: string; href?: string }
    			startDate?: string
    			amountOrPercent?: string
    			markDown?: string
    			markUp?: string
    			lowerLimit?: string
    			upperLimit?: string
    			memo?: string
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    				createdByUser?: { key?: string; id?: string; href?: string }
    				modifiedByUser?: { key?: string; id?: string; href?: string }
    			}
    		}[]
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    			createdByUser?: { key?: string; id?: string; href?: string }
    			modifiedByUser?: { key?: string; id?: string; href?: string }
    		}
    		status?: 'active' | 'inactive'
    	} & { currency: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/mea-price-list-entry`)
    
    	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