-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceipt.go
40 lines (32 loc) · 874 Bytes
/
receipt.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
package receiptscanner
import (
"time"
)
type Receipt struct {
URL string
ID int64
Business string
DisplayDate string
Date time.Time
Subtotal float64
Tax float64
Total float64
}
func(r *Receipt) SetDate(t time.Time) {
r.Date = t
r.DisplayDate = t.Format("01/02/2006")
}
// ReceiptDatabase provides thread-safe access to a database of books.
type ReceiptDatabase interface {
// GetReceipt retrieves a book by its ID.
GetReceipt(id int64) (*Receipt, error)
// AddReceipt saves a given book, assigning it a new ID.
AddReceipt(b *Receipt) (id int64, err error)
// DeleteReceipt removes a given book by its ID.
DeleteReceipt(id int64) error
// UpdateReceipt updates the entry for a given book.
UpdateReceipt(b *Receipt) error
// Close closes the database, freeing up any available resources.
// TODO(cbro): Close() should return an error.
Close()
}