1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a project contract |
7 | * Updates an existing project contract by setting field values. Any fields not provided remain unchanged. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | key: string, |
12 | body: { |
13 | key?: string |
14 | id?: string |
15 | href?: string |
16 | name?: string |
17 | project?: { key?: string; id?: string; name?: string; href?: string } |
18 | location?: { key?: string; id?: string; name?: string; href?: string } |
19 | customer?: { key?: string; id?: string; name?: string; href?: string } |
20 | contractDate?: string |
21 | description?: string |
22 | projectContractType?: { key?: string; id?: string; href?: string } |
23 | architect?: { key?: string; id?: string; href?: string } |
24 | isBillable?: false | true |
25 | attachment?: { key?: string; id?: string; href?: string } |
26 | status?: 'active' | 'inactive' |
27 | summary?: { |
28 | totalPrice?: string |
29 | originalPrice?: string |
30 | revisionPrice?: string |
31 | approvedChangePrice?: string |
32 | pendingChangePrice?: string |
33 | otherPrice?: string |
34 | forecastPrice?: string |
35 | } |
36 | billing?: { |
37 | billedPrice?: string |
38 | totalBilledNetRetainage?: string |
39 | percentBilled?: string |
40 | percentBilledNetRetainage?: string |
41 | totalRetainageHeld?: string |
42 | totalRetainageReleased?: string |
43 | retainageBalance?: string |
44 | balanceToBill?: string |
45 | balanceToBillNetRetainage?: string |
46 | totalPaymentsReceived?: string |
47 | netTotalBilled?: string |
48 | netTotalPaymentsReceived?: string |
49 | subtotalBilledAsTax?: string |
50 | subtotalBilledAsDiscount?: string |
51 | subtotalBilledAsCharge?: string |
52 | lastApplicationNumber?: string |
53 | } |
54 | excludeFromWIPReporting?: false | true |
55 | scope?: string |
56 | inclusions?: string |
57 | exclusions?: string |
58 | terms?: string |
59 | schedule?: { |
60 | scheduledStartDate?: string |
61 | actualStartDate?: string |
62 | scheduledCompletionDate?: string |
63 | revisedCompletionDate?: string |
64 | substantialCompletionDate?: string |
65 | actualCompletionDate?: string |
66 | noticeToProceedDate?: string |
67 | responseDueDate?: string |
68 | executedOnDate?: string |
69 | scheduleImpact?: string |
70 | } |
71 | internalReference?: { |
72 | referenceNumber?: string |
73 | initiatedBy?: { key?: string; id?: string; name?: string; href?: string } |
74 | verbalApprovalBy?: { |
75 | key?: string |
76 | id?: string |
77 | name?: string |
78 | href?: string |
79 | } |
80 | issuedBy?: { key?: string; id?: string; name?: string; href?: string } |
81 | issuedOnDate?: string |
82 | approvedBy?: { key?: string; id?: string; name?: string; href?: string } |
83 | approvedOnDate?: string |
84 | signedBy?: { key?: string; id?: string; name?: string; href?: string } |
85 | signedOnDate?: string |
86 | source?: string |
87 | sourceReferenceNumber?: string |
88 | } |
89 | externalReference?: { |
90 | referenceNumber?: string |
91 | verbalApprovalBy?: { key?: string; id?: string; href?: string } |
92 | approvedBy?: { key?: string; id?: string; href?: string } |
93 | approvedOnDate?: string |
94 | signedBy?: { key?: string; id?: string; href?: string } |
95 | signedOnDate?: string |
96 | } |
97 | audit?: { |
98 | createdDateTime?: string |
99 | modifiedDateTime?: string |
100 | createdBy?: string |
101 | modifiedBy?: string |
102 | } |
103 | entity?: { key?: string; id?: string; name?: string; href?: string } |
104 | } & { id?: {} } |
105 | ) { |
106 | const url = new URL( |
107 | `https://api.intacct.com/ia/api/v1/objects/construction/project-contract/${key}` |
108 | ) |
109 |
|
110 | const response = await fetch(url, { |
111 | method: 'PATCH', |
112 | headers: { |
113 | 'Content-Type': 'application/json', |
114 | Authorization: 'Bearer ' + auth.token |
115 | }, |
116 | body: JSON.stringify(body) |
117 | }) |
118 | if (!response.ok) { |
119 | const text = await response.text() |
120 | throw new Error(`${response.status} ${text}`) |
121 | } |
122 | return await response.json() |
123 | } |
124 |
|