Sha256: d1ac7c329f05d8abb26d67e3c9a676273835a306192a05e2de4a8a7039ff88a5

Contents?: true

Size: 431 Bytes

Versions: 2

Compression:

Stored size: 431 Bytes

Contents

KEY = 'SALES-HISTORY'

Skr.Api.Models.SalesHistory = {

    _encode: (sale) ->
        _.pick(sale, 'visible_id', 'hash_code', 'invoice_date', 'total')

    record: (sale) ->
        sales = @get()
        sales.push(@_encode(sale))
        localStorage.setItem(KEY, JSON.stringify({sales}) )

    get: ->
        sales = JSON.parse(localStorage.getItem(KEY))?.sales
        _.map sales, (sale) -> new Skr.Api.Models.Sale(sale)

}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stockor-0.5.0 client/skr/api/Models/SalesHistory.coffee
stockor-0.4.0 client/skr/api/Models/SalesHistory.coffee