Skip to content

Commit

Permalink
add user_primary_id to payment records and cleanup transaction report
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Nov 20, 2024
1 parent 7d21b55 commit c53e46e
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 45 deletions.
1 change: 1 addition & 0 deletions app/controllers/reports/transactions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Reports::TransactionsController < AdminController
def show
@transaction = PaymentTransaction.find(params[:id])
@logs = TransactionLog.where(transaction_id: @transaction.id).order(:logged_at)
end
end
1 change: 1 addition & 0 deletions app/models/payment_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ def copy_additional_alma_fee_details
update_attribute :fee_item_barcode, fee.item_barcode
update_attribute :fee_type, fee.fee_type
update_attribute :fee_description, fee.fee_description
update_attribute :user_primary_id, fee.user_primary_id
end
end
27 changes: 8 additions & 19 deletions app/views/reports/transactions/_fee.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@

<table class="table table-condensed">
<tr><td class="font-weight-light">Fee ID</td><td><%= fee.fee_id %></td></tr>
<tr><td class="font-weight-light">Fee TYPE</td><td><%= fee.fee_type %></td></tr>
<tr><td class="font-weight-light">Fee STATUS</td><td><%= fee.fee_status %></td></tr>
<tr><td class="font-weight-light">Fee Description</td><td><%= fee.fee_description %></td></tr>
<tr><td class="font-weight-light">Fee User Primary ID</td><td><%= fee.user_primary_id %></td></tr>
<tr><td class="font-weight-light">Fee Remaining VAT Amount</td><td><%= fee.remaining_vat_amount %></td></tr>
<tr><td class="font-weight-light">Fee Original Amount</td><td><%= fee.original_amount %></td></tr>
<tr><td class="font-weight-light">Fee Original Vat Amount</td><td><%= fee.original_vat_amount %></td></tr>
<tr><td class="font-weight-light">Fee Creation Time</td><td><%= fee.creation_time %></td></tr>
<tr><td class="font-weight-light">Fee Status Time</td><td><%= fee.status_time %></td></tr>
<tr><td class="font-weight-light">Fee Owner ID</td><td><%= fee.owner_id %></td></tr>
<tr><td class="font-weight-light">Fee Owner Description</td><td><%= fee.owner_description %></td></tr>
<tr><td class="font-weight-light">Fee Item Title</td><td><%= fee.item_title %></td></tr>
<tr><td class="font-weight-light">Fee Item Barcode</td><td><%= fee.item_barcode %></td></tr>
<tr><td class="font-weight-light">Fee YorkU ID</td><td><%= fee.yorku_id %></td></tr>
<tr><td class="font-weight-light">Fee Created At</td><td><%= fee.created_at %></td></tr>
</table>
<% fee.attribute_names.each do |a| %>
<% if fee[a].to_s.strip.length > 0 %>
<div class="row border-bottom border-bottom-1">
<div class="col col-5 col-md-3 text-truncate text-muted"><%= a %></div>
<div class="col col-7 col-md-9 text-truncate text-muted"><%= fee[a] %></div>
</div>
<% end %>
<% end %>
13 changes: 13 additions & 0 deletions app/views/reports/transactions/_logs.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<ul class="list-group list-group-flush">
<% logs.each do |log| %>
<li class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><%= log.logged_at.in_time_zone("Eastern Time (US & Canada)").strftime("%A, %b %d %I:%M:%S %p") %></h6>
<small class="text-muted"><%= log.process_name.upcase %></small>
</div>
<p class="mb-1"><%= log.message %></p>
<small class="text-muted">User ID: <%= log.username ? log.username : log.yorku_id %> </small>
<span class="badge badge-primary badge-pill"><%= log.alma_fee_id %></span>
</li>
<% end %>
</ul>
14 changes: 7 additions & 7 deletions app/views/reports/transactions/_record.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<table class="table table-condensed">
<% record.attribute_names.each do |a| %>
<tr>
<td class="font-weight-light"><%= a.humanize %> </td>
<td><%= record[a] %></td>
<tr/>
<% record.attribute_names.each do |a| %>
<% if record[a].to_s.strip.length > 0 %>
<div class="row border-bottom border-bottom-1">
<div class="col col-5 col-md-3 text-truncate text-muted"><%= a %></div>
<div class="col col-7 col-md-9 text-truncate text-muted"><%= record[a] %></div>
</div>
<% end %>
</table>
<% end %>
8 changes: 8 additions & 0 deletions app/views/reports/transactions/_transaction.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% transaction.attribute_names.each do |a| %>
<% if transaction[a].to_s.strip.length > 0 %>
<div class="row border-bottom border-bottom-1">
<div class="col col-5 col-md-3 text-truncate text-muted"><%= a %></div>
<div class="col col-7 col-md-9 text-truncate text-muted"><%= transaction[a] %></div>
</div>
<% end %>
<% end %>
8 changes: 8 additions & 0 deletions app/views/reports/transactions/_user.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% user.attribute_names.each do |a| %>
<% if user[a].to_s.strip.length > 0 %>
<div class="row border-bottom border-bottom-1">
<div class="col col-5 col-md-3 text-truncate text-muted"><%= a %></div>
<div class="col col-7 col-md-9 text-truncate text-muted"><%= user[a] %></div>
</div>
<% end %>
<% end %>
78 changes: 60 additions & 18 deletions app/views/reports/transactions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,80 @@
<%= @transaction.created_at.strftime("%A, %b %d %Y %I:%M:%S %p") %>
</p>

