Sha256: 5cda6860d0ab936ae95dbd3497bcbde50bdb0cb82bf36988ccfc0fca2bbc7308
Contents?: true
Size: 493 Bytes
Versions: 4
Compression:
Stored size: 493 Bytes
Contents
# frozen_string_literal: true module SolidusProductAssembly module Spree module InventoryUnitDecorator def percentage_of_line_item product = line_item.product if product.assembly? total_value = line_item.quantity_by_variant.map { |part, quantity| part.price * quantity }.sum variant.price / total_value else 1 / BigDecimal(line_item.quantity) end end ::Spree::InventoryUnit.prepend self end end end
Version data entries
4 entries across 4 versions & 1 rubygems