Merge pull request #2346 from oeoeaio/subs-totals

Subs: totals in backend are consistent and include fee breakdown
This commit is contained in:
Maikel
2018-08-07 18:17:13 +10:00
committed by GitHub
8 changed files with 43 additions and 9 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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) }

View File

@@ -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'

View File

@@ -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"

View File

@@ -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' : '' }

View File

@@ -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"

View File

@@ -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