Skip to content

Commit

Permalink
home page styling
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Nov 17, 2024
1 parent 2d21ebf commit 800f067
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 108 deletions.
9 changes: 3 additions & 6 deletions app/models/payment_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class PaymentTransaction < ApplicationRecord
STATUS_REJECTED_BY_ALMA = "ALMA_REJECTED" # all payments were rejected by alma
STATUS_PROCESSING = "PROCESSING"
STATUS_NEW = "NEW"
STATUS_ABANDONED = "ABANDONED"

STATUSES = [STATUS_PROCESSING, STATUS_PAID, STATUS_PAID_PARTIAL, STATUS_REJECTED_BY_ALMA,
STATUS_APPROVED, STATUS_DECLINED, STATUS_CANCELLED, STATUS_ABANDONED ]
STATUS_APPROVED, STATUS_DECLINED, STATUS_CANCELLED ]

## RELATIONSHIPS ##
belongs_to :user
Expand All @@ -31,14 +30,14 @@ class PaymentTransaction < ApplicationRecord
STATUS_NEW, STATUS_PROCESSING,
STATUS_PAID, STATUS_PAID_PARTIAL,
STATUS_REJECTED_BY_ALMA,
STATUS_YPB_CANCELLED,STATUS_YPB_DECLINED ]
STATUS_YPB_CANCELLED, STATUS_YPB_DECLINED ]

## CALLBACKS ##
after_create :generate_new_order_id

## SCOPES ##
scope :processing, -> { where(status: STATUS_PROCESSING )}
scope :older_than, ->(time_from = 15.minutes.ago) { where("created_at <= ?", time_from) }
scope :older_than, ->(time_from = 1.minutes.ago) { where("created_at <= ?", time_from) }
scope :approved, -> { where(status: STATUS_APPROVED )}
scope :paid, -> { where(status: STATUS_PAID )}
scope :paid_partial, -> { where(status: STATUS_PAID_PARTIAL )}
Expand All @@ -47,8 +46,6 @@ class PaymentTransaction < ApplicationRecord
scope :cancelled, -> { where(status: STATUS_CANCELLED )}
scope :stale, -> { where(status: STATUS_STALE )}
scope :declined_or_cancelled, -> { declined.or(cancelled) }
scope :abandoned, -> { older_than.where(status: PaymentTransaction::STATUS_NEW, uid: nil, yporderid: nil) }


def mark_paid!
return if status != STATUS_APPROVED
Expand Down
27 changes: 7 additions & 20 deletions app/views/home/_fee_listing.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<div class="row mb-4">
<div class="col-12 col-md-3 text-center pb-2 ">
<span class="text-muted text-sm">Date</span><br/>
<span class="text-muted">
<%= format_date fee.creation_time %>
</span>
<span class="badge badge-pill d-block"> <%= fee.fee_status %></span>
</div>
<div class="col-12 col-md-6 pb-2">
<span class="text-muted text-sm">Item</span><br/>
<span class="h6 font-weight-light"><%= fee.item_title %></span>
<div class="xtext-sm text-muted">
<div class="col-12 col-md-auto pb-2">
<div class="h4 text-muted">
<%= fee.fee_description %>
</div>
<div class="text-muted"><%= fee.item_title %></div>
</div>
<div class="col-6 col-md-3 text-center">
<span class="text-muted text-sm">Balance</span><br/>
<span class="h4"><%= number_to_currency fee.balance %></span>
<div class="col-12 col-md-3">
<div class="h4 text-muted">
<span class="visually-hidden">Balance:</span> <%= number_to_currency fee.balance %>
</div>
</div>

<!-- <div class="col-6 col-md-2 text-center">
<span class="text-muted text-sm">Owner</span><br/>
<% fee.owner_description %>
<span class="text-sm text-white d-block"><% fee.owner_id %></span>
</div> -->
</div>
52 changes: 11 additions & 41 deletions app/views/home/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,61 +1,31 @@
<% page_header "Overview", page_title: true %>

<% if @active_fees.size > 0 %>
<h5 class="text-center text-lg">Fines + Fees (YUL)</h5>
<% @other_fees.each do |fee| %>
<%= render "fee_listing", fee: fee %>
<% end %>
<% if @other_fees.size > 0 %>
<h3 class="border-bottom border-2 mb-4 h2">Fines + Fees (YUL)</h3>
<% @other_fees.each do |fee| %>
<%= render "fee_listing", fee: fee %>
<% end %>

<p class="text-center">
<%= link_to "Pay YUL", new_process_payment_path, class: 'btn btn-primary' %>
</p>
<p class="text-center">
<%= link_to "Pay Fines + Fees (YUL)", new_process_payment_path, class: 'btn btn-primary' %>
</p>
<% end %>

<% if @osgoode_fees.size > 0 %>
<hr class="mt-5"/>
<h5 class="text-center text-lg">Fines + Fees (Osgoode)</h5>
<h2 class="">Fines + Fees (Osgoode)</h2>
<% @osgoode_fees.each do |fee| %>
<%= render "fee_listing", fee: fee %>
<% end %>


