/**
 * Created by Mai on 2017/4/24.
 */

var billsData = require('../../main/models/bills');
var BillsTemplateData = require('../../templates/models/bills_template');

module.exports = {
    copyTemplateData: function (tempType, newProjID, callback) {
        BillsTemplateData.getTemplate(tempType).then(function (templates) {
            var datas = [];
            templates.forEach(function (template) {
                template._doc.projectID = newProjID;
                datas.push(template._doc);
            })
            return billsData.AddBillsFromTemplate(datas, callback);
        }).catch(function (err) {
            callback(err);
        });
    }
};