Edits history of script submission #18791 for ' Create a bank transaction rule (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a bank transaction rule
     * Creates a new bank transaction rule.
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		ruleId?: string
    		name?: string
    		description?: string
    		ruleType?: 'match' | 'create'
    		location?: { key?: string; id?: string; href?: string }
    		rulesetCount?: number
    		filterAttributes?: {
    			key?: string
    			id?: string
    			href?: string
    			dataSource?: 'intacctTransaction' | 'bankTransaction'
    			intacctTxnAttribute?:
    				| 'transactionType'
    				| 'documentNumber'
    				| 'documentDate'
    				| 'transactionAmount'
    				| 'baseAmount'
    				| 'transactionCurrency'
    				| 'baseCurrency'
    				| 'postingDate'
    				| 'description'
    			bankTxnAttribute?:
    				| 'transactionType'
    				| 'documentNumber'
    				| 'postingDate'
    				| 'description'
    				| 'documentType'
    				| 'amount'
    				| 'currency'
    				| 'feedType'
    			operator?:
    				| 'equals'
    				| 'contains'
    				| 'within'
    				| 'notContains'
    				| 'beginsWith'
    				| 'endsWith'
    				| 'greaterThan'
    				| 'lessThan'
    			value?: string
    			order?: number
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			bankTransactionRule?: { id?: string; key?: string; href?: string }
    		}[]
    		groupAttributes?: {
    			key?: string
    			id?: string
    			href?: string
    			dataSource?: 'intacctTransaction' | 'bankTransaction'
    			intacctTxnAttribute?: 'documentNumber' | 'postingDate'
    			bankTxnAttribute?: 'documentNumber' | 'postingDate'
    			order?: number
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			bankTransactionRule?: { id?: string; key?: string; href?: string }
    		}[]
    		status?: 'active' | 'inactive'
    		matchRuleAttributes?: {
    			key?: string
    			id?: string
    			intacctTxnAttribute?: 'documentNumber' | 'postingDate' | 'description' | 'amount'
    			bankTxnAttribute?:
    				| 'documentNumber'
    				| 'postingDate'
    				| 'description'
    				| 'amount'
    				| 'documentNumberLeadingZerosRemoved'
    			operator?: 'equals' | 'contains' | 'within'
    			value?: string
    			order?: number
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    			bankTransactionRule?: { id?: string; key?: string; href?: string }
    		}[]
    		createRuleObject?: {
    			objectType?: 'cctransaction' | 'journalEntry'
    			journalEntryTemplate?: { id?: string; key?: string; href?: string }
    			creditCardTxnTemplate?: { id?: string; key?: string; href?: string }
    		}
    		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/cash-management/bank-txn-rule`)
    
    	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