//native
type Zoho = {
token: string;
};
/**
* Update a vendor payment
* Update an existing vendor payment. You can also modify the amount applied to the bills.
*/
export async function main(
auth: Zoho,
payment_id: string,
organization_id: string | undefined,
body: {
vendor_id?: string;
bills?: {
bill_payment_id?: string;
bill_id?: string;
amount_applied?: number;
tax_amount_withheld?: number;
}[];
date?: string;
exchange_rate?: number;
amount: number;
paid_through_account_id?: string;
payment_mode?: string;
description?: string;
reference_number?: string;
is_paid_via_print_check?: false | true;
check_details?: string[];
location_id?: string;
custom_fields?: { index?: number; value?: string }[];
},
) {
const url = new URL(
`https://www.zohoapis.com/books/v3/vendorpayments/${payment_id}`,
);
for (const [k, v] of [["organization_id", organization_id]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + 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