//native
type Zoho = {
token: string;
};
/**
* Categorize a vendor payment
* Categorize an uncategorized transaction as Vendor Payment.
*/
export async function main(
auth: Zoho,
transaction_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;
}[];
payment_mode?: string;
description?: string;
date?: string;
reference_number?: string;
exchange_rate?: number;
paid_through_account_id?: string;
amount?: number;
custom_fields?: { index?: number; value?: string }[];
is_paid_via_print_check?: false | true;
check_details?: { memo?: string; check_number?: string }[];
},
) {
const url = new URL(
`https://www.zohoapis.com/books/v3/banktransactions/uncategorized/${transaction_id}/categorize/vendorpayments`,
);
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: "POST",
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