-
Notifications
You must be signed in to change notification settings - Fork 2
/
invoice_model.go
144 lines (128 loc) · 5.47 KB
/
invoice_model.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
package model
import "strings"
type InvoicePaymentSummary struct {
Label string `json:"label"`
Value string `json:"value"`
Key string `json:"key"`
Typename string `json:"__typename"`
}
type InvoiceShippingData struct {
ShippingAddress string `json:"shipping_address"`
ShippingCourier string `json:"shipping_courier"`
ShippingWeight string `json:"shipping_weight"`
ReceiverName string `json:"receiver_name"`
ReceiverPhone string `json:"receiver_phone"`
IsBebasOngkir bool `json:"is_bebas_ongkir"`
BebasOngkirImgURL string `json:"bebas_ongkir_img_url"`
IsShippingInsurance bool `json:"is_shipping_insurance"`
ShippingInsuranceLabel string `json:"shipping_insurance_label"`
Typename string `json:"__typename"`
}
type InvoiceDropshipInfo struct {
Name string `json:"name"`
Phone string `json:"phone"`
Typename string `json:"__typename"`
}
type TokopediaMerchandise struct {
Name string `json:"name"`
Address string `json:"address"`
Npwp string `json:"npwp"`
WordingPpn string `json:"wording_ppn"`
IsStampDuty bool `json:"is_stamp_duty"`
WordingStampDuty string `json:"wording_stamp_duty"`
Typename string `json:"__typename"`
}
type InvoiceFeatures struct {
PartialFulfillment any `json:"partial_fulfillment"`
Typename string `json:"__typename"`
}
type InvoiceDetailNonBundle struct {
ProductID int64 `json:"product_id"`
ProductName string `json:"product_name"`
ProductPrice string `json:"product_price"`
ProductPriceTotal string `json:"product_price_total"`
ProductQty int `json:"product_qty"`
ProductSkuID string `json:"product_sku_id"`
ProductWeight string `json:"product_weight"`
ProductNotes string `json:"product_notes"`
ProductCashbackLabel string `json:"product_cashback_label"`
ProductSnapshotURL string `json:"product_snapshot_url"`
IsPpp bool `json:"is_ppp"`
AddonSummary any `json:"addon_summary"`
Typename string `json:"__typename"`
}
type InvoiceOrderDataDetail struct {
Bundles []any `json:"bundles"`
NonBundles []*InvoiceDetailNonBundle `json:"non_bundles"`
BundleIcon string `json:"bundle_icon"`
TotalProducts int `json:"total_products"`
AddonIcon string `json:"addon_icon"`
AddonLabel string `json:"addon_label"`
BmgmIcon string `json:"bmgm_icon"`
Bmgms []any `json:"bmgms"`
Typename string `json:"__typename"`
}
type InvoiceOrderData struct {
InvoiceDate string `json:"invoice_date"`
InvoiceRefNum string `json:"invoice_ref_num"`
Status string `json:"status"`
UpdateTime string `json:"update_time"`
ShopName string `json:"shop_name"`
CustomerName string `json:"customer_name"`
IsTokoCabang bool `json:"is_toko_cabang"`
IsPreOrder bool `json:"is_pre_order"`
PreOrderDay string `json:"pre_order_day"`
AdditionalStatusLabel string `json:"additional_status_label"`
HaveProductBundle bool `json:"have_product_bundle"`
PaymentSummaryInvoice []*InvoicePaymentSummary `json:"payment_summary_invoice"`
ShippingData *InvoiceShippingData `json:"shipping_data"`
DropshipInfo *InvoiceDropshipInfo `json:"dropship_info"`
TokopediaMerchandise *TokopediaMerchandise `json:"tokopedia_merchandise"`
AddonInfo any `json:"addon_info"`
Features *InvoiceFeatures `json:"features"`
Details *InvoiceOrderDataDetail `json:"details"`
Typename string `json:"__typename"`
}
type Invoice struct {
OrderData []InvoiceOrderData `json:"order_data"`
PaymentData struct {
PaymentMethod []struct {
Name string `json:"name"`
ImgURL string `json:"img_url"`
Amount string `json:"amount"`
InstallmentDetail string `json:"installment_detail"`
Typename string `json:"__typename"`
} `json:"payment_method"`
PaymentDetails []any `json:"payment_details"`
OrderCount int `json:"order_count"`
Orders []any `json:"orders"`
VoucherDetails []any `json:"voucher_details"`
VoucherDisclaimer string `json:"voucher_disclaimer"`
VoucherDisclaimerDisplayType int `json:"voucher_disclaimer_display_type"`
Typename string `json:"__typename"`
} `json:"payment_data"`
Typename string `json:"__typename"`
}
type GetInvoiceV3 struct {
Invoices []*Invoice `json:"invoices"`
Typename string `json:"__typename"`
}
type InvoiceData struct {
GetInvoiceV3 *GetInvoiceV3 `json:"get_invoice_v3"`
}
type InvoiceRes struct {
Data *InvoiceData `json:"data"`
}
func (inv *InvoiceRes) IsCod() bool {
invoices := inv.Data.GetInvoiceV3.Invoices
if len(invoices) > 0 {
for _, paymetd := range invoices[0].PaymentData.PaymentMethod {
payname := strings.ToLower(paymetd.Name)
isCod := strings.Contains(payname, "cod")
if isCod {
return true
}
}
}
return false
}