Edits history of script submission #15378 for ' Create Vendor Bill (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create Vendor Bill
     * Create vendor bills from external invoice provider data
     **Token scopes**: `treasury-vendorbill:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/accounts-payable/vendor-bills`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export interface Body {
    	data: {
    		/**
    		 * Invoice/bill date
    		 */
    		date: string
    		/**
    		 * Total amount including VAT
    		 */
    		amount: number
    		/**
    		 * ISO 4217 currency code
    		 */
    		currency: string
    		/**
    		 * Due date for payment
    		 */
    		due_date: string
    		/**
    		 * Subtotal amount excluding VAT
    		 */
    		subtotal: number
    		/**
    		 * Vendor bill reference
    		 */
    		reference: string
    		/**
    		 * Unique identifier for the Vendor
    		 */
    		vendor_id: string
    		/**
    		 * Line items for the vendor bill
    		 *
    		 * @minItems 1
    		 */
    		line_items: {
    			/**
    			 * Total amount for this line item
    			 */
    			amount: number
    			/**
    			 * Quantity of items
    			 */
    			quantity: number
    			/**
    			 * VAT rate percentage
    			 */
    			vat_rate: number
    			/**
    			 * Price per unit
    			 */
    			unit_price: number
    			/**
    			 * VAT amount for this line item
    			 */
    			vat_amount?: number
    			/**
    			 * Description of the line item
    			 */
    			description: string
    			/**
    			 * Unique Identifier for the Financial department
    			 */
    			department_id?: string
    			/**
    			 * Unique Identifier for the Expense account
    			 */
    			expense_account_id?: string
    			[k: string]: unknown
    		}[]
    		/**
    		 * General description of the vendor bill
    		 */
    		description: string
    		/**
    		 * External system identifier (e.g., Brightflag ID)
    		 */
    		external_id: string
    		/**
    		 * Type of document
    		 */
    		document_type: 'INVOICE' | 'RECEIPT' | 'BILL'
    		/**
    		 * Unique identifier for the Deel legal entity/subsidiary
    		 */
    		subsidiary_id: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago