UNPKG

flexbiz-server

Version:

Flexible Server

8 lines (7 loc) 2.96 kB
const dkvt=require("./dkvt"),sokho=global.getModel("sokho"),async=require("async"); module.exports=function($condition$$,$fn$$){if(!($condition$$&&$condition$$.tu_ngay&&$condition$$.ma_vt&&$condition$$.den_ngay&&$condition$$.id_app))return $fn$$("L\u1ed7i: B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_ngay,den_ngay,ma_vt,id_app");let $ma_dvcs$$=$condition$$.ma_dvcs,$ma_kho$$=$condition$$.ma_kho,$ma_vt$$=$condition$$.ma_vt,$tu_ngay$$=$condition$$.tu_ngay,$den_ngay$$=$condition$$.den_ngay,$id_app$$=$condition$$.id_app;async.series({dn:function($callback$$){setImmediate(()=> {dkvt($condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$callback$$(null,$result$$)})})},ps:function($callback$$){setImmediate(()=>{let $query$$={id_app:$id_app$$,ngay_ct:{$gte:$tu_ngay$$,$lte:$den_ngay$$},ma_vt:$ma_vt$$};$ma_kho$$&&($query$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($query$$.ma_dvcs=$ma_dvcs$$);$condition$$.ma_lo&&($query$$.ma_lo=$condition$$.ma_lo);$condition$$.han_sd&&($query$$.han_sd=$condition$$.han_sd);$condition$$.ma_tt1&&($query$$.ma_tt1=$condition$$.ma_tt1); $condition$$.ma_tt2&&($query$$.ma_tt2=$condition$$.ma_tt2);$condition$$.ma_tt3&&($query$$.ma_tt3=$condition$$.ma_tt3);$condition$$.ma_kh&&($query$$.ma_kh=$condition$$.ma_kh);sokho.find($query$$).lean().then(function($pss$$){$pss$$=$pss$$.map($ps$$=>{$ps$$.sl_nhap=$ps$$.sl_nhap_qd;$ps$$.sl_xuat=$ps$$.sl_xuat_qd;return $ps$$});$callback$$(null,$pss$$)}).catch($error$$=>{$callback$$($error$$)})})}},function($error$$,$results$$){if($error$$)return $fn$$($error$$);let $data$$=[];$results$$.ps.forEach(function($r$$){$r$$.sysorder= 5;$r$$.bold=!1;$data$$.push($r$$)});async.parallel({ton_dau:function($callback$$){var $ton_dau$$=$results$$.dn.csum("ton00");$callback$$(null,$ton_dau$$)},du_dau:function($callback$$){var $du_dau$$=$results$$.dn.csum("du00");$callback$$(null,$du_dau$$)},sl_nhap:function($callback$$){var $sl_nhap$$=$results$$.ps.csum("sl_nhap");$callback$$(null,$sl_nhap$$)},tien_nhap:function($callback$$){var $tien_nhap$$=$results$$.ps.csum("tien_nhap");$callback$$(null,$tien_nhap$$)},sl_xuat:function($callback$$){var $sl_xuat$$= $results$$.ps.csum("sl_xuat");$callback$$(null,$sl_xuat$$)},tien_xuat:function($callback$$){var $tien_xuat$$=$results$$.ps.csum("tien_xuat");$callback$$(null,$tien_xuat$$)}},function($error$$,$results$$){$data$$.push({sysorder:1,bold:!0,dien_giai:"T\u1ed3n \u0111\u1ea7u k\u1ef3",sl_nhap:$results$$.ton_dau,tien_nhap:$results$$.du_dau,sl_xuat:0,tien_xuat:0});$data$$.push({sysorder:6,bold:!0,dien_giai:"C\u1ed9ng ph\u00e1t sinh trong k\u1ef3",sl_nhap:$results$$.sl_nhap,tien_nhap:$results$$.tien_nhap, sl_xuat:$results$$.sl_xuat,tien_xuat:$results$$.tien_xuat});$data$$.push({sysorder:9,bold:!0,dien_giai:"T\u1ed3n cu\u1ed1i k\u1ef3",sl_nhap:$results$$.ton_dau+$results$$.sl_nhap-$results$$.sl_xuat,tien_nhap:$results$$.du_dau+$results$$.tien_nhap-$results$$.tien_xuat});$fn$$(null,$data$$)})})};