Sha256: cbd0ca53044d884ff29e34b9624fbe1270ffa4e114086f6dd3d5f3d8e290fe89

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

module Skr
    module Concerns

        module INV

            module Payments
                def total
                    if proxy_association.loaded?
                        inject(0){ | sum, pymnt | sum+pymnt.amount }
                    else
                        sum('amount')
                    end
                end

            end

            module Lines

                def other_charge
                    select{|l| l.sku.is_other_charge? }
                end

                def regular
                    reject{|l| l.sku.is_other_charge? }
                end

                def product
                    reject{|l| l.time_entry }
                end

                def time_entry
                    select{|l| l.time_entry }
                end

                def from_pick_ticket!
                    proxy_association.owner.pick_ticket.lines.each do | line |
                        build({ pt_line: line, qty: line.qty_to_ship })
                    end
                end

                def from_sales_order!
                    proxy_association.owner.sales_order.lines.each do | line |
                        build({ so_line: line, qty: line.qty_allocated })
                    end
                end

                def ea_qty
                    if proxy_association.loaded?
                        inject(0){ | sum, il | sum+(il.qty*il.uom_size) }
                    else
                        sum('qty*uom_size')
                    end
                end

            end

        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stockor-0.5.0 lib/skr/concerns/inv_extensions.rb
stockor-0.4.0 lib/skr/concerns/inv_extensions.rb