//native
type SageIntacct = {
token: string
}
/**
* Update a customer
* Updates an existing customer by setting field values. Any fields not provided remain unchanged. Customers included in posted transactions will not be updated. Only new transactions and records will refer to the updated customer information.
Permissions and other requirements
SubscriptionAccounts Receivable
User typeBusiness
PermissionsList, View, Edit Customers
*/
export async function main(
auth: SageIntacct,
key: string,
body: {
key?: string
id?: string
name?: string
href?: string
status?: 'active' | 'activeNonPosting' | 'inactive'
customerType?: { key?: string; id?: string; href?: string }
parent?: { key?: string; id?: string; name?: string; href?: string }
salesRepresentative?: {
key?: string
id?: string
name?: string
href?: string
}
taxId?: string
defaultRevenueGLAccount?: {
key?: string
id?: string
name?: string
href?: string
}
shippingMethod?: { key?: string; id?: string; href?: string }
creditLimit?: number
isOnHold?: false | true
contacts?: {
default?: {
key?: string
id?: string
href?: string
lastName?: string
firstName?: string
middleName?: string
prefix?: string
printAs?: string
email1?: string
email2?: string
phone1?: string
phone2?: string
mobile?: string
pager?: string
fax?: string
URL1?: string
URL2?: string
companyName?: string
mailingAddress?: {
addressLine1?: string
addressLine2?: string
addressLine3?: string
city?: string
state?: string
postCode?: string
country?: string
}
} & {
showInContactList?: false | true
tax?: {
isTaxable?: false | true
group?: { key?: string; id?: string; href?: string }
}
electronicInvoiceDetails?: {
legalCategory?: string
mainActivity?: string
typeOfCompany?: string
registeredCapital?: number
valueAddedTaxRegime?: string
}
internationalTaxId?: string
}
primary?: { key?: string; id?: string; href?: string }
billTo?: { key?: string; id?: string; href?: string }
shipTo?: { key?: string; id?: string; href?: string }
}
contactList?: {
key?: string
id?: string
categoryName?: string
href?: string
contact?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
customer?: { key?: string; id?: string; href?: string }
}[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
customerEmailTemplates?: {
key?: string
id?: string
href?: string
customer?: { key?: string; id?: string; href?: string }
txnDefinition?: { href?: string; key?: string; id?: string }
emailTemplate?: {
key?: string
id?: string
name?: string
templateType?: 'arInvoice' | 'arStatement' | 'contract' | 'orderEntryTxn' | 'purchasingTxn'
href?: string
}
}[]
discountPercent?: string
term?: { key?: string; id?: string; href?: string }
advanceBillBy?: string
advanceBillByType?: '' | 'days' | 'months'
totalDue?: string
lastInvoiceCreatedDate?: string
lastStatementGeneratedDate?: string
resaleNumber?: number
deliveryOptions?: 'print' | 'email' | 'both'
overridePriceList?: 'customer' | 'billingContact' | 'shippingContact'
customerMessage?: {
key?: string
id?: string
message?: string
href?: string
}
currency?: string
emailOptIn?: false | true
activationDate?: string
subscriptionEndDate?: string
territory?: { key?: string; id?: string; name?: string; href?: string }
enableOnlineACHPayment?: false | true
enableOnlineCardPayment?: false | true
isOneTimeUse?: false | true
accountGroup?: { key?: string; id?: string; href?: string }
accountLabel?: { key?: string; id?: string; href?: string }
attachment?: { key?: string; id?: string; href?: string }
retainagePercentage?: number
notes?: string
priceList?: { key?: string; id?: string; href?: string }
priceSchedule?: { key?: string; id?: string; href?: string }
overrideOffsetGLAccount?: {
key?: string
id?: string
name?: string
href?: string
}
customerRestriction?: 'unrestricted' | 'rootOnly' | 'restricted'
restrictedLocations?: {
key?: string
id?: string
href?: string
location?: { key?: string; id?: string; href?: string }
locationGroup?: { key?: string; id?: string; href?: string }
customer?: { key?: string; id?: string; href?: string }
}[]
restrictedDepartments?: {
key?: string
id?: string
href?: string
department?: { key?: string; id?: string; href?: string }
departmentGroup?: { key?: string; id?: string; href?: string }
customer?: { key?: string; id?: string; href?: string }
}[]
entity?: { key?: string; id?: string; name?: string; href?: string }
} & { id?: {} }
) {
const url = new URL(
`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer/${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