UNPKG

kpiplus

Version:

KPI+

1 lines 1.52 kB
var model=require("../../models/rptform"),kbmPttct=require("../../models/kbm_pttct"),underscore=require("underscore"),controller=require("../../controllers/controller"),rptform=function(t){this.contr=new controller(t,model,"rptform",{sort:{rptform_name:1},onFinding:(t,r,o)=>{"PTTCT"==r.rptform_type&&r.id_app?model.find({rptform_type:r.rptform_type,id_app:r.id_app}).lean().exec(function(t,e){if(0==e.length){let t={id_app:r.id_app};underscore.extend(t,rptFormDefault),model.create(t,(t,e)=>{if(e){let t=[];underscore.extend(t,kbm),t.forEach(t=>{t.id_rptform=e._id.toString(),t.id_app=r.id_app}),kbmPttct.create(t,(t,e)=>{t&&console.log("error create rows for default form",t),o(null,r)})}else console.log("error create default form",t),o(null,r)})}else o(null,r)}):o(null,r)}}),this.contr.route()};module.exports=rptform;let rptFormDefault={rptform_type:"PTTCT",rptform_name:"Kết quả kinh doanh"},kbm=[{cach_tinh:"2",stt:1,ma_so:"01",chi_tieu:"Doanh thu",chart:"bar",status:!0,ma_sp:"",ma_nv:"",ma_dt:"",ma_hd:"",ma_phi:"",ma_bp:"",giam_tru_co:!1,giam_tru_no:!1,tk_co:["511"],tk_no:[],bold:!1,print:!0},{cach_tinh:"2",stt:2,ma_so:"02",chi_tieu:"Chi phí",chart:"bar",ma_sp:"",ma_nv:"",ma_dt:"",ma_hd:"",ma_phi:"",ma_bp:"",giam_tru_co:!1,giam_tru_no:!1,tk_co:[],tk_no:["641","642","632"],bold:!1,print:!0},{cach_tinh:"1",stt:3,ma_so:"03",chi_tieu:"Lãi/lỗ",cong_thuc:"[01]-[02]",chart:"line",ma_sp:"",ma_nv:"",ma_dt:"",ma_hd:"",ma_phi:"",ma_bp:"",giam_tru_co:!1,giam_tru_no:!1,tk_co:[],tk_no:[],bold:!1,print:!0}];