mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Show fee estimates in subscription totals in UI
This commit is contained in:
@@ -8,8 +8,11 @@ angular.module("admin.subscriptions").factory 'SubscriptionFunctions', ($injecto
|
||||
subtotal += item.price_estimate * item.quantity
|
||||
, 0
|
||||
|
||||
estimatedFees: ->
|
||||
@shipping_fee_estimate + @payment_fee_estimate
|
||||
|
||||
estimatedTotal: ->
|
||||
@estimatedSubtotal()
|
||||
@estimatedSubtotal() + @estimatedFees()
|
||||
|
||||
customer: ->
|
||||
return unless @customer_id
|
||||
|
||||
@@ -3,6 +3,7 @@ module Api
|
||||
class SubscriptionSerializer < ActiveModel::Serializer
|
||||
attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id, :begins_at, :ends_at
|
||||
attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state, :credit_card_id
|
||||
attributes :shipping_fee_estimate, :payment_fee_estimate
|
||||
|
||||
has_many :subscription_line_items, serializer: Api::Admin::SubscriptionLineItemSerializer
|
||||
has_many :closed_proxy_orders, serializer: Api::Admin::ProxyOrderSerializer
|
||||
@@ -38,6 +39,14 @@ module Api
|
||||
return '' unless object.id
|
||||
edit_admin_subscription_path(object)
|
||||
end
|
||||
|
||||
def shipping_fee_estimate
|
||||
object.shipping_fee_estimate.to_f
|
||||
end
|
||||
|
||||
def payment_fee_estimate
|
||||
object.payment_fee_estimate.to_f
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user