mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
WIP: ProxyOrders don't require an order, calculating total for serialized proxy orders from standing order where order does not exist
This commit is contained in:
@@ -12,5 +12,9 @@ class StandingLineItem < ActiveRecord::Base
|
||||
.any?
|
||||
end
|
||||
|
||||
def total_estimate
|
||||
(price_estimate || 0) * (quantity || 0)
|
||||
end
|
||||
|
||||
default_scope order('id ASC')
|
||||
end
|
||||
|
||||
@@ -2,7 +2,11 @@ class Api::Admin::ProxyOrderSerializer < ActiveModel::Serializer
|
||||
attributes :id, :state, :edit_path, :number, :completed_at, :order_cycle_id, :total
|
||||
|
||||
def total
|
||||
object.total.to_money.to_s
|
||||
if object.total.present?
|
||||
object.total.to_money.to_s
|
||||
else
|
||||
object.standing_order.standing_line_items.sum(&:total_estimate)
|
||||
end
|
||||
end
|
||||
|
||||
def completed_at
|
||||
|
||||
Reference in New Issue
Block a user