Use estimated subscription total for proxy orders if order has not been initialized

This commit is contained in:
Rob Harrington
2018-05-30 12:49:11 +10:00
committed by Maikel Linke
parent fb93351386
commit cead905d05
3 changed files with 4 additions and 6 deletions

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 unless object.total.present?
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

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