flexbiz-server
Version:
Flexible Server
13 lines (12 loc) • 5.71 kB
JavaScript
const dtbanletheosp=require("../../libs/dtbanletheosp"),controller=require("../../controllers/controllerRPT");
module.exports=function($router$$){new controller($router$$,"dtbanlekempk",async function($req$$,$callback$$){const $condition$$=$req$$.query;try{$condition$$.den_ngay=$condition$$.den_gio||$condition$$.den_ngay;$condition$$.tu_ngay=$condition$$.tu_gio||$condition$$.tu_ngay;const $data$$=await dtbanletheosp($condition$$);await $data$$.asyncJoinModel2($condition$$.id_app,"dmvt",{where:"ma_vt",fields:["ma_nvt","ma_nvt2","ma_nvt3","ma_nvt4"]});await $data$$.filter($r$$=>$r$$.ma_kh).asyncJoinModel2($condition$$.id_app,
"customer",{where:{ma_kh:"ma_kh"},fields:["nh_kh"]});let $group_by$$=$req$$.query.group_by,$report$$;$group_by$$?(typeof $group_by$$=="string"&&($group_by$$=[$group_by$$]),$report$$=await $data$$.asyncGroupBy($group_by$$,"sl_xuat sl_nhap sl_xuat_qd sl_nhap_qd sl_xuat_qd_bc sl_nhap_qd_bc tien_hang_nt tien_hang_ct_nt tien_hang tien_hang_ct tien_cp tien_cp_nt tien_ck_nt tien_ck tien_thue tien_thue_nt tien tien_nt tt tt_nt tien_xuat_tmp tien_xuat tien_nhap loi_nhuan_tmp loi_nhuan tien_hoa_hong tien_hoa_hong_gt tien_hoa_hong_ctv tien_hoa_hong_ql t_hoa_hong sl_vt_du gt_vt_du".split(" "))):
$report$$=$data$$;$group_by$$&&$condition$$.show_detail&&($report$$.forEach($r$$=>{$r$$.bold=!0;$r$$.sysorder=3}),$report$$=$report$$.concat($data$$));await $report$$.filter($r$$=>$r$$.ma_vt).asyncJoinModel2($condition$$.id_app,"dmvt",{where:"ma_vt",fields:["ten_vt","ma_nvt","ma_nvt2","ma_nvt3","ma_nvt4"]});await $report$$.filter($r$$=>$r$$.ma_nvt).asyncJoinModel2($condition$$.id_app,"dmnvt",{where:{ma_nvt:"_id"},fields:["ten_nvt"]});await $report$$.filter($r$$=>$r$$.ma_nvt2).asyncJoinModel2($condition$$.id_app,
"dmnvt",{where:{ma_nvt2:"_id"},fields:[{ten_nvt2:"ten_nvt"}]});await $report$$.filter($r$$=>$r$$.ma_nvt3).asyncJoinModel2($condition$$.id_app,"dmnvt",{where:{ma_nvt3:"_id"},fields:[{ten_nvt3:"ten_nvt"}]});await $report$$.filter($r$$=>$r$$.ma_nvt4).asyncJoinModel2($condition$$.id_app,"dmnvt",{where:{ma_nvt4:"_id"},fields:[{ten_nvt4:"ten_nvt"}]});await $report$$.filter($r$$=>$r$$.ma_kh).asyncJoinModel2($condition$$.id_app,"customer",{where:{ma_kh:"ma_kh"},fields:["ten_kh","nh_kh","dia_chi","dien_thoai"]});
await $report$$.filter($r$$=>$r$$.nh_kh).asyncJoinModel2($condition$$.id_app,"group",{where:{nh_kh:"_id"},fields:[{ten_nh_kh:"group_name"}]});await $report$$.filter($r$$=>$r$$.ma_bp).asyncJoinModel2($condition$$.id_app,"dmbp",{where:{ma_bp:"ma_bp"},fields:[{ten_bp:"ten_bp"}]});await $report$$.filter($r$$=>$r$$.ma_vt_du).asyncJoinModel2($condition$$.id_app,"dmvt",{where:{ma_vt_du:"ma_vt"},fields:[{ten_vt_du:"ten_vt"}]});await $report$$.filter($r$$=>$r$$.user_nv_giao_hang).asyncJoinModel2(null,"user",
{where:{user_nv_giao_hang:"email"},fields:[{ten_nv_giao_hang:"name"}]});$req$$.query.group_by&&$condition$$.show_detail&&($report$$=$report$$.sort(($a$$,$b$$)=>{var $date2Diff_dateDiff_groupByDiff_sysorderDiff$$=$a$$[$req$$.query.group_by].localeCompare($b$$[$req$$.query.group_by]);if($date2Diff_dateDiff_groupByDiff_sysorderDiff$$!==0)return $date2Diff_dateDiff_groupByDiff_sysorderDiff$$;$date2Diff_dateDiff_groupByDiff_sysorderDiff$$=$a$$.sysorder-$b$$.sysorder;if($date2Diff_dateDiff_groupByDiff_sysorderDiff$$!==
0)return $date2Diff_dateDiff_groupByDiff_sysorderDiff$$;$date2Diff_dateDiff_groupByDiff_sysorderDiff$$=new Date($a$$.ngay_ct)-new Date($b$$.ngay_ct);if($date2Diff_dateDiff_groupByDiff_sysorderDiff$$!==0)return $date2Diff_dateDiff_groupByDiff_sysorderDiff$$;$date2Diff_dateDiff_groupByDiff_sysorderDiff$$=new Date($a$$.date_created)-new Date($b$$.date_created);if($date2Diff_dateDiff_groupByDiff_sysorderDiff$$!==0)return $date2Diff_dateDiff_groupByDiff_sysorderDiff$$;$a$$=$a$$.so_ct.localeCompare($b$$.so_ct);
return $a$$!==0?$a$$:0}));const $tong_cong$$={[$group_by$$?$group_by$$[0]:"ten_vt"]:"T\u1ed5ng c\u1ed9ng",sl_xuat:$report$$.csum("sl_xuat",{sysorder:5}),sl_nhap:$report$$.csum("sl_nhap",{sysorder:5}),sl_xuat_qd:$report$$.csum("sl_xuat_qd",{sysorder:5}),sl_nhap_qd:$report$$.csum("sl_nhap_qd",{sysorder:5}),sl_xuat_qd_bc:$report$$.csum("sl_xuat_qb_bc",{sysorder:5}),sl_nhap_qd_bc:$report$$.csum("sl_nhap_qd_bc",{sysorder:5}),tien_hang_nt:$report$$.csum("tien_hang_nt",{sysorder:5}),tien_hang_ct_nt:$report$$.csum("tien_hang_ct_nt",
{sysorder:5}),tien_hang:$report$$.csum("tien_hang",{sysorder:5}),tien_hang_ct:$report$$.csum("tien_hang_ct",{sysorder:5}),tien_cp:$report$$.csum("tien_cp",{sysorder:5}),tien_cp_nt:$report$$.csum("tien_cp_nt",{sysorder:5}),tien_ck_nt:$report$$.csum("tien_ck_nt",{sysorder:5}),tien_ck:$report$$.csum("tien_ck",{sysorder:5}),tien_thue:$report$$.csum("tien_thue",{sysorder:5}),tien_thue_nt:$report$$.csum("tien_thue_nt",{sysorder:5}),tien:$report$$.csum("tien",{sysorder:5}),tien_nt:$report$$.csum("tien_nt",
{sysorder:5}),tt:$report$$.csum("tt",{sysorder:5}),tt_nt:$report$$.csum("tt_nt",{sysorder:5}),tien_xuat_tmp:$report$$.csum("tien_xuat_tmp",{sysorder:5}),tien_xuat:$report$$.csum("tien_xuat",{sysorder:5}),tien_nhap:$report$$.csum("tien_nhap",{sysorder:5}),loi_nhuan_tmp:$report$$.csum("loi_nhuan_tmp",{sysorder:5}),loi_nhuan:$report$$.csum("loi_nhuan",{sysorder:5}),tien_hoa_hong:$report$$.csum("tien_hoa_hong",{sysorder:5}),tien_hoa_hong_gt:$report$$.csum("tien_hoa_hong_gt",{sysorder:5}),tien_hoa_hong_ctv:$report$$.csum("tien_hoa_hong_ctv",
{sysorder:5}),tien_hoa_hong_ql:$report$$.csum("tien_hoa_hong_ql",{sysorder:5}),t_hoa_hong:$report$$.csum("t_hoa_hong",{sysorder:5}),sl_vt_du:$report$$.csum("sl_vt_du",{sysorder:5}),gt_vt_du:$report$$.csum("gt_vt_du",{sysorder:5}),sysorder:9,bold:!0};$report$$.push($tong_cong$$);$callback$$(null,$report$$)}catch($e$$){$callback$$($e$$)}})};