forked from omniboost/go-fortnox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoice.go
188 lines (173 loc) · 17.1 KB
/
invoice.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
package fortnox
import (
"github.com/maokomioko/go-fortnox/utils"
"gopkg.in/guregu/null.v3"
)
type Invoices []Invoice
type Invoice struct {
URL utils.URL `json:"@url,omitempty"` // Direct url to the record.
UrlTaxReductionList string `json:"@UrlTaxReductionList,omitempty"` // Direct url to the tax reduction for the invoice. This is visible even if no tax reduction exists.
AccountingMethod string `json:"AccountingMethod"` // Accounting Method. Can be ACCRUAL orCASH
AdministrationFee float64 `json:"AdministrationFee"` // The invoice administration fee.
AdministrationFeeVAT float64 `json:"AdministrationFeeVAT,omitempty"` // VAT of the invoice administration fee.
Address1 string `json:"Address1"` // Invoice address 1.
Address2 string `json:"Address2"` // Invoice address 2.
Balance float64 `json:"Balance,omitempty"` // Balance of the invoice.
BasisTaxReduction float64 `json:"BasisTaxReduction,omitempty"` // Basis of tax reduction.
Booked null.Bool `json:"Booked"` // If the invoice is bookkept. This value can be changed by using the action “bookkeep”.
Cancelled null.Bool `json:"Cancelled,omitempty"` // If the invoice is cancelled. This value can be changed by using the action “cancel”.
Credit string `json:"Credit,omitempty"` // If the invoice is a credit invoice.
CreditInvoiceReference IntIsh `json:"CreditInvoiceReference,omitempty"` // Reference to the credit invoice, if one exits. The reference must be a document number for an existing credit invoice.
City string `json:"City,omitempty"` // City for the invoice address.
Comments string `json:"Comments"` // Comments of the invoice
ContractReference IntIsh `json:"ContractReference,omitempty"` // Reference to the contract, if one exists.
ContributionPercent FloatIsh `json:"ContributionPercent,omitempty"` // Invoice contribution in percent.
ContributionValue FloatIsh `json:"ContributionValue,omitempty"` // Invoice contribution in amount.
Country string `json:"Country"` // Country for the invoice address. Must be a name of an existing country.
CostCenter string `json:"CostCenter,omitempty"` // Code of the cost center. The code must be of an existing cost center.
Currency string `json:"Currency"` // Code of the currency. The code must be of an existing currency.
CurrencyRate Number `json:"CurrencyRate,omitempty"` // Currency rate used for the invoice.
CurrencyUnit float64 `json:"CurrencyUnit,omitempty"` // Currency unit used for the invoice.
CustomerName string `json:"CustomerName"` // Name of the customer.
CustomerNumber string `json:"CustomerNumber"` // Customer number of the customer. The customer number must be of an existing customer.
DeliveryAddress1 string `json:"DeliveryAddress1"` // Invoice delivery address 1.
DeliveryAddress2 string `json:"DeliveryAddress2"` // Invoice delivery address 2.
DeliveryCity string `json:"DeliveryCity"` // City for the invoice delivery address.
DeliveryCountry string `json:"DeliveryCountry"` // Country for the invoice delivery address. Must be a name of an existing country.
DeliveryDate Date `json:"DeliveryDate"` // Date of delivery. Must be a valid date according to our date format.
DeliveryName string `json:"DeliveryName"` // Name of the recipient of the delivery
DeliveryZipCode string `json:"DeliveryZipCode"` // ZipCode for the invoice delivery address.
DocumentNumber string `json:"DocumentNumber"` // The invoice number. If no document number is provided, the next number in the series will be used.
DueDate Date `json:"DueDate"` // Due date of the invoice. Must be a valid date according to our date format.
EDIInformation *EDIInformation `json:"EDIInformation,omitempty"` // The properties for this object is listed in the table for “EDI Information”.
EmailInformation *EmailInformation `json:"EmailInformation,omitempty"` // The properties for this object is listed in the table for “Email Information”.
EUQuarterlyReport bool `json:"EUQuarterlyReport"` // EU Quarterly Report On / Off
ExternalInvoiceReference1 string `json:"ExternalInvoiceReference1"` // External invoice reference 1.
ExternalInvoiceReference2 string `json:"ExternalInvoiceReference2"` // External invoice reference 1.
FinalPayDate Date `json:"FinalPayDate,omitempty"` // The date when the invoice became fully paid. Only available if the invoice is fully paid.
Freight float64 `json:"Freight"` // Freight cost of the invoice.
FreightVAT float64 `json:"FreightVAT,omitempty"` // VAT of the freight cost.
Gross float64 `json:"Gross,omitempty"` // Gross value of the invoice
HouseWork null.Bool `json:"HouseWork,omitempty"` // If there is any row of the invoice marked “house work”.
InvoiceDate Date `json:"InvoiceDate"` // Invoice date. Must be a valid date according to our date format.
InvoicePeriodStart Date `json:"InvoicePeriodStart,omitempty"` // Start date of the invoice period, only applicable for contract invoices.
InvoicePeriodEnd Date `json:"InvoicePeriodEnd,omitempty"` // End date of the invoice period, only applicable for contract invoices.
InvoiceReference IntIsh `json:"InvoiceReference,omitempty"`
InvoiceRows InvoiceRows `json:"InvoiceRows"` // The properties for the object in this array is listed in the table “Invoice Rows”.
InvoiceType InvoiceType `json:"InvoiceType"` // The type of invoice. Can be INVOICE AGREEMENTINVOICE INTRESTINVOICE SUMMARYINVOICE or CASHINVOICE.
Labels Labels `json:"Labels"` // The properties for the object in this array is listed in the table “Labels”
Language string `json:"Language"` // Language code. Can be SV or EN.
LastRemindDate Date `json:"LastRemindDate,omitempty"` // Date of last reminder.
Net float64 `json:"Net,omitempty"` // Net amount
NotCompleted bool `json:"NotCompleted"` // If the invoice is set as not completed.
NoxFinans null.Bool `json:"NoxFinans,omitempty"` // If the invoice is managed by NoxFinans
OCR string `json:"OCR"` // OCR number of the invoice.
OfferReference IntIsh `json:"OfferReference,omitempty"` // Reference to the offer, if one exists.
OrderReference IntIsh `json:"OrderReference,omitempty"` // Reference to the order, if one exists.
OrganisationNumber string `json:"OrganisationNumber,omitempty"` // Organisation number of the customer for the invoice.
OurReference string `json:"OurReference"` // Our reference.
PaymentWay PaymentWay `json:"PaymentWay,omitempty"` // CASH, CARD, AG
Phone1 string `json:"Phone1"` // Phone number 1 of the customer for the invoice.
Phone2 string `json:"Phone2"` // Phone number 2 of the customer for the invoice.
PriceList string `json:"PriceList"` // Code of the price list. The code must be of an existing price list.
PrintTemplate string `json:"PrintTemplate"` // Print template of the invoice. Must be an existing print template.
Project string `json:"Project"` // Code of the project. The code must be of an existing project.
WarehouseReady null.Bool `json:"WarehouseReady,omitempty"`
OutboundDate Date `json:"OutboundDate"`
Remarks string `json:"Remarks"` // Remarks of the invoice. This is the invoice text shown on the invoice.
Reminders int `json:"Reminders,omitempty"` // Number of reminders sent to the customer.
RoundOff float64 `json:"RoundOff,omitempty"` // Round off amount for the invoice.
Sent null.Bool `json:"Sent,omitempty"` // If the document is printed or sent in any way.
TaxReduction int `json:"TaxReduction,omitempty"` // The amount of tax reduction.
TaxReductionType string `json:"TaxReductionType,omitempty"` // The type of tax reduction. ROT, RUT, GREEN, NONE.
TermsOfDelivery string `json:"TermsOfDelivery"` // Code of the terms of delivery. The code must be of an existing terms of delivery.
TermsOfPayment StringIsh `json:"TermsOfPayment"` // Code of the terms of payment. The code must be of an existing terms of payment.
TimeBasisReference int `json:"TimeBasisReference,omitempty"` // Reference to the time basis, if one exists.
Total float64 `json:"Total,omitempty"` // The total amount of the invoice.
TotalVAT float64 `json:"TotalVAT,omitempty"` // The total VAT amount of the invoice.
TotalToPay int `json:"TotalToPay,omitempty"`
VATIncluded bool `json:"VATIncluded"` // If the price of the invoice is including VAT.
VoucherNumber int `json:"VoucherNumber,omitempty"` // Voucher number for the invoice. This is created when the invoice is bookkept.
VoucherSeries string `json:"VoucherSeries,omitempty"` // Voucher series for the invoice. This is created when the invoice is bookkept.
VoucherYear int `json:"VoucherYear,omitempty"` // Voucher year for the invoice. This is created when the invoice is bookkept.
WayOfDelivery string `json:"WayOfDelivery,omitempty"` // Code of the way of delivery. The code must be of an existing way of delivery.
YourOrderNumber string `json:"YourOrderNumber"` // Your order number.
YourReference string `json:"YourReference"` // Your reference.
ZipCode string `json:"ZipCode"` // Zip code of the invoice.
}
type EDIInformation struct {
EDIGlobalLocationNumber string `json:"EDIGlobalLocationNumber"` // Invoice address GLN for EDI
EDIGlobalLocationNumberDelivery string `json:"EDIGlobalLocationNumberDelivery"` // Delivery address GLN for EDI
EDIInvoiceExtra1 string `json:"EDIInvoiceExtra1"` // Extra EDI Information
EDIInvoiceExtra2 string `json:"EDIInvoiceExtra2"` // Extra EDI Information
EDIOurElectronicReference string `json:"EDIOurElectronicReference"` // Our electronic reference for EDI
EDIYourElectronicReference string `json:"EDIYourElectronicReference"` // Your electronic reference for EDI
EDIStatus EDIStatus `json:"EDIStatus,omitempty"` // Status of the send process of the invoice. Can have the following codes:
}
type EDIStatus string
var (
EDIStatusSentToCrediflow EDIStatus = "1"
EDIStatusCheckedByCrediflow EDIStatus = "2"
EDIStatusDeliveredElectronically EDIStatus = "3"
EDIStatusDeliveredToPrintingService EDIStatus = "4"
EDIStatusDeliveredToPostenByPrintCompany EDIStatus = "5"
EDIStatusDeclinedByCrediflow EDIStatus = "6"
EDIStatusDeclinedByReceiver EDIStatus = "7"
)
type EmailInformation struct {
EmailAddressFrom string `json:"EmailAddressFrom"` // Reply to adress. Must be a valid e-mail address
EmailAddressTo string `json:"EmailAddressTo"` // Customer e-mail address. Must be a valid e-mail address.
EmailAddressCC string `json:"EmailAddressCC"` // Customer e-mail address – Copy. Must be a valid e-mail address.
EmailAddressBCC string `json:"EmailAddressBCC"` // Customer e-mail address – Blind carbon copy. Must be a valid e-mail address.
EmailSubject string `json:"EmailSubject"` // Subject of the e-mail
// The variable {no} = document number. The variable {name} = customer name
EmailBody string `json:"EmailBody"` // Body of the e-mail.
}
type InvoiceRows []InvoiceRow
type InvoiceRow struct {
RowId int `json:"RowId,omitempty"` // Row ID from Fortnox response
AccountNumber int `json:"AccountNumber"` // Account number. If not provided the predefined account will be used.
ArticleNumber string `json:"ArticleNumber"` // Article number.
ContributionPercent FloatIsh `json:"ContributionPercent,omitempty"` // Contribution Percent.
ContributionValue FloatIsh `json:"ContributionValue,omitempty"` // Contribution Value.
CostCenter string `json:"CostCenter,omitempty"` // Code of the cost center for the row. The code must be of an existing cost center.
DeliveredQuantity string `json:"DeliveredQuantity"` // Delivered quantity.
Description string `json:"Description"` // Row description.
Discount float64 `json:"Discount"` // Discount amount.
// 12 digits (for amount) / 5 digits (for percent)
DiscountType string `json:"DiscountType"` // The type of discount used for the row. Can be AMOUNT or PERCENT.
HouseWork bool `json:"HouseWork"` // If the row is housework
HouseWorkHoursToReport int `json:"HouseWorkHoursToReport"` // Hours to be reported if the quantity of the row should not be used as hours.
HouseWorkType string `json:"HouseWorkType"` // The type of house work. Can be
// CONSTRUCTIONELECTRICITYGLASSMETALWORK
// GROUNDDRAINAGEWORKMASONRY
// PAINTINGWALLPAPERINGHVACMAJORAPPLIANCEREPAIR
// MOVINGSERVICESITSERVICESCLEANINGTEXTILECLOTHINGSNOWPLOWING
// GARDENINGBABYSITTINGOTHERCAREOTHERCOSTS or empty.
Price float64 `json:"Price"` // Price per unit
PriceExcludingVAT float64 `json:"PriceExcludingVAT,omitempty"` // Price per unit excluding VAT (regardless of value of VATIncluded flag)
Project string `json:"Project,omitempty"` // Code of the project for the row. The code must be of an existing project.
StockPointCode string `json:"StockPointCode,omitempty"`
Total float64 `json:"Total,omitempty"` // Total amount for the row.
TotalExcludingVAT float64 `json:"TotalExcludingVAT,omitempty"` // Total amount for the row excluding VAT (regardless of value of VATIncluded flag)
Unit string `json:"Unit"` // Code of the unit for the row. The code must be of an existing unit.
VAT int `json:"VAT"` // VAT percentage of the row. The percentage needs to be of an existing VAT percentage.
}
type InvoiceType string
var (
InvoiceTypeInvoice InvoiceType = "INVOICE"
InvoiceTypeAgreementInvoice InvoiceType = "AGREEMENTINVOICE"
InvoiceTypeIntrestInvoice InvoiceType = "INTRESTINVOICE"
InvoiceTypeSummaryInvoice InvoiceType = "SUMMARYINVOICE"
InvoiceTypeCashInvoice InvoiceType = "CASHINVOICE"
)
type Labels []Label
type Label struct {
ID string `json:"Id"` // Id of the label.
}
type PaymentWay string
var (
PaymentWayCash PaymentWay = "CASH" // Payment Way is set to Cash payment
PaymentWayCard PaymentWay = "Card" // Payment Way is set to Card.
PaymentWayAG PaymentWay = "AG" // Payment Way is set to Direct debit
)