@@ -10,7 +10,7 @@ import (
10
10
"unicode/utf8"
11
11
12
12
"github.com/LucaBernstein/beancount-bot-tg/db/crud"
13
- "github.com/LucaBernstein/beancount-bot-tg/helpers"
13
+ . "github.com/LucaBernstein/beancount-bot-tg/helpers"
14
14
tb "gopkg.in/tucnak/telebot.v2"
15
15
)
16
16
@@ -96,14 +96,6 @@ type SimpleTx struct {
96
96
step int
97
97
}
98
98
99
- const (
100
- STX_DESC = "txDesc"
101
- STX_DATE = "txDate"
102
- STX_ACCF = "accFrom"
103
- STX_AMTF = "amountFrom"
104
- STX_ACCT = "accTo"
105
- )
106
-
107
99
func CreateSimpleTx () Tx {
108
100
return (& SimpleTx {
109
101
stepDetails : make (map [command ]Input ),
@@ -112,7 +104,7 @@ func CreateSimpleTx() Tx {
112
104
addStep ("from" , "Please enter the account the money came from (or select one from the list)" , HandleRaw ).
113
105
addStep ("to" , "Please enter the account the money went to (or select one from the list)" , HandleRaw ).
114
106
addStep ("description" , "Please enter a description (or select one from the list)" , HandleRaw ).
115
- addStep ("date" , "Please enter the transaction data in the format YYYY-MM-DD (or select one from the list, e.g. 'today')" , HandleDate )
107
+ addStep ("date" , "Please enter the transaction data in the format YYYY-MM-DD (or type 't' / 'today')" , HandleDate )
116
108
}
117
109
118
110
func (tx * SimpleTx ) addStep (command command , hint string , handler func (m * tb.Message ) (string , error )) Tx {
@@ -146,9 +138,9 @@ func (tx *SimpleTx) EnrichHint(r *crud.Repo, m *tb.Message, i Input) *Hint {
146
138
return tx .hintDescription (r , m , i .hint )
147
139
}
148
140
if i .key == "date" {
149
- return tx .hintDate (r , m , i .hint )
141
+ return tx .hintDate (i .hint )
150
142
}
151
- if helpers . ArrayContains ([]string {"from" , "to" }, i .key ) {
143
+ if ArrayContains ([]string {"from" , "to" }, i .key ) {
152
144
return tx .hintAccount (r , m , i )
153
145
}
154
146
return i .hint
@@ -182,21 +174,8 @@ func (tx *SimpleTx) hintDescription(r *crud.Repo, m *tb.Message, h *Hint) *Hint
182
174
return h
183
175
}
184
176
185
- func (tx * SimpleTx ) hintDate (r * crud.Repo , m * tb.Message , h * Hint ) * Hint {
186
- res , err := r .GetCacheHints (m , STX_DATE )
187
- if err != nil {
188
- log .Printf ("Error occurred getting cached hint (hintDate): %s" , err .Error ())
189
- }
190
- selection := []string {"today" }
191
- today := time .Now ().Format (BEANCOUNT_DATE_FORMAT )
192
- // Sort out today's date
193
- for _ , v := range res {
194
- if v != today {
195
- selection = append (selection , v )
196
- }
197
- }
198
-
199
- h .KeyboardOptions = selection
177
+ func (tx * SimpleTx ) hintDate (h * Hint ) * Hint {
178
+ h .KeyboardOptions = []string {"today" }
200
179
return h
201
180
}
202
181
0 commit comments