Edits history of script submission #19754 for ' Update a billing price list entry (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a billing price list entry
     * Updates an existing billing price list entry by setting field values. Any fields not provided remain unchanged.
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		billingPriceList?: { key?: string; id?: string; href?: string }
    		currency?: {
    			exchangeRateDate?: string
    			exchangeRateTypeId?: string
    			exchangeRate?: number
    			baseCurrency?: string
    			txnCurrency?: string
    		}
    		priceType?: 'range' | 'tiered'
    		flatAmountFrequency?: 'oneTime' | 'useBillingTemplate' | 'includeWithEveryInvoice'
    		usageQuantityResetPeriod?: 'afterEachRenewal' | 'afterEachInvoice'
    		roundingType?: 'standard' | 'roundUp' | 'roundDown'
    		isQuantityRecurring?: false | true
    		variableUnitDivisor?: string
    		tieredPricingType?: 'volume' | 'step' | 'absolute'
    		item?: { key?: string; id?: string; name?: string; href?: string }
    		lines?: {
    			key?: string
    			id?: string
    			href?: string
    			startDate?: string
    			flatAmount?: string
    			variableUnitRate?: string
    			includedUnits?: string
    			memo?: string
    			billingPriceListEntry?: { key?: string; id?: string; href?: string }
    			tiers?: {
    				key?: string
    				id?: string
    				href?: string
    				beginQuantity?: string
    				tierRate?: string
    				billingPriceListEntryLine?: {
    					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 }
    				}
    			}[]
    			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'
    	}
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/contracts/billing-price-list-entry/${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