<p class="text-center">
<%= link_to "Pay Osgoode", new_process_payment_path(osgoode: true), class: 'btn btn-primary' %>
<%= link_to "Pay Fines + Fees (Osgoode)", new_process_payment_path(osgoode: true), class: 'btn btn-primary' %>
</p>
<% end %>


<% else %>
<p class="text-center">You have no outstanding fees.</p>
<% end %>

<% if @processing_fees.count > 0 %>
<hr class="mt-5"/>
<% @processing_fees.each do |fee| %>
<div class="row mb-2">
<div class="col-6 pb-2">
<div class="col-12 pb-2">
<span class="h6"><%= fee.fee_description %></span><br/>
<span class="h6"><%= fee.item_title %></span>
</div>
</div>
<div class="col-6 pb-2">
<span class="text-muted text-sm">Debit</span>
<span class="text-sm"><%= number_to_currency fee.balance %></span><br/>
<span class="text-muted text-sm">Fine date:</span>
<span class="text-monospace text-sm"><%= format_date fee.creation_time %></span><br/>
<span class="text-muted text-sm">Fine Type: </span>
<span class="text-sm"><%= fee.fee_status %></span><br/>
<span class="text-muted text-sm">Fine Main Location: </span>
<span class="text-sm"><%= fee.owner_description %></span><br/>
<span class="text-muted text-sm">Fine ID:</span>
<span class="text-sm"><%= fee.fee_id %></span><br/>
</div>
</div>
<hr class="mt-2"/>
<% end %>
<% end %>


<% if Rails.env.development? %>
<p class="mt-5">
<%= link_to "Reload Fees", load_alma_fees_path, data: { disable_with: "Loading Fees, Please wait..." }%>
Expand Down
4 changes: 2 additions & 2 deletions app/views/process_payments/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% page_header "Pay - #{@which}", page_title: true %>
<% page_header "Pay Fines + Fees (#{@which})", page_title: true %>
<%= simple_form_for :records, url: process_payments_path do |f| %>
<% @records.each do |record| %>
<%= f.fields_for "payment_record[#{record.fee_id}]" do |fr| %>
Expand Down Expand Up @@ -30,7 +30,7 @@
</div>

<div class="row">
<div class="col-12">
<div class="col-12 text-center">
<%= f.button :submit, "Pay Selected Items", class: 'btn btn-primary'%>
</div>
</div>
Expand Down
31 changes: 4 additions & 27 deletions app/views/transactions/_transaction.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="mb-5">
<h3 class="border-bottom border-2"><%= format_date transaction.created_at %></h3>
<h3 class="border-bottom border-2 mb-4 h2"><%= format_date transaction.created_at %></h3>

<div class="row">
<div class="col-12 col-md-9">
Expand Down Expand Up @@ -35,6 +35,9 @@
<% if transaction.status == 'PAID' %>
<p class="card-text">Your fee payment is now complete.</p>
<% end %>
<% if transaction.status == 'PROCESSING' %>
<p class="card-text">Your card payment is in progress.</p>
<% end %>
<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"%>
Expand All @@ -46,29 +49,3 @@
</div>
</div>
</div>

<!--
<div class="col-12 col-md-6 pb-2">
<span class="text-muted text-sm">Date: </span>
<span class="text-monospace">
<%= format_date transaction.created_at %></span><br/>
<span class="text-muted text-sm">Amount: </span>
<span class="text-monospace">
<%= number_to_currency transaction.amount %></span><br/>
<span class="text-muted text-sm">Status: </span>
<span class="text-monospace">
<%= transaction.status %></span><br/>
<span class="text-muted text-sm">Receipt</span>
<span class="text-monospace">
<% if transaction.uid != nil %>
<%= link_to "View Receipt", "#{Settings.ypb.receipt_page_url}?tokenid=#{transaction.uid}" %>
<% else %>
<%= transaction.order_id %>
<% end %>
</span>
-->
12 changes: 0 additions & 12 deletions lib/tasks/check_ypb_status.rake
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ namespace :ypb do
#TLOG.log_ypb_processor txn.yorku_id, txt.id, "Cleaned Up: #{txn.status} ID: #{txn.id}"
end
end

# clean up abandoned transactions
# older than 15 minutes AND status is NEW and uid (token) is nill and yporderid (YPB order ID) is nil
transactions = PaymentTransaction.older_than.where(status: PaymentTransaction::STATUS_NEW, uid: nil, yporderid: nil)
TLOG.info "Cleaning up Abandoned transactions - #{transactions.size}"
transactions.each do |txn|
txn.records.each do |record|
record.mark_incomplete!
end
txn.status = PaymentTransaction::STATUS_ABANDONED
txn.save
end
end


Expand Down

0 comments on commit 800f067

Please sign in to comment.