Class: RogIQ::Commands::Billing
- Defined in:
- lib/rogiq/commands/billing.rb
Instance Method Summary collapse
Instance Method Details
#coins(identifier) ⇒ Object
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 |
# File 'lib/rogiq/commands/billing.rb', line 9 def coins(identifier) RogIQ.load_rails! account = RogIQ::Helpers.resolve_account(identifier) unless account fmt.error_msg("Account not found") exit 1 end w = account.rogue_coin_wallet unless w fmt.output(wallet: nil, message: "No RogueCoinWallet for account") return end txs = w.transactions.order(created_at: :desc).limit(25).map do |t| [t.created_at.iso8601, t.transaction_type, t.amount, t.description.to_s.truncate(60)] end fmt.output( account_id: account.id, balance: w.balance, lifetime_purchased: w.lifetime_purchased, lifetime_spent: w.lifetime_spent, recent_transactions: txs ) end |
#invoices(identifier) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rogiq/commands/billing.rb', line 65 def invoices(identifier) RogIQ.load_rails! account = RogIQ::Helpers.resolve_account(identifier) unless account fmt.error_msg("Account not found") exit 1 end rows = account.invoices.order(created_at: :desc).limit([:limit]).map do |inv| [ inv.id, inv.invoice_number, inv.status, inv.total.to_f, inv.striven_invoice_id, inv.created_at.iso8601 ] end fmt.output( headers: %w[id invoice_number status total striven_invoice_id created_at], rows: rows ) end |
#overages ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rogiq/commands/billing.rb', line 37 def overages RogIQ.load_rails! rows = ::UsageOverage.status_pending.includes(:account).order(created_at: :desc).limit([:limit]).map do |o| [ o.id, o.account&.name, o.metric_type, o.total_charge.to_f, o.created_at.iso8601 ] end fmt.output(headers: %w[id account metric total_charge created_at], rows: rows) end |
#summary ⇒ Object
56 57 58 59 60 61 |
# File 'lib/rogiq/commands/billing.rb', line 56 def summary RogIQ.load_rails! date = [:date].present? ? Date.parse([:date]) : nil ::Billing::DailyBillingSummaryJob.perform_later(date: date) fmt.success("Billing::DailyBillingSummaryJob enqueued.") end |