flexbiz-server 12.2.3 → 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 +1 -1
- package/server/auths/local.js +27 -26
- package/server/controllers/controller.js +56 -55
- package/server/controllers/controllerRPT.js +18 -17
- package/server/libs/cdpstk.js +1 -1
- package/server/libs/databanle.js +13 -13
- package/server/libs/getGiaban.js +23 -22
- package/server/libs/post-book.js +9 -8
- package/server/libs/post-socai.js +9 -9
- package/server/libs/prototypes.js +4 -4
- 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 +4 -4
- 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 -8
- package/server/models/dh2.js +10 -9
- package/server/models/dmgiaban.js +6 -6
- package/server/models/dmhoahonghd.js +6 -5
- 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 +4 -2
- package/server/models/hd2.js +8 -8
- package/server/models/hd3.js +9 -9
- package/server/models/hd7.js +1 -1
- package/server/models/notification.js +3 -2
- 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 +7 -6
- package/server/models/socai.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/usergroup.js +5 -4
- 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-customer.js +13 -14
- package/server/modules/lists/ls-dmvt.js +48 -39
- 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-introducecode.js +1 -1
- 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 +1 -1
- package/server/modules/public/callin.js +6 -6
- 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-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 -8
- 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 +15 -38
- package/server/modules/vouchers/vo-dnm.js +11 -12
- package/server/modules/vouchers/vo-hd2.js +63 -83
- 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 +94 -119
- package/server/modules/vouchers/vo-so4.js +1 -1
- package/server/modules/vouchers/vo-so5.js +2 -2
- 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$$,"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,9 +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$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
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$$=$report$$.filter($r
|
|
8
|
-
{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
|
-
{$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 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$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
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");$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
|
-
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})};
|
|
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$$,tg_tk:!0};if($query$$.ma_ncc||$query$$.ma_kh)$_query$$.ma_ncc=$query$$.ma_ncc||$query$$.ma_kh;$query$$.ma_nvt&&($_query$$.ma_nvt=$query$$.ma_nvt);$query$$.ma_nvt2&&($_query$$.ma_nvt2=$query$$.ma_nvt2);$query$$.ma_nvt3&&($_query$$.ma_nvt3=$query$$.ma_nvt3);$query$$.ma_nvt4&&($_query$$.ma_nvt4=$query$$.ma_nvt4);$callback$jscomp$0$$(null,null,
|
|
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");$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
|
-
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})};
|
|
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")})})};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
'use strict';const model=global.getModel("app"),Participant=global.getModel("participant"),User=global.getModel("user"),UserGroup=global.getModel("usergroup"),Customer=global.getModel("customer"),Trangthai=global.getModel("trangthai"),_Notification=global.getModel("notification"),underscore=require("underscore"),async=require("async"),{isSupperAdmin}=require("../../libs/utils"),permission=require("../../libs/permission"),controller=require("../../controllers/controller"),fs=require("fs"),path=require("path"),
|
|
2
2
|
validator=require("validator"),StaticPool=require("../../libs/WorkerStaticPool"),calcTimeExpired=$item$$=>{$item$$.expire_date?($item$$.so_ngay_con_lai=Math.roundBy(($item$$.expire_date-new Date)/864E5,0),0>$item$$.so_ngay_con_lai&&($item$$.so_ngay_con_lai=0)):$item$$.so_ngay_con_lai=0},checkadmin=async($user$$,$item$$,$callback$$)=>{let $_ps$$=await Participant.findOne({id_app:$item$$._id,email:$user$$.email}).lean();if($_ps$$){if($item$$.appAdmin=$_ps$$.admin,$_ps$$.group_id&&global.mongoose.Types.ObjectId.isValid($_ps$$.group_id)){$item$$.group_id=
|
|
3
|
-
$_ps$$.group_id;delete $_ps$$.password;const $group$$=await UserGroup.findOne({_id:$_ps$$.group_id});$group$$&&($item$$.phu_trach_nhom=$group$$.phu_trach==$user$$.email)}}else $item$$.appAdmin=$item$$.user_created===$user$$.email;$item$$.par=$_ps$$||{};$callback$$()},createUserOwner=async($obj$$,$next$$)=>{let $owner$$=$obj$$.owner;if($owner$$&&$obj$$.user_created!==$owner$$){$owner$$=$owner$$.toLowerCase();let $user$$=await User.findOne({email:$owner$$});if(!$user$$){$user$$=
|
|
4
|
-
|
|
5
|
-
$e$$.message)}}}let $_p$$={email:$obj$$.user_created,name:$obj$$.user_created.split("@")[0],admin:!0,active:!0,cancel:!1,id_app:$obj$$._id.toString()};Participant.createParticipant($_p$$,$e$$=>{$e$$&&console.log("participant",$_p$$.email,"exists");$next$$(null,$obj$$)})};
|
|
6
|
-
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"app",{require_id_app:!1,sort:{name:1}});$contr_router$$.route();$contr_router$$.found=($user$$,$condition$$,$items$$,$fn$$)=>{async.mapSeries($items$$,($item$$,$callback$$)=>{calcTimeExpired($item$$);Customer.findOne({id_app:$item$$._id,of_user:$user$$.email},async($cust_e$$,$rs$$)=>{if($rs$$)return $callback$$();$cust_e$$=
|
|
7
|
-
user_updated:$user$$.email,kh_yn:!0,of_user:$user$$.email};validator.isMobilePhone($user$$.email,["vi-VN"])&&($cust_e$$.dien_thoai=$user$$.email);try{await Customer.asyncCreateCustomer($cust_e$$)}catch($e$$){console.log("Auto create new customer with error:",$e$$.message)}$callback$$()})},$e$$=>{$e$$&&console.error($e$$)
|
|
8
|
-
{$items$$.joinModel2(null,Trangthai,{where:$item$$=>({ma_ct:"APP",ma_trang_thai:$item$$.trang_thai}),fields:["ten_trang_thai","color"]},()=>{$callback$$()})},show_gia_von_va_nguoi_duyet:$callback$jscomp$0$$=>{async.mapSeries($items$$,($item$$,$callback$$)=>{$item$$.options=$item$$.options||{};$item$$.show_gia_von
|
|
9
|
-
|
|
10
|
-
async($user$$,$id$$,$next$$)=>{(await model.participants($id$$)).find($p$$=>$p$$.email===$user$$.email&&0==$p$$.cancel)?$next$$():$next$$("Not allowed")};$contr_router$$.finding=async($user$$,$condition$$,$next$$)=>{var $_appsOfUser_or1$$=await Participant.appsOfUser($user$$.email)
|
|
11
|
-
delete $condition$$.$or;$or2$$?$condition$$.$and=[{$or:$_appsOfUser_or1$$},{$or:$or2$$}]:$condition$$.$or=$_appsOfUser_or1$$;$condition$$.working||(isSupperAdmin($user$$.email.toLowerCase())?delete $user_created_condition$$.user_created:underscore.contains(configs.admins,$user$$.email)&&
|
|
12
|
-
$now_user$$.email)&&!isSupperAdmin($now_user$$.email.toLowerCase())){if(await model.findOne({user_created:$now_user$$.email},{_id:1}))return $next$$("M\u1ed7i t\u00e0i kho\u1ea3n ch\u1ec9 \u0111\u01b0\u1ee3c ph\u00e9p t\u1ea1o m\u1ed9t c\u00f4ng ty");delete $obj$$.allow_modules;
|
|
13
|
-
new Date("2000-01-01"));$obj$$.ngay_ky1||($obj$$.ngay_ky1=new Date);$now_user$$=new Date;$now_user$$.setMonth($now_user$$.getMonth()+1);$obj$$.expire_date=new Date($now_user$$);$obj$$.nam_bd=$obj$$.ngay_ky1.getFullYear();$obj$$.options=$obj$$.options||{};$next$$(null,$obj$$)};$contr_router$$.created=
|
|
14
|
-
$next$$(null,$obj$$)})})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){const $usersAdmin$$=configs.admins;underscore.contains($usersAdmin$$,$user$$.email)||isSupperAdmin($user$$.email.toLowerCase())||(delete $data$$.allow_modules,delete $data$$.expire_date,delete $data$$.trang_thai,
|
|
15
|
-
" have not permission");$data$$.ngay_ky1&&($data$$.nam_bd=(new Date($data$$.ngay_ky1)).getFullYear());$data$$.options&&0===Object.keys($data$$.options).length&&delete $data$$.options;$data$$.options=$data$$.options?{...$obj$$.options,...$data$$.options}:$obj$$.options||
|
|
16
|
-
configs.admins;if($user$$.email!=$obj$$.user_created&&!underscore.contains($usersAdmin$$,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n x\u00f3a c\u00f4ng ty n\u00e0y");$next$$(null,$obj$$)}
|
|
17
|
-
underscore.has($_model$$.schema.paths,"id_app")?$_model$$.deleteMany({id_app:$obj$$._id},()=>{console.log("Deleted ",$file$$,"id_app",$obj$$._id);$callback$$()}):$callback$$()}catch($e$$){console.error("Can't delete mode",$file$$,"error:",$e$$.message),$callback$$()}},
|
|
18
|
-
$admin$$){if(!$admin$$)return $res$$.status(400).send({error:"Ch\u1ec9 admin m\u1edbi c\u00f3 quy\u1ec1n backup d\u1eef li\u1ec7u c\u1ee7a c\u00f4ng ty"});global.backupPool||($backupWorkerFile_e$$=path.dirname(path.dirname(__dirname))+"/workers/backupApp.js",
|
|
19
|
-
$response$$=>{if($response$$.error)return $res$$.status(400).send($response$$.error);$res$$.sendFile(path.dirname(path.dirname(__dirname))+"/backup/"+$response$$.file)})})});$contr_router$$.router.route($contr_router$$.route_name+"/restore/:id").post(function($req
|
|
20
|
-
$e$$=$req$$.files.backup.path;global.restorePool||($admin$$=path.dirname(path.dirname(__dirname))+"/workers/restoreApp.js",global.restorePool=
|
|
21
|
-
null,null,!0,$req$$.access_token,!0)});$res$$.send("Ch\u01b0\u01a1ng tr\u00ecnh \u0111ang th\u1ef1c hi\u1ec7n. Xin ch\u1edd trong gi\u00e2y l\u00e1t")})})
|
|
22
|
-
$
|
|
23
|
-
if(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
3
|
+
$_ps$$.group_id;delete $_ps$$.password;const $group$$=await UserGroup.findOne({_id:$_ps$$.group_id}).lean();$group$$&&($_ps$$.group=$group$$,$item$$.phu_trach_nhom=$group$$.phu_trach==$user$$.email)}}else $item$$.appAdmin=$item$$.user_created===$user$$.email;$item$$.par=$_ps$$||{};$callback$$()},createUserOwner=async($obj$$,$next$$)=>{let $owner$$=$obj$$.owner;if($owner$$&&$obj$$.user_created!==$owner$$){$owner$$=$owner$$.toLowerCase();let $user$$=await User.findOne({email:$owner$$});if(!$user$$){$user$$=
|
|
4
|
+
new User;$user$$.email=$owner$$;$user$$.name=$owner$$.split("@")[0];$user$$.local={};$user$$.local.email=$user$$.email;$user$$.local.name=$user$$.name;$user$$.local.picture="/images/avatar.jpg";$user$$.local.password=$user$$.generateHash($user$$.email+($obj$$.default_password||$user$$.email+"@123456"));try{await $user$$.save();let $_p$$={email:$owner$$,name:$owner$$.split("@")[0],admin:!0,active:!0,cancel:!1,id_app:$obj$$._id.toString()};await new Promise($resolve$$=>{Participant.createParticipant($_p$$,
|
|
5
|
+
()=>{$resolve$$()})})}catch($e$$){console.error("can't create user owner",$e$$.message)}}}let $_p$$={email:$obj$$.user_created,name:$obj$$.user_created.split("@")[0],admin:!0,active:!0,cancel:!1,id_app:$obj$$._id.toString()};Participant.createParticipant($_p$$,$e$$=>{$e$$&&console.log("participant",$_p$$.email,"exists");$next$$(null,$obj$$)})};
|
|
6
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"app",{require_id_app:!1,sort:{name:1}});$contr_router$$.route();$contr_router$$.found=($user$$,$condition$$,$items$$,$fn$$)=>{async.mapSeries($items$$,($item$$,$callback$$)=>{calcTimeExpired($item$$);Customer.findOne({id_app:$item$$._id,of_user:$user$$.email},async($cust_e$$,$rs$$)=>{if($rs$$)return $item$$.customerInfo=$rs$$.toObject(),delete $item$$.customerInfo.default_password,$callback$$();$cust_e$$=
|
|
7
|
+
{ten_kh:$user$$.name,email:$user$$.email,id_app:$item$$._id,user_created:$user$$.email,user_updated:$user$$.email,kh_yn:!0,of_user:$user$$.email};validator.isMobilePhone($user$$.email,["vi-VN"])&&($cust_e$$.dien_thoai=$user$$.email);try{let $c$$=await Customer.asyncCreateCustomer($cust_e$$);$item$$.customerInfo=$c$$.toObject();delete $item$$.customerInfo.default_password}catch($e$$){console.log("Auto create new customer with error:",$e$$.message)}$callback$$()})},$e$$=>{$e$$&&console.error($e$$);
|
|
8
|
+
$fn$$(null,$items$$)})};$contr_router$$.view=function($user$$,$items$$,$fn$$){$items$$.forEach($item$$=>{$item$$.trang_thai=$item$$.trang_thai||"0"});async.parallel({trangthai:$callback$$=>{$items$$.joinModel2(null,Trangthai,{where:$item$$=>({ma_ct:"APP",ma_trang_thai:$item$$.trang_thai}),fields:["ten_trang_thai","color"]},()=>{$callback$$()})},show_gia_von_va_nguoi_duyet:$callback$jscomp$0$$=>{async.mapSeries($items$$,($item$$,$callback$$)=>{$item$$.options=$item$$.options||{};$item$$.show_gia_von=
|
|
9
|
+
!0;$callback$$()},()=>{$callback$jscomp$0$$()})},check_admin:$callback$jscomp$0$$=>{async.mapSeries($items$$,($item$$,$callback$$)=>{checkadmin($user$$,$item$$,()=>{$item$$.appAdmin||(delete $item$$.viettel_user,delete $item$$.viettel_password,delete $item$$.viettel_url_service,delete $item$$.wallet_address,delete $item$$.wallet_token,delete $item$$.voiip_access_token,delete $item$$.sip_password,delete $item$$.email_host,delete $item$$.email_port,delete $item$$.email_secure,delete $item$$.email_authMethod,
|
|
10
|
+
delete $item$$.email_user,delete $item$$.email_pass,delete $item$$.email_name);$callback$$()})},()=>{$callback$jscomp$0$$()})}},function(){$items$$.forEach(function($item$$){calcTimeExpired($item$$)});$fn$$(null,$items$$)})};$contr_router$$.getting=async($user$$,$id$$,$next$$)=>{(await model.participants($id$$)).find($p$$=>$p$$.email===$user$$.email&&0==$p$$.cancel)?$next$$():$next$$("Not allowed")};$contr_router$$.finding=async($user$$,$condition$$,$next$$)=>{var $_appsOfUser_or1$$=await Participant.appsOfUser($user$$.email);
|
|
11
|
+
$_appsOfUser_or1$$=$_appsOfUser_or1$$.map($p$$=>$p$$.id_app);let $user_created_condition$$={user_created:$user$$.email};$_appsOfUser_or1$$=[{_id:{$in:$_appsOfUser_or1$$}},$user_created_condition$$];let $or2$$=$condition$$.$or;delete $condition$$.$or;$or2$$?$condition$$.$and=[{$or:$_appsOfUser_or1$$},{$or:$or2$$}]:$condition$$.$or=$_appsOfUser_or1$$;$condition$$.working||(isSupperAdmin($user$$.email.toLowerCase())?delete $user_created_condition$$.user_created:underscore.contains(configs.admins,$user$$.email)&&
|
|
12
|
+
($user_created_condition$$.user_created={$nin:["invncur@gmail.com","admin"]}));delete $condition$$.working;$next$$(null,$condition$$)};$contr_router$$.creating=async function($now_user$$,$obj$$,$next$$){if(!underscore.contains(configs.admins,$now_user$$.email)&&!isSupperAdmin($now_user$$.email.toLowerCase())){if(await model.findOne({user_created:$now_user$$.email},{_id:1}))return $next$$("M\u1ed7i t\u00e0i kho\u1ea3n ch\u1ec9 \u0111\u01b0\u1ee3c ph\u00e9p t\u1ea1o m\u1ed9t c\u00f4ng ty");delete $obj$$.allow_modules;
|
|
13
|
+
delete $obj$$.trang_thai;delete $obj$$.sale_online}if(!$obj$$.ngay_dn)return $next$$(Error("Ng\u00e0y \u0111\u1ea7u n\u0103m t\u00e0i ch\u00ednh kh\u00f4ng \u0111\u01b0\u1ee3c tr\u1ed1ng"));$obj$$.ngay_ks||($obj$$.ngay_ks=new Date("2000-01-01"));$obj$$.ngay_ky1||($obj$$.ngay_ky1=new Date);$now_user$$=new Date;$now_user$$.setMonth($now_user$$.getMonth()+1);$obj$$.expire_date=new Date($now_user$$);$obj$$.nam_bd=$obj$$.ngay_ky1.getFullYear();$obj$$.options=$obj$$.options||{};$next$$(null,$obj$$)};$contr_router$$.created=
|
|
14
|
+
function($user$$,$obj$$,$next$$){require("../../libs/initDatabase").init($obj$$._id,async $error$$=>{$error$$&&console.error("Can't init database \n"+$error$$);createUserOwner($obj$$,$e$$=>{$e$$&&console.error($e$$);$next$$(null,$obj$$)})})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){const $usersAdmin$$=configs.admins;underscore.contains($usersAdmin$$,$user$$.email)||isSupperAdmin($user$$.email.toLowerCase())||(delete $data$$.allow_modules,delete $data$$.expire_date,delete $data$$.trang_thai,
|
|
15
|
+
delete $data$$.sale_online);permission.isAdmin($obj$$._id,$user$$.email,function($e$$,$admin$$){if(!$admin$$&&!underscore.contains($usersAdmin$$,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$($user$$.email+" have not permission");$data$$.ngay_ky1&&($data$$.nam_bd=(new Date($data$$.ngay_ky1)).getFullYear());$data$$.options&&0===Object.keys($data$$.options).length&&delete $data$$.options;$data$$.options=$data$$.options?{...$obj$$.options,...$data$$.options}:$obj$$.options||
|
|
16
|
+
{};$next$$(null,$data$$,$obj$$)})};$contr_router$$.updated=function($user$$,$obj$$,$next$$){createUserOwner($obj$$,$e$$=>{$e$$&&console.error($e$$);$next$$(null,$obj$$)})};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){const $usersAdmin$$=configs.admins;if($user$$.email!=$obj$$.user_created&&!underscore.contains($usersAdmin$$,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n x\u00f3a c\u00f4ng ty n\u00e0y");$next$$(null,$obj$$)};
|
|
17
|
+
$contr_router$$.deleted=function($user$$,$obj$$,$next$$){async.mapSeries(fs.readdirSync(path.dirname(path.dirname(__dirname))+"/models").filter($f$$=>0<$f$$.indexOf(".js")),($file$$,$callback$$)=>{try{let $_model$$=global.getModel(""+$file$$);underscore.has($_model$$.schema.paths,"id_app")?$_model$$.deleteMany({id_app:$obj$$._id},()=>{console.log("Deleted ",$file$$,"id_app",$obj$$._id);$callback$$()}):$callback$$()}catch($e$$){console.error("Can't delete mode",$file$$,"error:",$e$$.message),$callback$$()}},
|
|
18
|
+
()=>{$next$$(null,$obj$$)})};$contr_router$$.router.route($contr_router$$.route_name+"/backup/:id").get(function($req$$,$res$$){let $email$$=$req$$.user.email,$id_app$$=$req$$.params.id;permission.isAdmin($id_app$$,$email$$,function($backupWorkerFile_e$$,$admin$$){if(!$admin$$)return $res$$.status(400).send({error:"Ch\u1ec9 admin m\u1edbi c\u00f3 quy\u1ec1n backup d\u1eef li\u1ec7u c\u1ee7a c\u00f4ng ty"});global.backupPool||($backupWorkerFile_e$$=path.dirname(path.dirname(__dirname))+"/workers/backupApp.js",
|
|
19
|
+
global.backupPool=new StaticPool($backupWorkerFile_e$$));global.backupPool.exec({id:$id_app$$,user:$email$$,dateFrom:$req$$.query.dateFrom,dateTo:$req$$.query.dateTo,backup_app_info:$req$$.query.backup_app_info,configs:{database:global.configs.database}},$response$$=>{if($response$$.error)return $res$$.status(400).send($response$$.error);$res$$.sendFile(path.dirname(path.dirname(__dirname))+"/backup/"+$response$$.file)})})});$contr_router$$.router.route($contr_router$$.route_name+"/restore/:id").post(function($req$$,
|
|
20
|
+
$res$$){if(!$req$$.files.backup)return $res$$.status(400).send("Kh\u00f4ng t\u00ecm th\u1ea5y file backup");let $email$$=$req$$.user.email,$id_app$$=$req$$.params.id;permission.isAdmin($id_app$$,$email$$,function($e$$,$admin$$){if(!$admin$$)return $res$$.status(400).send({error:"Ch\u1ec9 admin m\u1edbi c\u00f3 quy\u1ec1n backup d\u1eef li\u1ec7u c\u1ee7a c\u00f4ng ty"});$e$$=$req$$.files.backup.path;global.restorePool||($admin$$=path.dirname(path.dirname(__dirname))+"/workers/restoreApp.js",global.restorePool=
|
|
21
|
+
new StaticPool($admin$$));global.restorePool.exec({id:$id_app$$,user:$email$$,file:$e$$,configs:{database:global.configs.database}},$response$$=>{$response$$.error?_Notification.createNotification($email$$,$email$$,$response$$.error,$response$$.error,null,null,!0,$req$$.access_token,!0):_Notification.createNotification($email$$,$email$$,$response$$.result,$response$$.result,null,null,!0,$req$$.access_token,!0)});$res$$.send("Ch\u01b0\u01a1ng tr\u00ecnh \u0111ang th\u1ef1c hi\u1ec7n. Xin ch\u1edd trong gi\u00e2y l\u00e1t")})});
|
|
22
|
+
$contr_router$$.router.route($contr_router$$.route_name+"/apps/:email_owner").get(function($query_req$$,$res$$){let $email$$=$query_req$$.params.email_owner;if(!underscore.contains(configs.admins,$query_req$$.user.email)&&!isSupperAdmin($query_req$$.user.email.toLowerCase()))return $res$$.status(403).send("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n truy c\u1eadp t\u00ednh n\u0103ng n\u00e0y");$query_req$$={};"all"!=$email$$.toLowerCase()&&($query_req$$.user_created=$email$$);model.find($query_req$$).lean().exec(function($error$$,
|
|
23
|
+
$apps$$){if($error$$)return $res$$.status(400).send($error$$);$apps$$.forEach(function($item$$){calcTimeExpired($item$$)});$res$$.send($apps$$)})});$contr_router$$.router.route($contr_router$$.route_name+"/remove/:id").get(async($app_req$$,$res$$)=>{var $id_app$jscomp$2_p$$=$app_req$$.params.id;let $email$$=$app_req$$.user.email;$app_req$$=await model.findById($id_app$jscomp$2_p$$);if(!$app_req$$)return $res$$.status(400).send("C\u00f4ng ty n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i");$app_req$$.participants&&
|
|
24
|
+
($app_req$$.participants=$app_req$$.participants.filter($p$$=>$p$$.email!==$email$$),$app_req$$.save(()=>{}));if($id_app$jscomp$2_p$$=await Participant.findOne({id_app:$id_app$jscomp$2_p$$,email:$email$$}))await Participant.deleteOne({_id:$id_app$jscomp$2_p$$._id}),$id_app$jscomp$2_p$$=`${$id_app$jscomp$2_p$$.name} (${$email$$}) \u0111\u00e3 r\u1eddi kh\u1ecfi c\u00f4ng ty ${$app_req$$.name}`,_Notification.createNotification($email$$,$app_req$$.user_created,$id_app$jscomp$2_p$$,$id_app$jscomp$2_p$$);
|
|
25
|
+
$res$$.send("ok")});$contr_router$$.router.route($contr_router$$.route_name+"/join/:id/:group").get(async($req$$,$res$$)=>{let $id_app$$=$req$$.params.id,$group_id$$=$req$$.params.group,$email$$=$req$$.user.email,$user$$=$req$$.user,$app$$=await model.findById($id_app$$);if(!$app$$)return $res$$.status(400).send("C\u00f4ng ty n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i");if(!await Participant.findOne({id_app:$id_app$$,email:$email$$})&&$group_id$$&&global.mongoose.Types.ObjectId.isValid($group_id$$))try{if(!await UserGroup.findOne({_id:$group_id$$,
|
|
26
|
+
is_customer_group:!0}))return $res$$.status(400).send("Nh\u00f3m kh\u00e1ch h\u00e0ng kh\u00f4ng t\u1ed3n t\u1ea1i");Participant.createParticipant({id_app:$id_app$$,email:$email$$,name:$user$$.name,group_id:$group_id$$,active:!0},$cust$jscomp$1_e$$=>{if($cust$jscomp$1_e$$)return $res$$.status(400).send("can't add user",$user$$.email,"to company",$app$$.name);$cust$jscomp$1_e$$={ten_kh:$user$$.name,email:$user$$.email,id_app:$id_app$$,user_created:$user$$.email,user_updated:$user$$.email,kh_yn:!0,
|
|
27
|
+
of_user:$user$$.email};validator.isMobilePhone($user$$.email,["vi-VN"])&&($cust$jscomp$1_e$$.dien_thoai=$user$$.email);try{Customer.asyncCreateCustomer($cust$jscomp$1_e$$)}catch($e$$){console.log("Auto create new customer with error:",$e$$.message)}$res$$.send("ok")})}catch($e$$){$res$$.status(400).send($e$$.message)}$res$$.send("ok")})};
|
|
@@ -3,6 +3,6 @@ module.exports=function($contr_router$$){const $usersAdmin$$=configs.admins;$con
|
|
|
3
3
|
value:"picture"}]}],function(){$result$$.forEach(function($r$$){$r$$.picture_sender||($r$$.picture_sender="/images/avatar.jpg");$r$$.name_sender||($r$$.name_sender=$r$$.email_sender);$r$$.picture_receiver||($r$$.picture_receiver="/images/avatar.jpg");$r$$.name_receiver||($r$$.name_receiver=$r$$.email_receiver)});$fn$$(null,$result$$)})};$contr_router$$.getting=function($user$$,$id$$,$next$$,$obj$$){if($obj$$.email_owner!=$user$$.email)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");
|
|
4
4
|
$next$$()};$contr_router$$.finding=function($user$$,$condition$$,$next$$){$condition$$.$or=[{email_owner:$user$$.email}];$next$$(null,$condition$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.email_sender=$user$$.email;$obj$$.email_owner=$user$$.email;$obj$$.read=!0;$next$$(null,$obj$$)};$contr_router$$.created=function($obj_receiver_user$$,$obj$$,$next$$){$obj_receiver_user$$=new model;$obj_receiver_user$$.email_sender=$obj$$.email_sender;$obj_receiver_user$$.email_receiver=
|
|
5
5
|
$obj$$.email_receiver;$obj_receiver_user$$.email_owner=$obj$$.email_receiver;$obj_receiver_user$$.content=$obj$$.content;$obj_receiver_user$$.save(function($error$$){if($error$$)return console.log($error$$);global.alertNotification($obj$$.email_receiver);User.emitEvent($obj$$.email_receiver,"notify:new",{_id:$obj$$._id,sender:$obj$$.email_sender,content:$obj$$.content})});$next$$(null,$obj$$)};$contr_router$$.updated=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email_receiver);
|
|
6
|
-
User.emitEvent($obj$$.email_receiver,"notify:update",{_id:$obj$$._id,sender:$obj$$.email_sender,content:$obj$$.content});$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email_owner);$next$$(null,$obj$$)};$contr_router$$.createRoute("broadcast",function($q_req$$,$callback$jscomp$0$$){let $body$$=$q_req$$.body;if(!$body$$||!$body$$.title||!$body$$.message)return $callback$jscomp$0$$("error: Notification is empty");
|
|
6
|
+
User.emitEvent($obj$$.email_receiver,"notify:update",{_id:$obj$$._id,sender:$obj$$.email_sender,content:$obj$$.content});$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email_owner);$next$$(null,$obj$$)};$contr_router$$.createRoute("broadcast/all",function($q_req$$,$callback$jscomp$0$$){let $body$$=$q_req$$.body;if(!$body$$||!$body$$.title||!$body$$.message)return $callback$jscomp$0$$("error: Notification is empty");
|
|
7
7
|
if(!underscore.contains($usersAdmin$$,$q_req$$.user.email))return $callback$jscomp$0$$("Not permission");$q_req$$={};$body$$.to&&($q_req$$.email={$in:$body$$.to.split(",")});User.find($q_req$$,{email:1}).lean().exec(function($e$$,$us$$){if($e$$)return $callback$jscomp$0$$($e$$);async.mapSeries($us$$,($u$$,$callback$$)=>{model.createNotification("SYSTEM",$u$$.email,$body$$.title,$body$$.message,$e$$=>{$callback$$($e$$)},!0)},$e$$=>{if($e$$)return $callback$jscomp$0$$($e$$);$callback$jscomp$0$$(null,
|
|
8
|
-
"broadcast is sent")})})},{method:"POST"})};
|
|
8
|
+
"broadcast is sent")})})},{method:"POST"});$contr_router$$.createRoute("read/all",async function($req$$,$callback$$){try{await model.updateMany({email_owner:$req$$.user.email,read:{$ne:!0}},{read:!0}),global.alertNotification($req$$.user.email),$callback$$(null,{result:"ok"})}catch($e$$){$callback$$($e$$)}},{method:"GET"})};
|