-
Notifications
You must be signed in to change notification settings - Fork 0
/
financial_line_read.go
218 lines (189 loc) · 7.69 KB
/
financial_line_read.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
package webservices
import (
"net/http"
"net/url"
"github.com/omniboost/go-exactglobe-webservices/edm"
"github.com/omniboost/go-exactglobe-webservices/odata"
"github.com/omniboost/go-exactglobe-webservices/utils"
)
func (c *Client) NewFinancialLineReadRequest() FinancialLineReadRequest {
return FinancialLineReadRequest{
client: c,
queryParams: c.NewFinancialLineReadQueryParams(),
pathParams: c.NewFinancialLineReadPathParams(),
method: http.MethodGet,
headers: http.Header{},
requestBody: c.NewFinancialLineReadRequestBody(),
}
}
type FinancialLineReadRequest struct {
client *Client
queryParams *FinancialLineReadQueryParams
pathParams *FinancialLineReadPathParams
method string
headers http.Header
requestBody FinancialLineReadRequestBody
}
func (c *Client) NewFinancialLineReadQueryParams() *FinancialLineReadQueryParams {
selectFields, _ := utils.Fields(&FinancialLine{})
return &FinancialLineReadQueryParams{
Select: odata.NewSelect(selectFields),
Filter: odata.NewFilter(),
Top: odata.NewTop(),
Skip: odata.NewSkip(),
}
}
type FinancialLineReadQueryParams struct {
// @TODO: check if this an OData struct or something
Select *odata.Select `schema:"$select,omitempty"`
Filter *odata.Filter `schema:"$filter,omitempty"`
Top *odata.Top `schema:"$top,omitempty"`
Skip *odata.Skip `schema:"$skip,omitempty"`
}
func (p FinancialLineReadQueryParams) ToURLValues() (url.Values, error) {
encoder := utils.NewSchemaEncoder()
params := url.Values{}
err := encoder.Encode(p, params)
if err != nil {
return params, err
}
return params, nil
}
func (r *FinancialLineReadRequest) QueryParams() *FinancialLineReadQueryParams {
return r.queryParams
}
func (c *Client) NewFinancialLineReadPathParams() *FinancialLineReadPathParams {
return &FinancialLineReadPathParams{}
}
type FinancialLineReadPathParams struct {
}
func (p *FinancialLineReadPathParams) Params() map[string]string {
return map[string]string{}
}
func (r *FinancialLineReadRequest) PathParams() *FinancialLineReadPathParams {
return r.pathParams
}
func (r *FinancialLineReadRequest) SetMethod(method string) {
r.method = method
}
func (r *FinancialLineReadRequest) Method() string {
return r.method
}
func (s *Client) NewFinancialLineReadRequestBody() FinancialLineReadRequestBody {
return FinancialLineReadRequestBody{}
}
type FinancialLineReadRequestBody FinancialLines
func (r *FinancialLineReadRequest) RequestBody() *FinancialLineReadRequestBody {
return &r.requestBody
}
func (r *FinancialLineReadRequest) SetRequestBody(body FinancialLineReadRequestBody) {
r.requestBody = body
}
func (r *FinancialLineReadRequest) NewResponseBody() *FinancialLineReadResponseBody {
return &FinancialLineReadResponseBody{}
}
type FinancialLineReadResponseBody struct {
D struct {
Results []struct {
Next string `json:"__next"`
MetaData edm.MetaData `json:"__metadata"`
FinancialLine
} `json:"results"`
Next string `json:"__next"`
} `json:"d"`
}
func (r *FinancialLineReadRequest) URL() url.URL {
return r.client.GetEndpointURL("FinancialLine", r.PathParams())
}
func (r *FinancialLineReadRequest) Do() (FinancialLineReadResponseBody, error) {
// Create http request
req, err := r.client.NewRequest(nil, r.Method(), r.URL(), r.RequestBody())
if err != nil {
return *r.NewResponseBody(), err
}
// Process query parameters
err = utils.AddQueryParamsToRequest(r.QueryParams(), req, false)
if err != nil {
return *r.NewResponseBody(), err
}
responseBody := r.NewResponseBody()
_, err = r.client.Do(req, responseBody)
return *responseBody, err
}
type FinancialLines []FinancialLine
type FinancialLine struct {
ID int `json:"ID"`
TransactionKey interface{} `json:"TransactionKey"`
FinancialYear int `json:"FinancialYear"`
FinancialPeriod int `json:"FinancialPeriod"`
SequenceNumber int `json:"SequenceNumber"`
EntryNumber string `json:"EntryNumber"`
Journal string `json:"Journal"`
LineNumber int `json:"LineNumber"`
EntryDate edm.Date `json:"EntryDate"`
GLAccount string `json:"GLAccount"`
Description string `json:"Description"`
CurrencyCode string `json:"CurrencyCode"`
CurrencyRate int `json:"CurrencyRate"`
Amount float64 `json:"Amount"`
VATBasis float64 `json:"VATBasis"`
VATAmount float64 `json:"VATAmount"`
VATCode string `json:"VATCode"`
CostCenter string `json:"CostCenter"`
CostCenterDescription string `json:"CostCenterDescription"`
CostUnit interface{} `json:"CostUnit"`
CostUnitDescription interface{} `json:"CostUnitDescription"`
FulfillmentDate edm.Date `json:"FulfillmentDate"`
DebtorNumber interface{} `json:"DebtorNumber"`
DebtorName interface{} `json:"DebtorName"`
CreditorNumber interface{} `json:"CreditorNumber"`
CreditorName interface{} `json:"CreditorName"`
Resource int `json:"Resource"`
FullName string `json:"FullName"`
OurReference string `json:"OurReference"`
YourReference string `json:"YourReference"`
Quantity int `json:"Quantity"`
SerialNumber interface{} `json:"SerialNumber"`
ItemCode string `json:"ItemCode"`
Project interface{} `json:"Project"`
ProjectDescription interface{} `json:"ProjectDescription"`
Warehouse string `json:"Warehouse"`
WarehouseLocation string `json:"WarehouseLocation"`
OrderNumber interface{} `json:"OrderNumber"`
ReportingDate edm.Date `json:"ReportingDate"`
Textfield1 interface{} `json:"Textfield1"`
Textfield2 interface{} `json:"Textfield2"`
Textfield3 interface{} `json:"Textfield3"`
NumberField1 int `json:"NumberField1"`
NumberField2 int `json:"NumberField2"`
TaxCode2 interface{} `json:"TaxCode2"`
TaxCode3 interface{} `json:"TaxCode3"`
TaxCode4 interface{} `json:"TaxCode4"`
TaxCode5 interface{} `json:"TaxCode5"`
TaxBasis2 int `json:"TaxBasis2"`
TaxBasis3 int `json:"TaxBasis3"`
TaxBasis4 int `json:"TaxBasis4"`
TaxBasis5 int `json:"TaxBasis5"`
TaxAmount2 int `json:"TaxAmount2"`
TaxAmount3 int `json:"TaxAmount3"`
TaxAmount4 int `json:"TaxAmount4"`
TaxAmount5 int `json:"TaxAmount5"`
OrderDebtor interface{} `json:"OrderDebtor"`
TransactionType string `json:"TransactionType"`
EntryType string `json:"EntryType"`
BankAccount interface{} `json:"BankAccount"`
PaymentMethod interface{} `json:"PaymentMethod"`
PaymentCondition interface{} `json:"PaymentCondition"`
PaymentReference interface{} `json:"PaymentReference"`
CSSDDueDate edm.Date `json:"CSSDDueDate"`
CSSDDueDate2 edm.Date `json:"CSSDDueDate2"`
InvoiceDueDate edm.Date `json:"InvoiceDueDate"`
TransactionOrigin string `json:"TransactionOrigin"`
DocumentID interface{} `json:"DocumentID"`
DocAttachmentID interface{} `json:"DocAttachmentID"`
Shipment interface{} `json:"Shipment"`
UnitCode string `json:"UnitCode"`
PriceList interface{} `json:"PriceList"`
Discount interface{} `json:"Discount"`
BankTransactionGUID interface{} `json:"BankTransactionGUID"`
}