test

mail@pastecode.io avatar
unknown
javascript
3 years ago
1.1 kB
1
Indexable
Never
update_lines: function(lines){
        console.log('-------update orderlines-------')
        if(!this.pos.config.promotion_receipt){
            var no_promotion = _.filter(lines, function(line){return !line.promotion})
            var promotion = _.filter(lines, function(line){return line.promotion})
            if(promotion.length){
                var line = []
                for(var x=0; x<promotion.length; x++){
                    if(promotion[x].insert_after_line){
                        for(var y=0; y<no_promotion.length; y++){
                            if(no_promotion[y].id == promotion[x].insert_after_line){
                                no_promotion.splice(y+1,0,promotion[x])
                            }
                        }
                    }else{
                        no_promotion.push(promotion[x])
                    }
                }
                if(promotion){
                    return lines
                }
                return no_promotion
            }else{
                return lines
            }
        } else{
            return lines
        }
    },