1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a project |
7 | * Updates an existing project by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionProjects |
13 | User typeBusiness, Project Manager |
14 | PermissionsEdit Projects |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | name?: string |
27 | description?: string |
28 | projectCurrency?: string |
29 | category?: 'contract' | 'capitalized' | 'internalNonBillable' | 'internalBillable' |
30 | projectStatus?: { |
31 | key?: string |
32 | id?: string |
33 | disableGenerateInvoice?: false | true |
34 | disablePurchasingAPEntry?: false | true |
35 | disableExpenseEntry?: false | true |
36 | disableTimesheetEntry?: false | true |
37 | href?: string |
38 | } |
39 | startDate?: string |
40 | endDate?: string |
41 | budget?: { |
42 | billingAmount?: string |
43 | budgetedDuration?: string |
44 | budgetedCost?: string |
45 | } |
46 | glBudget?: { key?: string; id?: string; href?: string } |
47 | contractAmount?: string |
48 | actualAmount?: string |
49 | progress?: { |
50 | estimatedDuration?: string |
51 | actualDuration?: string |
52 | approvedDuration?: string |
53 | remainingDuration?: string |
54 | percentComplete?: string |
55 | observedPercentComplete?: string |
56 | } |
57 | billingType?: 'timeAndMaterial' | 'fixedFee' | 'fixedFeeAndExpenses' |
58 | salesOrderNumber?: string |
59 | purchaseOrderNumber?: string |
60 | purchaseOrderAmount?: string |
61 | purchaseQuoteNumber?: string |
62 | salesforceKey?: string |
63 | documentNumber?: string |
64 | parent?: { key?: string; id?: string; name?: string; href?: string } |
65 | invoiceWithParent?: false | true |
66 | rootProject?: { key?: string; id?: string; name?: string; href?: string } |
67 | wipScheduleProject?: { |
68 | key?: string |
69 | id?: string |
70 | name?: string |
71 | href?: string |
72 | } |
73 | excludeFromWIPSchedule?: false | true |
74 | customer?: { key?: string; id?: string; name?: string; href?: string } |
75 | salesContact?: { key?: string; id?: string; name?: string; href?: string } |
76 | projectType?: { key?: string; id?: string; href?: string } |
77 | manager?: { key?: string; id?: string; name?: string; href?: string } |
78 | department?: { key?: string; id?: string; name?: string; href?: string } |
79 | location?: { key?: string; id?: string; name?: string; href?: string } |
80 | paymentTerm?: { key?: string; id?: string; href?: string } |
81 | customerUser?: { key?: string; id?: string; href?: string } |
82 | class?: { key?: string; id?: string; name?: string; href?: string } |
83 | userRestrictions?: 'systemDefault' | 'anyUser' | 'projectUsers' | 'projectTaskUsers' |
84 | isBillableEmployeeExpense?: false | true |
85 | isBillablePurchasingAPExpense?: false | true |
86 | ratesAndPricing?: { |
87 | laborPricing?: 'billingRate' | 'costPlusFee' |
88 | laborMarkup?: string |
89 | expensePricing?: 'billingRate' | 'costPlusFee' |
90 | expenseMarkup?: string |
91 | defaultRate?: string |
92 | purchasingAPPricing?: 'costPlusFee' |
93 | } |
94 | contacts?: { |
95 | primary?: { key?: string; id?: string; href?: string } |
96 | billTo?: { key?: string; id?: string; href?: string } |
97 | shipTo?: { key?: string; id?: string; href?: string } |
98 | } |
99 | invoiceMessage?: string |
100 | invoiceCurrency?: string |
101 | billingOverMax?: 'doNothing' | 'issueAWarningMessage' | 'preventBilling' |
102 | excludeExpenses?: false | true |
103 | contract?: { key?: string; id?: string; href?: string } |
104 | attachment?: { key?: string; id?: string; href?: string } |
105 | grant?: { |
106 | aln?: string |
107 | fundedProjectName?: string |
108 | agency?: string |
109 | payer?: 'federal' | 'thirdParty' |
110 | otherId?: string |
111 | assistanceType?: 'cash' | 'nonCash' |
112 | revenueRestriction?: 'purpose' | 'time' | 'NA' |
113 | restrictionExpiry?: string |
114 | restrictionExpirationDate?: string |
115 | isTimeSatisfactionScheduled?: false | true |
116 | } |
117 | scopeDetails?: { |
118 | scope?: string |
119 | inclusions?: string |
120 | exclusions?: string |
121 | terms?: string |
122 | } |
123 | scheduleDetails?: { |
124 | scheduledStartDate?: string |
125 | scheduledCompletionDate?: string |
126 | actualStartDate?: string |
127 | actualCompletionDate?: string |
128 | revisedCompletionDate?: string |
129 | substantialCompletionDate?: string |
130 | noticeToProceedDate?: string |
131 | responseDueDate?: string |
132 | executedOnDate?: string |
133 | scheduleImpactNotes?: string |
134 | } |
135 | multiEntityLocation?: { |
136 | key?: string |
137 | id?: string |
138 | name?: string |
139 | href?: string |
140 | } |
141 | status?: 'active' | 'inactive' |
142 | entity?: { key?: string; id?: string; name?: string; href?: string } |
143 | audit?: { |
144 | createdDateTime?: string |
145 | modifiedDateTime?: string |
146 | createdBy?: string |
147 | modifiedBy?: string |
148 | } |
149 | } & { id?: {} } |
150 | ) { |
151 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/projects/project/${key}`) |
152 |
|
153 | const response = await fetch(url, { |
154 | method: 'PATCH', |
155 | headers: { |
156 | 'Content-Type': 'application/json', |
157 | Authorization: 'Bearer ' + auth.token |
158 | }, |
159 | body: JSON.stringify(body) |
160 | }) |
161 | if (!response.ok) { |
162 | const text = await response.text() |
163 | throw new Error(`${response.status} ${text}`) |
164 | } |
165 | return await response.json() |
166 | } |
167 |
|