//native
type SageIntacct = {
token: string
}
/**
* Create a timesheet
* Creates a new timesheet.
Permissions and other requirements
SubscriptionTime & Expenses
User typeBusiness, Project Manager, or Employee
PermissionsAdd timesheets
*/
export async function main(
auth: SageIntacct,
body: {
key?: string
id?: string
href?: string
beginDate?: string
endDate?: string
postingDate?: string
state?:
| 'submitted'
| 'approved'
| 'partiallyApproved'
| 'declined'
| 'draft'
| 'partiallyDeclined'
| 'saved'
unitOfMeasure?: string
hoursInDay?: number
description?: string
calculationMethod?: 'hourly' | 'salary'
postActualLaborCost?: false | true
employee?: { key?: string; id?: string; href?: string }
employeeContact?: {
key?: string
id?: string
firstName?: string
lastName?: string
href?: string
}
attachment?: { key?: string; id?: string; href?: string }
lines?: {
key?: string
id?: string
href?: string
timesheet?: { key?: string; id?: string; href?: string }
entryDate?: string
quantity?: number
lineNumber?: number
description?: string
notes?: string
state?:
| 'submitted'
| 'approved'
| 'partiallyApproved'
| 'declined'
| 'draft'
| 'saved'
| 'readyForApproval'
timeType?: { key?: string; id?: string; href?: string }
isBillable?: false | true
isBilled?: 'true' | 'false' | 'partial'
statisticalJournal?: { key?: string; id?: string; href?: string }
billableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
nonBillableUtilizedGLAccount?: {
key?: string
id?: string
href?: string
}
billableNonUtilizedGLAccount?: {
key?: string
id?: string
href?: string
}
nonBillableNonUtilizedGLAccount?: {
key?: string
id?: string
href?: string
}
hours?: {
billable?: number
nonBillable?: number
approved?: number
approvedBillable?: number
approvedNonBillable?: number
utilized?: number
nonUtilized?: number
approvedUtilized?: number
approvedNonUtilized?: number
}
externalPayroll?: {
costRate?: number
billingRate?: number
amount?: string
employerTaxes?: number
fringes?: number
cashFringes?: number
}
laborClass?: { key?: string; id?: string; name?: string; href?: string }
laborShift?: { key?: string; id?: string; name?: string; href?: string }
laborUnion?: { key?: string; id?: string; name?: string; href?: string }
dimensions?: {
location?: { key?: string; id?: string; name?: string; href?: string }
department?: {
key?: string
id?: string
name?: string
href?: string
}
employee?: { key?: string; id?: string; name?: string; href?: string }
project?: { key?: string; id?: string; name?: string; href?: string }
customer?: { key?: string; id?: string; name?: string; href?: string }
vendor?: { key?: string; id?: string; name?: string; href?: string }
item?: { key?: string; id?: string; name?: string; href?: string }
warehouse?: { key?: string; id?: string; name?: string; href?: string }
class?: { key?: string; id?: string; name?: string; href?: string }
task?: { id?: string; key?: string; name?: string; href?: string }
costType?: { id?: string; key?: string; name?: string; href?: string }
asset?: { id?: string; key?: string; name?: string; href?: string }
contract?: { id?: string; key?: string; name?: string; href?: string }
affiliateEntity?: {
key?: string
id?: string
href?: string
name?: string
}
} & {
location?: { key?: string; id?: string; name?: string; href?: string }
department?: {
key?: string
id?: string
name?: string
href?: string
}
}
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
entity?: { key?: string; id?: string; name?: string; href?: string }
} & {}
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/time/timesheet`)
const response = await fetch(url, {
method: 'POST',
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