-
Notifications
You must be signed in to change notification settings - Fork 4
/
report_counterparty.go
58 lines (51 loc) · 2.44 KB
/
report_counterparty.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
package moysklad
import "github.com/shopspring/decimal"
// ReportCounterparty Показатели контрагентов.
// Ключевое слово: counterparty
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-pokazateli-kontragentow-pokazateli-kontragentow
type ReportCounterparty struct {
FirstDemandDate Timestamp `json:"firstDemandDate"`
Updated Timestamp `json:"updated"`
LastEventDate Timestamp `json:"lastEventDate"`
LastDemandDate Timestamp `json:"lastDemandDate"`
Counterparty CounterpartyData `json:"counterparty"`
Meta Meta `json:"meta"`
DiscountsSum decimal.Decimal `json:"discountsSum"`
LastEventText string `json:"lastEventText"`
DemandsSum decimal.Decimal `json:"demandsSum"`
AverageReceipt decimal.Decimal `json:"averageReceipt"`
BonusBalance decimal.Decimal `json:"bonusBalance"`
Profit decimal.Decimal `json:"profit"`
ReturnsSum decimal.Decimal `json:"returnsSum"`
Balance decimal.Decimal `json:"balance"`
DemandsCount int `json:"demandsCount"`
ReturnsCount int `json:"returnsCount"`
}
// CounterpartyData Контрагент
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/reports/#otchety-otchet-pokazateli-kontragentow-dopolnitel-nye-atributy-dostupnye-dlq-fil-tracii-kontragent
type CounterpartyData struct {
CompanyType CompanyType `json:"companyType"` // Тип контрагента
ExternalCode string `json:"externalCode"` // Внешний код контрагента
ID string `json:"id"` // ID Контрагента
Meta Meta `json:"meta"` // Метаданные Контрагента
Name string `json:"name"` // Наименование Контрагента
}
func (r ReportCounterparty) MetaType() MetaType {
return MetaTypeReportCounterparty
}
type CounterpartyElement struct {
Counterparty MetaWrapper `json:"counterparty"`
}
type CounterpartiesMeta struct {
Counterparties Slice[CounterpartyElement] `json:"counterparties"`
}
func (c *CounterpartiesMeta) Push(elements ...*Counterparty) {
for _, element := range elements {
ce := &CounterpartyElement{
Counterparty: MetaWrapper{
Meta: *element.GetMeta(),
},
}
c.Counterparties = append(c.Counterparties, ce)
}
}