<%= link_to "View Log", report_transaction_log_url(@transaction),
class: "btn btn-secondary"%>

<p class="card-text">
<% if @transaction.uid != nil %>
<%= link_to "View Receipt", "#{Settings.ypb.receipt_page_url}?tokenid=#{@transaction.uid}",
target: "_blank", class: "btn btn-secondary"%>
<% end %>
</p>

<div class="accordion accordion-flush mt-4" id="payment_records_accordion">
<% @transaction.records.each do |record| %>
<div class="accordion-item">
<h2 class="accordion-header" id="heading_<%= record.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_<%= record.id %>" aria-controls="collapse_<%= record.id %>" aria-expanded="false">
<span class="text-muted text-truncate"><%= record.fee_item_title %></span>
<h5 class="accordion-header" id="heading_payment_<%= record.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_payment_<%= record.id %>" aria-controls="collapse_payment_<%= record.id %>" aria-expanded="false">
<span class="text-muted h5">Fee Payment Record: <%= record.id %></span>
</button>
</h5>
<div id="collapse_payment_<%= record.id %>" class="accordion-collapse collapse" aria-labelledby="heading_payment_<%= record.id %>" data-bs-parent="#payment_records_accordion">
<div class="accordion-body">
<%= render "record", record: record %>
</div>
</div>
</div>

<div class="accordion-item">
<h5 class="accordion-header" id="heading_fee_<%= record.fee.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_fee_<%= record.fee.id %>" aria-controls="collapse_fee_<%= record.fee.id %>" aria-expanded="false">
<span class="text-muted h5">Fee Record: <%= record.fee.id %></span>
</button>
</h2>
<div id="collapse_<%= record.id %>" class="accordion-collapse collapse" aria-labelledby="heading_<%= record.id %>" data-bs-parent="#payment_records_accordion">
</h5>
<div id="collapse_fee_<%= record.fee.id %>" class="accordion-collapse collapse" aria-labelledby="heading_fee_<%= record.fee.id %>" data-bs-parent="#payment_records_accordion">
<div class="accordion-body">
<div class="row">
<div class="col-md-6">
<span class="text-muted text-sm">Full Payment Record Details</span>
<%= render "record", record: record rescue "n/a" %>
</div>
<div class="col-md-6">
<span class="text-muted text-sm">Full Fee Details</span>
<%= render "fee", fee: record.fee rescue "n/a" %>
</div>
</div>
<%= render "fee", fee: record.fee %>
</div>
</div>
</div>
<% end %>

<div class="accordion-item">
<h5 class="accordion-header" id="heading_transaction_<%= @transaction.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_transaction_<%= @transaction.id %>" aria-controls="collapse_transaction_<%= @transaction.id %>" aria-expanded="false">
<span class="text-muted h5">Payment Transaction Record</span>
</button>
</h5>
<div id="collapse_transaction_<%= @transaction.id %>" class="accordion-collapse collapse" aria-labelledby="heading_transaction_<%= @transaction.id %>" data-bs-parent="#payment_records_accordion">
<div class="accordion-body">
<%= render "transaction", transaction: @transaction %>
</div>
</div>
</div>

<div class="accordion-item">
<h5 class="accordion-header" id="heading_user_<%= @transaction.user.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_user_<%= @transaction.user.id %>" aria-controls="collapse_user_<%= @transaction.user.id %>" aria-expanded="false">
<span class="text-muted h5">User Record</span>
</button>
</h5>
<div id="collapse_user_<%= @transaction.user.id %>" class="accordion-collapse collapse" aria-labelledby="heading_user_<%= @transaction.user.id %>" data-bs-parent="#payment_records_accordion">
<div class="accordion-body">
<%= render "user", user: @transaction.user %>
</div>
</div>
</div>

<div class="accordion-item">
<h5 class="accordion-header" id="heading_logs_<%= @transaction.id %>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse_logs_<%= @transaction.id %>" aria-controls="collapse_logs_<%= @transaction.id %>" aria-expanded="false">
<span class="text-muted h5">Transaction Logs</span>
</button>
</h5>
<div id="collapse_logs_<%= @transaction.id %>" class="accordion-collapse collapse" aria-labelledby="heading_logs_<%= @transaction.id %>" data-bs-parent="#payment_records_accordion">
<div class="accordion-body">
<%= render "logs", logs: @logs %>
</div>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddUserPrimaryIdToPaymentRecords < ActiveRecord::Migration[7.0]
def self.up
add_column :payment_records, :user_primary_id, :string
end
def self.down
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_11_20_000523) do
ActiveRecord::Schema[7.0].define(version: 2024_11_20_101610) do
create_table "alma_fees", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "fee_id"
t.string "fee_type"
Expand Down Expand Up @@ -56,6 +56,7 @@
t.string "fee_item_barcode"
t.string "fee_type"
t.string "fee_description"
t.string "user_primary_id"
end

create_table "payment_transactions", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
Expand Down

0 comments on commit c53e46e

Please sign in to comment.