Edits history of script submission #19845 for ' Update a transaction definition (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a transaction definition
     * Updates an existing purchasing transaction definition by setting field values. Any fields not provided remain unchanged.
    
    
    Permissions and other requirements
    
    SubscriptionPurchasing
    User typeBusiness, Employee, Project Manager, Warehouse
    PermissionsList, View, Edit Purchasing transactions
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		docClass?: 'quote' | 'order' | 'list' | 'invoice' | 'adjustment' | 'other'
    		workflowCategory?: 'quote' | 'order' | 'invoice' | 'shipping' | 'return'
    		disableTax?: false | true
    		enableUserOrGroupPermmission?: false | true
    		enableOverrideTax?: false | true
    		enableNumberingSequence?: false | true
    		preserveNumberingSequence?: false | true
    		inheritDocumentNumber?: false | true
    		xslTemplate?: string
    		description?: string
    		inventoryUpdateType?: 'no' | 'quantity' | 'value' | 'quantityAndValue'
    		txnPostingMethod?: 'toAP' | 'toGL' | 'noPosting'
    		partialConvertMethod?:
    			| 'leaveTransactionOpen'
    			| 'closeOriginalAndCreateBackOrder'
    			| 'closeTransaction'
    		affectsCost?: false | true
    		exchangeRateType?: { key?: string; id?: string; href?: string }
    		overrideExchangeRateType?: false | true
    		showBaseCurrency?: false | true
    		enableCreditLimitCheck?: false | true
    		freezeRecallValue?: false | true
    		overridePrice?: false | true
    		enableSubtotals?: false | true
    		showExpandedTaxDetails?: false | true
    		allowDepartmentOverride?: false | true
    		allowLocationOverride?: false | true
    		requireSupplyOfPrices?: false | true
    		fixedMessage?: string
    		editPolicy?: 'noEdit' | 'beforePrinting' | 'editInDraftOnly' | 'all'
    		deletePolicy?: 'beforePrinting' | 'all' | 'noDelete'
    		customerVendorEditRule?: 'always' | 'exceptConvertedDocuments' | 'never'
    		printPayToContact?: false | true
    		printReturnToContact?: false | true
    		printDeliverToContact?: false | true
    		allowEditingPayToContact?: false | true
    		allowEditingReturnToContact?: false | true
    		allowEditingDeliverToContact?: false | true
    		contactOneTitle?: string
    		contactTwoTitle?: string
    		contactThreeTitle?: string
    		enableWarnOnLowQuantity?: false | true
    		warehouseSelectionMethod?:
    			| 'sortByID'
    			| 'sortByName'
    			| 'warehouseWithAvailableInventory'
    			| 'useTheDefaultWarehouse'
    		postToGL?: false | true
    		enableAllocations?: false | true
    		documentConversionPolicy?: 'newDocumentOnly' | 'newDocumentOrConvert' | 'convertOnly'
    		multiEntityRuleForTransaction?: 'topLevelOrEntity' | 'topLevelOnly' | 'entityOnly'
    		subtotalTemplate?: { key?: string; id?: string; href?: string }
    		lineLevelSimpleTax?: false | true
    		enableRetainage?: false | true
    		enableAdditionalInformationScope?: false | true
    		enableAdditionalInformationSchedule?: false | true
    		enableInternalReference?: false | true
    		enableExternalReference?: false | true
    		enableBond?: false | true
    		documentChangeType?: 'noChange' | 'enableChange' | 'changeOrder'
    		enablePrimaryDocumentWorkflow?: false | true
    		increaseOrDecreaseInventory?: 'increase' | 'decrease'
    		reportingCategory?:
    			| 'bidsAndQuotes'
    			| 'purchaseOrders'
    			| 'purchaseOrderChangeOrders'
    			| 'purchaseReceivers'
    			| 'purchaseOrderInvoices'
    			| 'purchaseReturns'
    			| 'purchaseCredits'
    			| 'purchaseDebits'
    			| 'purchaseClearingReceivers'
    			| 'subcontractBids'
    			| 'subcontracts'
    			| 'subcontractChangeOrders'
    			| 'subcontractInvoices'
    			| 'internalSupplyRequisitions'
    			| 'purchaseRequisitions'
    			| 'blanketPurchaseOrdersOrVendorContracts'
    			| 'grantRequests'
    			| 'grantAwards'
    		initialPriceList?: { key?: string; id?: string; href?: string }
    		documentSequence?: { key?: string; id?: string; href?: string }
    		specialPriceList?: { key?: string; id?: string; href?: string }
    		updatePriceList?: { key?: string; id?: string; href?: string }
    		apTerm?: { key?: string; id?: string; href?: string }
    		warehouse?: { key?: string; id?: string; href?: string }
    		status?: 'active' | 'inactive'
    		entity?: { key?: string; id?: string; name?: string; href?: string }
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    		additionalGLDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			isOffset?: false | true
    			txnType?: 'debit' | 'credit'
    			moduleType?: 'subledger' | 'inventory' | 'additional'
    			lineNumber?: number
    			glAccount?: { key?: string; id?: string; href?: string }
    			location?: { href?: string; key?: string; id?: string }
    			department?: { href?: string; key?: string; id?: string }
    			itemGLGroup?: { key?: string; id?: string; href?: string }
    			warehouse?: { key?: string; id?: string; href?: string }
    			status?: 'active' | 'inactive'
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    		accountPayableOrDirectGLDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			isOffset?: false | true
    			txnType?: 'debit' | 'credit'
    			moduleType?: 'subledger' | 'inventory' | 'additional'
    			lineNumber?: number
    			glAccount?: { key?: string; id?: string; href?: string }
    			location?: { href?: string; key?: string; id?: string }
    			department?: { href?: string; key?: string; id?: string }
    			itemGLGroup?: { href?: string; key?: string; id?: string }
    			warehouse?: { href?: string; key?: string; id?: string }
    			status?: 'active' | 'inactive'
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    		inventoryTotalDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			maintainType?: 'quantity' | 'value' | 'quantityAndValue'
    			operation?: 'add' | 'subtract'
    			inventoryTotal?: { key?: string; id?: string; href?: string }
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    		subtotalDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			subtotalType?: 'discount' | 'charge'
    			lineNumber?: number
    			description?: string
    			valueType?: 'amount' | 'percent'
    			subtotalValue?: string
    			isApportioned?: false | true
    			glAccount?: { key?: string; id?: string; href?: string }
    			offsetGLAccount?: { key?: string; id?: string; href?: string }
    			txnType?: 'debit' | 'credit'
    			appliedToLineNumber?: number
    			isTax?: false | true
    			department?: { href?: string; key?: string; id?: string }
    			location?: { key?: string; id?: string; href?: string }
    			enableAvalaraTax?: false | true
    			entity?: { href?: string; key?: string; id?: string }
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    		sourceDocumentDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			sourceDocument?: { href?: string; key?: string; id?: string }
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    		entitySettingDetail?: {
    			key?: string
    			id?: string
    			href?: string
    			enableNumberingSequence?: false | true
    			preserveNumberingSequence?: false | true
    			canInheritSourceDocumentNumber?: false | true
    			documentTemplate?: { key?: string; id?: string }
    			subtotalTemplate?: { href?: string; key?: string; id?: string }
    			showExpandedTaxDetail?: false | true
    			enableOverrideTax?: false | true
    			enableLineLevelSimpleTax?: false | true
    			entity?: { href?: string; key?: string; id?: string }
    			documentSequence?: { key?: string; href?: string; id?: string }
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			purchasingTxnDefinition?: { key?: string; id?: string; href?: string }
    		}[]
    	} & { id?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/purchasing/txn-definition/${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