-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #162 allow payout to be optional for product
- Loading branch information
Showing
16 changed files
with
185 additions
and
38 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/controllers/spree/admin/payout_profile_products_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 25 additions & 2 deletions
27
app/views/spree/admin/payout_profile_products/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
<%= f.field_container :payout_profile_id do %> | ||
<%= f.label :payout_profile_id, Spree.t(:payout_profile) %> | ||
<%= f.collection_select :payout_profile_id, @product.vendor.payout_profiles, :id, :name, { prompt: Spree.t('match_choices.none') }, class: 'form-control select2' %> | ||
<%= f.collection_select :payout_profile_id, @product.vendor.payout_profiles, :id, :display_name, { prompt: Spree.t('match_choices.none') }, class: 'form-control select2' %> | ||
<%= f.error_message_on :payout_profile_id %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= render partial: 'payout_profile_info_card', locals: { payout_profile: f.object.payout_profile } if f.object.payout_profile.present? %> | ||
|
||
<%= f.field_container :optional, class: ["form-group card card-body"] do %> | ||
<% default = object.class.columns_hash['optional'].default %> | ||
|
||
<strong><%= Spree.t(:optional) %></strong> | ||
<div class="radio my-2 form-check"> | ||
<%= f.radio_button :optional, true, class: 'form-check-input' %> | ||
<%= f.label :optional_true, Spree.t(:say_yes) + (default == 'true' ? ' (default)' : ''), class: 'form-check-label' %> | ||
<small class="form-text text-muted"> | ||
<%= "User can buy this product with other payment methods beside #{f.object.payout_profile.bank_name}, but amount will be sent to #{Spree::Store.default.name} account" %> | ||
</small> | ||
</div> | ||
|
||
<div class="radio my-2 form-check"> | ||
<%= f.radio_button :optional, false, class: 'form-check-input' %> | ||
<%= f.label :optional_false, Spree.t(:say_no) + (default == 'false' ? ' (default)' : ''), class: 'form-check-label' %> | ||
<small class="form-text text-muted"> | ||
<%= "User can only buy this product with #{f.object.payout_profile.bank_name} payment methods" %> | ||
</small> | ||
</div> | ||
<% end if f.object.payout_profile.present? %> |
24 changes: 24 additions & 0 deletions
24
app/views/spree/admin/payout_profile_products/_payout_profile_info_card.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<ul class="list-group mb-3"> | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
<%= Spree.t(:bank_account_number) %> | ||
<strong> | ||
<%= button_link_to payout_profile&.bank_account_number, edit_admin_payout_profile_path(payout_profile), icon: 'edit.svg' %> | ||
</strong> | ||
</li> | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
<%= Spree.t(:bank) %> | ||
<span><%= payout_profile&.bank_name %></span> | ||
</li> | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
<%= Spree.t(:active) %> | ||
<span><%= active_badge(payout_profile&.active) %></span> | ||
</li> | ||
<li class="list-group-item d-flex justify-content-between align-items-center"> | ||
<%= Spree.t(:verified_at) %> | ||
<% if payout_profile&.verified? %> | ||
<span><%= pretty_time(payout_profile&.verified_at) %></span> | ||
<% else %> | ||
<span><%= active_badge(false) %></span> | ||
<% end %> | ||
</li> | ||
</ul> |
11 changes: 11 additions & 0 deletions
11
app/views/spree/admin/payout_profile_products/_payout_profile_status.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% if payout_profile.present? && !payout_profile.receivable? %> | ||
<div class="alert alert-warning mb-3 d-flex justify-content-between align-items-center"> | ||
Profile is not verified or is inactive. Please verify and mark it as active to receive payout amount. | ||
<%= button_link_to Spree.t(:verify), spree.edit_admin_payout_profile_path(payout_profile), class: "btn-warning", icon: 'send.svg' %> | ||
</div> | ||
<% elsif payout_profile&.receivable? %> | ||
<div class="alert alert-success mb-3"> | ||
<%= svg_icon name: "tick.svg", classes: 'mr-2', width: '16', height: '16' %> | ||
This product is now eligible for payout | ||
</div> | ||
<% end %> |
18 changes: 18 additions & 0 deletions
18
app/views/spree/admin/payout_profile_products/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= render partial: 'spree/admin/shared/product_tabs', locals: { current: :payout_profile_products } %> | ||
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @payout_profile_product } %> | ||
|
||
<%= render partial: 'payout_profile_status', locals: { payout_profile: @payout_profile_product.payout_profile } %> | ||
|
||
<% content_for :page_actions do %> | ||
<%= button_link_to Spree.t(:add_profiles), admin_payout_profiles_url(q: { vendor_id_eq: @product.vendor_id }), icon: 'arrow-right-circle.svg' %> | ||
<% end %> | ||
|
||
<%= form_for @payout_profile_product, url: object_url do |f| %> | ||
<fieldset> | ||
<%= render partial: 'form', locals: { f: f } %> | ||
<div class="form-actions" data-hook="buttons"> | ||
<%= button Spree.t('actions.update'), 'save.svg', 'submit', { class: 'btn-success', data: { disable_with: "#{ Spree.t(:saving) }..." } } %> | ||
<%= link_to_with_icon 'delete.svg', Spree.t(:delete), object_url(@payout_profile_product), { class: 'btn btn-danger float-right', data: { confirm: Spree.t(:are_you_sure), method: :delete } } %> | ||
</div> | ||
</fieldset> | ||
<% end %> |
17 changes: 15 additions & 2 deletions
17
app/views/spree/admin/payout_profile_products/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
<%= render partial: 'spree/admin/shared/product_tabs', locals: { current: :payout_profile_products } %> | ||
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @payout_profile_product } %> | ||
|
||
<% content_for :page_actions do %> | ||
<%= button_link_to Spree.t(:add_profiles) + " (#{@product.vendor&.name})", admin_payout_profiles_url(q: { vendor_id_eq: @product.vendor_id }), icon: 'arrow-right-circle.svg' %> | ||
<% end if @product.vendor.payout_profiles.any? %> | ||
|
||
<% if @product.vendor.payout_profiles.none? %> | ||
<div class="alert alert-warning mb-3 d-flex justify-content-between align-items-center"> | ||
To set up payouts for this product, make sure the vendor has a payout account linked | ||
<%= button_link_to Spree.t(:add_profiles) + " (#{@product.vendor&.name})", new_admin_payout_profile_url(vendor_id: @product.vendor_id), class: "btn-warning", icon: 'arrow-right-circle.svg' %> | ||
</div> | ||
<% end %> | ||
|
||
<%= form_for @payout_profile_product, url: collection_url do |f| %> | ||
<fieldset> | ||
<%= render partial: 'form', locals: { f: f } %> | ||
<%= render partial: 'spree/admin/shared/new_resource_links' %> | ||
<div class="form-actions" data-hook="buttons"> | ||
<%= button Spree.t('actions.create'), 'save.svg', 'submit', {class: 'btn-success', data: { disable_with: "#{ Spree.t(:saving) }..." }} %> | ||
<div> | ||
</fieldset> | ||
<% end %> | ||
<% end if @product.vendor.payout_profiles.any? %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%= search_form_for [:admin, @search] do |f| %> | ||
<div data-hook="admin_payout_profile_search" class="row"> | ||
<div class="col-12 col-lg-6"> | ||
<div class="form-group"> | ||
<%= f.label :name_cont, Spree.t(:name) %> | ||
<%= f.text_field :name_cont, size: 15, class: "form-control js-quick-search-target js-filterable" %> | ||
</div> | ||
</div> | ||
<div class="col-12 col-lg-6"> | ||
<div class="form-group"> | ||
<%= f.label :vendor_id_eq, Spree.t(:vendor) %> | ||
<%= f.select :vendor_id_eq, Spree::Vendor.all.map{|t| [t.name , t.id]}, { include_blank: true}, class: 'form-control js-filterable' %> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-actions"> | ||
<%= button Spree.t(:search), 'search.svg' %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20240523070757_add_optional_spere_payout_profile_products.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddOptionalSperePayoutProfileProducts < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :spree_payout_profile_products, :optional, :boolean, null: false, default: false, if_not_exists: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters