menu-voucherlist #101
@ -635,13 +635,18 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
code := codeFromCtx(ctx)
|
||||
l := gotext.NewLocale(translationDir, code)
|
||||
l.AddDomain("default")
|
||||
|
||||
store := h.userdataStore
|
||||
Alfred-mk marked this conversation as resolved
Outdated
|
||||
|
||||
lash marked this conversation as resolved
Outdated
lash
commented
Why should it be 0.00 when error? Why should it be 0.00 when error?
Alfred-mk
commented
The 0.00 is a placeholder. I set it like this without a symbol since the error indicates no symbol exists. I have updated this to check the specific db error The 0.00 is a placeholder. I set it like this without a symbol since the error indicates no symbol exists.
I have updated this to check the specific db error
|
||||
// get the active sym and active balance
|
||||
activeSym, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM)
|
||||
if err != nil {
|
||||
if db.IsNotFound(err) {
|
||||
res.Content = "0.00"
|
||||
balance := "0.00"
|
||||
res.Content = l.Get("Balance: %s\n", balance)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -650,10 +655,10 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
|
||||
|
||||
activeBal, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_BAL)
|
||||
if err != nil {
|
||||
return res, nil
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.Content = fmt.Sprintf("%s %s", activeBal, activeSym)
|
||||
res.Content = l.Get("Balance: %s\n", fmt.Sprintf("%s %s", activeBal, activeSym))
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ msgstr "Ombi lako limetumwa. %s atapokea %s kutoka kwa %s."
|
||||
msgid "Thank you for using Sarafu. Goodbye!"
|
||||
msgstr "Asante kwa kutumia huduma ya Sarafu. Kwaheri!"
|
||||
|
||||
|
||||
msgid "For more help,please call: 0757628885"
|
||||
msgstr "Kwa usaidizi zaidi,piga: 0757628885"
|
||||
|
||||
msgid "Balance: %s\n"
|
||||
msgstr "Salio: %s\n"
|
||||
|
@ -1 +1 @@
|
||||
Balance: {{.check_balance}}
|
||||
{{.check_balance}}
|
@ -1 +1 @@
|
||||
Salio: {{.check_balance}}
|
||||
{{.check_balance}}
|
Loading…
Reference in New Issue
Block a user
If no active sym then the user has no vouchers yet, and then no balance should be displayed, I think?
For this, I've added a function that sets the default voucher, (expecting it to be SRF) if no active voucher is set for the user.
This will be loaded on the main.vis, ensuring that one has the default sym if they haven't set their own