module.exports = Self => {
    Self.remoteMethod('collectionFaults', {
        description: 'Update sale of a collection',
        accessType: 'WRITE',
        accepts: [{
            arg: 'shelvingFk',
            type: 'String',
            required: true,
            description: 'The shalving id'
        }, {
            arg: 'quantity',
            type: 'Number',
            required: true,
            description: 'The quantity to sale'
        }, {
            arg: 'itemFk',
            type: 'Number',
            required: true,
            description: 'The ticket id'
        }],
        returns: {
            type: 'Object',
            root: true
        },
        http: {
            path: `/collectionFaults`,
            verb: 'POST'
        }
    });

    Self.collectionFaults = async(shelvingFk, quantity, itemFk) => {
        query = `CALL vn.collection_faults(?,?,?)`;
        return await Self.rawSql(query, [shelvingFk, quantity, itemFk]);
    };
};