diff --git a/app/assets/stylesheets/admin/index_panel_buttons.css.scss b/app/assets/stylesheets/admin/index_panel_buttons.css.scss index 50e174eb37..4ff84bac89 100644 --- a/app/assets/stylesheets/admin/index_panel_buttons.css.scss +++ b/app/assets/stylesheets/admin/index_panel_buttons.css.scss @@ -5,6 +5,7 @@ tbody.panel-ctrl { > td { a.update { cursor: pointer; + margin-top: 10px; margin-bottom: 10px; font-size: 1.3rem; background-color: $warning-red; diff --git a/app/serializers/api/admin/proxy_order_serializer.rb b/app/serializers/api/admin/proxy_order_serializer.rb index f5f24522bd..00f87e3f5d 100644 --- a/app/serializers/api/admin/proxy_order_serializer.rb +++ b/app/serializers/api/admin/proxy_order_serializer.rb @@ -5,11 +5,8 @@ module Api attributes :update_issues def total - if object.total.present? - object.total.to_money.to_s - else - object.subscription.subscription_line_items.sum(&:total_estimate) - end + return if object.total.blank? + object.total.to_money.to_s end def update_issues diff --git a/app/views/admin/subscriptions/_orders_panel.html.haml b/app/views/admin/subscriptions/_orders_panel.html.haml index 7bbf1b20b0..7314ee244d 100644 --- a/app/views/admin/subscriptions/_orders_panel.html.haml +++ b/app/views/admin/subscriptions/_orders_panel.html.haml @@ -19,7 +19,7 @@ %div{ ng: { bind: "::orderCycleCloses(proxyOrder.order_cycle_id)" } } %td.text-center %span.state{ ng: { class: "proxyOrder.state", bind: 'stateText(proxyOrder.state)' } } - %td.text-center{ ng: { bind: 'proxyOrder.total | currency' } } + %td.text-center{ ng: { bind: '(proxyOrder.total || subscription.estimatedTotal()) | currency' } } %td.actions %a.edit-order.icon-edit.no-text{ href: '{{::proxyOrder.edit_path}}', target: '_blank', 'ofn-with-tip' => t(:edit_order), confirm_order_edit: true } %a.cancel-order.icon-remove.no-text{ href: 'javascript:void(0)', ng: { hide: "proxyOrder.state == 'canceled'", click: "cancelOrder(proxyOrder)" }, 'ofn-with-tip' => t(:cancel_order) } diff --git a/app/views/admin/subscriptions/_review.html.haml b/app/views/admin/subscriptions/_review.html.haml index 38f597a36b..e1591e6210 100644 --- a/app/views/admin/subscriptions/_review.html.haml +++ b/app/views/admin/subscriptions/_review.html.haml @@ -91,3 +91,5 @@ \: %td.total.align-center %span#order_form_total {{ subscription.estimatedTotal() | currency }} + %p.notice + = t "this_is_an_estimate", scope: 'admin.subscriptions.subscription_line_items' diff --git a/app/views/admin/subscriptions/_subscription_line_items.html.haml b/app/views/admin/subscriptions/_subscription_line_items.html.haml index dcfd0c5fe0..0be91f2c93 100644 --- a/app/views/admin/subscriptions/_subscription_line_items.html.haml +++ b/app/views/admin/subscriptions/_subscription_line_items.html.haml @@ -29,7 +29,16 @@ = t(:subtotal) \: %td.total.align-center - %span {{ subscription.estimatedSubtotal() | currency }} + %span#order_subtotal {{ subscription.estimatedSubtotal() | currency }} + %td.actions + %tbody#fees.no-border-top{ ng: { show: "subscription.estimatedFees() > 0" } } + %tr#fees-row + %td{:colspan => "3"} + %b + = t(:fees) + \: + %td.total.align-center + %span#order_fees {{ subscription.estimatedFees() | currency }} %td.actions %tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"} %tr @@ -40,3 +49,5 @@ %td.total.align-center %span#order_form_total {{ subscription.estimatedTotal() | currency }} %td.actions +%p.notice + = t ".this_is_an_estimate" diff --git a/app/views/admin/subscriptions/setup_explanation.html.haml b/app/views/admin/subscriptions/setup_explanation.html.haml index f771b6af1d..676483a55e 100644 --- a/app/views/admin/subscriptions/setup_explanation.html.haml +++ b/app/views/admin/subscriptions/setup_explanation.html.haml @@ -14,7 +14,7 @@ .steps %div = t('.enable_subscriptions_step_1_html', - enterprises_link: link_to(t('admin.enterprises.title'), main_app.admin_enterprises_path, target: '_blank')) + enterprises_link: link_to(t('admin.enterprises.index.title'), main_app.admin_enterprises_path, target: '_blank')) %div= t('.enable_subscriptions_step_2') .row.margin-bottom-20.todo{ class: shipping_and_payment_methods_ok?(@shop) ? 'done' : '' } diff --git a/config/locales/en.yml b/config/locales/en.yml index 7f85aff207..d1f17bfa5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -999,6 +999,10 @@ en: address: 2. Address products: 3. Add Products review: 4. Review & Save + subscription_line_items: + this_is_an_estimate: | + The displayed prices are only an estimate and calculated at the time the subscription is changed. + If you change prices or fees, orders will be updated, but the subscription will still display the old values. details: details: Details invalid_error: Oops! Please fill in all of the required fields... @@ -2048,7 +2052,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using edit_profile_details_etc: "Change your profile description, images, etc." order_cycle: "Order Cycle" order_cycles: "Order Cycles" - enterprises: "Enterprises" enterprise_relationships: "Enterprise permissions" remove_tax: "Remove tax" enterprise_terms_of_service: "Enterprise Terms of Service" diff --git a/spec/features/admin/subscriptions_spec.rb b/spec/features/admin/subscriptions_spec.rb index 556164386a..3ca4e0efe2 100644 --- a/spec/features/admin/subscriptions_spec.rb +++ b/spec/features/admin/subscriptions_spec.rb @@ -17,6 +17,13 @@ feature 'Subscriptions' do let!(:subscription2) { create(:subscription, shop: shop2, with_items: true, with_proxy_orders: true) } let!(:subscription_unmanaged) { create(:subscription, shop: shop_unmanaged, with_items: true, with_proxy_orders: true) } + before do + subscription.update_attributes(shipping_fee_estimate: 3.5) + subscription.subscription_line_items.each do |sli| + sli.update_attributes(price_estimate: 5) + end + end + it "passes the smoke test" do visit spree.admin_path click_link 'Orders' @@ -60,6 +67,18 @@ feature 'Subscriptions' do expect(page).to_not have_selector "th.customer" expect(page).to_not have_content subscription.customer.email + # Viewing Products + within "tr#so_#{subscription.id}" do + expect(page).to have_selector "td.items.panel-toggle", text: 3 + page.find("td.items.panel-toggle").trigger('click') + end + + within "#subscription-line-items" do + expect(page).to have_selector "span#order_subtotal", text: "$15.00" # 3 x $5 items + expect(page).to have_selector "span#order_fees", text: "$3.50" # $3.5 shipping + expect(page).to have_selector "span#order_form_total", text: "$18.50" # 3 x $5 items + $3.5 shipping + end + # Viewing Orders within "tr#so_#{subscription.id}" do expect(page).to have_selector "td.orders.panel-toggle", text: 1 @@ -68,6 +87,7 @@ feature 'Subscriptions' do within ".subscription-orders" do expect(page).to have_selector "tr.proxy_order", count: 1 + expect(page).to have_content "$18.50" # 3 x $5 items + $3.5 shipping proxy_order = subscription.proxy_orders.first within "tr#po_#{proxy_order.id}" do