Sha256: 434cc56f368590e8e8bb178a60280cfa8da3bf6fed84c85089c8aa78d650dc59

Contents?: true

Size: 1.11 KB

Versions: 34

Compression:

Stored size: 1.11 KB

Contents

module Workarea
  module Admin
    class FulfillmentViewModel < ApplicationViewModel
      def order
        options[:order] || OrderViewModel.wrap(Order.find(model.id))
      end

      def packages
        @packages ||= model.packages.map do |package|
          PackageViewModel.new(package, order: order)
        end
      end

      def pending_items
        @pending_items ||= model.pending_items.map do |fulfillment_item|
          next unless order_item = order
            .items
            .detect { |i| i.id.to_s == fulfillment_item.order_item_id }

          FulfillmentItemViewModel.new(
            order_item,
            quantity: fulfillment_item.quantity_pending
          )
        end.compact
      end

      def cancellations
        @cancellations ||= model.canceled_items.map do |fulfillment_item|
          next unless order_item = order
            .items
            .detect { |i| i.id.to_s == fulfillment_item.order_item_id }

          FulfillmentItemViewModel.new(
            order_item,
            quantity: fulfillment_item.quantity_canceled
          )
        end.compact
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.44 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.43 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.42 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.41 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.40 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.39 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.38 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.37 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.36 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.35 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.34 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.33 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.32 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.31 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.30 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.29 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.28 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.27 app/view_models/workarea/admin/fulfillment_view_model.rb
workarea-admin-3.4.26 app/view_models/workarea/admin/fulfillment_view_model.rb