Skip to content

Commit

Permalink
Handle sorting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tungleduyxyz committed Feb 2, 2025
1 parent 6fcf39f commit 82d1e1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
8 changes: 1 addition & 7 deletions app/controllers/kaui/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ def pagination
end
else
lambda do |invoice, column|
[
invoice.invoice_number.to_i,
invoice.invoice_date,
invoice.amount,
invoice.balance,
invoice.status
][column]
Kaui.account_invoices_columns.call(invoice, view_context)[2][column]
end
end

Expand Down
10 changes: 1 addition & 9 deletions app/controllers/kaui/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,7 @@ def pagination
end

data_extractor = lambda do |payment, column|
[
payment.payment_number.to_i,
payment.payment_date,
payment.total_authed_amount_to_money,
payment.paid_amount_to_money,
payment.returned_amount_to_money,
payment.transactions.empty? ? nil : payment.transactions[-1].status,
payment.payment_external_key
][column]
Kaui.account_payments_columns.call(account, payment, view_context)[2][column]
end

formatter = lambda do |payment|
Expand Down
17 changes: 14 additions & 3 deletions lib/kaui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ module Kaui
invoice&.send(attr.downcase)
end
end
# Add additional values if needed
[headers, values]

raw_data = fields.map { |attr| invoice&.send(attr.downcase) }

[headers, values, raw_data]
end

self.account_payments_columns = lambda do |account = nil, payment = nil, view_context = nil|
Expand Down Expand Up @@ -177,8 +179,17 @@ module Kaui
end
end

raw_data = fields.map do |attr|
case attr
when 'status'
payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status)
else
payment&.send(attr.downcase)
end
end

# Add additional values if needed
[headers, values]
[headers, values, raw_data]
end

self.account_audit_logs_columns = lambda do
Expand Down

0 comments on commit 82d1e1f

Please sign in to comment.