flexbiz-server 12.2.2 → 12.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/server/app.js +14 -14
- package/server/auths/local.js +27 -26
- package/server/cluster.js +12 -11
- package/server/controllers/controller.js +83 -79
- package/server/controllers/controllerRPT.js +18 -17
- package/server/data/sys/listinfo.js +80395 -78085
- package/server/data/sys/reportinfo.js +8826 -8826
- package/server/data/sys/trangthai.js +10348 -10229
- package/server/libs/cdpstk.js +1 -1
- package/server/libs/databanle.js +13 -13
- package/server/libs/getGiaban.js +17 -16
- package/server/libs/permission.js +12 -12
- package/server/libs/post-book.js +9 -8
- package/server/libs/post-socai.js +9 -9
- package/server/libs/prototypes.js +7 -7
- package/server/libs/tinhGtPhanboSltp.js +5 -5
- package/server/libs/tinhGtPhanboYtcp.js +2 -2
- package/server/libs/tinhGtThcppstk.js +1 -1
- package/server/libs/tinhGtTrucTiep.js +8 -7
- package/server/libs/tinhgiatb.js +16 -19
- package/server/libs/tinhgiatb1vt.js +3 -3
- package/server/libs/tinhhoahong.js +32 -0
- package/server/libs/utils.js +4 -3
- package/server/models/app.js +9 -8
- package/server/models/approve.js +4 -4
- package/server/models/customer.js +8 -4
- package/server/models/dh2.js +10 -7
- package/server/models/dmbp.js +7 -4
- package/server/models/dmgiaban.js +6 -6
- package/server/models/dmhoahonghd.js +6 -5
- package/server/models/dmnvt.js +3 -3
- package/server/models/dmvt.js +9 -9
- package/server/models/ecomcategories.js +2 -2
- package/server/models/ecomcategories_cty.js +3 -0
- package/server/models/fbconversation.js +9 -0
- package/server/models/fbmessage.js +2 -0
- package/server/models/fbpage.js +2 -0
- package/server/models/group.js +7 -5
- package/server/models/hd2.js +11 -8
- package/server/models/hd3.js +9 -9
- package/server/models/hd7.js +1 -1
- package/server/models/listinfo.js +15 -8
- package/server/models/notification.js +3 -2
- package/server/models/originimportid.js +1 -0
- package/server/models/participant.js +5 -5
- package/server/models/pbl.js +4 -4
- package/server/models/reportinfo.js +2 -2
- package/server/models/rptform.js +3 -2
- package/server/models/schedule.js +1 -1
- package/server/models/so1.js +17 -14
- package/server/models/socai.js +7 -5
- package/server/models/task.js +4 -4
- package/server/models/tdttco.js +8 -4
- package/server/models/tdttno.js +8 -4
- package/server/models/tokens.js +2 -2
- package/server/models/tontucthoi.js +2 -2
- package/server/models/usergroup.js +4 -3
- package/server/models/vatra.js +2 -2
- package/server/models/vatvao.js +4 -4
- package/server/modules/lists/ls-assinvestment.js +1 -1
- package/server/modules/lists/ls-asskey.js +34 -34
- package/server/modules/lists/ls-customer.js +13 -7
- package/server/modules/lists/ls-dmbp.js +7 -3
- package/server/modules/lists/ls-dmnkh.js +5 -1
- package/server/modules/lists/ls-dmnvt.js +5 -5
- package/server/modules/lists/ls-dmvt.js +48 -35
- package/server/modules/lists/ls-ecomcategories.js +5 -0
- package/server/modules/lists/ls-ecomcategories_cty.js +5 -0
- package/server/modules/lists/ls-fbconversation.js +3 -0
- package/server/modules/lists/ls-fbmessage.js +3 -0
- package/server/modules/lists/ls-fbpage.js +10 -0
- package/server/modules/lists/ls-file.js +21 -25
- package/server/modules/lists/ls-group.js +5 -1
- package/server/modules/lists/ls-introducecode.js +8 -7
- package/server/modules/lists/ls-introducer.js +16 -17
- package/server/modules/lists/ls-message2.js +8 -7
- package/server/modules/lists/ls-message2setting.js +4 -4
- package/server/modules/lists/ls-news.js +1 -1
- package/server/modules/lists/ls-opportunity.js +3 -3
- package/server/modules/lists/ls-session.js +2 -2
- package/server/modules/lists/ls-task.js +18 -18
- package/server/modules/lists/ls-usergroup.js +6 -2
- package/server/modules/public/callin.js +6 -6
- package/server/modules/reports/calc-tinhgiatb.js +2 -2
- package/server/modules/reports/rp-cdpstk.js +3 -3
- package/server/modules/reports/rp-chitiettaisan.js +9 -8
- package/server/modules/reports/rp-ckvt.js +9 -7
- package/server/modules/reports/rp-congviectheonv.js +5 -5
- package/server/modules/reports/rp-ctbanle.js +13 -12
- package/server/modules/reports/rp-databanle.js +8 -4
- package/server/modules/reports/rp-dtbanletheoct.js +16 -9
- package/server/modules/reports/rp-dtbanletheokh.js +12 -6
- package/server/modules/reports/rp-dtbanletheokho.js +14 -9
- package/server/modules/reports/rp-dtbanletheonam.js +15 -9
- package/server/modules/reports/rp-dtbanletheongay.js +13 -8
- package/server/modules/reports/rp-dtbanletheonv.js +15 -9
- package/server/modules/reports/rp-dtbanletheoquy.js +15 -9
- package/server/modules/reports/rp-dtbanletheothang.js +15 -9
- package/server/modules/reports/rp-getinvoice2pay.js +4 -6
- package/server/modules/reports/rp-getinvoice2receive.js +4 -6
- package/server/modules/reports/rp-hoahong.js +9 -0
- package/server/modules/reports/rp-kqhdkd.js +5 -4
- package/server/modules/reports/rp-ptcttct.js +7 -6
- package/server/modules/reports/rp-pttct.js +8 -8
- package/server/modules/reports/rp-pttctkho.js +3 -2
- package/server/modules/reports/rp-pttctkho2.js +3 -3
- package/server/modules/reports/rp-thnxt.js +8 -7
- package/server/modules/reports/rp-thnxt_sl.js +6 -6
- package/server/modules/reports/rp-thnxttt.js +6 -6
- package/server/modules/reports/rp-tmbctc.js +16 -16
- package/server/modules/systems/sys-app.js +25 -24
- package/server/modules/systems/sys-notification.js +2 -2
- package/server/modules/systems/sys-schedule.js +1 -1
- package/server/modules/systems/sys-user.js +8 -8
- package/server/modules/vouchers/vo-bc1.js +9 -8
- package/server/modules/vouchers/vo-bg2.js +9 -9
- package/server/modules/vouchers/vo-bn1.js +5 -4
- package/server/modules/vouchers/vo-dh2.js +14 -19
- package/server/modules/vouchers/vo-dnm.js +11 -12
- package/server/modules/vouchers/vo-hd2.js +66 -54
- package/server/modules/vouchers/vo-hd3.js +28 -22
- package/server/modules/vouchers/vo-hd7.js +37 -36
- package/server/modules/vouchers/vo-pbl.js +49 -49
- package/server/modules/vouchers/vo-pc1.js +9 -8
- package/server/modules/vouchers/vo-pn1.js +24 -22
- package/server/modules/vouchers/vo-pn5.js +1 -1
- package/server/modules/vouchers/vo-pn9.js +23 -23
- package/server/modules/vouchers/vo-pnc.js +8 -8
- package/server/modules/vouchers/vo-pnh.js +5 -5
- package/server/modules/vouchers/vo-pt1.js +17 -16
- package/server/modules/vouchers/vo-pxc.js +16 -16
- package/server/modules/vouchers/vo-pxh.js +12 -10
- package/server/modules/vouchers/vo-so1.js +90 -116
- package/server/modules/vouchers/vo-so4.js +1 -1
- package/server/modules/vouchers/vo-so5.js +2 -2
- package/server/templates/reset mat khau.html +1 -1
- package/server/templates/reset mat khau.pug +1 -3
- package/server/workers/restoreApp.js +21 -12
- package/server/workers/runScript.js +3 -3
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';const databanle=require("../../libs/databanle"),async=require("async"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT"),moment=require("moment");
|
|
2
|
-
module.exports=function($router$$){new controller($router$$,"dtbanletheoquy",function($condition_req$$,$callback$jscomp$0$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.nam)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:nam");const $query$$={id_app:$condition_req$$.id_app}
|
|
3
|
-
{$gte:$
|
|
4
|
-
|
|
5
|
-
$
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"dtbanletheoquy",async function($condition_req$$,$callback$jscomp$0$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.nam)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:nam");const $query$$={id_app:$condition_req$$.id_app};var $condition_kh_custs_tu_ngay$$=moment(new Date($condition_req$$.nam,0,1)).startOf("year").toDate(),$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=moment(new Date($condition_req$$.nam,
|
|
3
|
+
11,31)).endOf("year").toDate();$query$$.ngay_ct={$gte:$condition_kh_custs_tu_ngay$$,$lte:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$};$condition_req$$.ma_dvcs&&($query$$.ma_dvcs=$condition_req$$.ma_dvcs);$condition_req$$.ma_kho&&($query$$.ma_kho=$condition_req$$.ma_kho);$condition_req$$.ma_ct&&($query$$.ma_ct=$condition_req$$.ma_ct);$condition_req$$.ma_kh?$query$$.ma_kh=$condition_req$$.ma_kh:($condition_kh_custs_tu_ngay$$={},$condition_req$$.nh_kh&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=
|
|
4
|
+
await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh2&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh2,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh2={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh3&&
|
|
5
|
+
($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh3,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh3={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh4&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh4,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh4={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),
|
|
6
|
+
$condition_req$$.nh_kh5&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh5,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh5={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),0<Object.keys($condition_kh_custs_tu_ngay$$).length&&($condition_kh_custs_tu_ngay$$.id_app=$condition_req$$.id_app,$condition_kh_custs_tu_ngay$$=await global.getModel("customer").find($condition_kh_custs_tu_ngay$$,{ma_kh:1}).lean(),
|
|
7
|
+
$query$$.ma_kh={$in:$condition_kh_custs_tu_ngay$$.map($c$$=>$c$$.ma_kh)}));$condition_req$$.user_hoa_hong&&($query$$.$or=[{user_nv:$condition_req$$.user_hoa_hong},{user_ctv:$condition_req$$.user_hoa_hong},{user_gt:$condition_req$$.user_hoa_hong},{user_ql:$condition_req$$.user_hoa_hong}]);databanle($query$$,function($error$jscomp$2$$,$rs$$,$ptthanhtoans$$){if($error$jscomp$2$$)return $callback$jscomp$0$$($error$jscomp$2$$);const $thanh_toan$$=$ptthanhtoans$$.map($pt$$=>({name:$pt$$.ma,value:$pt$$.ma,
|
|
8
|
+
ma:$pt$$.ma,ten:$pt$$.ten}));$rs$$.forEach(function($r$$){$r$$.thang=$r$$.ngay_ct.getMonth()+1;$r$$.nam=moment($r$$.ngay_ct).year();$r$$.quy=moment($r$$.ngay_ct).quarter()});async.mapSeries($rs$$,function($r$$,$callback$$){$r$$.t_sl_xuat=$r$$.details.csum("sl_xuat");$r$$.t_tien_hang=$r$$.details.csum("tien_hang");$r$$.t_tien_cp=$r$$.details.csum("tien_cp");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien=$r$$.details.csum("tien");$r$$.tien_freeship=$r$$.tien_freeship||0;$r$$.tien_phi_vc=$r$$.tien_phi_vc||
|
|
9
|
+
0;$r$$.tien_ck_hd=$r$$.tien_ck_hd?$r$$.tien_ck_hd:0;$r$$.t_tien_xuat=$r$$.details.csum("tien_xuat");$r$$.t_tien_hoa_hong=$r$$.details.csum("tien_hoa_hong");$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.details_tl?($r$$.t_tien_tl=$r$$.details_tl.csum("tien"),$r$$.t_tien_nhap=$r$$.details_tl.csum("tien_nhap"),$r$$.t_sl_nhap=$r$$.details_tl.csum("sl_nhap"),
|
|
10
|
+
$r$$.t_tien_hoa_hong-=$r$$.details_tl.csum("tien_hoa_hong"),$r$$.t_tien_hoa_hong_gt-=$r$$.details_tl.csum("tien_hoa_hong_gt"),$r$$.t_tien_hoa_hong_ctv-=$r$$.details_tl.csum("tien_hoa_hong_ctv"),$r$$.t_tien_hoa_hong_ql-=$r$$.details_tl.csum("tien_hoa_hong_ql")):($r$$.t_tien_tl=0,$r$$.t_sl_nhap=0,$r$$.t_tien_nhap=0);$callback$$(null,$r$$)},function($error$jscomp$0$$,$rs$jscomp$0$$){if($error$jscomp$0$$)return $callback$jscomp$0$$($error$jscomp$0$$);$rs$jscomp$0$$.groupBy(["nam","quy"],[{name:"t_sl_xuat",
|
|
11
|
+
value:"t_sl_xuat"},{name:"t_tien_hang",value:"t_tien_hang"},{name:"t_tien_cp",value:"t_tien_cp"},{name:"t_tien_ck",value:"t_tien_ck"},{name:"t_tien",value:"t_tien"},{name:"tien_ck_hd",value:"tien_ck_hd"},{name:"tien_freeship",value:"tien_freeship"},{name:"tien_phi_vc",value:"tien_phi_vc"},{name:"tien_evoucher",value:"tien_evoucher"},{name:"tien_thu",value:"tien_thu"},{name:"tien_thu2",value:"tien_thu2"},{name:"tien_paymentByPoints",value:"tien_paymentByPoints"},{name:"t_tien_xuat",value:"t_tien_xuat"},
|
|
12
|
+
{name:"t_sl_nhap",value:"t_sl_nhap"},{name:"t_tien_tl",value:"t_tien_tl"},{name:"t_tien_nhap",value:"t_tien_nhap"},{name:"phai_tra",value:"phai_tra"},{name:"t_tien_hoa_hong",value:"t_tien_hoa_hong"},{name:"t_tien_hoa_hong_gt",value:"t_tien_hoa_hong_gt"},{name:"t_tien_hoa_hong_ctv",value:"t_tien_hoa_hong_ctv"},{name:"t_tien_hoa_hong_ql",value:"t_tien_hoa_hong_ql"},...$thanh_toan$$],function($error$$,$rs$$){if($error$$)return $callback$jscomp$0$$($error$$);const $report$$=underscore.sortBy($rs$$,function($r$$){return Number($r$$.quy)});
|
|
13
|
+
let $i$$=1;$report$$.forEach(function($r$$){$r$$.stt=$i$$;$r$$.bold=!1;$r$$.t_doanh_thu=$r$$.t_tien+$r$$.tien_phi_vc-$r$$.tien_freeship-($r$$.tien_ck_hd||0)-($r$$.tien_evoucher||0);$r$$.t_lai=$r$$.t_doanh_thu-$r$$.t_tien_xuat-($r$$.t_tien_tl-$r$$.t_tien_nhap);$r$$.t_doanh_thu_thuan=$r$$.t_doanh_thu-$r$$.t_tien_tl;$r$$.t_tien_thu=$thanh_toan$$.map($pt$$=>$r$$[$pt$$.ma]||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$r$$.tu_ngay=moment([$r$$.nam,0,1]).quarter($r$$.quy).startOf("quarter").toDate();$r$$.den_ngay=
|
|
14
|
+
moment([$r$$.nam,0,1]).quarter($r$$.quy).endOf("quarter").toDate();$r$$.t_tien_paymentByPoints=$r$$.tien_paymentByPoints||0;$i$$++});const $tong_cong$$={quy:"T\u1ed5ng c\u1ed9ng",t_sl_xuat:$report$$.csum("t_sl_xuat"),t_tien_hang:$report$$.csum("t_tien_hang"),t_tien_cp:$report$$.csum("t_tien_cp"),t_tien_ck:$report$$.csum("t_tien_ck"),t_tien:$report$$.csum("t_tien"),tien_ck_hd:$report$$.csum("tien_ck_hd"),tien_phi_vc:$report$$.csum("tien_phi_vc"),tien_freeship:$report$$.csum("tien_freeship"),t_tien_xuat:$report$$.csum("t_tien_xuat"),
|
|
15
|
+
t_doanh_thu:$report$$.csum("t_doanh_thu"),t_sl_nhap:$report$$.csum("t_sl_nhap"),t_tien_tl:$report$$.csum("t_tien_tl"),t_tien_nhap:$report$$.csum("t_tien_nhap"),tien_evoucher:$report$$.csum("tien_evoucher"),tien_thu:$report$$.csum("tien_thu"),tien_thu2:$report$$.csum("tien_thu2"),t_tien_evoucher:$report$$.csum("tien_evoucher"),t_tien_thu:$report$$.csum("t_tien_thu"),phai_tra:$report$$.csum("phai_tra"),t_tien_paymentByPoints:$report$$.csum("tien_paymentByPoints"),t_lai:$report$$.csum("t_lai"),t_tien_hoa_hong:$report$$.csum("t_tien_hoa_hong"),
|
|
16
|
+
t_tien_hoa_hong_gt:$report$$.csum("t_tien_hoa_hong_gt"),t_tien_hoa_hong_ctv:$report$$.csum("t_tien_hoa_hong_ctv"),t_tien_hoa_hong_ql:$report$$.csum("t_tien_hoa_hong_ql"),bold:!0};$thanh_toan$$.forEach($pt$$=>{$pt$$.tong_cong=$tong_cong$$[$pt$$.ma]=$report$$.csum($pt$$.ma)});$report$$.push($tong_cong$$);$callback$jscomp$0$$(null,{data:$report$$,thanh_toan:$thanh_toan$$.filter($t$$=>$t$$.tong_cong)})})})})})};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';const databanle=require("../../libs/databanle"),async=require("async"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT"),moment=require("moment");
|
|
2
|
-
module.exports=function($router$$){new controller($router$$,"dtbanletheothang",function($condition_req$$,$callback$jscomp$0$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.nam)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:nam");const $query$$={id_app:$condition_req$$.id_app}
|
|
3
|
-
$query$$.ngay_ct={$gte:$
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"dtbanletheothang",async function($condition_req$$,$callback$jscomp$0$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.nam)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:nam");const $query$$={id_app:$condition_req$$.id_app};var $condition_kh_custs_tu_ngay$$=moment(new Date($condition_req$$.nam,0,1)).startOf("year").toDate(),$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=
|
|
3
|
+
moment(new Date($condition_req$$.nam,11,31)).endOf("year").toDate();$query$$.ngay_ct={$gte:$condition_kh_custs_tu_ngay$$,$lte:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$};$condition_req$$.ma_dvcs&&($query$$.ma_dvcs=$condition_req$$.ma_dvcs);$condition_req$$.ma_kho&&($query$$.ma_kho=$condition_req$$.ma_kho);$condition_req$$.ma_kh?$query$$.ma_kh=$condition_req$$.ma_kh:($condition_kh_custs_tu_ngay$$={},$condition_req$$.nh_kh&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,
|
|
4
|
+
$condition_req$$.nh_kh,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh2&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh2,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh2={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh3&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,
|
|
5
|
+
$condition_req$$.nh_kh3,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh3={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh4&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,$condition_req$$.nh_kh4,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh4={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),$condition_req$$.nh_kh5&&($den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition_req$$.id_app,
|
|
6
|
+
$condition_req$$.nh_kh5,{status:!0}),$condition_kh_custs_tu_ngay$$.nh_kh5={$in:$den_ngay_nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}),0<Object.keys($condition_kh_custs_tu_ngay$$).length&&($condition_kh_custs_tu_ngay$$.id_app=$condition_req$$.id_app,$condition_kh_custs_tu_ngay$$=await global.getModel("customer").find($condition_kh_custs_tu_ngay$$,{ma_kh:1}).lean(),$query$$.ma_kh={$in:$condition_kh_custs_tu_ngay$$.map($c$$=>$c$$.ma_kh)}));$condition_req$$.ma_ct&&($query$$.ma_ct=$condition_req$$.ma_ct);
|
|
7
|
+
$condition_req$$.user_hoa_hong&&($query$$.$or=[{user_nv:$condition_req$$.user_hoa_hong},{user_ctv:$condition_req$$.user_hoa_hong},{user_gt:$condition_req$$.user_hoa_hong},{user_ql:$condition_req$$.user_hoa_hong}]);databanle($query$$,function($error$jscomp$2$$,$rs$$,$ptthanhtoans$$){if($error$jscomp$2$$)return $callback$jscomp$0$$($error$jscomp$2$$);const $thanh_toan$$=$ptthanhtoans$$.map($pt$$=>({name:$pt$$.ma,value:$pt$$.ma,ma:$pt$$.ma,ten:$pt$$.ten}));$rs$$.forEach(function($r$$){$r$$.thang=moment($r$$.ngay_ct).month()+
|
|
8
|
+
1;$r$$.nam=moment($r$$.ngay_ct).year()});async.mapSeries($rs$$,function($r$$,$callback$$){$r$$.t_sl_xuat=$r$$.details.csum("sl_xuat");$r$$.t_tien_hang=$r$$.details.csum("tien_hang");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien_cp=$r$$.details.csum("tien_cp");$r$$.t_tien=$r$$.details.csum("tien");$r$$.tien_ck_hd=$r$$.tien_ck_hd||0;$r$$.t_tien_xuat=$r$$.details.csum("tien_xuat");$r$$.tien_freeship=$r$$.tien_freeship||0;$r$$.tien_phi_vc=$r$$.tien_phi_vc||0;$r$$.t_tien_hoa_hong=$r$$.details.csum("tien_hoa_hong");
|
|
9
|
+
$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.details_tl?($r$$.t_tien_tl=$r$$.details_tl.csum("tien"),$r$$.t_tien_nhap=$r$$.details_tl.csum("tien_nhap"),$r$$.t_sl_nhap=$r$$.details_tl.csum("sl_nhap"),$r$$.t_tien_hoa_hong-=$r$$.details_tl.csum("tien_hoa_hong"),$r$$.t_tien_hoa_hong_gt-=$r$$.details_tl.csum("tien_hoa_hong_gt"),$r$$.t_tien_hoa_hong_ctv-=$r$$.details_tl.csum("tien_hoa_hong_ctv"),
|
|
10
|
+
$r$$.t_tien_hoa_hong_ql-=$r$$.details_tl.csum("tien_hoa_hong_ql")):($r$$.t_tien_tl=0,$r$$.t_sl_nhap=0,$r$$.t_tien_nhap=0);$callback$$(null,$r$$)},function($error$jscomp$0$$,$rs$jscomp$0$$){if($error$jscomp$0$$)return $callback$jscomp$0$$($error$jscomp$0$$);$rs$jscomp$0$$.groupBy(["nam","thang"],[{name:"t_sl_xuat",value:"t_sl_xuat"},{name:"t_tien_hang",value:"t_tien_hang"},{name:"t_tien_cp",value:"t_tien_cp"},{name:"t_tien_ck",value:"t_tien_ck"},{name:"t_tien",value:"t_tien"},{name:"tien_ck_hd",value:"tien_ck_hd"},
|
|
11
|
+
{name:"tien_freeship",value:"tien_freeship"},{name:"tien_phi_vc",value:"tien_phi_vc"},{name:"tien_evoucher",value:"tien_evoucher"},{name:"tien_thu",value:"tien_thu"},{name:"tien_thu2",value:"tien_thu2"},{name:"tien_paymentByPoints",value:"tien_paymentByPoints"},{name:"t_tien_xuat",value:"t_tien_xuat"},{name:"t_sl_nhap",value:"t_sl_nhap"},{name:"t_tien_tl",value:"t_tien_tl"},{name:"t_tien_nhap",value:"t_tien_nhap"},{name:"phai_tra",value:"phai_tra"},{name:"t_tien_hoa_hong",value:"t_tien_hoa_hong"},
|
|
12
|
+
{name:"t_tien_hoa_hong_gt",value:"t_tien_hoa_hong_gt"},{name:"t_tien_hoa_hong_ctv",value:"t_tien_hoa_hong_ctv"},{name:"t_tien_hoa_hong_ql",value:"t_tien_hoa_hong_ql"},...$thanh_toan$$],function($error$$,$rs$$){if($error$$)return $callback$jscomp$0$$($error$$);const $report$$=underscore.sortBy($rs$$,function($r$$){return Number($r$$.thang)});let $i$$=1;$report$$.forEach(function($r$$){$r$$.stt=$i$$;$r$$.bold=!1;$r$$.t_doanh_thu=$r$$.t_tien+$r$$.tien_phi_vc-$r$$.tien_freeship-($r$$.tien_ck_hd||0)-($r$$.tien_evoucher||
|
|
13
|
+
0);$r$$.t_doanh_thu_thuan=$r$$.t_doanh_thu-$r$$.t_tien_tl;$r$$.t_lai=$r$$.t_doanh_thu-$r$$.t_tien_xuat-($r$$.t_tien_tl-$r$$.t_tien_nhap);$r$$.t_tien_thu=$thanh_toan$$.map($pt$$=>$r$$[$pt$$.ma]||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$r$$.tu_ngay=moment([$r$$.nam,$r$$.thang-1,1]).startOf("month").toDate();$r$$.den_ngay=moment([$r$$.nam,$r$$.thang-1,1]).endOf("month").toDate();$r$$.t_tien_paymentByPoints=$r$$.tien_paymentByPoints||0;$i$$++});const $tong_cong$$={thang:"T\u1ed5ng c\u1ed9ng",t_sl_xuat:$report$$.csum("t_sl_xuat"),
|
|
14
|
+
t_tien_hang:$report$$.csum("t_tien_hang"),t_tien_cp:$report$$.csum("t_tien_cp"),t_tien_ck:$report$$.csum("t_tien_ck"),t_tien:$report$$.csum("t_tien"),tien_ck_hd:$report$$.csum("tien_ck_hd"),tien_phi_vc:$report$$.csum("tien_phi_vc"),tien_freeship:$report$$.csum("tien_freeship"),t_tien_xuat:$report$$.csum("t_tien_xuat"),t_doanh_thu:$report$$.csum("t_doanh_thu"),t_sl_nhap:$report$$.csum("t_sl_nhap"),t_tien_nhap:$report$$.csum("t_tien_nhap"),t_tien_tl:$report$$.csum("t_tien_tl"),t_doanh_thu_thuan:$report$$.csum("t_doanh_thu_thuan"),
|
|
15
|
+
tien_evoucher:$report$$.csum("tien_evoucher"),tien_thu:$report$$.csum("tien_thu"),tien_thu2:$report$$.csum("tien_thu2"),t_tien_thu:$report$$.csum("t_tien_thu"),phai_tra:$report$$.csum("phai_tra"),t_tien_paymentByPoints:$report$$.csum("tien_paymentByPoints"),t_lai:$report$$.csum("t_lai"),t_tien_hoa_hong:$report$$.csum("t_tien_hoa_hong"),t_tien_hoa_hong_gt:$report$$.csum("t_tien_hoa_hong_gt"),t_tien_hoa_hong_ctv:$report$$.csum("t_tien_hoa_hong_ctv"),t_tien_hoa_hong_ql:$report$$.csum("t_tien_hoa_hong_ql"),
|
|
16
|
+
bold:!0};$thanh_toan$$.forEach($pt$$=>{$pt$$.tong_cong=$tong_cong$$[$pt$$.ma]=$report$$.csum($pt$$.ma)});$report$$.push($tong_cong$$);$callback$jscomp$0$$(null,{data:$report$$,thanh_toan:$thanh_toan$$.filter($t$$=>$t$$.tong_cong)})})})})})};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
'use strict';const tdttco=global.getModel("tdttco"),
|
|
2
|
-
module.exports=function($router$$){new controller($router$$,"getinvoice2pay",function($
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{id_tdtt:$invoice$$._id};$condition$$.id_ct&&($query$$.id_ct={$ne:$condition$$.id_ct});tdttco_tt.find($query$$).lean().exec(($da_thanh_toan_nt_error$$,$results$$)=>{$da_thanh_toan_nt_error$$=0;for(let $i$$=0;$i$$<$results$$.length;$i$$++)$da_thanh_toan_nt_error$$+=$results$$[$i$$].thanh_toan_qd;$t_invoice$$.da_thanh_toan_nt=$da_thanh_toan_nt_error$$;$t_invoice$$.con_lai_nt=$t_invoice$$.tien_hd_nt-$t_invoice$$.da_thanh_toan_nt;$callback$$(null,$t_invoice$$)})})},function($error$$,$results$$){if($error$$)return $callback$jscomp$0$$($error$$);
|
|
6
|
-
$callback$jscomp$0$$(null,$results$$.filter($r$$=>0<$r$$.con_lai_nt))})})})};
|
|
1
|
+
'use strict';const tdttco=global.getModel("tdttco"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"getinvoice2pay",function($condition_req$$,$callback$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.ma_kh||!$condition_req$$.id_app)return $callback$$("Ch\u1ee9c n\u0103ng n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1: ma_kh,id_app");$condition_req$$.tat_toan=!1;tdttco.getBalance($condition_req$$).then($invoices_results$$=>{$invoices_results$$=$invoices_results$$.filter($r$$=>0<$r$$.con_lai_nt).map($invoice$$=>{let $t_invoice$$=
|
|
3
|
+
{sel:!1,id_tdtt:$invoice$$._id,line:$invoice$$.line,id_hd:$invoice$$.id_ct,so_hd:$invoice$$.so_hd,ngay_hd:$invoice$$.ngay_hd,tien_hd_nt:$invoice$$.tien_nt};$t_invoice$$.ma_nt_hd=$invoice$$.ma_nt;$t_invoice$$.ty_gia_hd=$invoice$$.ty_gia;$t_invoice$$.ma_kh=$invoice$$.ma_kh;$t_invoice$$.dien_giai=$invoice$$.dien_giai;$t_invoice$$.tien_nt=0;$t_invoice$$.tien=0;$t_invoice$$.thanh_toan_qd=0;$t_invoice$$.tk_no=$invoice$$.tk_co;$t_invoice$$.da_thanh_toan_nt=$invoice$$.da_thanh_toan_nt;$t_invoice$$.da_thanh_toan=
|
|
4
|
+
$invoice$$.da_thanh_toan;$t_invoice$$.con_lai_nt=$invoice$$.con_lai_nt;$t_invoice$$.con_lai=$invoice$$.con_lai;return $t_invoice$$});$callback$$(null,$invoices_results$$)}).catch($error$$=>{$callback$$($error$$)})})};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
'use strict';const tdttno=global.getModel("tdttno"),
|
|
2
|
-
module.exports=function($router$$){new controller($router$$,"getinvoice2receive",function($
|
|
3
|
-
|
|
4
|
-
$
|
|
5
|
-
$invoice$$.tk_no;let $query$$={id_tdtt:$invoice$$._id};$condition$$.id_ct&&($query$$.id_ct={$ne:$condition$$.id_ct});tdttno_tt.find($query$$).lean().exec(($da_thanh_toan_nt_error$$,$results$$)=>{$da_thanh_toan_nt_error$$=0;for(let $i$$=0;$i$$<$results$$.length;$i$$++)$da_thanh_toan_nt_error$$+=$results$$[$i$$].thanh_toan_qd;$t_invoice$$.da_thanh_toan_nt=$da_thanh_toan_nt_error$$;$t_invoice$$.con_lai_nt=$t_invoice$$.tien_hd_nt-$t_invoice$$.da_thanh_toan_nt;$callback$$(null,$t_invoice$$)})})},function($error$$,
|
|
6
|
-
$results$$){if($error$$)return $callback$jscomp$0$$($error$$);$callback$jscomp$0$$(null,$results$$.filter($r$$=>0<$r$$.con_lai_nt))})})})};
|
|
1
|
+
'use strict';const tdttno=global.getModel("tdttno"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"getinvoice2receive",function($condition_req$$,$callback$$){$condition_req$$=$condition_req$$.query;if(!$condition_req$$.ma_kh||!$condition_req$$.id_app)return $callback$$("Ch\u1ee9c n\u0103ng n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1: ma_kh,id_app");$condition_req$$.tat_toan=!1;tdttno.getBalance($condition_req$$).then($invoices_results$$=>{$invoices_results$$=$invoices_results$$.filter($r$$=>0<$r$$.con_lai_nt).map($invoice$$=>{let $t_invoice$$=
|
|
3
|
+
{sel:!1,id_tdtt:$invoice$$._id,line:$invoice$$.line,id_hd:$invoice$$.id_ct,so_hd:$invoice$$.so_hd,ngay_hd:$invoice$$.ngay_hd,tien_hd_nt:$invoice$$.tien_nt};$t_invoice$$.ma_nt_hd=$invoice$$.ma_nt;$t_invoice$$.ty_gia_hd=$invoice$$.ty_gia;$t_invoice$$.ma_kh=$invoice$$.ma_kh;$t_invoice$$.dien_giai=$invoice$$.dien_giai;$t_invoice$$.tien_nt=0;$t_invoice$$.tien=0;$t_invoice$$.thanh_toan_qd=0;$t_invoice$$.tk_co=$invoice$$.tk_no;$t_invoice$$.da_thanh_toan_nt=$invoice$$.da_thanh_toan_nt;$t_invoice$$.da_thanh_toan=
|
|
4
|
+
$invoice$$.da_thanh_toan;$t_invoice$$.con_lai_nt=$invoice$$.con_lai_nt;$t_invoice$$.con_lai=$invoice$$.con_lai;return $t_invoice$$});$callback$$(null,$invoices_results$$)}).catch($error$$=>{$callback$$($error$$)})})};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';const databanle=require("../../libs/databanle"),async=require("async"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"hoahong",async function($query_req$$,$callback$jscomp$0$$){const $condition$$=$query_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");$query_req$$={id_app:$condition$$.id_app};$query_req$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query_req$$.ma_dvcs=$condition$$.ma_dvcs);
|
|
3
|
+
$condition$$.ma_kho&&($query_req$$.ma_kho=$condition$$.ma_kho);$condition$$.ma_ct&&($query_req$$.ma_ct=$condition$$.ma_ct);$condition$$.user_hoa_hong&&($query_req$$.$or=[{user_nv:$condition$$.user_hoa_hong},{user_ctv:$condition$$.user_hoa_hong},{user_gt:$condition$$.user_hoa_hong},{user_ql:$condition$$.user_hoa_hong}]);databanle($query_req$$,function($error$jscomp$0$$,$rs$$){if($error$jscomp$0$$)return $callback$jscomp$0$$($error$jscomp$0$$);async.mapSeries($rs$$,function($r$$,$callback$$){$r$$.t_tien_hoa_hong=
|
|
4
|
+
$r$$.details.csum("tien_hoa_hong");$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.thang=(new Date($r$$.ngay_ct)).getMonth()+1;$r$$.nam=(new Date($r$$.ngay_ct)).getFullYear();$condition$$.chi_hien_chua_post_sokho?global.getModel("sokho").find({id_ct:$r$$._id}).lean().then($rs$$=>{$r$$.t_sl_xuat_kho=$rs$$.map($r$$=>$r$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,
|
|
5
|
+
0);$callback$$(null,$r$$)}):$callback$$(null,$r$$)},function($data_error$$,$rs$$){if($data_error$$)return $callback$jscomp$0$$($data_error$$);$condition$$.chi_hien_chua_post_sokho&&($rs$$=$rs$$.filter($r$$=>!$r$$.t_sl_xuat_kho));let $data_orgin$$=[...$rs$$];$rs$$.filter($r$$=>$r$$.details_tl).forEach($tl$$=>{$tl$$.details_tl.forEach($r$$=>{$r$$.t_tien_hoa_hong=0-$r$$.tien_hoa_hong;$r$$.t_tien_hoa_hong_ql=0-$r$$.tien_hoa_hong_ql;$r$$.t_tien_hoa_hong_ctv=0-$r$$.tien_hoa_hong_ctv;$r$$.t_tien_hoa_hong_gt=
|
|
6
|
+
0-$r$$.tien_hoa_hong_gt;$r$$.thang=(new Date($tl$$.ngay_ct)).getMonth()+1;$r$$.nam=(new Date($tl$$.ngay_ct)).getFullYear();$data_orgin$$.push($r$$)})});$data_error$$=$data_orgin$$.map($r$$=>{let $_r$$=[];$r$$.user_nv&&$r$$.t_tien_hoa_hong&&$_r$$.push({user_hoa_hong:$r$$.user_nv,t_tien_hoa_hong:$r$$.t_tien_hoa_hong,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ql&&$r$$.t_tien_hoa_hong_ql&&$_r$$.push({user_hoa_hong:$r$$.user_ql,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ql,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ctv&&
|
|
7
|
+
$r$$.t_tien_hoa_hong_ctv&&$_r$$.push({user_hoa_hong:$r$$.user_ctv,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ctv,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_gt&&$r$$.t_tien_hoa_hong_gt&&$_r$$.push({user_hoa_hong:$r$$.user_gt,t_tien_hoa_hong_gt:$r$$.t_tien_hoa_hong_gt,thang:$r$$.thang,nam:$r$$.nam});return $_r$$}).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$condition$$.user_hoa_hong&&($data_error$$=$data_error$$.filter($r$$=>$r$$.user_hoa_hong==$condition$$.user_hoa_hong));$data_error$$=$data_error$$.filter($r$$=>
|
|
8
|
+
$r$$.t_tien_hoa_hong||$r$$.t_tien_hoa_hong_gt);$data_error$$.groupBy(["thang","nam","user_hoa_hong"],[{name:"t_tien_hoa_hong",value:"t_tien_hoa_hong"},{name:"t_tien_hoa_hong_gt",value:"t_tien_hoa_hong_gt"}],async function($error$$,$report$$){if($error$$)return $callback$jscomp$0$$($error$$);await $report$$.asyncJoinModel2($condition$$.id_app,"participant",{where:{user_hoa_hong:"email"},fields:{ten_user_hoa_hong:"name"}});$report$$=$report$$.sort(($a$$,$b$$)=>12*$a$$.nam+$a$$.thang-(12*$b$$.nam+$b$$.thang));
|
|
9
|
+
$report$$.forEach(function($r$$,$i$$){$r$$.stt=$i$$+1;$r$$.bold=!1});$error$$={nam:"T\u1ed5ng c\u1ed9ng",t_tien_hoa_hong:$report$$.csum("t_tien_hoa_hong"),t_tien_hoa_hong_gt:$report$$.csum("t_tien_hoa_hong_gt"),bold:!0};$report$$.push($error$$);$callback$jscomp$0$$(null,$report$$)})})})})};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';const socai=global.getModel("socai"),kbmkqhdkd=global.getModel("kbmkqhdkd"),{calcGrid}=require("../../libs/utils"),async=require("async"),controller=require("../../controllers/controllerRPT"),getRegString=function($arrayTk$$){return $arrayTk$$.reg()};
|
|
2
2
|
module.exports=function($router$$){new controller($router$$,"kqhdkd",function($kbm_query_req$$,$callback$jscomp$0$$){const $query$$=$kbm_query_req$$.query;if(!$query$$.den_ngay||!$query$$.tu_ngay)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1: t\u1eeb ng\u00e0y(tu_ngay), \u0111\u1ebfn ng\u00e0y(den_ngay)");$query$$.tu_ngay=new Date($query$$.tu_ngay);$query$$.den_ngay=new Date($query$$.den_ngay);$query$$.tu_ngay_kt&&$query$$.den_ngay_kt||($query$$.tu_ngay_kt=
|
|
3
3
|
new Date($query$$.tu_ngay),$query$$.tu_ngay_kt.setYear($query$$.tu_ngay_kt.getFullYear()-1),$query$$.den_ngay_kt=new Date($query$$.den_ngay),$query$$.den_ngay_kt.setYear($query$$.den_ngay_kt.getFullYear()-1));let $report$$;$kbm_query_req$$={id_app:$query$$.id_app};$kbm_query_req$$.id_rptform=$query$$.id_rptform?$query$$.id_rptform:{$in:[void 0,null,""]};kbmkqhdkd.find($kbm_query_req$$).sort({stt:1}).lean().exec(function($error$jscomp$0$$,$kbm$$){if($error$jscomp$0$$)return $callback$jscomp$0$$($error$jscomp$0$$);
|
|
4
|
-
$report$$=$kbm$$;async.mapSeries($report$$,function($r$$,$c1$$){setImmediate(()=>{"1"==$r$$.cach_tinh?$c1$$(null,$r$$):async.series({ky_truoc:function($callback$$){const $condition$$={ngay_ct:{$gte:$query$$.tu_ngay_kt,$lte:$query$$.den_ngay_kt},id_app:$query$$.id_app};$query$$.ma_dvcs&&($condition$$.ma_dvcs={$regex:"^"+$query$$.ma_dvcs,$options:"i"});var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no
|
|
5
|
-
$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};socai.find($condition$$,{tien:1,tien_nt:1},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.ky_truoc=$rs$$.csum("tien");$r$$.ky_truoc_nt=$rs$$.csum("tien_nt");$callback$$(null,$r$$)})},ky_nay:function($callback$$){const $condition$$={ngay_ct:{$gte:$query$$.tu_ngay
|
|
6
|
-
($condition$$.ma_dvcs={$regex:"^"+$query$$.ma_dvcs,$options:"i"});var $tk_co$jscomp$1_tk_no$$=getRegString($r$$.tk_no);$tk_co$jscomp$1_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co$jscomp$1_tk_no$$)}:{$regex:$tk_co$jscomp$1_tk_no$$,$options:"i"});if($tk_co$jscomp$1_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co?
|
|
7
|
-
$rs$$){if($error$$)return $callback$$($error$$);$r$$.ky_nay=$rs$$.csum("tien");$r$$.ky_nay_nt=$rs$$.csum("tien_nt");$callback$$(null,$r$$)})}},function($error$$,$results$$){$c1$$($error$$,$results$$)})})},function($error$$){if($error$$)return $callback$jscomp$0$$($error$$);calcGrid($report$$,"ky_nay,ky_nay_nt,ky_truoc,ky_truoc_nt",function($rs$$){$callback$jscomp$0$$(null
|
|
4
|
+
$report$$=$kbm$$;async.mapSeries($report$$,function($r$$,$c1$$){setImmediate(()=>{"1"==$r$$.cach_tinh?$c1$$(null,$r$$):async.series({ky_truoc:function($callback$$){const $condition$$={ngay_ct:{$gte:$query$$.tu_ngay_kt,$lte:$query$$.den_ngay_kt},id_app:$query$$.id_app};$query$$.ma_dvcs&&($condition$$.ma_dvcs={$regex:"^"+$query$$.ma_dvcs,$options:"i"});$query$$.ma_kho&&($condition$$.ma_kho={$regex:"^"+$query$$.ma_kho,$options:"i"});var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=
|
|
5
|
+
$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};socai.find($condition$$,{tien:1,tien_nt:1},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.ky_truoc=$rs$$.csum("tien");$r$$.ky_truoc_nt=$rs$$.csum("tien_nt");$callback$$(null,$r$$)})},ky_nay:function($callback$$){const $condition$$={ngay_ct:{$gte:$query$$.tu_ngay,
|
|
6
|
+
$lte:$query$$.den_ngay},id_app:$query$$.id_app};$query$$.ma_dvcs&&($condition$$.ma_dvcs={$regex:"^"+$query$$.ma_dvcs,$options:"i"});$query$$.ma_kho&&($condition$$.ma_kho={$regex:"^"+$query$$.ma_kho,$options:"i"});var $tk_co$jscomp$1_tk_no$$=getRegString($r$$.tk_no);$tk_co$jscomp$1_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co$jscomp$1_tk_no$$)}:{$regex:$tk_co$jscomp$1_tk_no$$,$options:"i"});if($tk_co$jscomp$1_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co?
|
|
7
|
+
{$not:new RegExp($tk_co$jscomp$1_tk_no$$)}:{$regex:$tk_co$jscomp$1_tk_no$$,$options:"i"};socai.find($condition$$,{tien:1,tien_nt:1},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.ky_nay=$rs$$.csum("tien");$r$$.ky_nay_nt=$rs$$.csum("tien_nt");$callback$$(null,$r$$)})}},function($error$$,$results$$){$c1$$($error$$,$results$$)})})},function($error$$){if($error$$)return $callback$jscomp$0$$($error$$);calcGrid($report$$,"ky_nay,ky_nay_nt,ky_truoc,ky_truoc_nt",function($rs$$){$callback$jscomp$0$$(null,
|
|
8
|
+
$rs$$)})})})})};
|
|
@@ -3,12 +3,13 @@ module.exports=function($router$$){new controller($router$$,"ptcttct",function($
|
|
|
3
3
|
(new Promise(($resolve$$,$reject$$)=>{rptform.findOne({_id:$query$$.id_rptform}).lean().exec(($e$$,$rs$$)=>{if($e$$||!$rs$$)return $reject$$($e$$);$resolve$$($rs$$)})})).then(async $_rptform$$=>{$query$$.tu_ngay=moment(new Date($query$$.tu_ngay)).startOf("date").toDate();$query$$.den_ngay=moment(new Date($query$$.den_ngay)).endOf("date").toDate();let $report$$=$_rptform$$.report;$report$$&&0!==$_rptform$$.report.length||($report$$=await kbmpttct.find({id_rptform:$_rptform$$._id.toString()}).sort({stt:1}).lean());
|
|
4
4
|
async.mapSeries($report$$,function($r$$,$c1$$){setImmediate(()=>{$r$$.stt_child=0;if("9"===$r$$.cach_tinh)$r$$.cong_thuc="",utils.getInfoFromQuery($query$$,$r$$.query,($e$$,$rs$$)=>{if($e$$)return $c1$$();_.isNumber($rs$$)?($r$$.so_kn=$rs$$,$r$$.so_kn_nt=$rs$$):$r$$.value_string=$rs$$;$c1$$()});else if("2"===$r$$.cach_tinh)$r$$.cong_thuc="",async.series({ky_nay:function($callback$jscomp$0$$){let $condition$$={ngay_ct:{$gte:$query$$.tu_ngay,$lte:$query$$.den_ngay},id_app:$query$$.id_app};$query$$.ma_dvcs&&
|
|
5
5
|
($condition$$.ma_dvcs=$query$$.ma_dvcs);$query$$.ma_bp&&($condition$$.ma_bp=$query$$.ma_bp);$query$$.ma_hd&&($condition$$.ma_hd=$query$$.ma_hd);$query$$.ma_dt&&($condition$$.ma_dt=$query$$.ma_dt);$query$$.ma_sp&&($condition$$.ma_sp=$query$$.ma_sp);$query$$.ma_nv&&($condition$$.ma_nv=$query$$.ma_nv);$r$$.ma_phi&&($condition$$.ma_phi=$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:
|
|
6
|
-
{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{
|
|
7
|
-
function($error$$,$rs$jscomp$0$$){if($error$$)return $callback$jscomp$0$$($error$$);$r$$.so_kn=$rs$jscomp$0$$.csum("tien");$r$$.so_kn_nt=$rs$jscomp$0$$.csum("tien_nt");let $id_cts$$=$rs$jscomp$0$$.map($r$$=>$r$$.id_ct);async.series({vatra:$callback$$=>{vatra.find({id_ct:{$in:$id_cts$$}}).lean().exec(($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null
|
|
8
|
-
$rs$$)})},sokho:$callback$$=>{sokho.find({id_ct:{$in:$id_cts$$}}).lean().exec(($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,$rs$$)})},socai:$callback$$=>{$rs$jscomp$0$$.groupBy(["id_ct"],["tien","tien_nt"],($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)},{fieldmaxs:["so_ct","ngay_ct","dien_giai","ma_ct"]})}},($e$$,$rs$$)=>{$r$$.vatra=$rs$$.vatra.csum("t_thue")
|
|
9
|
-
$r$$.thue=$r$$.vatra+$r$$.vatvao;$r$$.thue_nt=$r$$.vatra_nt+$r$$.vatvao_nt;$r$$.sl_nhap=$rs$$.sokho.csum("sl_nhap");$r$$.sl_xuat=$rs$$.sokho.csum("sl_xuat");$r$$.so_luong=$r$$.sl_nhap+$r$$.sl_xuat;$r$$.t_tt=$r$$.thue+$r$$.so_kn;$r$$.t_tt_nt=$r$$.thue_nt+$r$$.so_kn_nt;$r$$.sokho=$rs$$.sokho;$r$$.ct_socai&&($r$$.socai=$rs$$.socai,$r$$.socai.sort(($a$$,$b$$)=>(new Date($a$$.ngay_ct)).getTime()>
|
|
10
|
-
|
|
11
|
-
Math.roundBy($s$$.tien_nt/$s$$.so_luong,2):0;$s$$.t_tt=$s$$.thue+$s$$.tien;$s$$.t_tt_nt=$s$$.thue_nt+$s$$.tien_nt;$s$$.stt=$r$$.stt;$r$$.stt_child=$index$$+1;$report$$.push($s$$)}));$callback$jscomp$0$$($e$$,$r$$)})})}},function($error$$,$results$$){$c1$$($error$$,$results$$)});else if("99"===$r$$.cach_tinh&&$r$$.script){$r$$.cong_thuc="";if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");
|
|
6
|
+
{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{0>$r$$.dieu_kien_khac.indexOf("{")&&($r$$.dieu_kien_khac="{"+$r$$.dieu_kien_khac+"}");let $str_func$$=$r$$.dieu_kien_khac;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $dieu_kien_khac$$=utils.evalute($str_func$$,{moment,condition:$condition$$,
|
|
7
|
+
row:$r$$});$condition$$={...$condition$$,...$dieu_kien_khac$$}}catch($e$$){$callback$jscomp$0$$($e$$.toString())}socai.find($condition$$,function($error$$,$rs$jscomp$0$$){if($error$$)return $callback$jscomp$0$$($error$$);$r$$.so_kn=$rs$jscomp$0$$.csum("tien");$r$$.so_kn_nt=$rs$jscomp$0$$.csum("tien_nt");let $id_cts$$=$rs$jscomp$0$$.map($r$$=>$r$$.id_ct);async.series({vatra:$callback$$=>{vatra.find({id_ct:{$in:$id_cts$$}}).lean().exec(($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,
|
|
8
|
+
$rs$$)})},vatvao:$callback$$=>{vatvao.find({id_ct:{$in:$id_cts$$}}).lean().exec(($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,$rs$$)})},sokho:$callback$$=>{sokho.find({id_ct:{$in:$id_cts$$}}).lean().exec(($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,$rs$$)})},socai:$callback$$=>{$rs$jscomp$0$$.groupBy(["id_ct"],["tien","tien_nt"],($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)},{fieldmaxs:["so_ct","ngay_ct","dien_giai","ma_ct"]})}},($e$$,$rs$$)=>{$r$$.vatra=$rs$$.vatra.csum("t_thue");
|
|
9
|
+
$r$$.vatvao=$rs$$.vatvao.csum("t_thue");$r$$.vatra_nt=$rs$$.vatra.csum("t_thue_nt");$r$$.vatvao_nt=$rs$$.vatvao.csum("t_thue_nt");$r$$.thue=$r$$.vatra+$r$$.vatvao;$r$$.thue_nt=$r$$.vatra_nt+$r$$.vatvao_nt;$r$$.sl_nhap=$rs$$.sokho.csum("sl_nhap");$r$$.sl_xuat=$rs$$.sokho.csum("sl_xuat");$r$$.so_luong=$r$$.sl_nhap+$r$$.sl_xuat;$r$$.t_tt=$r$$.thue+$r$$.so_kn;$r$$.t_tt_nt=$r$$.thue_nt+$r$$.so_kn_nt;$r$$.sokho=$rs$$.sokho;$r$$.ct_socai&&($r$$.socai=$rs$$.socai,$r$$.socai.sort(($a$$,$b$$)=>(new Date($a$$.ngay_ct)).getTime()>
|
|
10
|
+
(new Date($b$$.ngay_ct)).getTime()?1:(new Date($a$$.ngay_ct)).getTime()<(new Date($b$$.ngay_ct)).getTime()?-1:$a$$.so_ct>$b$$.so_ct?1:$a$$.so_ct<$b$$.so_ct?-1:0).forEach(($s$$,$index$$)=>{$s$$.thue=$rs$$.vatra.csum("t_thue",{id_ct:$s$$.id_ct})+$rs$$.vatvao.csum("t_thue",{id_ct:$s$$.id_ct});$s$$.thue_nt=$rs$$.vatra.csum("t_thue_nt",{id_ct:$s$$.id_ct})+$rs$$.vatvao.csum("t_thue_nt",{id_ct:$s$$.id_ct});$s$$.so_luong=$rs$$.sokho.csum("sl_nhap",{id_ct:$s$$.id_ct})+$rs$$.sokho.csum("sl_xuat",{id_ct:$s$$.id_ct});
|
|
11
|
+
$s$$.gia=0!==$s$$.so_luong?Math.roundBy($s$$.tien/$s$$.so_luong,0):0;$s$$.gia_nt=0!==$s$$.so_luong?Math.roundBy($s$$.tien_nt/$s$$.so_luong,2):0;$s$$.t_tt=$s$$.thue+$s$$.tien;$s$$.t_tt_nt=$s$$.thue_nt+$s$$.tien_nt;$s$$.stt=$r$$.stt;$r$$.stt_child=$index$$+1;$report$$.push($s$$)}));$callback$jscomp$0$$($e$$,$r$$)})})}},function($error$$,$results$$){$c1$$($error$$,$results$$)});else if("99"===$r$$.cach_tinh&&$r$$.script){$r$$.cong_thuc="";if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");
|
|
12
|
+
let $func_string$$=`return (async ()=>{
|
|
12
13
|
try{
|
|
13
14
|
${$r$$.script}
|
|
14
15
|
}catch(e){
|
|
@@ -17,14 +17,14 @@ $query$$.den_ngay.getTime()&&($den_ngay_den_ngay$jscomp$1_den_ngay$jscomp$2_den_
|
|
|
17
17
|
$_rptform_tu_ngay_tu_ngay$jscomp$1_tu_ngay$jscomp$2_tu_ngay$jscomp$3_tu_ngay$$=moment($den_ngay_den_ngay$jscomp$1_den_ngay$jscomp$2_den_ngay$jscomp$3_den_ngay$$).add(1,"days").startOf("date").toDate();break;case "kn":$kys$$=[{ma_ky:"kn",ten_ky:"Gi\u00e1 tr\u1ecb",tu_ngay:$query$$.tu_ngay,den_ngay:$query$$.den_ngay}];break;default:$query$$.tu_ngay_kt=new Date($query$$.tu_ngay),$query$$.tu_ngay_kt.setYear($query$$.tu_ngay_kt.getFullYear()-1),$query$$.den_ngay_kt=new Date($query$$.den_ngay),$query$$.den_ngay_kt.setYear($query$$.den_ngay_kt.getFullYear()-
|
|
18
18
|
1),$kys$$=[{ma_ky:"kt",ten_ky:"K\u1ef3 tr\u01b0\u1edbc",tu_ngay:$query$$.tu_ngay_kt,den_ngay:$query$$.den_ngay_kt},{ma_ky:"kn",ten_ky:"K\u1ef3 n\u00e0y",tu_ngay:$query$$.tu_ngay,den_ngay:$query$$.den_ngay}]}async.mapSeries($report$$,($r$$,$c1$$)=>{setImmediate(()=>{switch($r$$.cach_tinh){case "9":$r$$.cong_thuc="";utils.getInfoFromQuery($query$$,$r$$.query,($e$$,$rs$$)=>{if($e$$)return $c1$$();_.isNumber($rs$$)?($r$$.so_kn=$rs$$,$r$$.so_kn_nt=$rs$$,$r$$.so_kt=$rs$$,$r$$.so_kt_nt=$rs$$):$r$$.value_string=
|
|
19
19
|
$rs$$;$c1$$()});break;case "2":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={ngay_ct:{$gte:$ky$$.tu_ngay,$lte:$ky$$.den_ngay},id_app:$query$$.id_app};$query$$.ma_dvcs&&($condition$$.ma_dvcs=$query$$.ma_dvcs);$query$$.ma_bp&&($condition$$.ma_bp=$query$$.ma_bp);$query$$.ma_hd&&($condition$$.ma_hd=$query$$.ma_hd);$query$$.ma_dt&&($condition$$.ma_dt=$query$$.ma_dt);$query$$.ma_sp&&($condition$$.ma_sp=$query$$.ma_sp);$query$$.ma_nv&&($condition$$.ma_nv=$query$$.ma_nv);
|
|
20
|
-
$r$$.ma_phi&&($condition$$.ma_phi=$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{
|
|
21
|
-
"{"+$r$$.dieu_kien_khac+"}");let $dieu_kien_khac$$=
|
|
22
|
-
{let $condition$$={...$query$$};$condition$$.ngay=$ky$$.tu_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;dktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_no00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_no_nt00");
|
|
23
|
-
($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "6":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay=$ky$$.tu_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;dktk($condition$$,function($error
|
|
24
|
-
$result$$.csum("du_co_nt00");0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "7":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay
|
|
25
|
-
cktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_no00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_no_nt00");0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null
|
|
26
|
-
{...$query$$};$condition$$.ngay=$ky$$.den_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;cktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_co00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_co_nt00");
|
|
27
|
-
0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "99":if(!$r$$.script)return $c1$$(null,$r$$);if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");let $func_string$$=`return (async ()=>{
|
|
20
|
+
$r$$.ma_phi&&($condition$$.ma_phi=$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{0>$r$$.dieu_kien_khac.indexOf("{")&&($r$$.dieu_kien_khac=
|
|
21
|
+
"{"+$r$$.dieu_kien_khac+"}");let $str_func$$=$r$$.dieu_kien_khac;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $dieu_kien_khac$$=utils.evalute($str_func$$,{moment,condition:$condition$$,row:$r$$});$condition$$={...$condition$$,...$dieu_kien_khac$$}}catch($e$$){return $callback$$($e$$.toString())}socai.find($condition$$).lean().exec(($error$$,$rs$$)=>{if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$rs$$.csum("tien");$r$$[`so_${$ky$$.ma_ky}_nt`]=$rs$$.csum("tien_nt");
|
|
22
|
+
$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "5":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay=$ky$$.tu_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;dktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_no00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_no_nt00");
|
|
23
|
+
0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "6":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay=$ky$$.tu_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;dktk($condition$$,function($error$$,
|
|
24
|
+
$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_co00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_co_nt00");0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "7":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay=
|
|
25
|
+
$ky$$.den_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;cktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_no00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_no_nt00");0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,
|
|
26
|
+
$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "8":$r$$.cong_thuc="";async.mapSeries($kys$$,($ky$$,$callback$$)=>{let $condition$$={...$query$$};$condition$$.ngay=$ky$$.den_ngay;$condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$$.tk=$r$$.tk;delete $condition$$.tu_ngay;delete $condition$$.den_ngay;cktk($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$[`so_${$ky$$.ma_ky}`]=$result$$.csum("du_co00");$r$$[`so_${$ky$$.ma_ky}_nt`]=$result$$.csum("du_co_nt00");
|
|
27
|
+
0>$r$$[`so_${$ky$$.ma_ky}`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}`]=0);0>$r$$[`so_${$ky$$.ma_ky}_nt`]&&$r$$.khong_am&&($r$$[`so_${$ky$$.ma_ky}_nt`]=0);$callback$$(null,$r$$)})},($e$$,$rs$$)=>{$c1$$($e$$,$rs$$)});break;case "99":if(!$r$$.script)return $c1$$(null,$r$$);if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");let $func_string$$=`return (async ()=>{
|
|
28
28
|
try{
|
|
29
29
|
${$r$$.script}
|
|
30
30
|
}catch(e){
|
|
@@ -6,8 +6,9 @@ $bao_cao_theo$$)&&($query_ds_bc_theo$$[$bao_cao_theo$$]=$query$$[$bao_cao_theo$$
|
|
|
6
6
|
$rs$$){if($e$$)return $callback$$($e$$);$rs$$.forEach(function($r$$){$r$$.ma_obj=$r$$[$rptobj$$.value_field];$r$$.ten_obj=$r$$[$rptobj$$.header_field]});$callback$$(null,$rs$$)})})}},function($e$jscomp$0$$,$rs$jscomp$0$$){if($e$jscomp$0$$)return $callback$jscomp$0$$($e$jscomp$0$$);let $ds_obj$$=$rs$jscomp$0$$.dsobj;async.mapSeries($report$$,function($r$$,$c1$$){setImmediate(()=>{if("9"===$r$$.cach_tinh)$r$$.cong_thuc="",async.mapSeries($ds_obj$$,function($kho$$,$callback$$){utils.getInfoFromQuery($kho$$,
|
|
7
7
|
$r$$.query,($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);_.isNumber($rs$$)?($r$$[$kho$$.ma_obj]=$rs$$,$r$$[$kho$$.ma_obj+"_nt"]=$rs$$):$r$$[$kho$$.ma_obj+"_string"]=$rs$$;$callback$$()})},$e$$=>{$c1$$($e$$,$r$$)});else if("2"===$r$$.cach_tinh)$r$$.cong_thuc="",async.mapSeries($ds_obj$$,function($kho$$,$callback$$){let $condition$$={ngay_ct:{$gte:$query$$.tu_ngay,$lte:$query$$.den_ngay},id_app:$query$$.id_app};"ma_kh"===$bao_cao_theo$$.toLowerCase()?$condition$$.$or=[{ma_kh_co:$kho$$.ma_obj},{ma_kh_no:$kho$$.ma_obj}]:
|
|
8
8
|
$condition$$[$bao_cao_theo$$]=$kho$$.ma_obj;$query$$.ma_dvcs&&($condition$$.ma_dvcs=$query$$.ma_dvcs);$query$$.ma_bp&&($condition$$.ma_bp=$query$$.ma_bp);$query$$.ma_hd&&($condition$$.ma_hd=$query$$.ma_hd);$query$$.ma_dt&&($condition$$.ma_dt=$query$$.ma_dt);$query$$.ma_sp&&($condition$$.ma_sp=$query$$.ma_sp);$query$$.ma_nv&&($condition$$.ma_nv=$query$$.ma_nv);$r$$.ma_phi&&($condition$$.ma_phi=$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&
|
|
9
|
-
($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{
|
|
10
|
-
{tien:1,tien_nt:1}).lean().exec(function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$error$$=$rs$$.csum("tien");$rs$$=$rs$$.csum("tien_nt");if($error$$||$rs$$)$r$$[$kho$$.ma_obj]=$error$$,$r$$[$kho$$.ma_obj+"_nt"]=$rs$$,$kho$$.has_data=!0;$callback$$(null,$r$$)})},function($e$$){$c1$$($e$$)});else if("99"
|
|
9
|
+
($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{0>$r$$.dieu_kien_khac.indexOf("{")&&($r$$.dieu_kien_khac="{"+$r$$.dieu_kien_khac+"}");let $str_func$$=$r$$.dieu_kien_khac;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $dieu_kien_khac$$=
|
|
10
|
+
utils.evalute($str_func$$,{moment,condition:$condition$$,row:$r$$});$condition$$={...$condition$$,...$dieu_kien_khac$$}}catch($e$$){$callback$$($e$$.toString())}socai.find($condition$$,{tien:1,tien_nt:1}).lean().exec(function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$error$$=$rs$$.csum("tien");$rs$$=$rs$$.csum("tien_nt");if($error$$||$rs$$)$r$$[$kho$$.ma_obj]=$error$$,$r$$[$kho$$.ma_obj+"_nt"]=$rs$$,$kho$$.has_data=!0;$callback$$(null,$r$$)})},function($e$$){$c1$$($e$$)});else if("99"===
|
|
11
|
+
$r$$.cach_tinh&&$r$$.script){$r$$.cong_thuc="";if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");let $func_string$$=`return (async ()=>{
|
|
11
12
|
try{
|
|
12
13
|
${$r$$.script}
|
|
13
14
|
}catch(e){
|
|
@@ -6,9 +6,9 @@ $bao_cao_theo$$)&&($query_ds_bc_theo$$[$bao_cao_theo$$]=$query$$[$bao_cao_theo$$
|
|
|
6
6
|
[$rptobj$$.header_field]:1}).lean().exec(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);$rs$$.forEach(function($r$$){$r$$.ma_obj=$r$$[$rptobj$$.value_field];$r$$.ten_obj=$r$$[$rptobj$$.header_field];let $_kbm$$=_.cloneDeep($kbm$$);$r$$.kbm=$_kbm$$});$callback$$(null,$rs$$)})})}},function($e$jscomp$0$$,$rs$jscomp$0$$){if($e$jscomp$0$$)return $callback$jscomp$2$$($e$jscomp$0$$);let $ds_obj$$=$rs$jscomp$0$$.dsobj;async.mapSeries($ds_obj$$,($kho$$,$callback$jscomp$1$$)=>{setImmediate(()=>{async.mapSeries($kho$$.kbm,
|
|
7
7
|
function($r$$,$callback$jscomp$0$$){setImmediate(()=>{async.series({tinh_theo_query:$callback$$=>{"9"===$r$$.cach_tinh&&$r$$.query?($r$$.cong_thuc="",utils.getInfoFromQuery($kho$$,$r$$.query,($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);_.isNumber($rs$$)?($r$$.tien=$rs$$,$r$$.tien_nt=$rs$$):$r$$.value_string=$rs$$;$callback$$()})):$callback$$()},tinh_theo_socai:$callback$$=>{if("2"===$r$$.cach_tinh){$r$$.cong_thuc="";let $condition$$={ngay_ct:{$gte:$query$$.tu_ngay,$lte:$query$$.den_ngay},id_app:$query$$.id_app};
|
|
8
8
|
"ma_kh"===$bao_cao_theo$$.toLowerCase()?$condition$$.$or=[{ma_kh_co:$kho$$.ma_obj},{ma_kh_no:$kho$$.ma_obj}]:$condition$$[$bao_cao_theo$$]=$kho$$.ma_obj;$query$$.ma_dvcs&&($condition$$.ma_dvcs=$query$$.ma_dvcs);$query$$.ma_bp&&($condition$$.ma_bp=$query$$.ma_bp);$query$$.ma_hd&&($condition$$.ma_hd=$query$$.ma_hd);$query$$.ma_dt&&($condition$$.ma_dt=$query$$.ma_dt);$query$$.ma_sp&&($condition$$.ma_sp=$query$$.ma_sp);$query$$.ma_nv&&($condition$$.ma_nv=$query$$.ma_nv);$r$$.ma_phi&&($condition$$.ma_phi=
|
|
9
|
-
$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{
|
|
10
|
-
"}");let $dieu_kien_khac$$=
|
|
11
|
-
$r$$.cong_thuc="";let $func_string$$=`return (async ()=>{
|
|
9
|
+
$r$$.ma_phi);$r$$.ma_kho&&($condition$$.ma_kho=$r$$.ma_kho);var $tk_co_tk_no$$=getRegString($r$$.tk_no);$tk_co_tk_no$$&&($condition$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});if($tk_co_tk_no$$=getRegString($r$$.tk_co))$condition$$.tk_co=$r$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{0>$r$$.dieu_kien_khac.indexOf("{")&&($r$$.dieu_kien_khac="{"+$r$$.dieu_kien_khac+
|
|
10
|
+
"}");let $str_func$$=$r$$.dieu_kien_khac;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $dieu_kien_khac$$=utils.evalute($str_func$$,{moment,condition:$condition$$,row:$r$$});$condition$$={...$condition$$,...$dieu_kien_khac$$}}catch($e$$){$callback$$($e$$.toString())}socai.find($condition$$,{tien:1,tien_nt:1}).lean().exec(function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.tien=$rs$$.csum("tien");$r$$.tien_nt=$rs$$.csum("tien_nt");$callback$$(null,$r$$)})}else $callback$$()},
|
|
11
|
+
calc_expression:$c1$$=>{if("99"===$r$$.cach_tinh&&$r$$.script){if(0<=$r$$.script.indexOf("async "))return $c1$$("async function is not allow");$r$$.cong_thuc="";let $func_string$$=`return (async ()=>{
|
|
12
12
|
try{
|
|
13
13
|
${$r$$.script}
|
|
14
14
|
}catch(e){
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
'use strict';const thnxt=require("../../libs/thnxt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),
|
|
1
|
+
'use strict';const thnxt=require("../../libs/thnxt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),controller=require("../../controllers/controllerRPT"),async=require("async");
|
|
2
2
|
module.exports=function($router$$){new controller($router$$,"thnxt",function($req$$,$callback$jscomp$0$$){const $query$$=$req$$.query,$id_app$$=$req$$.query.id_app;if(!$query$$.tu_ngay||!$query$$.den_ngay)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_ngay,den_ngay");$callback$jscomp$0$$(null,null,"begin");(new Promise(($resolve$$,$reject$$)=>{if(!$query$$.ma_vt&&($query$$.ma_ncc||$query$$.ma_kh||$query$$.ma_nvt||$query$$.ma_nvt2||$query$$.ma_nvt3||
|
|
3
|
-
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app
|
|
4
|
-
null,"running");$resolve$$(
|
|
5
|
-
$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r
|
|
6
|
-
$r$$.ma_kho).joinModel2($id_app$$,dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})},tt1:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_vt&&$r$$.ma_tt1).joinModel2($id_app$$,global.getModel("dmtt"),{where:$item$$=>({ma_vt:$item$$.ma_vt,ma_tt:$item$$.ma_tt1,loai_tt:"1"}),fields:{barcode1:"ma_tt2"}},()=>{$callback$$()})},tt2:$callback$$=>{$report$$.filter($r
|
|
7
|
-
loai_tt:"2"}),fields:{barcode2:"ma_tt2"}},()=>{$callback$$()})},tt3:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_vt&&$r$$.ma_tt3).joinModel2($id_app$$,global.getModel("dmtt"),{where:$item$$=>({ma_vt:$item$$.ma_vt,ma_tt:$item$$.ma_tt3,loai_tt:"3"}),fields:{barcode3:"ma_tt2"}},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");$report$$.
|
|
8
|
-
du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),tien_xuat:$report$$.csum("tien_xuat"),ton_cuoi:$report$$.csum("ton_cuoi"),du_cuoi:$report$$.csum("du_cuoi"),systotal:1,bold:!0};$report$$.push($total$$);$callback$jscomp$0$$(null
|
|
3
|
+
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&0<$query$$.ma_nvt.length&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&0<$query$$.ma_nvt2.length&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&0<$query$$.ma_nvt3.length&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&0<$query$$.ma_nvt4.length&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
4
|
+
"running");dmvt.find($_query$$,{ma_vt:1}).lean().exec(($err$$,$rs$$)=>{if($err$$)return $reject$$($err$$);$callback$jscomp$0$$(null,null,"running");$resolve$$($rs$$.map($r$$=>$r$$.ma_vt))})}else $resolve$$($query$$.ma_vt)})).then($ma_vt$$=>{$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$callback$jscomp$0$$(null,null,"running");thnxt($query$$,function($error$$,$report$$){if($error$$)return $callback$jscomp$0$$($error$$);$callback$jscomp$0$$(null,null,"running");async.series({vt:$callback$$=>{$report$$.filter($r$$=>
|
|
5
|
+
$r$$.ma_vt).joinModel2($id_app$$,dmvt,{where:"ma_vt",fields:"ten_vt tg_tk ma_ncc ma_dvt ma_nvt ma_vt2".split(" "),setFields:($a$$,$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r$$=>
|
|
6
|
+
$r$$.ma_nvt).joinModel2($id_app$$,dmnvt,{where:{ma_nvt:"_id"},fields:["ten_nvt"]},()=>{$callback$$()})})})},kho:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_kho).joinModel2($id_app$$,dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})},tt1:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_vt&&$r$$.ma_tt1).joinModel2($id_app$$,global.getModel("dmtt"),{where:$item$$=>({ma_vt:$item$$.ma_vt,ma_tt:$item$$.ma_tt1,loai_tt:"1"}),fields:{barcode1:"ma_tt2"}},()=>{$callback$$()})},tt2:$callback$$=>{$report$$.filter($r$$=>
|
|
7
|
+
$r$$.ma_vt&&$r$$.ma_tt2).joinModel2($id_app$$,global.getModel("dmtt"),{where:$item$$=>({ma_vt:$item$$.ma_vt,ma_tt:$item$$.ma_tt2,loai_tt:"2"}),fields:{barcode2:"ma_tt2"}},()=>{$callback$$()})},tt3:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_vt&&$r$$.ma_tt3).joinModel2($id_app$$,global.getModel("dmtt"),{where:$item$$=>({ma_vt:$item$$.ma_vt,ma_tt:$item$$.ma_tt3,loai_tt:"3"}),fields:{barcode3:"ma_tt2"}},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");$report$$=$report$$.filter($r$$=>
|
|
8
|
+
$r$$.tg_tk);$report$$.forEach($r$$=>{$r$$.barcode=$r$$.barcode1||$r$$.barcode2||$r$$.barcode3||$r$$.ma_vt2});const $total$$={ma_vt:"",ten_vt:"T\u1ed5ng c\u1ed9ng",ton_dau:$report$$.csum("ton_dau"),du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),tien_xuat:$report$$.csum("tien_xuat"),ton_cuoi:$report$$.csum("ton_cuoi"),du_cuoi:$report$$.csum("du_cuoi"),systotal:1,bold:!0};$report$$.push($total$$);$callback$jscomp$0$$(null,
|
|
9
|
+
$report$$,"data");$callback$jscomp$0$$(null,null,"end")})},$log$$=>{$callback$jscomp$0$$(null,null,"running");console.log($log$$)})}).catch($e$$=>{$callback$jscomp$0$$($e$$)})},{stream:!0})};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';const thnxt=require("../../libs/thnxt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),
|
|
1
|
+
'use strict';const thnxt=require("../../libs/thnxt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),controller=require("../../controllers/controllerRPT"),async=require("async");
|
|
2
2
|
module.exports=function($router$$){new controller($router$$,"thnxt_sl",function($req$$,$callback$jscomp$0$$){const $query$$=$req$$.query,$id_app$$=$req$$.query.id_app;if(!$query$$.tu_ngay||!$query$$.den_ngay)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_ngay,den_ngay");$callback$jscomp$0$$(null,null,"begin");(new Promise(($resolve$$,$reject$$)=>{if(!$query$$.ma_vt&&($query$$.ma_ncc||$query$$.ma_kh||$query$$.ma_nvt||$query$$.ma_nvt2||$query$$.ma_nvt3||
|
|
3
|
-
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app
|
|
4
|
-
null,"running");$resolve$$(
|
|
5
|
-
$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r$$=>$r$$.ma_nvt).joinModel2($id_app$$,
|
|
6
|
-
dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");const $total$$={ma_vt:"",ten_vt:"T\u1ed5ng c\u1ed9ng",ton_dau:$report$$.csum("ton_dau"),du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),
|
|
7
|
-
$report$$,"data");$callback$jscomp$0$$(null,null,"end")})},$log$$=>{$callback$jscomp$0$$(null,null,"running");console.log($log$$)})}).catch($e$$=>{$callback$jscomp$0$$($e$$)})},{stream:!0})};
|
|
3
|
+
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&0<$query$$.ma_nvt.length&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&0<$query$$.ma_nvt2.length&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&0<$query$$.ma_nvt3.length&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&0<$query$$.ma_nvt4.length&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
4
|
+
"running");dmvt.find($_query$$,{ma_vt:1}).lean().exec(($err$$,$rs$$)=>{if($err$$)return $reject$$($err$$);$callback$jscomp$0$$(null,null,"running");$resolve$$($rs$$.map($r$$=>$r$$.ma_vt))})}else $resolve$$($query$$.ma_vt)})).then($ma_vt$$=>{$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$callback$jscomp$0$$(null,null,"running");thnxt($query$$,function($error$$,$report$$){if($error$$)return $callback$jscomp$0$$($error$$);$callback$jscomp$0$$(null,null,"running");async.series({vt:$callback$$=>{$report$$.filter($r$$=>
|
|
5
|
+
$r$$.ma_vt).joinModel2($id_app$$,dmvt,{where:"ma_vt",fields:["ten_vt","tg_tk","ma_ncc","ma_dvt","ma_nvt"],setFields:($a$$,$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r$$=>$r$$.ma_nvt).joinModel2($id_app$$,
|
|
6
|
+
dmnvt,{where:{ma_nvt:"_id"},fields:["ten_nvt"]},()=>{$callback$$()})})})},kho:$callback$$=>{$report$$.joinModel2($id_app$$,dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");$report$$=$report$$.filter($r$$=>$r$$.tg_tk);const $total$$={ma_vt:"",ten_vt:"T\u1ed5ng c\u1ed9ng",ton_dau:$report$$.csum("ton_dau"),du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),
|
|
7
|
+
tien_xuat:$report$$.csum("tien_xuat"),ton_cuoi:$report$$.csum("ton_cuoi"),du_cuoi:$report$$.csum("du_cuoi"),systotal:1,bold:!0};$report$$.push($total$$);$callback$jscomp$0$$(null,$report$$,"data");$callback$jscomp$0$$(null,null,"end")})},$log$$=>{$callback$jscomp$0$$(null,null,"running");console.log($log$$)})}).catch($e$$=>{$callback$jscomp$0$$($e$$)})},{stream:!0})};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';const thnxt=require("../../libs/thnxttt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),
|
|
1
|
+
'use strict';const thnxt=require("../../libs/thnxttt"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),dmnvt=global.getModel("dmnvt"),customer=global.getModel("customer"),controller=require("../../controllers/controllerRPT"),async=require("async");
|
|
2
2
|
module.exports=function($router$$){new controller($router$$,"thnxttt",function($req$$,$callback$jscomp$0$$){const $query$$=$req$$.query,$id_app$$=$req$$.query.id_app;if(!$query$$.tu_ngay||!$query$$.den_ngay)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_ngay,den_ngay");$callback$jscomp$0$$(null,null,"begin");(new Promise(($resolve$$,$reject$$)=>{if(!$query$$.ma_vt&&($query$$.ma_ncc||$query$$.ma_kh||$query$$.ma_nvt||$query$$.ma_nvt2||$query$$.ma_nvt3||
|
|
3
|
-
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app
|
|
4
|
-
null,"running");$resolve$$(
|
|
5
|
-
$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r$$=>$r$$.ma_nvt).joinModel2($id_app$$,
|
|
6
|
-
$r$$.ma_kho).joinModel2($id_app$$,dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");const $total$$={ma_vt:"",ten_vt:"T\u1ed5ng c\u1ed9ng",ton_dau:$report$$.csum("ton_dau"),du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),
|
|
7
|
-
$callback$jscomp$0$$(null,$report$$,"data");$callback$jscomp$0$$(null,null,"end")})},$log$$=>{$callback$jscomp$0$$(null,null,"running");console.log($log$$)})}).catch($e$$=>{$callback$jscomp$0$$($e$$)})},{stream:!0})};
|
|
3
|
+
$query$$.ma_nvt4)){const $_query$$={id_app:$id_app$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&0<$query$$.ma_nvt.length&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&0<$query$$.ma_nvt2.length&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&0<$query$$.ma_nvt3.length&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&0<$query$$.ma_nvt4.length&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
4
|
+
"running");dmvt.find($_query$$,{ma_vt:1}).lean().exec(($err$$,$rs$$)=>{if($err$$)return $reject$$($err$$);$callback$jscomp$0$$(null,null,"running");$resolve$$($rs$$.map($r$$=>$r$$.ma_vt))})}else $resolve$$($query$$.ma_vt)})).then($ma_vt$$=>{$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$callback$jscomp$0$$(null,null,"running");thnxt($query$$,function($error$$,$report$$){if($error$$)return $callback$jscomp$0$$($error$$);$callback$jscomp$0$$(null,null,"running");async.series({vt:$callback$$=>{$report$$.filter($r$$=>
|
|
5
|
+
$r$$.ma_vt).joinModel2($id_app$$,dmvt,{where:"ma_vt",fields:["ten_vt","tg_tk","ma_ncc","ma_dvt","ma_nvt"],setFields:($a$$,$b$$)=>{if($b$$.picture){let $p$$=$b$$.picture.split(".");$a$$.picture_thumb=$b$$.picture+".thumb."+$p$$[$p$$.length-1]}else $a$$.picture="/getfile/others/noimage.png",$a$$.picture_thumb="/getfile/others/noimage.png"}},()=>{$report$$.filter($r$$=>$r$$.ma_ncc).joinModel2($id_app$$,customer,{where:{ma_ncc:"ma_kh"},fields:[{ten_ncc:"ten_kh"}]},()=>{$report$$.filter($r$$=>$r$$.ma_nvt).joinModel2($id_app$$,
|
|
6
|
+
dmnvt,{where:{ma_nvt:"_id"},fields:["ten_nvt"]},()=>{$callback$$()})})})},kho:$callback$$=>{$report$$.filter($r$$=>$r$$.ma_kho).joinModel2($id_app$$,dmkho,{where:"ma_kho",fields:["ten_kho"]},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,null,"running");$report$$=$report$$.filter($r$$=>$r$$.tg_tk);const $total$$={ma_vt:"",ten_vt:"T\u1ed5ng c\u1ed9ng",ton_dau:$report$$.csum("ton_dau"),du_dau:$report$$.csum("du_dau"),sl_nhap:$report$$.csum("sl_nhap"),tien_nhap:$report$$.csum("tien_nhap"),sl_xuat:$report$$.csum("sl_xuat"),
|
|
7
|
+
tien_xuat:$report$$.csum("tien_xuat"),ton_cuoi:$report$$.csum("ton_cuoi"),du_cuoi:$report$$.csum("du_cuoi"),systotal:1,bold:!0};$report$$.push($total$$);$callback$jscomp$0$$(null,$report$$,"data");$callback$jscomp$0$$(null,null,"end")})},$log$$=>{$callback$jscomp$0$$(null,null,"running");console.log($log$$)})}).catch($e$$=>{$callback$jscomp$0$$($e$$)})},{stream:!0})};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';const socai=global.getModel("socai"),cktk=require("../../libs/cktk"),dktk=require("../../libs/dktk"),kbmtmbctc=global.getModel("kbmtmbctc"),rptform=global.getModel("rptform"),async=require("async"),_=require("lodash"),utils=require("../../libs/utils"),controller=require("../../controllers/controllerRPT"),moment=require("moment"),getRegString=function($arrayTk$$){return $arrayTk$$.reg()},calcColumn=($condition_row$$,$column_name$$,$query_tk_co_tk_no$$,$callback$$)=>{let $r$$=$condition_row$$[$column_name$$];
|
|
2
2
|
if(!$r$$)return $callback$$(null,{value:0,value_nt:0,cong_thuc:""});switch($r$$.cach_tinh){case "9":$r$$.cong_thuc="";utils.getInfoFromQuery($query_tk_co_tk_no$$,$r$$.query,($e$$,$rs$$)=>{if($e$$)return $callback$$(null,$r$$);_.isNumber($rs$$)?$r$$.value=$rs$$:$r$$.value_string=$rs$$;$callback$$(null,$r$$)});break;case "2":$r$$.cong_thuc="";$condition_row$$={ngay_ct:{$gte:$query_tk_co_tk_no$$.tu_ngay,$lte:$query_tk_co_tk_no$$.den_ngay},id_app:$query_tk_co_tk_no$$.id_app};$query_tk_co_tk_no$$.ma_dvcs&&
|
|
3
3
|
($condition_row$$.ma_dvcs=$query_tk_co_tk_no$$.ma_dvcs);$query_tk_co_tk_no$$.ma_bp&&($condition_row$$.ma_bp=$query_tk_co_tk_no$$.ma_bp);$query_tk_co_tk_no$$.ma_hd&&($condition_row$$.ma_hd=$query_tk_co_tk_no$$.ma_hd);$query_tk_co_tk_no$$.ma_dt&&($condition_row$$.ma_dt=$query_tk_co_tk_no$$.ma_dt);$query_tk_co_tk_no$$.ma_sp&&($condition_row$$.ma_sp=$query_tk_co_tk_no$$.ma_sp);$query_tk_co_tk_no$$.ma_nv&&($condition_row$$.ma_nv=$query_tk_co_tk_no$$.ma_nv);$r$$.ma_phi&&($condition_row$$.ma_phi=$r$$.ma_phi);
|
|
4
|
-
$r$$.ma_kho&&($condition_row$$.ma_kho=$r$$.ma_kho);if($query_tk_co_tk_no$$=getRegString($r$$.tk_no))$condition_row$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($query_tk_co_tk_no$$=getRegString($r$$.tk_co))$condition_row$$.tk_co=$r$$.giam_tru_co&&$query_tk_co_tk_no$$?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{
|
|
5
|
-
"{"+$r$$.dieu_kien_khac+"}")
|
|
6
|
-
|
|
7
|
-
dktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_no00");$r$$.value_nt=$result$$.csum("du_no_nt00");0>$r$$.value&&$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "6":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=
|
|
4
|
+
$r$$.ma_kho&&($condition_row$$.ma_kho=$r$$.ma_kho);if($query_tk_co_tk_no$$=getRegString($r$$.tk_no))$condition_row$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($query_tk_co_tk_no$$=getRegString($r$$.tk_co))$condition_row$$.tk_co=$r$$.giam_tru_co&&$query_tk_co_tk_no$$?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{0>$r$$.dieu_kien_khac.indexOf("{")&&($r$$.dieu_kien_khac=
|
|
5
|
+
"{"+$r$$.dieu_kien_khac+"}");$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$=$r$$.dieu_kien_khac;0>$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.indexOf("return ")&&($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$=`return ${$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$}`);let $dieu_kien_khac$$=utils.evalute($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,{moment,condition:$condition_row$$,
|
|
6
|
+
row:$r$$});$condition_row$$={...$condition_row$$,...$dieu_kien_khac$$}}catch($e$$){return $callback$$($e$$.toString())}socai.find($condition_row$$).lean().exec(($error$$,$rs$$)=>{if($error$$)return $callback$$($error$$);$r$$.value=$rs$$.csum("tien");$r$$.value_nt=$rs$$.csum("tien_nt");$r$$.details=$rs$$;$callback$$(null,$r$$)});break;case "5":$r$$.cong_thuc="";var $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=
|
|
8
7
|
$query_tk_co_tk_no$$.tu_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;dktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);
|
|
9
|
-
$r$$.value=$result$$.csum("
|
|
10
|
-
$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;
|
|
11
|
-
$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "
|
|
12
|
-
$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;cktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("
|
|
13
|
-
$r$$)});break;
|
|
14
|
-
|
|
15
|
-
$
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
$rs$$.cong_thuc;$callback$$()})},
|
|
19
|
-
$rs$$.cong_thuc;$callback$$()})},
|
|
20
|
-
|
|
8
|
+
$r$$.value=$result$$.csum("du_no00");$r$$.value_nt=$result$$.csum("du_no_nt00");0>$r$$.value&&$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "6":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.tu_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=
|
|
9
|
+
$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;dktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_co00");$r$$.value_nt=$result$$.csum("du_co_nt00");0>$r$$.value&&
|
|
10
|
+
$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "7":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.den_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=
|
|
11
|
+
$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;cktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_no00");$r$$.value_nt=$result$$.csum("du_no_nt00");0>$r$$.value&&$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,
|
|
12
|
+
$r$$)});break;case "8":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.den_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;
|
|
13
|
+
delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;cktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_co00");$r$$.value_nt=$result$$.csum("du_co_nt00");0>$r$$.value&&$r$$.khong_am&&($r$$.value=0);0>$r$$.value_nt&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;default:$callback$$(null,$r$$)}};
|
|
14
|
+
module.exports=function($router$$){new controller($router$$,"tmbctc",function($req$$,$callback$jscomp$0$$){let $query$$=$req$$.query;if(!$query$$.den_ngay||!$query$$.tu_ngay||!$query$$.id_rptform)return $callback$jscomp$0$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1 t\u1eeb ng\u00e0y(tu_ngay), \u0111\u1ebfn ng\u00e0y(den_ngay), id m\u1eabu b\u00e1o c\u00e1o");if(!global.mongoose.Types.ObjectId.isValid($query$$.id_rptform))return $callback$jscomp$0$$("M\u1eabu b\u00e1o c\u00e1o n\u00e0y kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb");
|
|
15
|
+
(new Promise(($resolve$$,$reject$$)=>{rptform.findOne({_id:$query$$.id_rptform}).lean().exec(($e$$,$rs$$)=>{if($e$$||!$rs$$)return $reject$$($e$$);$resolve$$($rs$$)})})).then(async $_rptform$$=>{$query$$.tu_ngay=moment(new Date($query$$.tu_ngay)).startOf("date").toDate();$query$$.den_ngay=moment(new Date($query$$.den_ngay)).endOf("date").toDate();$query$$.tu_ngay_kt=new Date($query$$.tu_ngay);$query$$.tu_ngay_kt.setYear($query$$.tu_ngay_kt.getFullYear()-1);$query$$.den_ngay_kt=new Date($query$$.den_ngay);
|
|
16
|
+
$query$$.den_ngay_kt.setYear($query$$.den_ngay_kt.getFullYear()-1);let $report$$=$_rptform$$.report;$report$$&&0!==$_rptform$$.report.length||($report$$=await kbmtmbctc.find({id_rptform:$_rptform$$._id.toString()}).sort({stt:1}).lean());async.mapSeries($report$$,($r$$,$c1$$)=>{async.series({so_dau_nam:$callback$$=>{calcColumn($r$$,"so_dau_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_dau_nam_value=$rs$$.value;$r$$.so_dau_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_dau_nam_value=
|
|
17
|
+
$rs$$.cong_thuc;$callback$$()})},so_tang_trong_nam:$callback$$=>{calcColumn($r$$,"so_tang_trong_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_tang_trong_nam_value=$rs$$.value;$r$$.so_tang_trong_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_tang_trong_nam_value=$rs$$.cong_thuc;$callback$$()})},so_giam_trong_nam:$callback$$=>{calcColumn($r$$,"so_giam_trong_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_giam_trong_nam_value=$rs$$.value;$r$$.so_giam_trong_nam_value_nt=
|
|
18
|
+
$rs$$.value_nt;$r$$.cong_thuc_so_giam_trong_nam_value=$rs$$.cong_thuc;$callback$$()})},so_cuoi_nam:$callback$$=>{calcColumn($r$$,"so_cuoi_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_cuoi_nam_value=$rs$$.value;$r$$.so_cuoi_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_cuoi_nam_value=$rs$$.cong_thuc;$callback$$()})},so_nam_nay:$callback$$=>{calcColumn($r$$,"so_nam_nay",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_nam_nay_value=$rs$$.value;$r$$.so_nam_nay_value_nt=
|
|
19
|
+
$rs$$.value_nt;$r$$.cong_thuc_so_nam_nay_value=$rs$$.cong_thuc;$callback$$()})},so_nam_truoc:$callback$$=>{const $_q$$={...$query$$};$_q$$.tu_ngay=$query$$.tu_ngay_kt;$_q$$.den_ngay=$query$$.den_ngay_kt;calcColumn($r$$,"so_nam_truoc",$_q$$,($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_nam_truoc_value=$rs$$.value;$r$$.so_nam_truoc_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_nam_truoc_value=$rs$$.cong_thuc;$callback$$()})}},()=>{$c1$$()})},function($error$$){if($error$$)return $callback$jscomp$0$$($error$$);
|
|
20
|
+
utils.calcGrid($report$$,"so_dau_nam_value,so_tang_trong_nam_value,so_giam_trong_nam_value,so_cuoi_nam_value,so_nam_nay_value,so_nam_truoc_value",function($rs$$){$callback$jscomp$0$$(null,$rs$$.filter($r$$=>!1!==$r$$.print))})})}).catch($e$$=>{$callback$jscomp$0$$($e$$||"Kh\u00f4ng c\u00f3 m\u1eabu b\u00e1o c\u00e1o n\u00e0o cho b\u00e1o c\u00e1o n\u00e0y")})})};
|