/**
 * Created by Zhong on 2018/3/22.
 */
/*补充定额库-定额*/
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const deleteSchema = require('../all_schemas/delete_schema');

//定额工料机
const compleRationGljItemSchema = new Schema({
    gljId: Number,
    consumeAmt: String,
    type: String,    //std or complementary
    fromUser: String,

}, { _id: false });

//辅助定额调整
const compleRationAssItemSchema = new Schema({
    name: String,
    assistID: Number,
    assistCode: String,
    stdValue: String,
    stepValue: String,
    decimal: Number,
    carryBit: String,
    minValue: String,
    maxValue: String,
    paramName:String,//参数名称
    param:String,//参数
    thirdRationCode:String//第三定额
}, { _id: false });

//定额安装增加费用
const rationInstSchema = new Schema({
    feeItemId: String,
    sectionId: String
},{_id: false});

//补充定额
const compleRationSchema = new Schema({
    userId: String,
    compilationId: String,
    rationRepId: Number,
    ID:{type: Number,index: true},
    code: String,
    name: String,
    unit: String,
    labourPrice: String,
    materialPrice: String,
    machinePrice: String,
    basePrice: String,
    sectionId: String,
    caption: String,
    feeType: Number,
    jobContent: String,
    annotation: String,
    rationGljList: [compleRationGljItemSchema],
    rationCoeList: Array,
    rationAssList: [compleRationAssItemSchema],
    rationInstList: [rationInstSchema],
    rationTemplateList : [new Schema({
        rationID:Number,
        type: String,
        billsLocation: String
    }, { _id: false })],
    deleteInfo: deleteSchema
}, {versionKey: false});

mongoose.model('complementary_ration_items', compleRationSchema, 'complementary_ration_items');