flexbiz-server
Version:
Flexible Server
9 lines (8 loc) • 3.49 kB
JavaScript
'use strict';const dtbanletheosp=require("../../libs/dtbanletheosp"),controller=require("../../controllers/controllerRPT");
module.exports=function($router$$){new controller($router$$,"dtbanletheosp",async function($req$$,$callback$$){const $condition$$=$req$$.query;try{let $report$$=await dtbanletheosp($condition$$);await $report$$.asyncJoinModel2($condition$$.id_app,"dmvt",{where:"ma_vt",fields:["ma_nvt","ma_nvt2","ma_nvt3","ma_nvt4"]});await $report$$.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;$group_by$$&&("string"==
typeof $group_by$$&&($group_by$$=[$group_by$$]),$report$$=await $report$$.asyncGroupBy($group_by$$,"sl_xuat sl_nhap sl_xuat_qd sl_nhap_qd 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".split(" ")));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"]});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"}]});const $tong_cong$$={[$group_by$$?$group_by$$[0]:"ten_vt"]:"T\u1ed5ng c\u1ed9ng",sl_xuat:$report$$.csum("sl_xuat"),sl_nhap:$report$$.csum("sl_nhap"),sl_xuat_qd:$report$$.csum("sl_xuat_qd"),sl_nhap_qd:$report$$.csum("sl_nhap_qd"),tien_hang_nt:$report$$.csum("tien_hang_nt"),tien_hang_ct_nt:$report$$.csum("tien_hang_ct_nt"),tien_hang:$report$$.csum("tien_hang"),tien_hang_ct:$report$$.csum("tien_hang_ct"),tien_cp:$report$$.csum("tien_cp"),tien_cp_nt:$report$$.csum("tien_cp_nt"),
tien_ck_nt:$report$$.csum("tien_ck_nt"),tien_ck:$report$$.csum("tien_ck"),tien_thue:$report$$.csum("tien_thue"),tien_thue_nt:$report$$.csum("tien_thue_nt"),tien:$report$$.csum("tien"),tien_nt:$report$$.csum("tien_nt"),tt:$report$$.csum("tt"),tt_nt:$report$$.csum("tt_nt"),tien_xuat_tmp:$report$$.csum("tien_xuat_tmp"),tien_xuat:$report$$.csum("tien_xuat"),tien_nhap:$report$$.csum("tien_nhap"),loi_nhuan_tmp:$report$$.csum("loi_nhuan_tmp"),loi_nhuan:$report$$.csum("loi_nhuan"),tien_hoa_hong:$report$$.csum("tien_hoa_hong"),
tien_hoa_hong_gt:$report$$.csum("tien_hoa_hong_gt"),tien_hoa_hong_ctv:$report$$.csum("tien_hoa_hong_ctv"),tien_hoa_hong_ql:$report$$.csum("tien_hoa_hong_ql"),t_hoa_hong:$report$$.csum("t_hoa_hong"),bold:!0};$report$$.push($tong_cong$$);$callback$$(null,$report$$)}catch($e$$){$callback$$($e$$)}})};