//native
type SageIntacct = {
token: string
}
/**
* Update an item
* Updates an existing item by setting field values. Any fields not provided remain unchanged.
*/
export async function main(
auth: SageIntacct,
key: string,
body: {
key?: string
id?: string
name?: string
status?: 'active' | 'inactive'
itemType?:
| 'inventory'
| 'nonInventory'
| 'purchaseOnlyNonInventory'
| 'salesOnlyNonInventory'
| 'kit'
| 'stockableKit'
enableFulfillment?: false | true
isItemEnabledForMRR?: false | true
productLine?: { key?: string; id?: string; href?: string }
costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO'
extendedDescription?: string
poDescription?: string
soDescription?: string
unitOfMeasureGroup?: { key?: string; id?: string; href?: string }
notes?: string
dateLastSold?: string
dateLastReceived?: string
isSuppliesItem?: false | true
quantityOnOrder?: string
quantityInTransit?: string
quantityOnHand?: string
quantityOnHold?: string
quantityReserved?: string
quantityAllocated?: string
quantityUncommitted?: string
inventory?: {
shippingWeight?: number
autoPrintLabel?: false | true
glGroup?: {
id?: string
key?: string
defaultRevenueRecognitionTemplate?: string
incomeGLAccount?: string
inventoryGLAccount?: string
expenseGLAccount?: string
cogsGLAccount?: string
arGLAccountNumber?: string
apGLAccountNumber?: string
deferredRevenueGLAccountNumber?: string
href?: string
}
}
vsoeCategory?:
| 'productSpecified'
| 'software'
| 'productUnspecified'
| 'upgradeUnspecified'
| 'upgradeSpecified'
| 'services'
| 'postContractSupport'
vsoeDefaultDeliveryStatus?: 'delivered' | 'undelivered'
vsoeDefaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered'
substituteItemId?: string
tracking?: {
enableSerialNo?: false | true
serialMask?: string
enableLotCategory?: false | true
lotCategory?: string
enableBins?: false | true
enableExpiration?: false | true
}
precision?: {
upc?: string
inventoryPrecision?: number
salesPrecision?: number
purchasingPrecision?: number
}
landedCost?: { enableLandedCost?: false | true }
itemLandedCost?: {
key?: string
id?: string
href?: string
distributionMethod?: 'volume' | 'weight' | 'count'
distributionMethodBaseUnit?: string
landedCostValue?: string
active?: false | true
item?: { key?: string; id?: string; href?: string }
}[]
replenishment?: {
enableReplenishment?: false | true
unitOfMeasureDefault?: string
safetyStock?: number
maximumOrderQuantity?: number
replenishmentMethod?:
| ''
| 'demandForecastBySingleValue'
| 'reorderPoint'
| 'demandForecastByFluctuatingValues'
reorderPoint?: number
reorderQuantity?: number
forecastDemandInLeadTime?: number
}
itemDetails?: {
primaryCountryOfOrigin?: string
condition?: string
engineeringAlert?: string
specification1?: string
specification2?: string
specification3?: string
universalProductCode?: number
internationalArticleNumber?: number
isSafetyItem?: false | true
isRestrictedItem?: false | true
isCompliantItem?: false | true
isApprovedByEngineering?: false | true
isApprovedByQualityControl?: false | true
isApprovedBySales?: false | true
}
measurements?: {
weightUnitOfMeasure?: { id?: string; key?: string; href?: string }
netWeight?: number
lengthWidthHeightUnitOfMeasure?: {
id?: string
key?: string
href?: string
}
length?: number
width?: number
height?: number
thicknessUnitOfMeasure?: { id?: string; key?: string; href?: string }
thickness?: number
minimumThickness?: number
maximumThickness?: number
areaUnitOfMeasure?: { id?: string; key?: string; href?: string }
area?: number
volumeUnitOfMeasure?: { id?: string; key?: string; href?: string }
volume?: number
densityUnitOfMeasure?: string
density?: number
durometerUnitOfMeasure?: string
diameterUnitOfMeasure?: { id?: string; key?: string; href?: string }
innerDiameter?: number
outerDiameter?: number
}
commercial?: {
brand?: string
subBrand?: string
category?: string
subCategory?: string
catalogReference?: string
color?: string
size1?: string
size2?: string
style?: string
webName?: string
webShortDiscription?: string
webLongDescription?: string
isGiftCard?: false | true
isWebEnabled?: false | true
}
defaultConversionType?: 'quantity' | 'price'
purchasing?: { standardCost?: string }
sales?: {
isTaxable?: false | true
basePrice?: string
isAvailableForDropShip?: false | true
isAvailableForBuyToOrder?: false | true
taxGroup?: { key?: string; id?: string; href?: string }
taxSolution?: { key?: string; id?: string; href?: string }
allowMultipleTaxGroups?: false | true
}
itemTaxMap?: {
key?: string
id?: string
href?: string
item?: { key?: string; id?: string; href?: string }
taxSolution?: { key?: string; id?: string; href?: string }
taxGroup?: { key?: string; id?: string; href?: string }
}[]
warehouseInfo?: {
key?: string
id?: string
item?: { key?: string; id?: string; href?: string }
warehouse?: { key?: string; id?: string; href?: string }
storageArea?: string
inventoryCycle?: { key?: string; id?: string; href?: string }
economicOrderQuantity?: number
standardCost?: string
lastCost?: string
averageCost?: string
reorderMethod?: 'reorderPoint' | 'economicQuantity' | 'maxStockLevel'
reorderPoint?: number
reorderQuantity?: number
minOrderQuantity?: number
maxOrderQuantity?: number
maximumStock?: number
minimumStock?: number
lastSoldDate?: string
lastReceivedDate?: string
defaultBin?: { key?: string; id?: string; href?: string }
warehouseLocation?: {
key?: string
id?: string
currency?: string
href?: string
}
safetyStock?: number
replenishmentMethod?:
| 'demandForecastBySingleValue'
| 'reorderPoint'
| 'demandForecastByFluctuatingValues'
enableReplenishment?: false | true
onOrder?: number
inTransit?: number
onHand?: number
onHold?: number
reserved?: number
allocated?: number
unCommitted?: number
href?: string
itemWarehouseVendor?: {
key?: string
id?: string
itemWarehouse?: { key?: string; id?: string; href?: string }
vendor?: { key?: string; id?: string; href?: string }
stockNumber?: string
leadTime?: number
demandForecastDuringLeadTime?: number
economicalOrderQuantity?: number
vendorMinimumOrderQuantity?: number
bestPrice?: string
latestPrice?: string
unitOfMeasure?: { key?: string; id?: string; href?: string }
conversionFactor?: string
isPreferredVendor?: false | true
href?: string
}[]
standardCostEntries?: {
key?: string
id?: string
href?: string
effectiveStartDate?: string
standardCost?: string
itemWarehouse?: {
key?: string
id?: string
href?: string
itemId?: string
warehouseId?: string
}
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
itemVendor?: {
key?: string
id?: string
item?: { key?: string; id?: string; href?: string }
vendor?: { key?: string; id?: string; href?: string }
stockNumber?: string
leadTime?: number
demandForecastDuringLeadTime?: number
economicalOrderQuantity?: number
vendorMinimumOrderQuantity?: number
bestPrice?: string
latestPrice?: string
unitOfMeasure?: { key?: string; id?: string; href?: string }
conversionFactor?: string
isPreferredVendor?: false | true
href?: string
}[]
isEnabledForContracts?: false | true
kitRevenuePosting?: 'componentLevel' | 'kitLevel'
kitRevenuePrinting?: 'kit' | 'individualComponents'
kitComponents?: {
key?: string
id?: string
kit?: { key?: string; id?: string; href?: string }
component?: {
key?: string
id?: string
href?: string
name?: string
costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO'
itemType?:
| 'inventory'
| 'nonInventory'
| 'purchaseOnlyNonInventory'
| 'salesOnlyNonInventory'
| 'kit'
| 'stockableKit'
standardCost?: string
unitOfMeasure?: string
}
numberOfUnits?: number
revenuePercentage?: number
defaultDeliveryStatus?: 'delivered' | 'undelivered'
defaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered'
lineNumber?: number
href?: string
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
contractTerm?: {
isStartDateAndEndDateEnabled?: false | true
periodsMeasuredIn?: 'days' | 'weeks' | 'months' | 'years'
numberOfPeriods?: number
isProratedPricingAllowed?: false | true
defaultRenewalTemplate?: { key?: string; id?: string; href?: string }
}
contractDefault?: {
billingTemplate?: { key?: string; id?: string; href?: string }
revRecTemplate1?: { key?: string; id?: string; href?: string }
revRecTemplate2?: { key?: string; id?: string; href?: string }
expenseTemplate1?: { key?: string; id?: string; href?: string }
expenseTemplate2?: { key?: string; id?: string; href?: string }
contractFairValueCategory?: { key?: string; id?: string; href?: string }
defaultContractDeliveryStatus?: 'delivered' | 'undelivered'
defaultContractDeferralStatus?:
| 'deferRevenueUntilItemIsDelivered'
| 'deferRevenueUntilAllItemsAreDelivered'
isDefaultBundle?: false | true
}
itemCrossReference?: {
key?: string
id?: string
href?: string
referenceType?: 'customer' | 'vendor' | 'substitute' | 'upgrade' | 'downgrade' | 'complement'
itemAliasId?: string
itemAliasDescription?: string
unitOfMeasure?: { key?: string; id?: string; href?: string }
referenceTypeContext?: 'internal' | 'external'
alternateItem?: {
key?: string
id?: string
name?: string
href?: string
}
customer?: { key?: string; id?: string; name?: string; href?: string }
item?: { key?: string; id?: string; name?: string; href?: string }
vendor?: { key?: string; id?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
href?: string
entity?: { key?: string; id?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
} & { id?: {}; costMethod?: {}; itemType?: {} }
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/inventory-control/item/${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