/**
 * Created by Zhong on 2017/9/13.
 */
const mongoose = require('mongoose');
let Schema = mongoose.Schema;

//安装增加费-费用规则
let feeRuleSchema = new Schema({
    ID: String,
    sectionId: String, //分册章节id
    feeItemId:String,
    code: String,
    rule: String,
    base: String,
    feeRate: Number,
    labour: Number,
    material: Number,
    machine: Number,
    position: String,//记取位置
    billID:String//记取位置对应的清单ID
},{versionKey:false,_id: false});

//安装增加费-分册章节
let installSectionSchema = new Schema({
    ID: String,
    feeItemId: String,
    feeRuleId: String,
    name: String
},{versionKey:false,_id: false});

//安装增加费-费用项
let installFeeItemSchema = new Schema({
    ID: String,
    feeItem: String, //费用项
    feeType: String, //费用类型
    position: String,//记取位置
    billID:String,//记取位置对应的清单ID
    isCal: {type: Number,default:0}//是否记取0:false 1:true
},{versionKey:false,_id: false});

let installationFeeSchema = new Schema({
    ID:String,
    libID:Number,
    libName:String,
    projectID:String,
    installFeeItem:[installFeeItemSchema],
    installSection:[installSectionSchema],
    feeRule:[feeRuleSchema]
},{versionKey:false});

mongoose.model("installation_fee",installationFeeSchema,"installation_fee");
