Sha256: 1e2491da15992b3ed39a4ee07f0a90fc2cf42109255cca4ebf4a145e0ded064c

Contents?: true

Size: 975 Bytes

Versions: 4

Compression:

Stored size: 975 Bytes

Contents

class Skr.Models.Uom extends Skr.Models.Base

    props:
        id:    {type:"integer"}
        sku_id:{type:"integer"}
        price: {type:"bigdec",  required:true}
        size:  {type:"integer", default: 1}
        code:  {type:"string",  required:true, default: "EA"}
        weight:"bigdec"
        height:"bigdec"
        width: "bigdec"
        depth: "bigdec"

    derived:
        combined:
            deps: ['size', 'code'], fn: ->
                if @size is 1 then @code else "#{@code}/#{@size}"

        isDefault:
            deps: ['code', 'sku'], fn: ->
                @sku.default_uom_code is @code

    associations:
        sku: { model: "Sku" }

    eq: (other) ->
        other.size is @size and other.code is @code

    setDefault: ->
        this.sku.default_uom_code = @code

    constructor: ->
        super
        @sku.on('change:default_uom_code', ->
            @trigger('change', @, {})
            @unCacheDerived('total')
        , this)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stockor-0.5.0 client/skr/models/Uom.coffee
stockor-0.4.0 client/skr/models/Uom.coffee
stockor-0.3.0 client/skr/models/Uom.coffee
stockor-0.2 client/skr/models/Uom.coffee