Skip to content

Commit

Permalink
Add CreditCardAccount feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Dec 3, 2024
1 parent 48d0585 commit 2fa4f74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ feature:
cross_core_order_view: <%= ENV.fetch("CROSS_CORE_ORDER_VIEW", true) %>
show_reconciliation_deposit_number: <%= ENV.fetch("RECONCILIATION_DEPOSIT_NUMBER", false) %>
show_daily_rate_option: <%= !Rails.env.production? %>
credit_card_accounts: true

split_accounts:
# Roles are allowed to create Split Accounts
Expand Down
22 changes: 13 additions & 9 deletions vendor/engines/c2po/lib/c2po.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

module C2po

C2PO_ACCOUNT_TYPES = %w(CreditCardAccount PurchaseOrderAccount).freeze
def self.setup_account_types
account_types = %w(PurchaseOrderAccount)
if Settings.feature.credit_card_accounts
account_types << "CreditCardAccount"
end

C2PO_ACCOUNT_TYPES_APPENDER = proc do
Account.config.account_types.concat C2po::C2PO_ACCOUNT_TYPES
Account.config.facility_account_types.concat C2po::C2PO_ACCOUNT_TYPES
Account.config.statement_account_types.concat C2po::C2PO_ACCOUNT_TYPES
Account.config.affiliate_account_types.concat C2po::C2PO_ACCOUNT_TYPES
Account.config.account_types.concat account_types
Account.config.facility_account_types.concat account_types
Account.config.statement_account_types.concat account_types
Account.config.affiliate_account_types.concat account_types
end.freeze

class Engine < Rails::Engine
Expand All @@ -22,7 +25,7 @@ class Engine < Rails::Engine
Facility.facility_account_validators << C2po::C2poAccountValidator

# Permit engine-specific params
FacilitiesController.permitted_facility_params.concat [:accepts_po, :accepts_cc]
FacilitiesController.permitted_facility_params.push [:accepts_po, :accepts_cc]

EngineManager.allow_view_overrides!("c2po")

Expand All @@ -31,7 +34,8 @@ class Engine < Rails::Engine
ViewHook.add_hook "facilities.facility_fields", "before_is_active", "c2po/facilities/facility_fields"
ViewHook.add_hook "facility_accounts.show", "additional_account_fields", "c2po/facility_accounts/show/additional_account_fields"
ViewHook.add_hook "facility_accounts.show", "after_end_of_form", "c2po/facility_accounts/show/remittance_information"
C2PO_ACCOUNT_TYPES_APPENDER.call

C2po.setup_account_types
end

initializer :append_migrations do |app|
Expand All @@ -41,7 +45,7 @@ class Engine < Rails::Engine
end

initializer :append_account_types, before: "set_routes_reloader_hook" do |app|
app.reloader.to_run(&C2PO_ACCOUNT_TYPES_APPENDER)
app.reloader.to_run(C2po.method(:setup_account_types))
end

initializer "model_core.factories", after: "factory_girl.set_factory_paths" do
Expand Down

0 comments on commit 2fa4f74

Please sign in to comment.