-
Notifications
You must be signed in to change notification settings - Fork 4
/
report_turnover_service.go
57 lines (49 loc) · 3.52 KB
/
report_turnover_service.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
package moysklad
import (
"context"
"fmt"
"github.com/go-resty/resty/v2"
)
// ReportTurnoverService
// Сервис для работы с отчётом "Обороты".
type ReportTurnoverService struct {
Endpoint
}
func NewReportTurnoverService(client *Client) *ReportTurnoverService {
e := NewEndpoint(client, "report/turnover")
return &ReportTurnoverService{e}
}
// GetAll Запрос на получение отчета "Обороты по товарам".
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-oboroty-poluchit-oboroty-po-towaram
func (s *ReportTurnoverService) GetAll(ctx context.Context) (*List[TurnoverAll], *resty.Response, error) {
path := fmt.Sprintf("%s/all", s.uri)
return NewRequestBuilder[List[TurnoverAll]](s.client, path).Get(ctx)
}
// GetByStoreWithProduct Отчет обороты по товару и его модификациям с детализацией по складам.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-oboroty-oboroty-po-towaru-s-detalizaciej-po-skladam
func (s *ReportTurnoverService) GetByStoreWithProduct(ctx context.Context, product *Product) (*List[TurnoverByOperation], *resty.Response, error) {
path := fmt.Sprintf("%s/bystore", s.uri)
params := new(Params).WithFilterEquals("product", *product.Meta.Href)
return NewRequestBuilder[List[TurnoverByOperation]](s.client, path).SetParams(params).Get(ctx)
}
// GetByStoreWithVariant Отчет обороты по модификации с детализацией по складам.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-oboroty-oboroty-po-towaru-s-detalizaciej-po-skladam
func (s *ReportTurnoverService) GetByStoreWithVariant(ctx context.Context, variant *Variant) (*List[TurnoverByOperation], *resty.Response, error) {
path := fmt.Sprintf("%s/bystore", s.uri)
params := new(Params).WithFilterEquals("variant", *variant.Meta.Href)
return NewRequestBuilder[List[TurnoverByOperation]](s.client, path).SetParams(params).Get(ctx)
}
// GetByOperationsWithProduct Запрос на получение отчета Обороты по товару с детализацией по документам.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-oboroty-poluchit-oboroty-po-towaru-s-detalizaciej-po-dokumentam
func (s *ReportTurnoverService) GetByOperationsWithProduct(ctx context.Context, product *Product) (*List[TurnoverByOperation], *resty.Response, error) {
path := fmt.Sprintf("%s/byoperations", s.uri)
params := new(Params).WithFilterEquals("product", *product.Meta.Href)
return NewRequestBuilder[List[TurnoverByOperation]](s.client, path).SetParams(params).Get(ctx)
}
// GetByOperationsWithVariant Запрос на получение отчета Обороты по модификации с детализацией по документам.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-oboroty-poluchit-oboroty-po-towaru-s-detalizaciej-po-dokumentam
func (s *ReportTurnoverService) GetByOperationsWithVariant(ctx context.Context, variant *Variant) (*List[TurnoverByOperation], *resty.Response, error) {
path := fmt.Sprintf("%s/byoperations", s.uri)
params := new(Params).WithFilterEquals("variant", *variant.Meta.Href)
return NewRequestBuilder[List[TurnoverByOperation]](s.client, path).SetParams(params).Get(ctx)
}