-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrispaystatement.go
390 lines (339 loc) · 13.3 KB
/
hrispaystatement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"github.com/Finch-API/finch-api-go/internal/apijson"
"github.com/Finch-API/finch-api-go/internal/param"
"github.com/Finch-API/finch-api-go/internal/requestconfig"
"github.com/Finch-API/finch-api-go/option"
"github.com/Finch-API/finch-api-go/packages/pagination"
"github.com/Finch-API/finch-api-go/shared"
)
// HRISPayStatementService contains methods and other services that help with
// interacting with the Finch API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewHRISPayStatementService] method instead.
type HRISPayStatementService struct {
Options []option.RequestOption
}
// NewHRISPayStatementService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewHRISPayStatementService(opts ...option.RequestOption) (r *HRISPayStatementService) {
r = &HRISPayStatementService{}
r.Options = opts
return
}
// Read detailed pay statements for each individual.
//
// Deduction and contribution types are supported by the payroll systems that
// supports Benefits.
func (r *HRISPayStatementService) GetMany(ctx context.Context, body HRISPayStatementGetManyParams, opts ...option.RequestOption) (res *pagination.ResponsesPage[PayStatementResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "employer/pay-statement"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Read detailed pay statements for each individual.
//
// Deduction and contribution types are supported by the payroll systems that
// supports Benefits.
func (r *HRISPayStatementService) GetManyAutoPaging(ctx context.Context, body HRISPayStatementGetManyParams, opts ...option.RequestOption) *pagination.ResponsesPageAutoPager[PayStatementResponse] {
return pagination.NewResponsesPageAutoPager(r.GetMany(ctx, body, opts...))
}
type PayStatement struct {
// The array of earnings objects associated with this pay statement
Earnings []PayStatementEarning `json:"earnings,nullable"`
// The array of deductions objects associated with this pay statement.
EmployeeDeductions []PayStatementEmployeeDeduction `json:"employee_deductions,nullable"`
EmployerContributions []PayStatementEmployerContribution `json:"employer_contributions,nullable"`
GrossPay Money `json:"gross_pay,nullable"`
// A stable Finch `id` (UUID v4) for an individual in the company
IndividualID string `json:"individual_id"`
NetPay Money `json:"net_pay,nullable"`
// The payment method.
PaymentMethod PayStatementPaymentMethod `json:"payment_method,nullable"`
// The array of taxes objects associated with this pay statement.
Taxes []PayStatementTax `json:"taxes,nullable"`
// The number of hours worked for this pay period
TotalHours float64 `json:"total_hours,nullable"`
// The type of the payment associated with the pay statement.
Type PayStatementType `json:"type,nullable"`
JSON payStatementJSON `json:"-"`
}
// payStatementJSON contains the JSON metadata for the struct [PayStatement]
type payStatementJSON struct {
Earnings apijson.Field
EmployeeDeductions apijson.Field
EmployerContributions apijson.Field
GrossPay apijson.Field
IndividualID apijson.Field
NetPay apijson.Field
PaymentMethod apijson.Field
Taxes apijson.Field
TotalHours apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatement) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementJSON) RawJSON() string {
return r.raw
}
type PayStatementEarning struct {
// The earnings amount in cents.
Amount int64 `json:"amount,nullable"`
// The earnings currency code.
Currency string `json:"currency,nullable"`
// The number of hours associated with this earning. (For salaried employees, this
// could be hours per pay period, `0` or `null`, depending on the provider).
Hours float64 `json:"hours,nullable"`
// The exact name of the deduction from the pay statement.
Name string `json:"name,nullable"`
// The type of earning.
Type PayStatementEarningsType `json:"type,nullable"`
JSON payStatementEarningJSON `json:"-"`
}
// payStatementEarningJSON contains the JSON metadata for the struct
// [PayStatementEarning]
type payStatementEarningJSON struct {
Amount apijson.Field
Currency apijson.Field
Hours apijson.Field
Name apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementEarning) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementEarningJSON) RawJSON() string {
return r.raw
}
// The type of earning.
type PayStatementEarningsType string
const (
PayStatementEarningsTypeSalary PayStatementEarningsType = "salary"
PayStatementEarningsTypeWage PayStatementEarningsType = "wage"
PayStatementEarningsTypeReimbursement PayStatementEarningsType = "reimbursement"
PayStatementEarningsTypeOvertime PayStatementEarningsType = "overtime"
PayStatementEarningsTypeSeverance PayStatementEarningsType = "severance"
PayStatementEarningsTypeDoubleOvertime PayStatementEarningsType = "double_overtime"
PayStatementEarningsTypePto PayStatementEarningsType = "pto"
PayStatementEarningsTypeSick PayStatementEarningsType = "sick"
PayStatementEarningsTypeBonus PayStatementEarningsType = "bonus"
PayStatementEarningsTypeCommission PayStatementEarningsType = "commission"
PayStatementEarningsTypeTips PayStatementEarningsType = "tips"
PayStatementEarningsType1099 PayStatementEarningsType = "1099"
PayStatementEarningsTypeOther PayStatementEarningsType = "other"
)
func (r PayStatementEarningsType) IsKnown() bool {
switch r {
case PayStatementEarningsTypeSalary, PayStatementEarningsTypeWage, PayStatementEarningsTypeReimbursement, PayStatementEarningsTypeOvertime, PayStatementEarningsTypeSeverance, PayStatementEarningsTypeDoubleOvertime, PayStatementEarningsTypePto, PayStatementEarningsTypeSick, PayStatementEarningsTypeBonus, PayStatementEarningsTypeCommission, PayStatementEarningsTypeTips, PayStatementEarningsType1099, PayStatementEarningsTypeOther:
return true
}
return false
}
type PayStatementEmployeeDeduction struct {
// The deduction amount in cents.
Amount int64 `json:"amount,nullable"`
// The deduction currency.
Currency string `json:"currency,nullable"`
// The deduction name from the pay statement.
Name string `json:"name,nullable"`
// Boolean indicating if the deduction is pre-tax.
PreTax bool `json:"pre_tax,nullable"`
// Type of benefit.
Type BenefitType `json:"type,nullable"`
JSON payStatementEmployeeDeductionJSON `json:"-"`
}
// payStatementEmployeeDeductionJSON contains the JSON metadata for the struct
// [PayStatementEmployeeDeduction]
type payStatementEmployeeDeductionJSON struct {
Amount apijson.Field
Currency apijson.Field
Name apijson.Field
PreTax apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementEmployeeDeduction) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementEmployeeDeductionJSON) RawJSON() string {
return r.raw
}
type PayStatementEmployerContribution struct {
// The contribution amount in cents.
Amount int64 `json:"amount,nullable"`
// The contribution currency.
Currency string `json:"currency,nullable"`
// The contribution name from the pay statement.
Name string `json:"name,nullable"`
// Type of benefit.
Type BenefitType `json:"type,nullable"`
JSON payStatementEmployerContributionJSON `json:"-"`
}
// payStatementEmployerContributionJSON contains the JSON metadata for the struct
// [PayStatementEmployerContribution]
type payStatementEmployerContributionJSON struct {
Amount apijson.Field
Currency apijson.Field
Name apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementEmployerContribution) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementEmployerContributionJSON) RawJSON() string {
return r.raw
}
// The payment method.
type PayStatementPaymentMethod string
const (
PayStatementPaymentMethodCheck PayStatementPaymentMethod = "check"
PayStatementPaymentMethodDirectDeposit PayStatementPaymentMethod = "direct_deposit"
)
func (r PayStatementPaymentMethod) IsKnown() bool {
switch r {
case PayStatementPaymentMethodCheck, PayStatementPaymentMethodDirectDeposit:
return true
}
return false
}
type PayStatementTax struct {
// The tax amount in cents.
Amount int64 `json:"amount,nullable"`
// The currency code.
Currency string `json:"currency,nullable"`
// `true` if the amount is paid by the employers.
Employer bool `json:"employer,nullable"`
// The exact name of tax from the pay statement.
Name string `json:"name,nullable"`
// The type of taxes.
Type PayStatementTaxesType `json:"type,nullable"`
JSON payStatementTaxJSON `json:"-"`
}
// payStatementTaxJSON contains the JSON metadata for the struct [PayStatementTax]
type payStatementTaxJSON struct {
Amount apijson.Field
Currency apijson.Field
Employer apijson.Field
Name apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementTax) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementTaxJSON) RawJSON() string {
return r.raw
}
// The type of taxes.
type PayStatementTaxesType string
const (
PayStatementTaxesTypeState PayStatementTaxesType = "state"
PayStatementTaxesTypeFederal PayStatementTaxesType = "federal"
PayStatementTaxesTypeLocal PayStatementTaxesType = "local"
PayStatementTaxesTypeFica PayStatementTaxesType = "fica"
)
func (r PayStatementTaxesType) IsKnown() bool {
switch r {
case PayStatementTaxesTypeState, PayStatementTaxesTypeFederal, PayStatementTaxesTypeLocal, PayStatementTaxesTypeFica:
return true
}
return false
}
// The type of the payment associated with the pay statement.
type PayStatementType string
const (
PayStatementTypeRegularPayroll PayStatementType = "regular_payroll"
PayStatementTypeOffCyclePayroll PayStatementType = "off_cycle_payroll"
PayStatementTypeOneTimePayment PayStatementType = "one_time_payment"
)
func (r PayStatementType) IsKnown() bool {
switch r {
case PayStatementTypeRegularPayroll, PayStatementTypeOffCyclePayroll, PayStatementTypeOneTimePayment:
return true
}
return false
}
type PayStatementResponse struct {
Body PayStatementResponseBody `json:"body"`
Code int64 `json:"code"`
PaymentID string `json:"payment_id"`
JSON payStatementResponseJSON `json:"-"`
}
// payStatementResponseJSON contains the JSON metadata for the struct
// [PayStatementResponse]
type payStatementResponseJSON struct {
Body apijson.Field
Code apijson.Field
PaymentID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementResponseJSON) RawJSON() string {
return r.raw
}
type PayStatementResponseBody struct {
Paging shared.Paging `json:"paging"`
// The array of pay statements for the current payment.
PayStatements []PayStatement `json:"pay_statements"`
JSON payStatementResponseBodyJSON `json:"-"`
}
// payStatementResponseBodyJSON contains the JSON metadata for the struct
// [PayStatementResponseBody]
type payStatementResponseBodyJSON struct {
Paging apijson.Field
PayStatements apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *PayStatementResponseBody) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r payStatementResponseBodyJSON) RawJSON() string {
return r.raw
}
type HRISPayStatementGetManyParams struct {
// The array of batch requests.
Requests param.Field[[]HRISPayStatementGetManyParamsRequest] `json:"requests,required"`
}
func (r HRISPayStatementGetManyParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type HRISPayStatementGetManyParamsRequest struct {
// A stable Finch `id` (UUID v4) for a payment.
PaymentID param.Field[string] `json:"payment_id,required"`
// Number of pay statements to return (defaults to all).
Limit param.Field[int64] `json:"limit"`
// Index to start from.
Offset param.Field[int64] `json:"offset"`
}
func (r HRISPayStatementGetManyParamsRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}