forms/transactions.rb 🔗
@@ -0,0 +1,9 @@
+result!
+title "Transactions"
+
+table(
+ @transactions,
+ formatted_amount: "Amount",
+ note: "Note",
+ created_at: "Date"
+)
Christopher Vollick created
Using the new Financials object a user can list their transaction list
We only show the user the date, amount, and method.
forms/transactions.rb | 9 +++++++++
lib/form_template.rb | 11 +++++++++++
sgx_jmp.rb | 12 ++++++++++++
3 files changed, 32 insertions(+)
@@ -0,0 +1,9 @@
+result!
+title "Transactions"
+
+table(
+ @transactions,
+ formatted_amount: "Amount",
+ note: "Note",
+ created_at: "Date"
+)
@@ -80,6 +80,17 @@ class FormTemplate
open || regex || range
end
+ # Given a map of fields to labels, and a list of objects this will
+ # produce a table from calling each field's method on every object in the
+ # list. So, this list is value_semantics / OpenStruct style
+ def table(list, **fields)
+ keys = fields.keys
+ FormTable.new(
+ list.map { |x| keys.map { |k| x.public_send(k) } },
+ **fields
+ ).add_to_form(@__form)
+ end
+
def field(datatype: nil, open: false, regex: nil, range: nil, **kwargs)
f = Blather::Stanza::X::Field.new(kwargs)
if datatype || open || regex || range
@@ -472,6 +472,18 @@ Command.new(
end
}.register(self).then(&CommandList.method(:register))
+Command.new(
+ "transactions",
+ "Show Transactions",
+ list_for: ->(customer:, **) { !!customer&.currency }
+) {
+ Command.customer.then(&:transactions).then do |txs|
+ Command.finish do |reply|
+ reply.command << FormTemplate.render("transactions", transactions: txs)
+ end
+ end
+}.register(self).then(&CommandList.method(:register))
+
Command.new(
"configure calls",
"Configure Calls",