<%= t('.subscription') %>
<% if f.object.new_record? %>
<%= f.label :user_id, I18n.t('spree.user'), class: "required" %> <%= f.collection_select :user_id, Spree.user_class.all, :id, :email, {}, class: "select2 fullwidth" %>
<% end %>
<%= f.label :actionable_date %> <%= f.text_field :actionable_date, class: "form-control fullwidth datepicker" %>
<%= f.label :interval_length %> <%= f.number_field :interval_length, class: "form-control fullwidth" %>
<% unit_values = SolidusSubscriptions::LineItem.interval_units.keys units = unit_values.map do |unit| [ SolidusSubscriptions::LineItem.human_attribute_name("interval_units.#{unit}"), unit, ] end %> <%= f.label :interval_units %> <%= f.select(:interval_units, units, {}, class: 'fullwidth select2') %>
<%= f.label :end_date %> <%= f.text_field :end_date, class: "fullwidth datepicker" %>
<%= f.label :store_id %> <%= f.collection_select :store_id, Spree::Store.all, :id, :name, {}, class: 'fullwidth select2' %>
<% if @subscription.persisted? && @subscription.user %>
<%= t('spree.admin.subscriptions.edit.payment') %>
<%= f.label :payment_method %> <%= f.select :payment_method_id, @payment_methods.map { |pm| [pm.name, pm.id] }, { include_blank: true }, class: 'select2 fullwidth' %>
<%= f.label :payment_source %> <%= f.select :payment_source_id, nil, {}, class: 'select2 fullwidth' do %> selected<% end %>> <% @subscription.user.wallet_payment_sources.select { |wps| wps.payment_source.reusable? }.each do |wps| %> <% end %> <% end %>
<% end %>
<%= t('spree.shipping_address') %>
<%= f.fields_for :shipping_address do |sa_form| %> <%= render partial: 'spree/admin/shared/address_form', locals: { f: sa_form, type: "shipping" } %> <% end %>
<%= t('spree.billing_address') %>
<%= f.fields_for :billing_address do |ba_form| %> <%= render partial: 'spree/admin/shared/address_form', locals: { f: ba_form, type: "billing" } %> <% end %>
<%= t('.subscription_line_items') %> <%= f.fields_for :line_items do |lf| %>
<%= lf.label :subscribable_id %> <%= lf.collection_select :subscribable_id, Spree::Variant.where(subscribable: true), :id, :pretty_name, {}, { class: "fullwidth select2" } %>
<%= lf.label :quantity %> <%= lf.number_field :quantity, min: 1, class: "form-control fullwidth" %>
<%= lf.label :_destroy %> <%= lf.check_box :_destroy, class: "form-control", disabled: lf.object.new_record? %>
<% end %> <% if f.object.new_record? %> <%= render partial: 'spree/admin/shared/new_resource_links' %> <% else %> <%= render partial: 'spree/admin/shared/edit_resource_links' %> <% end %>