This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
payslips.go
47 lines (40 loc) · 1.37 KB
/
payslips.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
package factorial
import (
"encoding/json"
"net/url"
)
const (
payslipURL = "/api/v1/payslips"
)
// Payslip keeps the basic information related
// with payslips in Factorial
type Payslip struct {
ID int `json:"id"`
BaseCotizationInCents int `json:"base_cotization_in_cents"`
BaseIRPFInCents int `json:"base_irpf_in_cents"`
GrossSalaryInCents string `json:"gross_salary_in_cents"`
NetSalaryInCents string `json:"net_salary_in_cents"`
IRPFInCents bool `json:"irpf_in_cents"`
IRPFPercentage string `json:"irpf_percentage"`
IsLastPayslip bool `json:"is_last_payslip"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
EmployeeID int `json:"employee_id"`
Status string `json:"status"`
}
// ListPayslips gets all the payslips from your company
// you can filter this list by status, specific year and month,
// or get all payslips from a specific month and year
// with the from param: "from: {month: 12, year: 2019}".
func (c Client) ListPayslips(filter url.Values) ([]Payslip, error) {
var payslips []Payslip
resp, err := c.get(payslipURL, filter)
if err != nil {
return payslips, err
}
defer resp.Body.Close()
if err := json.NewDecoder(resp.Body).Decode(&payslips); err != nil {
return payslips, err
}
return payslips, nil
}