From c53e46eabcacde8ddb34d1596559d0a208d11100 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 20 Nov 2024 06:35:29 -0500 Subject: [PATCH] add user_primary_id to payment records and cleanup transaction report --- .../reports/transactions_controller.rb | 1 + app/models/payment_record.rb | 1 + app/views/reports/transactions/_fee.html.erb | 27 ++----- app/views/reports/transactions/_logs.html.erb | 13 ++++ .../reports/transactions/_record.html.erb | 14 ++-- .../transactions/_transaction.html.erb | 8 ++ app/views/reports/transactions/_user.html.erb | 8 ++ app/views/reports/transactions/show.html.erb | 78 ++++++++++++++----- ..._add_user_primary_id_to_payment_records.rb | 10 +++ db/schema.rb | 3 +- 10 files changed, 118 insertions(+), 45 deletions(-) create mode 100644 app/views/reports/transactions/_logs.html.erb create mode 100644 app/views/reports/transactions/_user.html.erb create mode 100644 db/migrate/20241120101610_add_user_primary_id_to_payment_records.rb diff --git a/app/controllers/reports/transactions_controller.rb b/app/controllers/reports/transactions_controller.rb index 0019b1f..096a538 100644 --- a/app/controllers/reports/transactions_controller.rb +++ b/app/controllers/reports/transactions_controller.rb @@ -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 diff --git a/app/models/payment_record.rb b/app/models/payment_record.rb index bbc1e68..2319633 100644 --- a/app/models/payment_record.rb +++ b/app/models/payment_record.rb @@ -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 diff --git a/app/views/reports/transactions/_fee.html.erb b/app/views/reports/transactions/_fee.html.erb index c201935..f7fb10a 100644 --- a/app/views/reports/transactions/_fee.html.erb +++ b/app/views/reports/transactions/_fee.html.erb @@ -1,19 +1,8 @@ - - - - - - - - - - - - - - - - - - -
Fee ID<%= fee.fee_id %>
Fee TYPE<%= fee.fee_type %>
Fee STATUS<%= fee.fee_status %>
Fee Description<%= fee.fee_description %>
Fee User Primary ID<%= fee.user_primary_id %>
Fee Remaining VAT Amount<%= fee.remaining_vat_amount %>
Fee Original Amount<%= fee.original_amount %>
Fee Original Vat Amount<%= fee.original_vat_amount %>
Fee Creation Time<%= fee.creation_time %>
Fee Status Time<%= fee.status_time %>
Fee Owner ID<%= fee.owner_id %>
Fee Owner Description<%= fee.owner_description %>
Fee Item Title<%= fee.item_title %>
Fee Item Barcode<%= fee.item_barcode %>
Fee YorkU ID<%= fee.yorku_id %>
Fee Created At<%= fee.created_at %>
+<% fee.attribute_names.each do |a| %> + <% if fee[a].to_s.strip.length > 0 %> +
+
<%= a %>
+
<%= fee[a] %>
+
+ <% end %> +<% end %> diff --git a/app/views/reports/transactions/_logs.html.erb b/app/views/reports/transactions/_logs.html.erb new file mode 100644 index 0000000..5d36cfb --- /dev/null +++ b/app/views/reports/transactions/_logs.html.erb @@ -0,0 +1,13 @@ + diff --git a/app/views/reports/transactions/_record.html.erb b/app/views/reports/transactions/_record.html.erb index 93e157e..b0b81e7 100644 --- a/app/views/reports/transactions/_record.html.erb +++ b/app/views/reports/transactions/_record.html.erb @@ -1,8 +1,8 @@ - - <% record.attribute_names.each do |a| %> - - - - +<% record.attribute_names.each do |a| %> + <% if record[a].to_s.strip.length > 0 %> +
+
<%= a %>
+
<%= record[a] %>
+
<% end %> -
<%= a.humanize %> <%= record[a] %>
+<% end %> diff --git a/app/views/reports/transactions/_transaction.html.erb b/app/views/reports/transactions/_transaction.html.erb index e69de29..f10608c 100644 --- a/app/views/reports/transactions/_transaction.html.erb +++ b/app/views/reports/transactions/_transaction.html.erb @@ -0,0 +1,8 @@ +<% transaction.attribute_names.each do |a| %> + <% if transaction[a].to_s.strip.length > 0 %> +
+
<%= a %>
+
<%= transaction[a] %>
+
+ <% end %> +<% end %> diff --git a/app/views/reports/transactions/_user.html.erb b/app/views/reports/transactions/_user.html.erb new file mode 100644 index 0000000..1f1ab60 --- /dev/null +++ b/app/views/reports/transactions/_user.html.erb @@ -0,0 +1,8 @@ +<% user.attribute_names.each do |a| %> + <% if user[a].to_s.strip.length > 0 %> +
+
<%= a %>
+
<%= user[a] %>
+
+ <% end %> +<% end %> diff --git a/app/views/reports/transactions/show.html.erb b/app/views/reports/transactions/show.html.erb index 7329bc1..a69a441 100644 --- a/app/views/reports/transactions/show.html.erb +++ b/app/views/reports/transactions/show.html.erb @@ -14,38 +14,80 @@ <%= @transaction.created_at.strftime("%A, %b %d %Y %I:%M:%S %p") %>

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

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

<% @transaction.records.each do |record| %>
-

- +

+
+
+ <%= render "record", record: record %> +
+
+
+ +
+
+ -
-
+ +
-
-
- Full Payment Record Details - <%= render "record", record: record rescue "n/a" %> -
-
- Full Fee Details - <%= render "fee", fee: record.fee rescue "n/a" %> -
-
+ <%= render "fee", fee: record.fee %>
<% end %> + +
+
+ +
+
+
+ <%= render "transaction", transaction: @transaction %> +
+
+
+ +
+
+ +
+
+
+ <%= render "user", user: @transaction.user %> +
+
+
+ +
+
+ +
+
+
+ <%= render "logs", logs: @logs %> +
+
+
diff --git a/db/migrate/20241120101610_add_user_primary_id_to_payment_records.rb b/db/migrate/20241120101610_add_user_primary_id_to_payment_records.rb new file mode 100644 index 0000000..14f2a38 --- /dev/null +++ b/db/migrate/20241120101610_add_user_primary_id_to_payment_records.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index cfd8078..dac82d8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -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|