lib/pack_material/repositories/replenish_repo.rb
# Only product variants that have suppliers and are not already set up for this purchase order id
#
# @return [Array] ['Product Variant Code', :id]
# @param [Integer] purchase_order_id
Only product variants that have suppliers and are not already set up for this purchase order id
Only product variants that have suppliers and are not already set up for this purchase order id
def for_select_po_product_variants(purchase_order_id) 
      role_id = DB[:mr_purchase_orders].where(id: purchase_order_id).select_map(:supplier_party_role_id).first
      supplier_id = DB[:suppliers].where(party_role_id: role_id).single_value
      product_variants = DB[:material_resource_product_variants].where(
        id: DB[:material_resource_product_variant_party_roles].where(
          supplier_id: supplier_id
        ).select_map(:material_resource_product_variant_id)
      ).reject do |r|
        DB[:mr_purchase_order_items].where(mr_purchase_order_id: purchase_order_id)
                                    .select_map(:mr_product_variant_id).include?(r[:id])
      end
      product_variants.map { |r| [r[:product_variant_code], r[:id]] }
    end
def for_select_po_product_variants ( purchase_order_id ) role_id = DB [ :mr_purchase_orders ] . where ( id : purchase_order_id ) . select_map ( :supplier_party_role_id ) . first supplier_id = DB [ :suppliers ] . where ( party_role_id : role_id ) . single_value product_variants = DB [ :material_resource_product_variants ] . where ( id : DB [ :material_resource_product_variant_party_roles ] . where ( supplier_id : supplier_id ) . select_map ( :material_resource_product_variant_id ) ) . reject do | r | DB [ :mr_purchase_order_items ] . where ( mr_purchase_order_id : purchase_order_id ) . select_map ( :mr_product_variant_id ) . include? ( r [ :id ] ) end product_variants . map { | r | [ r [ :product_variant_code ] , r [ :id ] ] } end
Only product variants that have suppliers and are not already set up for this purchase order id
Only product variants that have suppliers and are not already set up for this purchase order id
# rubocop:disable Metrics/AbcSize
['Product Variant Code', :id]
[ ' Product Variant Code ' : id ]
Array
purchase_order_id
<not_specific>
<not_specific>
None