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