BananaCrystal / email-templates

This repository contains in-house email templates that serve as structure for our emails. Each template can be updated and modified to fit requirements.
MIT License
0 stars 0 forks source link

chargebacks.rb #12

Open geekelo opened 1 month ago

geekelo commented 1 month ago

FILE

ActiveAdmin.register Chargeback do
  actions :all, except: %i[create new edit destroy]
  includes :user, :payment

  config.sort_order = 'created_at_desc'

  menu parent: 'Legacy', label: 'Master Wallet - Chargebacks'

  # See permitted parameters documentation:
  # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
  #
  # Uncomment all parameters which should be permitted for assignment
  #
  # permit_params :user_id, :payment_id, :external_id, :external_merchant_id, :status
  #
  # or
  #
  # permit_params do
  #   permitted = [:user_id, :payment_id, :external_id, :external_merchant_id, :status]
  #   permitted << :other if params[:action] == 'create' && current_user.admin?
  #   permitted
  # end
  index do
    selectable_column
    id_column
    column :user
    column 'Payment' do |chargeback|
      chargeback.payment
    end
    column 'Payment Amount' do |chargeback|
      chargeback.payment.gross_amount
    end
    column :reason_code
    column :category
    column 'Items' do |chargeback|
      chargeback.chargeback_items.count
    end
    column 'Chargeback Amount (USD)' do |chargeback|
      amount = 0.00
      chargeback.chargeback_items.where(chargeback_type: '1st Chargeback').each do |item|
        amount = item.provider_amount
      end
      amount
    end
    column 'Fees (USD)' do |chargeback|
      fees = 0.00
      chargeback.chargeback_items.where(chargeback_type: '1st Chargeback').each do |item|
        fees = item.provider_fee
      end
      fees
    end
    column :status
    column :external_id
    column :external_payment_id
    column :created_at
    column :updated_at
    column :history
    actions
  end

  show do
    default_main_content

    panel 'Chargeback Items' do
      table_for chargeback.chargeback_items do
        column :chargeback_type
        column :description
        column :provider_amount
        column :provider_fee
        column :settlement
        column :updated_at
      end
    end
  end
end
geekelo commented 1 month ago

This file defines the ActiveAdmin interface for managing Chargeback records. It provides read-only access to chargeback data, allowing administrators to view details but not create, edit, or delete records.

File: chargeback.rb

1. Menu Configuration

2. Actions

3. Includes

4. Configuration

5. Permitted Parameters

6. Index Page

7. Show Page

Summary: