/**
 * Created by zhang on 2018/3/22.
 */
let mongoose = require("mongoose");
let subSchema = require("../all_schemas/bills_sub_schemas");
let deleteSchema = require('../all_schemas/delete_schema');
let Schema = mongoose.Schema;
let billsSchema = new Schema({
    ID: {type: String, index: true},
    ParentID: String,
    NextSiblingID: String,
    projectID:{type: Number, index: true} ,
    serialNo: Number,
    chapterID: Number,
    billsLibId: Number,
    code: String,
    fullCode: String,
    type:{type: Number,default:4},//1 :大项费用 2：分部 3分项 4清单;5补项
    isAdd:{type: Number,default:0},//1 true 0 false是否新增
    name: String,
    unit: String,
    quantity: String, // Decimal
    quantity2:String,//预算项目中的数量2
    quantityEXP:String,//工程量表达式
    feeRateID:Number,
    feeRate:String,
    isFromDetail:{type: Number,default:0},//1 true 0 false
    programID: Number,
    calcBase: String,
    calcBaseValue: String,     // 计算基数表达式的值
    tenderCalcBaseValue: String,     // 调价后计算基数表达式的值
    baseProgressiveFee: String, // 累进计算中的基准值（报表需要这个中间值）
    // 工程量计算规则
    ruleText: String,
    // 说明
    comments: String,
    // 调价
    xs_Labour: String, // Decimal
    xs_Material: String, // Decimal
    xs_Machine: String, // Decimal
    xs_FeeRate: String, // Decimal
    xs_LabourPrice: String, // Decimal
    xs_MaterialPrice: String, // Decimal
    xs_MachinePrice: String, // Decimal
    isTender_Labour: Boolean,
    isTender_Material: Boolean,
    isTender_Machine: Boolean,
    targetUnitFee:String,//目标单价
    targetTotalFee:String,//目标合价
    //工作内容//zhong 2017-8-31
    jobContentText: String, //清单工作内容列显示文本, 减少第一次拉数据时的循环次数
    jobContent: [subSchema.jobContentSchema],
    //项目特征
    itemCharacterText: String,//清单项目特征列显示文本
    itemCharacter: [subSchema.itemCharacterSchema],
    // 费用字段
    fees: [subSchema.feesSchema],
    // 标记字段
    flags: [subSchema.flagsSchema],
    //消耗量调整系数字段
    quantityCoe:subSchema.quantityCoeSchema,
    //子目工程量调整系数
    rationQuantityCoe:String,
    // 不调价
    is_adjust_price: {type: Number,default: 0},
    installationKey:String,//用来记录安装增加费的关联字段
    deleteInfo: deleteSchema,
    isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估
    unitPriceAnalysis:{type: Number,default:0},       // 1 true 0 false 单价分析
    specialProvisional:String,
    remark:String,
    engineeringContent:String,//工程内容
    serviceContent:String,//服务内容
    claimVisa:String,//签证及索赔依据
    calcFlag: {type: Number},    // 叶子清单的计算类型。末定义：按定额计算。1：用户输入金额。2：用户输入单价。3：用户输入设计单价。
    bookmarkBackground:String,//书签背景色
    bookmarkAnnotation:String//批注
});

mongoose.model("bills", billsSchema);