flexbiz-server 12.1.22 → 12.1.24

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "flexbiz-server",
3
3
  "main": "./server/app.js",
4
4
  "description": "Flexible Server",
5
- "version": "12.1.22",
5
+ "version": "12.1.24",
6
6
  "author": {
7
7
  "name": "Van Truong Pham",
8
8
  "email": "invncur@gmail.com"
@@ -1,4 +1,4 @@
1
- 'use strict';const User=global.getModel("user"),Participant=global.getModel("participant"),UserGroup=global.getModel("usergroup"),Customer=global.getModel("customer"),request=require("request"),log=global.getModel("log"),App=global.getModel("app"),Wallet=global.getModel("wallet"),Token=global.getModel("token"),BasicStrategy=require("passport-http").BasicStrategy,_crypto=require("crypto"),validator=require("validator"),email=require("../libs/email"),loadTemplate=require("../libs/load-template"),permission=
1
+ 'use strict';const User=global.getModel("user"),Participant=global.getModel("participant"),UserGroup=global.getModel("usergroup"),Customer=global.getModel("customer"),axios=require("axios"),log=global.getModel("log"),App=global.getModel("app"),Wallet=global.getModel("wallet"),Token=global.getModel("token"),BasicStrategy=require("passport-http").BasicStrategy,_crypto=require("crypto"),validator=require("validator"),email=require("../libs/email"),loadTemplate=require("../libs/load-template"),permission=
2
2
  require("../libs/permission"),OTP=global.getModel("otp"),DIGITS="0123456789",jwt=require("jsonwebtoken"),redisCache=require("../libs/redis-cache");function generateOTP(){let $OTP$$="";for(let $i$$=0;6>$i$$;$i$$++)$OTP$$+=DIGITS[Math.floor(10*Math.random())];return $OTP$$}
3
3
  function generateToken($user$$){var $body_n_n$$={email:$user$$.email};configs.APP_SECRET?jwt.sign({user:$body_n_n$$},configs.APP_SECRET):($body_n_n$$=new Date,_crypto.createHash("md5").update($user$$.email+$body_n_n$$.toISOString()).digest("hex"));$body_n_n$$=new Date;return _crypto.createHash("md5").update($user$$.email+$body_n_n$$.toISOString()).digest("hex")}
4
4
  function saveOTP($Phone$$,$otp_code$$,$callback$$,$expires$$=5){let $expire_time$$=new Date;$expire_time$$.setMinutes($expire_time$$.getMinutes()+$expires$$);OTP.create({phone:$Phone$$,otp:$otp_code$$,expire_time:$expire_time$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,$rs$$.toObject())})}
@@ -10,15 +10,15 @@ $username$$+" ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u0103ng k\u00fd.");if(0==$use
10
10
  $user$$.email,$rs$$)});else{if(!$user$$.validPassword($password$$))return $done$$("M\u1eadt kh\u1ea9u kh\u00f4ng ch\u00ednh x\u00e1c.")}else{if(!$user$$.local.password)return $done$$("M\u1eadt kh\u1ea9u cho ng\u01b0\u1eddi d\u00f9ng n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i. H\u00e3y s\u1eed d\u1ee5ng t\u00ednh n\u0103ng kh\u00f4i ph\u1ee5c m\u1eadt kh\u1ea9u \u0111\u1ec3 \u0111\u1eb7t l\u1ea1i m\u1eadt kh\u1ea9u cho ng\u01b0\u1eddi d\u00f9ng n\u00e0y");if(!$user$$.validPassword($password$$))return $done$$("M\u1eadt kh\u1ea9u kh\u00f4ng ch\u00ednh x\u00e1c.")}return $done$$(null,
11
11
  $user$$)})})}));$app$jscomp$0$$.get("/send-otp/:address_receive_otp",$rateLimiter$$,async($req_url$$,$res$$)=>{if(configs.GOOGLE_RECAPTCHA_SECRET_KEY){if(!$req_url$$.query["g-recaptcha-response"])return $res$$.status(400).send("Ch\u1ee9c n\u0103ng n\u00e0y y\u00eau c\u1ea7u m\u1ed9t google recaptcha token");try{await permission.verifyReCaptcha($req_url$$.query["g-recaptcha-response"])}catch($e$$){return $res$$.status(400).send($e$$.messag||$e$$.error||$e$$)}}let $address_receive_otp$$=$req_url$$.params.address_receive_otp.trim().toLowerCase(),
12
12
  $u$$=await User.findOne({$or:[{email:$address_receive_otp$$},{"local.phone":$address_receive_otp$$}]});if(!$u$$)return $res$$.status(400).send({error:`T\u00e0i kho\u1ea3n ${$address_receive_otp$$} kh\u00f4ng t\u1ed3n t\u1ea1i`});const $username$$=$u$$.email,$otp_code$$=generateOTP();let $phone$$;$address_receive_otp$$!=$username$$&&validator.isMobilePhone($address_receive_otp$$)?$phone$$=$address_receive_otp$$:validator.isMobilePhone($username$$)?$phone$$=$username$$:validator.isMobilePhone(($u$$.local||
13
- {}).phone||"")&&($phone$$=($u$$.local||{}).phone);if($phone$$)configs.sms.send?configs.sms.send($phone$$,$otp_code$$,$req_url$$.query.id_app).then($rs$jscomp$0$$=>{$rs$jscomp$0$$.error_message?$res$$.status(400).send({error:$rs$jscomp$0$$.message||$rs$jscomp$0$$.error||$rs$jscomp$0$$.error_message||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`}):saveOTP($username$$,$otp_code$$,($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);
14
- $res$$.send($rs$$)})}).catch($e$$=>{console.error("Error send sms",$e$$);$res$$.status(400).send({error:$e$$.message||$e$$.error_message||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`})}):($req_url$$=configs.sms.genUrlSendOTP($phone$$,$otp_code$$,$req_url$$.query.id_app),request({url:$req_url$$},($error$$,$response$$,$body$$)=>{if($error$$||200!=$response$$.statusCode)$res$$.status(400).send({error:$error$$||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`});
15
- else try{const $info$$=JSON.parse($body$$);"100"==$info$$.CodeResult?saveOTP($username$$,$otp_code$$,($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);$res$$.send($rs$$)}):(console.error("Error send sms",$info$$),$res$$.status(400).send({error:`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`}))}catch($e$$){$res$$.status(400).send({error:$body$$})}}));else{let $email_address$$;validator.isEmail($address_receive_otp$$)&&$address_receive_otp$$!=
16
- $username$$?$email_address$$=$address_receive_otp$$:validator.isEmail($username$$)?$email_address$$=$username$$:$u$$.email2&&validator.isEmail($u$$.email2)&&($email_address$$=$u$$.email2);$email_address$$?email.sendHtml({to:{address:$email_address$$},subject:"M\u00e3 x\u00e1c th\u1ef1c",html:`Xin vui l\u00f2ng g\u1eedi qu\u00fd kh\u00e1ch m\u00e3 x\u00e1c th\u1ef1c: ${$otp_code$$}. M\u00e3 n\u00e0y s\u1ebd h\u1ebft h\u1ea1n s\u1eed d\u1ee5ng sau 5 ph\u00fat.`},function($error$$){$error$$?(console.error("Error send otp to email",
17
- $error$$),$res$$.status(400).send(`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi email ${$username$$}`)):saveOTP($username$$,$otp_code$$,($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);$res$$.send($rs$$)},5)},configs.sender_otp):$res$$.status(400).send({error:`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`})}});$app$jscomp$0$$.get("/verify-otp/:id/:otp",$rateLimiter$$,async function($req$$,$res$$){try{const $id$$=
18
- $req$$.params.id;if(!global.mongoose.Types.ObjectId.isValid($id$$))return $res$$.status(400).send({error:"ID c\u1ee7a m\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng h\u1ee3p l\u1ec7",code:4001});const $otp_code$$=$req$$.params.otp,$otp$$=await OTP.findById($id$$);if(!$otp$$)return $res$$.status(400).send({error:"M\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i",code:4001});$otp$$.tried_number=($otp$$.tried_number||0)+1;await $otp$$.save();if($otp$$.otp!=$otp_code$$||$otp$$.verified||
19
- $otp$$.tried_number>(configs.MAX_TRY_OTP||3)||$otp$$.expire_time.getTime()<(new Date).getTime())return $res$$.status(400).send({error:"M\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c \u0111\u00e3 h\u1ebft hi\u1ec7u l\u1ef1c",code:4001});await OTP.findOneAndUpdate({_id:$id$$},{verified:!0});let $user$$=await User.findOne({email:$otp$$.phone});if(!$user$$)return $res$$.status(400).send({error:"T\u00e0i kho\u1ea3n kh\u00f4ng t\u1ed3n t\u1ea1i",code:4001});if(!$user$$.local||
20
- !$user$$.local.active){$user$$.local=$user$$.local||{};$user$$.local.active=!0;try{await $user$$.save(),redisCache.set("user",$user$$.toObject(),function($e$$){$e$$?console.error($e$$):console.log("cache user infomation to redis")})}catch($e$$){return console.log("error verify otp, create user",$e$$),$res$$.status(500).send($e$$)}}const $accessToken$$=generateToken($user$$);(new Token({email:$user$$.email,session_created:($req$$.cookies||{}).uid,token:$accessToken$$,agent:$req$$.headers["user-agent"],
21
- ip:"",once:1==$req$$.query.once||"true"==$req$$.query.once||"1"===$req$$.query.once?!0:!1})).save(function($e$$,$rs$$){return $e$$?$res$$.status(500).send($e$$):$res$$.send({token:$accessToken$$,once:$rs$$.once})})}catch($e$$){console.error("error verify otp",$e$$),$res$$.status(400).send($e$$.message)}});$app$jscomp$0$$.post("/auth/sign",$rateLimiter$$,($req$$,$res$$,$next$$)=>{$passport$$.authenticate("basic",{session:!1},function($err$$,$user$$){if($err$$||!$user$$)return $res$$.status(401).send({message:$err$$||
13
+ {}).phone||"")&&($phone$$=($u$$.local||{}).phone);if($phone$$)if(configs.sms&&(configs.sms.send||configs.sms.genUrlSendOTP))if(configs.sms.send)configs.sms.send($phone$$,$otp_code$$,$req_url$$.query.id_app).then($rs$jscomp$0$$=>{$rs$jscomp$0$$.error_message?$res$$.status(400).send({error:$rs$jscomp$0$$.message||$rs$jscomp$0$$.error||$rs$jscomp$0$$.error_message||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`}):saveOTP($username$$,$otp_code$$,
14
+ ($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);$res$$.send($rs$$)})}).catch($e$$=>{console.error("Error send sms",$e$$);$res$$.status(400).send({error:$e$$.message||$e$$.error_message||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`})});else if($req_url$$=configs.sms.genUrlSendOTP($phone$$,$otp_code$$,$req_url$$.query.id_app))try{await axios.get($req_url$$),saveOTP($username$$,$otp_code$$,($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);
15
+ $res$$.send($rs$$)})}catch($e$$){console.error($e$$),$res$$.status(400).send({error:$e$$.message||$e$$.error||$e$$||`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`})}else $res$$.status(400).send({error:`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`});else $res$$.status(400).send({error:`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`});
16
+ else{let $email_address$$;validator.isEmail($address_receive_otp$$)&&$address_receive_otp$$!=$username$$?$email_address$$=$address_receive_otp$$:validator.isEmail($username$$)?$email_address$$=$username$$:$u$$.email2&&validator.isEmail($u$$.email2)&&($email_address$$=$u$$.email2);$email_address$$?email.sendHtml({to:{address:$email_address$$},subject:"M\u00e3 x\u00e1c th\u1ef1c",html:`Xin vui l\u00f2ng g\u1eedi qu\u00fd kh\u00e1ch m\u00e3 x\u00e1c th\u1ef1c: ${$otp_code$$}. M\u00e3 n\u00e0y s\u1ebd h\u1ebft h\u1ea1n s\u1eed d\u1ee5ng sau 5 ph\u00fat.`},
17
+ function($error$$){$error$$?(console.error("Error send otp to email",$error$$),$res$$.status(400).send(`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi email ${$username$$}`)):saveOTP($username$$,$otp_code$$,($e$$,$rs$$)=>{if($e$$)return $res$$.status(400).send($e$$);$res$$.send($rs$$)},5)},configs.sender_otp):$res$$.status(400).send({error:`Kh\u00f4ng th\u1ec3 g\u1eedi \u0111\u01b0\u1ee3c m\u00e3 OTP t\u1edbi t\u00e0i kho\u1ea3n ${$username$$}`})}});$app$jscomp$0$$.get("/verify-otp/:id/:otp",
18
+ $rateLimiter$$,async function($req$$,$res$$){try{const $id$$=$req$$.params.id;if(!global.mongoose.Types.ObjectId.isValid($id$$))return $res$$.status(400).send({error:"ID c\u1ee7a m\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng h\u1ee3p l\u1ec7",code:4001});const $otp_code$$=$req$$.params.otp,$otp$$=await OTP.findById($id$$);if(!$otp$$)return $res$$.status(400).send({error:"M\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i",code:4001});$otp$$.tried_number=($otp$$.tried_number||0)+1;await $otp$$.save();
19
+ if($otp$$.otp!=$otp_code$$||$otp$$.verified||$otp$$.tried_number>(configs.MAX_TRY_OTP||3)||$otp$$.expire_time.getTime()<(new Date).getTime())return $res$$.status(400).send({error:"M\u00e3 x\u00e1c th\u1ef1c n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c \u0111\u00e3 h\u1ebft hi\u1ec7u l\u1ef1c",code:4001});await OTP.findOneAndUpdate({_id:$id$$},{verified:!0});let $user$$=await User.findOne({email:$otp$$.phone});if(!$user$$)return $res$$.status(400).send({error:"T\u00e0i kho\u1ea3n kh\u00f4ng t\u1ed3n t\u1ea1i",
20
+ code:4001});if(!$user$$.local||!$user$$.local.active){$user$$.local=$user$$.local||{};$user$$.local.active=!0;try{await $user$$.save(),redisCache.set("user",$user$$.toObject(),function($e$$){$e$$?console.error($e$$):console.log("cache user infomation to redis")})}catch($e$$){return console.log("error verify otp, create user",$e$$),$res$$.status(500).send($e$$)}}const $accessToken$$=generateToken($user$$);(new Token({email:$user$$.email,session_created:($req$$.cookies||{}).uid,token:$accessToken$$,
21
+ agent:$req$$.headers["user-agent"],ip:"",once:1==$req$$.query.once||"true"==$req$$.query.once||"1"===$req$$.query.once?!0:!1})).save(function($e$$,$rs$$){return $e$$?$res$$.status(500).send($e$$):$res$$.send({token:$accessToken$$,once:$rs$$.once})})}catch($e$$){console.error("error verify otp",$e$$),$res$$.status(400).send($e$$.message)}});$app$jscomp$0$$.post("/auth/sign",$rateLimiter$$,($req$$,$res$$,$next$$)=>{$passport$$.authenticate("basic",{session:!1},function($err$$,$user$$){if($err$$||!$user$$)return $res$$.status(401).send({message:$err$$||
22
22
  "Unauthorized"});$req$$.user=$user$$;$next$$()})($req$$,$res$$,$next$$)},async($req$jscomp$3_user$$,$res$$)=>{let $data$$=$req$jscomp$3_user$$.body;$req$jscomp$3_user$$=$req$jscomp$3_user$$.user;if(!$data$$)return $res$$.status(400).send("Not have data to sign");if(!$data$$.id_app)return $res$$.status(400).send("Data miss id_app property");try{let $signature$$=await Wallet.sign($data$$.id_app,$req$jscomp$3_user$$.email,$data$$);$res$$.send($signature$$)}catch($e$$){return $res$$.status(400).send($e$$.message||
23
23
  $e$$)}});$app$jscomp$0$$.get("/auth/local",$rateLimiter$$,function($req$$,$res$$,$next$$){let $ip$$=($req$$.ip||$req$$.headers["x-forwarded-for"]||$req$$.connection.remoteAddress).split(".").join("").split(":").join(""),$authorization$$=$req$$.headers.authorization;if(!$authorization$$)return $res$$.status(400).send({message:"Authorization is required"});$authorization$$=Buffer.from($authorization$$.replace("Basic ",""),"base64").toString("utf-8");$authorization$$=$authorization$$.split(":");if(1<
24
24
  $authorization$$.length){let $t_session$$="times_login_"+$ip$$+"_"+$authorization$$[0].trim().toLowerCase(),$d_session$$="datetime_login_"+$ip$$+"_"+$authorization$$[0].trim().toLowerCase();$req$$.t_session=$t_session$$;$req$$.d_session=$d_session$$;let $now$$=new Date,$d$$=$now$$,$times_try$$=1;if($req$$.headers.cookie&&$req$$.session){$req$$=$req$$.session;$req$$[$t_session$$]?($times_try$$=$req$$[$t_session$$]+1,$req$$[$t_session$$]=$times_try$$):($req$$[$t_session$$]=$times_try$$,$req$$[$d_session$$]=
@@ -121,17 +121,24 @@ exports.onepay_configs= {
121
121
  domestic: true//thanh trong nuoc hay ngoai nuoc
122
122
  }
123
123
  //sms configs
124
- exports.sms = {
125
- genUrlSendOTP:(Phone,otp_code)=>{
124
+ /*exports.sms = {
125
+ send: async (Phone,otp_code,id_app)=>{
126
126
  let Brandname="";
127
127
  let Content =`Xin vui long gui Quy Khach ma xac thuc: ${otp_code}`;
128
128
  let ApiKey = "";
129
129
  let SecretKey = "";
130
130
  let SmsType ="2";
131
131
  let url = ``
132
- return url;
132
+ const axios = require('axios');
133
+ try{
134
+ let rs = await axios.get(url)
135
+ return rs.data;
136
+ }catch(e){
137
+ console.error(e);
138
+ throw e.message;
139
+ }
133
140
  }
134
- }
141
+ }*/
135
142
  //oauth2.0
136
143
  exports.google = {
137
144
  clientID: '',
package/server/global.js CHANGED
@@ -2,8 +2,8 @@
2
2
  global.socketContainer={loadConnectionId:async()=>new Promise($res$$=>{global.clientRedis.get("client-io",function($err$$,$reply$$){if($err$$)return console.error($err$$),$res$$({});if($reply$$)try{let $ios$$=JSON.parse($reply$$);return $res$$($ios$$||{})}catch($e$$){return console.error($e$$),$res$$({})}else return $res$$({})})}),saveConnectionId:async($clientIO$$={})=>new Promise(($res$$,$rej$$)=>{global.clientRedis.set("client-io",JSON.stringify($clientIO$$),$e$$=>{if($e$$)return console.error($e$$),
3
3
  $rej$$($e$$);$res$$($clientIO$$)})})};global.clientIO={};global.model_books="socai sokho sokhott sokhokhongton sosanxuat vatvao vatra vsocai socaitmp".split(" ");global.webPush=require("web-push");global.mongoose=require("mongoose");global.mongoose.plugin(leanID);global.mongoose.plugin(deletePost);global.Schema=global.mongoose.Schema;global.mongoose.set("useFindAndModify",!1);global.mongoose.set("useCreateIndex",!0);
4
4
  global.getModel=$model_name$$=>{$model_name$$=$model_name$$.split(".js")[0];"kbmpttct"===$model_name$$&&($model_name$$="kbmPttct");"kbmtkgtgt"===$model_name$$&&($model_name$$="kbmTkgtgt");"token"===$model_name$$&&($model_name$$="tokens");"bn1"===$model_name$$&&($model_name$$="pc1");"bc1"===$model_name$$&&($model_name$$="pt1");var $_requireFields_model_model_path_mySchema$$=mongoose.models[$model_name$$];if($_requireFields_model_model_path_mySchema$$)return $_requireFields_model_model_path_mySchema$$;
5
- $_requireFields_model_model_path_mySchema$$=(((global.configs||{}).paths||{}).models||"./models")+"/"+$model_name$$+".js";if(fs.existsSync($_requireFields_model_model_path_mySchema$$))return require($_requireFields_model_model_path_mySchema$$);$_requireFields_model_model_path_mySchema$$=__dirname+"/models/"+$model_name$$+".js";if(fs.existsSync($_requireFields_model_model_path_mySchema$$))return require($_requireFields_model_model_path_mySchema$$);console.error("model",$model_name$$,"is not exists. create new model");
6
- $_requireFields_model_model_path_mySchema$$={...require("./models/listinfo").requireFields};$_requireFields_model_model_path_mySchema$$=new global.Schema($_requireFields_model_model_path_mySchema$$,{strict:!1});return global.mongoose.model($model_name$$,$_requireFields_model_model_path_mySchema$$)};global.getLib=$lib_name$$=>require("./libs/"+$lib_name$$);
5
+ if(((global.configs||{}).paths||{}).models&&($_requireFields_model_model_path_mySchema$$=((global.configs||{}).paths||{}).models+"/"+$model_name$$+".js",fs.existsSync($_requireFields_model_model_path_mySchema$$)))return require($_requireFields_model_model_path_mySchema$$);$_requireFields_model_model_path_mySchema$$=__dirname+"/models/"+$model_name$$+".js";if(fs.existsSync($_requireFields_model_model_path_mySchema$$))return require($_requireFields_model_model_path_mySchema$$);console.error("model",
6
+ $model_name$$,"is not exists. create new model");$_requireFields_model_model_path_mySchema$$={...require("./models/listinfo").requireFields};$_requireFields_model_model_path_mySchema$$=new global.Schema($_requireFields_model_model_path_mySchema$$,{strict:!1});return global.mongoose.model($model_name$$,$_requireFields_model_model_path_mySchema$$)};global.getLib=$lib_name$$=>require("./libs/"+$lib_name$$);
7
7
  const pointSchema=new global.mongoose.Schema({type:{type:String,enum:["Point"],required:!0,default:"Point"},coordinates:{type:[Number],required:!0}}),polygonSchema=new global.mongoose.Schema({type:{type:String,enum:["Polygon"],required:!0,default:"Polygon"},coordinates:{type:[[[Number]]],required:!0}});global.customTypes={Point:pointSchema,Polygon:polygonSchema};const EventEmitter=require("events");class GlobalEmitter extends EventEmitter{}global.globalEvents=new GlobalEmitter;
8
8
  const Message=global.getModel("message"),Notification=global.getModel("notification"),User=global.getModel("user"),Sysconfig=global.getModel("sysconfig");global.getSysConfig=async $cf_code$$=>{if($cf_code$$=await Sysconfig.findOne({code:$cf_code$$}))return $cf_code$$.value};global.asyncCountUnRead=async $email$$=>new Promise($resolve$$=>{setImmediate(()=>{Message.countDocuments({email:$email$$,read:!1},($e$$,$rs$$)=>{$resolve$$($rs$$||0)})})});
9
9
  global.alertMessage=function($email$$){setImmediate(()=>{Message.countDocuments({email_owner:$email$$,email_receiver:$email$$,read:!1},function($error$$,$count$$){$error$$?console.log($error$$):User.emitEvent($email$$,"message:count",$count$$,!1)})})};
@@ -12,7 +12,7 @@ await global.getModel("tdttno").findOne({id_ct:$detail$$.id_hd},{_id:1}).lean())
12
12
  $model_book$$.modelName.toLowerCase()&&(await $details$$.asyncJoinModel2($master$$.id_app,Dmvt,{where:"ma_vt",fields:"tg_tk"}),$details$$=$details$$.filter($d$$=>0==$d$$.tg_tk),await $details$$.asyncJoinModel2($master$$.id_app,global.getModel("dmqddvt"),{where:{ma_vt:"ma_vt",ma_dvt:"ma_dvt"},fields:["tu","mau",{he_so_qd:"ty_le_qd"}]}),$details$$.forEach($detail$$=>{$detail$$.he_so_qd=$detail$$.he_so_qd||1;$detail$$.mau&&$detail$$.tu?($detail$$.he_so_qd=$detail$$.tu/$detail$$.mau,$detail$$.sl_xuat_qd=
13
13
  utils.round(($detail$$.sl_xuat||0)*$detail$$.tu/$detail$$.mau,round),$detail$$.sl_nhap_qd=utils.round(($detail$$.sl_nhap||0)*$detail$$.tu/$detail$$.mau,round)):($detail$$.sl_xuat_qd=utils.round(($detail$$.sl_xuat||0)*$detail$$.he_so_qd,round),$detail$$.sl_nhap_qd=utils.round(($detail$$.sl_nhap||0)*$detail$$.he_so_qd,round))}));if("vatra"===$model_book$$.modelName.toLowerCase()||"vatvao"===$model_book$$.modelName.toLowerCase())if($rs$jscomp$2_tdtts_tdtts$$=await Promise.all($details$$.filter($r$$=>
14
14
  $r$$.so_hd&&$r$$.so_hd.toUpperCase()!==($master$$.ma_ct||"").toUpperCase()).map($detail$$=>(async()=>{let $v$$=await $model_book$$.findOne({id_app:$master$$.id_app,so_hd:$detail$$.so_hd,ma_kh:$detail$$.ma_kh||$master$$.ma_kh,so_seri:$detail$$.so_seri,ky_hieu_hoa_don:$detail$$.ky_hieu_hoa_don,id_ct:{$ne:$master$$._id.toString()}});return $v$$?$v$$.so_hd:""})())),$rs$jscomp$2_tdtts_tdtts$$=$rs$jscomp$2_tdtts_tdtts$$.filter($r$$=>$r$$),0<$rs$jscomp$2_tdtts_tdtts$$.length)return $callback$$(`S\u1ed1 ho\u00e1 \u0111\u01a1n ${$rs$jscomp$2_tdtts_tdtts$$.join(",")} \u0111\u00e3 t\u1ed3n t\u1ea1i`);
15
- $details$$=$details$$.map(($detail$$,$line$$)=>{$detail$$.id_ct=$master$$._id.toString();for(let $attr$$ in $model_book$$.schema.paths)if("id_ct"!=$attr$$&&"_id"!=$attr$$&&"__v"!=$attr$$){let $v$$=$detail$$[$attr$$];void 0!=$v$$&&null!=$v$$&&""!=$v$$||0==$v$$||void 0==$master$$[$attr$$]||($detail$$[$attr$$]=$master$$[$attr$$])}$detail$$.line=$line$$;delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});const $self$$=this;$self$$.remove($error$$=>{if($error$$)return console.error("error delete data post",
15
+ $details$$=$details$$.map(($detail$$,$line$$)=>{$detail$$.id_ct=$master$$._id.toString();for(let $attr$$ in $model_book$$.schema.paths)if("id_ct"!=$attr$$&&"_id"!=$attr$$&&"__v"!=$attr$$){let $v$$=$detail$$[$attr$$];void 0!==$v$$&&null!==$v$$&&""!==$v$$||0===$v$$||void 0===$master$$[$attr$$]||($detail$$[$attr$$]=$master$$[$attr$$])}$detail$$.line=$line$$;delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});const $self$$=this;$self$$.remove($error$$=>{if($error$$)return console.error("error delete data post",
16
16
  $error$$),$callback$$($error$$);if(0==$details$$.length)return $callback$$(null,[]);$model_book$$.create($details$$,async($e$jscomp$0$$,$rs$$)=>{if($e$jscomp$0$$){var $contr_msg_error$$=$e$jscomp$0$$.message||$e$jscomp$0$$.error||$e$jscomp$0$$.toString();0<=$contr_msg_error$$.indexOf("E11000 duplicate")&&0<=$contr_msg_error$$.indexOf("id_ct_1_line_1")?($rs$$=await $model_book$$.find({id_ct:$master$$._id.toString()}),0<$rs$$.length?$callback$$(null,$rs$$):(console.error("error save data post",$e$jscomp$0$$,
17
17
  $details$$),$self$$.remove(()=>{$callback$$($e$jscomp$0$$)}))):(console.error("error save data post",$e$jscomp$0$$,$details$$),$self$$.remove(()=>{$callback$$($e$jscomp$0$$)}))}else{if($master$$.ma_ct)if($contr_msg_error$$=global.controllers[$master$$.ma_ct.toUpperCase()]){if(!await $contr_msg_error$$.model.findById($master$$._id)){console.error("Ch\u1ee9ng t\u1eeb kh\u00f4ng t\u1ed3n t\u1ea1i. X\u00f3a s\u1ed5 s\u00e1ch",$master$$._id);$self$$.remove(()=>{$callback$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng t\u1ed3n t\u1ea1i")});
18
18
  return}}else console.log("not found controller",$master$$.ma_ct.toUpperCase());$callback$$(null,$rs$$);$rs$$&&"sokho"===$model_book$$.modelName.toLowerCase()&&setImmediate(()=>{tontucthoi.tinhTonTucThoi($rs$$,$e$$=>{$e$$&&console.error("L\u1ed7i t\u00ednh t\u1ed3n t\u1ee9c th\u1eddi v\u1eadt t\u01b0",$rs$$,$e$$)})})}})})};module.exports=post;
@@ -13,8 +13,8 @@ $detail$$)})})},($e$$,$details$$)=>{$resolve$$($details$$)}):$resolve$$($details
13
13
  post.prototype.run=async function($callback$jscomp$0$$=()=>{}){if(!this.details)return $callback$jscomp$0$$(null,null);const $Socai$$=this.model||SocaiModel;let $master$$=this.master,$details$jscomp$0$$=await this.runPrepare(this.prepare,this.details);$details$jscomp$0$$.forEach($d$$=>{$d$$.tk_no=$d$$.tk_no||$master$$.tk_no;$d$$.tk_co=$d$$.tk_co||$master$$.tk_co});$details$jscomp$0$$=$details$jscomp$0$$.filter($d$$=>$d$$.tk_no&&$d$$.tk_co);if(!$master$$.ngay_ct)return $callback$jscomp$0$$("ngay_ct is not null");
14
14
  let $check_hmcn$$=$details$jscomp$0$$.map($d$$=>[{tk:$d$$.tk_no,tien:$d$$.tien,ma_kh:$d$$.ma_kh_no||$d$$.ma_kh||$master$$.ma_kh},{tk:$d$$.tk_co,tien:0-$d$$.tien,ma_kh:$d$$.ma_kh_co||$d$$.ma_kh||$master$$.ma_kh}]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]).filter($a$$=>$a$$.ma_kh&&$a$$.tien);$check_hmcn$$=await $check_hmcn$$.asyncGroupBy(["tk","ma_kh"],["tien"]);if(0<$check_hmcn$$.length)try{await Promise.all($check_hmcn$$.map($d$$=>asyncCheckHMCN($master$$.id_app,$master$$,$d$$.tk,$d$$.ma_kh,$d$$.tien)))}catch($e$$){return $callback$jscomp$0$$($e$$.message||
15
15
  $e$$.error||$e$$)}async.mapSeries($details$jscomp$0$$,($detail$jscomp$0$$,$callback$$)=>{setImmediate(()=>{$detail$jscomp$0$$.ma_kh_no||($detail$jscomp$0$$.ma_kh_no=$detail$jscomp$0$$.ma_kh||$master$$.ma_kh);$detail$jscomp$0$$.ma_kh_co||($detail$jscomp$0$$.ma_kh_co=$detail$jscomp$0$$.ma_kh||$master$$.ma_kh);checkData($master$$.id_app,$master$$.ngay_ct,$detail$jscomp$0$$,($e$$,$detail$$)=>{$callback$$($e$$,$detail$$)})})},($but_toan_loi_e$$,$details$$)=>{if($but_toan_loi_e$$)return $callback$jscomp$0$$($but_toan_loi_e$$);
16
- $but_toan_loi_e$$=$details$$.filter($detail$$=>isNaN($detail$$.tien_nt)||isNaN($detail$$.tien));0<$but_toan_loi_e$$.length&&console.error("Cac but toan khong hop ly",$but_toan_loi_e$$,"cua chung tu",$master$$._id);let $dks$$=$details$$.filter($detail$$=>!(0===$detail$$.tien_nt&&0===$detail$$.tien)&&!isNaN($detail$$.tien_nt)&&!isNaN($detail$$.tien)).map(($detail$$,$nh_dk$$)=>{for(let $attr$$ in $Socai$$.schema.paths)"id_ct"!=$attr$$&&"_id"!=$attr$$&&"__v"!=$attr$$&&(void 0!=$detail$$[$attr$$]&&null!=
17
- $detail$$[$attr$$]&&""!=$detail$$[$attr$$]||0==$detail$$[$attr$$]||void 0==$master$$[$attr$$]||($detail$$[$attr$$]=$master$$[$attr$$]));$detail$$.nh_dk=$nh_dk$$;$detail$$.id_ct=$master$$._id.toString();delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});$Socai$$.deleteMany({id_ct:$master$$._id.toString()},$error$$=>{if($error$$)return $callback$jscomp$0$$("Don't remove socai \n"+$error$$);if(0==$dks$$.length)return $callback$jscomp$0$$(null,[]);$Socai$$.create($dks$$,
16
+ $but_toan_loi_e$$=$details$$.filter($detail$$=>isNaN($detail$$.tien_nt)||isNaN($detail$$.tien));0<$but_toan_loi_e$$.length&&console.error("Cac but toan khong hop ly",$but_toan_loi_e$$,"cua chung tu",$master$$._id);let $dks$$=$details$$.filter($detail$$=>!(0===$detail$$.tien_nt&&0===$detail$$.tien)&&!isNaN($detail$$.tien_nt)&&!isNaN($detail$$.tien)).map(($detail$$,$nh_dk$$)=>{for(let $attr$$ in $Socai$$.schema.paths)"id_ct"!=$attr$$&&"_id"!=$attr$$&&"__v"!=$attr$$&&(void 0!==$detail$$[$attr$$]&&null!==
17
+ $detail$$[$attr$$]&&""!==$detail$$[$attr$$]||0===$detail$$[$attr$$]||void 0===$master$$[$attr$$]||($detail$$[$attr$$]=$master$$[$attr$$]));$detail$$.nh_dk=$nh_dk$$;$detail$$.id_ct=$master$$._id.toString();delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});$Socai$$.deleteMany({id_ct:$master$$._id.toString()},$error$$=>{if($error$$)return $callback$jscomp$0$$("Don't remove socai \n"+$error$$);if(0==$dks$$.length)return $callback$jscomp$0$$(null,[]);$Socai$$.create($dks$$,
18
18
  async($e$$,$msg_error_rs$$)=>{if($e$$)if($msg_error_rs$$=$e$$.message||$e$$.error||$e$$.toString(),0<=$msg_error_rs$$.indexOf("E11000 duplicate")&&0<=$msg_error_rs$$.indexOf("id_ct_1_nh_dk_1"))if($msg_error_rs$$=await $Socai$$.find({id_ct:$master$$._id.toString()}),0<$msg_error_rs$$.length)$callback$jscomp$0$$(null,$msg_error_rs$$);else{console.error("Error save socai",$e$$,$master$$);let $q_remove$$={id_app:$master$$.id_app,id_ct:$master$$._id.toString()};$Socai$$.deleteMany($q_remove$$,($_e$$,$rs$$)=>
19
19
  {console.error("delete socai because error when posting",$master$$._id.toString(),JSON.stringify($rs$$),$q_remove$$);$callback$jscomp$0$$($e$$)})}else{console.error("Error save socai",$e$$,$master$$);let $q_remove$$={id_app:$master$$.id_app,id_ct:$master$$._id.toString()};$Socai$$.deleteMany($q_remove$$,($_e$$,$rs$$)=>{console.error("delete socai because error when posting",$master$$._id.toString(),JSON.stringify($rs$$),$q_remove$$);$callback$jscomp$0$$($e$$)})}else if($master$$.ma_ct){let $contr$$=
20
20
  global.controllers[$master$$.ma_ct.toUpperCase()];$contr$$?await $contr$$.model.findById($master$$._id)?$callback$jscomp$0$$(null,$msg_error_rs$$):$Socai$$.deleteMany({id_ct:$master$$._id.toString()},($_e$$,$rs$$)=>{console.error("Ch\u1ee9ng t\u1eeb kh\u00f4ng t\u1ed3n t\u1ea1i. X\u00f3a socai",$master$$._id,$rs$$);$callback$jscomp$0$$($e$$)}):(console.log("not found controller",$master$$.ma_ct.toUpperCase()),$callback$jscomp$0$$(null,$msg_error_rs$$))}else $callback$jscomp$0$$(null,$msg_error_rs$$)})})})};
@@ -1 +1 @@
1
- 'use strict';const Account=global.getModel("account");exports.checkAccAndCust=function($id_app$$,$tk$$,$ma_kh$$,$fn$$){$ma_kh$$||($ma_kh$$="");if(""!==$ma_kh$$.trim())return $fn$$();Account.findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0},function($error$$,$acc$$){return $error$$?$fn$$($error$$):$acc$$?!0===$acc$$.tk_cn?$fn$$(Error("T\u00e0i kho\u1ea3n "+$tk$$+" y\u00eau c\u1ea7u m\u1ed9t m\u00e3 kh\u00e1ch")):$fn$$():$fn$$(Error("T\u00e0i kho\u1ea3n "+$tk$$+" kh\u00f4ng t\u1ed3n t\u1ea1i"))})};
1
+ 'use strict';exports.checkAccAndCust=function($id_app$$,$tk$$,$ma_kh$$,$fn$$){$ma_kh$$||($ma_kh$$="");if(""!==$ma_kh$$.trim())return $fn$$();global.getModel("account").findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0},function($error$$,$acc$$){return $error$$?$fn$$($error$$):$acc$$?!0===$acc$$.tk_cn?$fn$$(Error("T\u00e0i kho\u1ea3n "+$tk$$+" y\u00eau c\u1ea7u m\u1ed9t m\u00e3 kh\u00e1ch")):$fn$$():$fn$$(Error("T\u00e0i kho\u1ea3n "+$tk$$+" kh\u00f4ng t\u1ed3n t\u1ea1i"))})};
@@ -1,4 +1,4 @@
1
- 'use strict';const Account=global.getModel("account");exports.isTkcn=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),Account.findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0,loai_tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$($acc$$.tk_cn)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng ph\u1ea3i l\u00e0 t\u00e0i kho\u1ea3n c\u00f4ng n\u1ee3"];
2
- exports.isNotTkcn=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),Account.findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0,loai_tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!$acc$$.tk_cn)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng ph\u1ea3i l\u00e0 t\u00e0i kho\u1ea3n c\u00f4ng n\u1ee3"];
3
- exports.existsTk=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),Account.findOne({id_app:$id_app$$,tk:$tk$$},{tk:1,loai_tk:1},function($error$$,$acc$$){$error$$&&console.log($error$$);$acc$$||console.log("not found "+$tk$$+" of app "+$id_app$$);$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!0)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
4
- exports.existsAnyTk=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),Account.findOne({id_app:$id_app$$,tk:$tk$$},{tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!0)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
1
+ 'use strict';exports.isTkcn=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),global.getModel("account").findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0,loai_tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$($acc$$.tk_cn)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng ph\u1ea3i l\u00e0 t\u00e0i kho\u1ea3n c\u00f4ng n\u1ee3"];
2
+ exports.isNotTkcn=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),global.getModel("account").findOne({id_app:$id_app$$,tk:$tk$$},{tk_cn:1,_id:0,loai_tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!$acc$$.tk_cn)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng ph\u1ea3i l\u00e0 t\u00e0i kho\u1ea3n c\u00f4ng n\u1ee3"];
3
+ exports.existsTk=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),global.getModel("account").findOne({id_app:$id_app$$,tk:$tk$$},{tk:1,loai_tk:1},function($error$$,$acc$$){$error$$&&console.log($error$$);$acc$$||console.log("not found "+$tk$$+" of app "+$id_app$$);$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!0)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
4
+ exports.existsAnyTk=[function($id_app$$,$tk$$,$callback$$){$tk$$?($tk$$=$tk$$.trim(),global.getModel("account").findOne({id_app:$id_app$$,tk:$tk$$},{tk:1},function($error$$,$acc$$){$error$$||!$acc$$||0===$acc$$.loai_tk?$callback$$(!1):$callback$$(!0)})):$callback$$(!0)},"T\u00e0i kho\u1ea3n {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
@@ -1,2 +1,2 @@
1
- 'use strict';const Dmvt=global.getModel("dmvt"),Dmkho=global.getModel("dmkho");exports.existsVt=[function($id_app$$,$ma_vt$$,$callback$$){$ma_vt$$?Dmvt.findOne({id_app:$id_app$$,ma_vt:$ma_vt$$},{ma_vt:1},function($error$$,$vt$$){$error$$||!$vt$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 v\u1eadt t\u01b0 {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
2
- exports.existsKho=[function($id_app$$,$ma_kho$$,$callback$$){$ma_kho$$?Dmkho.findOne({id_app:$id_app$$,ma_kho:$ma_kho$$},{ma_kho:1},function($error$$,$kho$$){$error$$||!$kho$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 kho {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
1
+ 'use strict';exports.existsVt=[function($id_app$$,$ma_vt$$,$callback$$){$ma_vt$$?global.getModel("dmvt").findOne({id_app:$id_app$$,ma_vt:$ma_vt$$},{ma_vt:1},function($error$$,$vt$$){$error$$||!$vt$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 v\u1eadt t\u01b0 {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
2
+ exports.existsKho=[function($id_app$$,$ma_kho$$,$callback$$){$ma_kho$$?global.getModel("dmkho").findOne({id_app:$id_app$$,ma_kho:$ma_kho$$},{ma_kho:1},function($error$$,$kho$$){$error$$||!$kho$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 kho {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
@@ -1,11 +1,10 @@
1
- 'use strict';const Customer=global.getModel("customer"),Dvcs=global.getModel("dvcs"),Dmdvt=global.getModel("dmdvt"),Vat=global.getModel("vat"),Currency=global.getModel("currency"),Dmbp=global.getModel("dmbp"),Dmloaits=global.getModel("dmloaits"),Dmnguonvon=global.getModel("dmnguonvon"),Dmtanggiamts=global.getModel("dmtanggiamts"),app=global.getModel("app");
2
- exports.unlockBook=[async function($id_app$$,$ngay_ct$$,$callback$$,$options$$={}){if(!$ngay_ct$$)return $callback$$(!0);app.findOne({_id:$id_app$$},{ngay_ks:1,_id:0},function($error$$,$r$$){if($error$$||!$r$$||$r$$.ngay_ks.getTime()>=$ngay_ct$$.getTime()||$options$$.ngay_ks&&(new Date($options$$.ngay_ks)).getTime()>=$ngay_ct$$.getTime())return $callback$$(!1);$callback$$(!0)})},"\u0110\u00e3 kh\u00f3a s\u1ed5"];
3
- exports.existsKh=[function($id_app$$,$kh$$,$callback$$){if(!$kh$$)return $callback$$(!0);Customer.findOne({id_app:$id_app$$,ma_kh:$kh$$},{ma_kh:1},function($error$$,$cust$$){return $error$$||!$cust$$?$callback$$(!1):$callback$$(!0)})},"M\u00e3 kh\u00e1ch ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
4
- exports.existsDvcs=[function($id_app$$,$ma_dvcs$$,$callback$$){if(!$ma_dvcs$$)return $callback$$(!0);Dvcs.findOne({id_app:$id_app$$,_id:$ma_dvcs$$},function($error$$,$dvcs$$){return $error$$||!$dvcs$$?$callback$$(!1):$callback$$(!0)})},"M\u00e3 \u0111\u01a1n v\u1ecb c\u01a1 s\u1edf ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
5
- exports.existsNt=[function($id_app$$,$ma_nt$$,$callback$$){$ma_nt$$?Currency.findOne({id_app:$id_app$$,ma_nt:$ma_nt$$},function($error$$,$nt$$){return $error$$||!$nt$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 ngo\u1ea1i t\u1ec7 ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
6
- exports.existsDvt=[function($id_app$$,$ma_dvt$$,$callback$$){$ma_dvt$$?Dmdvt.findOne({id_app:$id_app$$,ma_dvt:$ma_dvt$$},function($error$$,$dvt$$){return $error$$||!$dvt$$?(console.log("check dvt",$error$$,$dvt$$,$id_app$$,$ma_dvt$$),$callback$$(!1)):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 \u0111\u01a1n v\u1ecb t\u00ednh ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
7
- exports.existsVat=[function($id_app$$,$ma_thue$$,$callback$$){$ma_thue$$?Vat.findOne({id_app:$id_app$$,ma_thue:$ma_thue$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 thu\u1ebf ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
8
- exports.existsBp=[function($id_app$$,$ma_bp$$,$callback$$){$ma_bp$$?Dmbp.findOne({id_app:$id_app$$,ma_bp:$ma_bp$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 b\u1ed9 ph\u1eadn ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
9
- exports.existsLts=[function($id_app$$,$ma_loai_ts$$,$callback$$){$ma_loai_ts$$?Dmloaits.findOne({id_app:$id_app$$,ma_loai_ts:$ma_loai_ts$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 lo\u1ea1i t\u00e0i s\u1ea3n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
10
- exports.existsNguonvon=[function($id_app$$,$ma_nguon_von$$,$callback$$){$ma_nguon_von$$?Dmnguonvon.findOne({id_app:$id_app$$,ma_nguon_von:$ma_nguon_von$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 ngu\u1ed3n v\u1ed1n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
11
- exports.existsTgts=[function($id_app$$,$ma_tang_giam_ts$$,$callback$$){$ma_tang_giam_ts$$?Dmtanggiamts.findOne({id_app:$id_app$$,ma_tang_giam_ts:$ma_tang_giam_ts$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 t\u0103ng gi\u1ea3m t\u00e0i s\u1ea3n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
1
+ 'use strict';exports.unlockBook=[async function($id_app$$,$ngay_ct$$,$callback$$,$options$$={}){if(!$ngay_ct$$)return $callback$$(!0);global.getModel("app").findOne({_id:$id_app$$},{ngay_ks:1,_id:0},function($error$$,$r$$){if($error$$||!$r$$||$r$$.ngay_ks.getTime()>=$ngay_ct$$.getTime()||$options$$.ngay_ks&&(new Date($options$$.ngay_ks)).getTime()>=$ngay_ct$$.getTime())return $callback$$(!1);$callback$$(!0)})},"\u0110\u00e3 kh\u00f3a s\u1ed5"];
2
+ exports.existsKh=[function($id_app$$,$kh$$,$callback$$){if(!$kh$$)return $callback$$(!0);global.getModel("customer").findOne({id_app:$id_app$$,ma_kh:$kh$$},{ma_kh:1},function($error$$,$cust$$){return $error$$||!$cust$$?$callback$$(!1):$callback$$(!0)})},"M\u00e3 kh\u00e1ch ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
3
+ exports.existsDvcs=[function($id_app$$,$ma_dvcs$$,$callback$$){if(!$ma_dvcs$$)return $callback$$(!0);global.getModel("dvcs").findOne({id_app:$id_app$$,_id:$ma_dvcs$$},function($error$$,$dvcs$$){return $error$$||!$dvcs$$?$callback$$(!1):$callback$$(!0)})},"M\u00e3 \u0111\u01a1n v\u1ecb c\u01a1 s\u1edf ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
4
+ exports.existsNt=[function($id_app$$,$ma_nt$$,$callback$$){$ma_nt$$?global.getModel("currency").findOne({id_app:$id_app$$,ma_nt:$ma_nt$$},function($error$$,$nt$$){return $error$$||!$nt$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 ngo\u1ea1i t\u1ec7 ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
5
+ exports.existsDvt=[function($id_app$$,$ma_dvt$$,$callback$$){$ma_dvt$$?global.getModel("dmdvt").findOne({id_app:$id_app$$,ma_dvt:$ma_dvt$$},function($error$$,$dvt$$){return $error$$||!$dvt$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 \u0111\u01a1n v\u1ecb t\u00ednh ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
6
+ exports.existsVat=[function($id_app$$,$ma_thue$$,$callback$$){$ma_thue$$?global.getModel("vat").findOne({id_app:$id_app$$,ma_thue:$ma_thue$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 thu\u1ebf ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
7
+ exports.existsBp=[function($id_app$$,$ma_bp$$,$callback$$){$ma_bp$$?global.getModel("dmbp").findOne({id_app:$id_app$$,ma_bp:$ma_bp$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 b\u1ed9 ph\u1eadn ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
8
+ exports.existsLts=[function($id_app$$,$ma_loai_ts$$,$callback$$){$ma_loai_ts$$?global.getModel("dmloaits").findOne({id_app:$id_app$$,ma_loai_ts:$ma_loai_ts$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 lo\u1ea1i t\u00e0i s\u1ea3n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
9
+ exports.existsNguonvon=[function($id_app$$,$ma_nguon_von$$,$callback$$){$ma_nguon_von$$?global.getModel("dmnguonvon").findOne({id_app:$id_app$$,ma_nguon_von:$ma_nguon_von$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 ngu\u1ed3n v\u1ed1n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
10
+ exports.existsTgts=[function($id_app$$,$ma_tang_giam_ts$$,$callback$$){$ma_tang_giam_ts$$?global.getModel("dmtanggiamts").findOne({id_app:$id_app$$,ma_tang_giam_ts:$ma_tang_giam_ts$$},function($error$$,$v$$){return $error$$||!$v$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 t\u0103ng gi\u1ea3m t\u00e0i s\u1ea3n ({PATH}) {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
@@ -1,7 +1,7 @@
1
- 'use strict';const socai=global.getModel("socai"),async=require("async"),underscore=require("underscore"),moment=require("moment");
2
- exports.find=function($query$$,$fn$$,$options$$){async.series({ps_no:function($callback$$){setImmediate(()=>{let $query_no$$={};underscore.extend($query_no$$,$query$$);$query_no$$.tk&&($query_no$$.tk_no=$query_no$$.tk,delete $query_no$$.tk);$query_no$$.ma_kh&&($query_no$$.ma_kh_no=$query_no$$.ma_kh,delete $query_no$$.ma_kh);socai.find($query_no$$).lean().exec(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);async.mapSeries($rs$$,($r$$,$cb$$)=>{setImmediate(()=>{$r$$.tk=$r$$.tk_no;$r$$.tk_du=
3
- $r$$.tk_co;$r$$.ma_kh=$r$$.ma_kh_no;!$r$$.ma_kh&&$r$$.ma_kh_co&&($r$$.ma_kh=$r$$.ma_kh_co);$r$$.ps_no_nt=$r$$.tien_nt;$r$$.ps_no=Math.roundBy($r$$.tien,0);$r$$.ps_co_nt=0;$r$$.ps_co=0;$cb$$()})},()=>{$callback$$(null,$rs$$)})})})},ps_co:function($callback$$){setImmediate(()=>{let $query_co$$={};underscore.extend($query_co$$,$query$$);$query_co$$.tk&&($query_co$$.tk_co=$query_co$$.tk,delete $query_co$$.tk);$query_co$$.ma_kh&&($query_co$$.ma_kh_co=$query_co$$.ma_kh,delete $query_co$$.ma_kh);socai.find($query_co$$).lean().exec(function($e$$,
4
- $rs$$){if($e$$)return $callback$$($e$$);async.mapSeries($rs$$,($r$$,$cb$$)=>{setImmediate(()=>{$r$$.tk=$r$$.tk_co;$r$$.tk_du=$r$$.tk_no;$r$$.ma_kh=$r$$.ma_kh_co;!$r$$.ma_kh&&$r$$.ma_kh_no&&($r$$.ma_kh=$r$$.ma_kh_no);$r$$.ps_co_nt=$r$$.tien_nt;$r$$.ps_co=Math.roundBy($r$$.tien,0);$r$$.ps_no_nt=0;$r$$.ps_no=0;$cb$$()})},()=>{$callback$$(null,$rs$$)})})})}},function($e$jscomp$0$$,$rs$jscomp$0$$){if($e$jscomp$0$$)return $fn$$($e$jscomp$0$$);$e$jscomp$0$$=[...$rs$jscomp$0$$.ps_no,...$rs$jscomp$0$$.ps_co];
5
- $options$$&&$options$$.sortData&&($e$jscomp$0$$=$e$jscomp$0$$.sort(($a$$,$b$$)=>{let $a_ngay_ct$$=moment($a$$.ngay_ct).endOf("date").toDate().getTime(),$b_ngay_ct$$=moment($b$$.ngay_ct).endOf("date").toDate().getTime();return $a_ngay_ct$$<$b_ngay_ct$$?-1:$a_ngay_ct$$>$b_ngay_ct$$?1:$a$$.so_ct<$b$$.so_ct?-1:$a$$.so_ct>$b$$.so_ct?1:$a$$.id_ct<$b$$.id_ct?-1:$a$$.id_ct>$b$$.id_ct?1:$a$$.nh_dk<$b$$.nh_dk?-1:$a$$.nh_dk>$b$$.nh_dk||$a$$.ps_no<$b$$.ps_no?1:$a$$.ps_no>$b$$.ps_no||$a$$.ps_co<$b$$.ps_co?-1:
6
- $a$$.ps_co>$b$$.ps_co?1:0}));if($options$$&&$options$$.groupBy){let $groupBy$$;$options$$.groupBy&&(underscore.isArray($options$$.groupBy)&&0<$options$$.groupBy.length&&($groupBy$$=$options$$.groupBy),$groupBy$$=$groupBy$$||"id_app ma_dvcs id_ct ma_ct ma_gd ngay_ct so_ct ngay_hd so_hd tk tk_du ma_kh ong_ba ma_nt ty_gia dien_giai ma_bp id_lenhsx ma_phi ma_hd ma_dt ma_nv ma_sp ma_cp ma_kho ma_vt ma_kenh ma_td1 ma_td2 ma_td3 ma_td4 ma_td5 ma_td6 ma_td7 ma_td8 ma_td9 gio ngay thang quy nam".split(" "));
1
+ 'use strict';const async=require("async"),underscore=require("underscore"),moment=require("moment");
2
+ exports.find=function($query$$,$fn$$,$options$$){const $socai$$=global.getModel("socai");async.series({ps_no:function($callback$$){setImmediate(()=>{let $query_no$$={};underscore.extend($query_no$$,$query$$);$query_no$$.tk&&($query_no$$.tk_no=$query_no$$.tk,delete $query_no$$.tk);$query_no$$.ma_kh&&($query_no$$.ma_kh_no=$query_no$$.ma_kh,delete $query_no$$.ma_kh);$socai$$.find($query_no$$).lean().exec(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);async.mapSeries($rs$$,($r$$,$cb$$)=>{setImmediate(()=>
3
+ {$r$$.tk=$r$$.tk_no;$r$$.tk_du=$r$$.tk_co;$r$$.ma_kh=$r$$.ma_kh_no;!$r$$.ma_kh&&$r$$.ma_kh_co&&($r$$.ma_kh=$r$$.ma_kh_co);$r$$.ps_no_nt=$r$$.tien_nt;$r$$.ps_no=Math.roundBy($r$$.tien,0);$r$$.ps_co_nt=0;$r$$.ps_co=0;$cb$$()})},()=>{$callback$$(null,$rs$$)})})})},ps_co:function($callback$$){setImmediate(()=>{let $query_co$$={};underscore.extend($query_co$$,$query$$);$query_co$$.tk&&($query_co$$.tk_co=$query_co$$.tk,delete $query_co$$.tk);$query_co$$.ma_kh&&($query_co$$.ma_kh_co=$query_co$$.ma_kh,delete $query_co$$.ma_kh);
4
+ $socai$$.find($query_co$$).lean().exec(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);async.mapSeries($rs$$,($r$$,$cb$$)=>{setImmediate(()=>{$r$$.tk=$r$$.tk_co;$r$$.tk_du=$r$$.tk_no;$r$$.ma_kh=$r$$.ma_kh_co;!$r$$.ma_kh&&$r$$.ma_kh_no&&($r$$.ma_kh=$r$$.ma_kh_no);$r$$.ps_co_nt=$r$$.tien_nt;$r$$.ps_co=Math.roundBy($r$$.tien,0);$r$$.ps_no_nt=0;$r$$.ps_no=0;$cb$$()})},()=>{$callback$$(null,$rs$$)})})})}},function($e$jscomp$0$$,$rs$jscomp$0$$){if($e$jscomp$0$$)return $fn$$($e$jscomp$0$$);$e$jscomp$0$$=
5
+ [...$rs$jscomp$0$$.ps_no,...$rs$jscomp$0$$.ps_co];$options$$&&$options$$.sortData&&($e$jscomp$0$$=$e$jscomp$0$$.sort(($a$$,$b$$)=>{let $a_ngay_ct$$=moment($a$$.ngay_ct).endOf("date").toDate().getTime(),$b_ngay_ct$$=moment($b$$.ngay_ct).endOf("date").toDate().getTime();return $a_ngay_ct$$<$b_ngay_ct$$?-1:$a_ngay_ct$$>$b_ngay_ct$$?1:$a$$.so_ct<$b$$.so_ct?-1:$a$$.so_ct>$b$$.so_ct?1:$a$$.id_ct<$b$$.id_ct?-1:$a$$.id_ct>$b$$.id_ct?1:$a$$.nh_dk<$b$$.nh_dk?-1:$a$$.nh_dk>$b$$.nh_dk||$a$$.ps_no<$b$$.ps_no?
6
+ 1:$a$$.ps_no>$b$$.ps_no||$a$$.ps_co<$b$$.ps_co?-1:$a$$.ps_co>$b$$.ps_co?1:0}));if($options$$&&$options$$.groupBy){let $groupBy$$;$options$$.groupBy&&(underscore.isArray($options$$.groupBy)&&0<$options$$.groupBy.length&&($groupBy$$=$options$$.groupBy),$groupBy$$=$groupBy$$||"id_app ma_dvcs id_ct ma_ct ma_gd ngay_ct so_ct ngay_hd so_hd tk tk_du ma_kh ong_ba ma_nt ty_gia dien_giai ma_bp id_lenhsx ma_phi ma_hd ma_dt ma_nv ma_sp ma_cp ma_kho ma_vt ma_kenh ma_td1 ma_td2 ma_td3 ma_td4 ma_td5 ma_td6 ma_td7 ma_td8 ma_td9 gio ngay thang quy nam".split(" "));
7
7
  $e$jscomp$0$$.groupBy($groupBy$$,["ps_no","ps_co","ps_no_nt","ps_co_nt"],($e$$,$rs$$)=>{if($e$$)return $fn$$($e$$);$fn$$(null,$rs$$)})}else $fn$$(null,$e$jscomp$0$$)})};
@@ -6,6 +6,6 @@ const dh2Schema=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_d
6
6
  ong_ba:{type:String,maxlength:1024},ma_kh:{type:String,uppercase:!0,required:!0,default:"",maxlength:32},ten_kh:String,ma_so_thue:{type:String,maxlength:1024},tk_no:{type:String,uppercase:!0,default:"",maxlength:32},ma_hoa_don:{type:String,default:"",uppercase:!0,trim:!0,maxlength:32},ky_hieu_hoa_don:{type:String,default:"",uppercase:!0,trim:!0,maxlength:32},so_hd:{type:String,uppercase:!0,maxlength:32},so_seri:{type:String,uppercase:!0,maxlength:32},ngay_hd:{type:Date,uppercase:!0},ma_thue:{type:String,
7
7
  uppercase:!0,maxlength:32},thue_suat:{type:Number,default:0},tk_thue_co:{type:String,uppercase:!0,maxlength:32},dia_chi:{type:String,default:"",maxlength:1024},ten_vt:{type:String,default:"",maxlength:1024},dien_giai_thue:{type:String,default:"",maxlength:1024},t_thue:{type:Number,default:0},t_thue_nt:{type:Number,default:0},han_tt:{type:Number,default:0},hinh_thuc_tt:{type:String,maxlength:1024},dien_giai:{type:String,default:"",maxlength:1024},exfields:Schema.Types.Mixed,trang_thai:{type:String,
8
8
  maxlength:32},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],details:{type:[detailSchema]},promotion:Schema.Types.Mixed,id_contract:{type:String,maxlength:1024},ma_kho:{type:String,uppercase:!0,maxlength:32},ma_kh_hoa_hong:{type:String,uppercase:!0,maxlength:32},ty_le_hoa_hong:Number,tien_hoa_hong:Number,
9
- tk_no_hoa_hong:String,tk_co_hoa_hong:String,ty_le_ck_hd:{type:Number,default:0},tien_ck_hd:{type:Number,default:0},result_export_einvoice:Schema.Types.Mixed,ma_bp:{type:String,uppercase:!0,maxlength:32},ma_nv:{type:String,uppercase:!0,maxlength:32},ma_phi:{type:String,uppercase:!0,maxlength:32},ma_hd:{type:String,uppercase:!0,maxlength:32},ma_dt:{type:String,uppercase:!0,maxlength:32},ma_lo:{type:String,uppercase:!0,maxlength:32}});
9
+ tk_no_hoa_hong:String,tk_co_hoa_hong:String,tu_tinh_hoa_hong:Boolean,ty_le_ck_hd:{type:Number,default:0},tien_ck_hd:{type:Number,default:0},result_export_einvoice:Schema.Types.Mixed,ma_bp:{type:String,uppercase:!0,maxlength:32},ma_nv:{type:String,uppercase:!0,maxlength:32},ma_phi:{type:String,uppercase:!0,maxlength:32},ma_hd:{type:String,uppercase:!0,maxlength:32},ma_dt:{type:String,uppercase:!0,maxlength:32},ma_lo:{type:String,uppercase:!0,maxlength:32}});
10
10
  dh2Schema.validate={ma_dvcs:validator.existsDvcs,ma_nt:validator.existsNt,ngay_ct:validator.unlockBook,ma_kh:validator.existsKh,tk_no:validAccount.existsTk,ma_thue:validator.existsVat,tk_thue_co:validAccount.existsTk};dh2Schema.index({id_app:1,ma_dvcs:1,so_ct:-1,ngay_ct:-1});dh2Schema.index({dien_giai:"text",ma_kh:"text",ten_kh:"text",so_ct:"text"},{name:"dh2_index_text"});dh2Schema.index({ma_ct:1});dh2Schema.index({ma_kh:1});dh2Schema.index({ma_kho:1});dh2Schema.index({id_contract:1});
11
11
  dh2Schema.index({user_created:1,date_created:-1});dh2Schema.index({date_updated:-1});dh2Schema.index({status:1});dh2Schema.index({user_created:1,visible_to:1,visible_to_users:1});dh2Schema.index({trang_thai:1});module.exports=mongoose.models.dh2||mongoose.model("dh2",dh2Schema);
@@ -0,0 +1,6 @@
1
+ 'use strict';const dmhoahonghdSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_hoahong:{type:String,uppercase:!0,required:!0,maxlength:32},ten_hoahong:{type:String,required:!0,maxlength:1024},mieu_ta:{type:String},chi_su_dung_cho_ct:{type:String,uppercase:!0},khong_su_dung_cho_ct:{type:String,uppercase:!0},ma_nv:{type:String,default:"",maxlength:32},ten_nv:String,ma_bp:{type:String,default:"",maxlength:1024},ten_bp:String,ma_kh:{type:String,default:"",maxlength:32},ten_kh:String,
2
+ nh_kh:{type:String,default:"",maxlength:1024},ten_nh_kh:String,ma_kho:{type:String,default:"",maxlength:32},ten_kho:String,gt_tu:{type:Number,default:0},gt_den:{type:Number,default:0},vts:[],sl_toi_thieu:{type:Number,default:0},tien_hh:{type:Number,default:0},ty_le_hh:{type:Number,default:0},so_tien_max:{type:Number,default:0},hieu_luc_tu:{type:Date,required:!0},hieu_luc_den:{type:Date,required:!0},ap_dung_lan_mua_thu:{type:Number},ap_dung_lan_mua_tu_thu:{type:Number},ap_dung_lan_mua_den_thu:{type:Number},
3
+ details_km:[],picture:{type:String},exfields:Schema.Types.Mixed,newsfeed:{type:Boolean,default:!0},online:{type:Boolean},offline:{type:Boolean},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},ma_kh_id:{type:Schema.Types.ObjectId,ref:"customer",localField:["ma_kh"],foreignField:["ma_kh"]},ma_kho_id:{type:Schema.Types.ObjectId,ref:"dmkho",localField:["ma_kho"],
4
+ foreignField:["ma_kho"]}});dmhoahonghdSchema.index({id_app:1,ma_hoahong:1,ma_kho:1,ma_kh:1,hieu_luc_tu:-1,hieu_luc_den:-1});dmhoahonghdSchema.index({ap_dung_lan_mua_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_tu_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_den_thu:1});dmhoahonghdSchema.index({gt_tu:1});dmhoahonghdSchema.index({gt_den:1});dmhoahonghdSchema.index({ten_kho:1});dmhoahonghdSchema.index({nh_kh:1});dmhoahonghdSchema.index({ten_nh_kh:1});dmhoahonghdSchema.index({ma_nv:1});dmhoahonghdSchema.index({ma_bp:1});
5
+ dmhoahonghdSchema.index({date_updated:-1});dmhoahonghdSchema.index({date_created:-1});dmhoahonghdSchema.index({user_created:1});dmhoahonghdSchema.index({online:1});dmhoahonghdSchema.index({offline:1});dmhoahonghdSchema.index({mieu_ta:"text",ma_hoahong:"text",ten_hoahong:"text",ma_kh:"text",ten_kh:"text",nh_kh:"text",ten_nh_kh:"text",ma_kho:"text",ten_kho:"text",ma_nv:"text",ten_nv:"text",ma_bp:"text",ten_bp:"text"},{name:"dmhoahonghd_index_text"});dmhoahonghdSchema.set("toObject",{virtuals:!0});
6
+ dmhoahonghdSchema.set("toJSON",{virtuals:!0});dmhoahonghdSchema.index({status:1});const model=mongoose.models.dmhoahonghd||mongoose.model("dmhoahonghd",dmhoahonghdSchema);module.exports=model;
@@ -1,12 +1,13 @@
1
1
  'use strict';const bpSchema=new Schema({ma_bp:{type:String,uppercase:!0,trim:!0,required:!0,maxlength:32},chuc_vu:{type:String,trim:!0,maxlength:1024},cong_viec:{type:String,trim:!0,maxlength:1024},phu_trach:{type:String,maxlength:1024},tu_ngay:{type:Date,default:Date.now},den_ngay:{type:Date},line:{type:Number,default:0}}),dmnvSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_nv:{type:String,required:!0,uppercase:!0,trim:!0,maxlength:32},ten_nv:{type:String,required:"Y\u00eau c\u1ea7u nh\u1eadp t\u00ean nh\u00e2n vi\u00ean",
2
- trim:!0,maxlength:1024},device_user_id:String,ma_so_thue:{type:String,maxlength:32},phu_trach:{type:String,maxlength:1024,trim:!0},ma_doi:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},ma_to:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},nh_nv:{type:String,trim:!0,maxlength:32},ma_nh_nv:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},nguoi_danh_gia:[{ma_doi_tuong_danh_gia:String,user:String,line:Number}],ma_bp:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},
3
- ten_bp:String,ma_kho:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},ten_kho:String,chuc_vu:{type:String,trim:!0,maxlength:1024},cong_viec:{type:String,trim:!0,maxlength:1024},cong_viec_chi_tiet:{type:String,trim:!0},trinh_do_hoc_van:String,trinh_do_chuyen_mon:String,bo_phan:[bpSchema],noi_sinh:{type:String,maxlength:1024},ngay_sinh:{type:Date},nguyen_quan:{type:String,maxlength:1024},ho_khau:{type:String,maxlength:1024},dia_chi:{type:String,maxlength:1024},dien_thoai:{type:String,maxlength:1024},
4
- fax:{type:String,maxlength:1024},email:{type:String,maxlength:1024},website:{type:String,maxlength:1024},dan_toc:{type:String,maxlength:1024},ton_giao:{type:String,maxlength:1024},cmnd:{type:String,maxlength:1024},ngay_cap:Date,noi_cap:{type:String,maxlength:1024},gioi_tinh:{type:String,maxlength:1024},tinh_trang_hon_nhan:{type:String,maxlength:1024},quoc_tich:{type:String,maxlength:1024},lam_viec:{type:Boolean,default:!0},cham_cong:{type:Boolean,default:!0},tinh_luong:{type:Boolean,default:!0},bhxh:{type:Boolean,
5
- default:!0},bhyt:{type:Boolean,default:!0},bhtn:{type:Boolean,default:!0},luong_co_ban:{type:Number,default:0},luong_bhxh:{type:Number,default:0},ngay_tinh_bhxh:Date,phu_cap:[],luong_thu_viec:{type:Number,default:0},thu_viec_tu_ngay:Date,thu_viec_den_ngay:Date,ngay_bat_dau_lam:Date,ngay_nghi_viec:Date,so_ngay_duoc_nghi_phep_nam:Number,ttncn_mst:String,ttncn_so_nguoi_phu_thuoc:Number,ttncn_muc_gt_phu_thuoc:Number,ttncn_so_thang_gt_ban_than:Number,ttncn_muc_gt_ban_than:Number,so_tk_ngan_hang:String,
6
- ten_chu_tk_ngan_hang:String,phat_hanh_boi_ngan_hang:String,user:{type:String,lowercase:!0,maxlength:1024,set:function($user$$){this._previous_user=this.user;return $user$$}},group_user:String,default_password:{type:String,maxlength:1024},ghi_chu:{type:String,trim:!0,maxlength:1024},picture:String,exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String},user_updated:{type:String},visible_to:{type:Number,
7
- default:0},visible_to_users:[String]},{toJSON:{virtuals:!0}});dmnvSchema.index({ma_nv:"text",ten_nv:"text",ma_bp:"text",ten_bp:"text",chuc_vu:"text"},{name:"dmnv_index_text"});dmnvSchema.index({status:1});dmnvSchema.index({user_created:1,visible_to:1,visible_to_users:1});dmnvSchema.index({phu_trach:1});dmnvSchema.index({ma_bp:1});dmnvSchema.index({ten_bp:1});dmnvSchema.index({chuc_vu:1});dmnvSchema.index({id_app:1,ma_nv:1},{unique:!0});dmnvSchema.index({ten_nv:1});dmnvSchema.index({ma_so_thue:1});
8
- dmnvSchema.index({user:1});dmnvSchema.pre("save",function($next$$){if(!this.user)return $next$$();const $self$$=this;this.isNew||this.user!=this._previous_user?mongoose.models.dmnv.countDocuments({id_app:this.id_app,user:this.user,ma_nv:{$ne:this.ma_nv}},($e$$,$count$$)=>{0<$count$$?$next$$(Error(`Ng\u01b0\u1eddi s\u1eed d\u1ee5ng '${$self$$.user}' \u0111\u00e3 \u0111\u01b0\u1ee3c g\u1eafn cho m\u1ed9t nh\u00e2n vi\u00ean kh\u00e1c`)):$next$$()}):$next$$()});
9
- const model=mongoose.models.dmnv||mongoose.model("dmnv",dmnvSchema);model.on("index",async function($err$$){$err$$?(console.error("Employee index error",$err$$),(await model.aggregate([{$group:{_id:{id_app:"$id_app",ma_nv:"$ma_nv"},count:{$sum:1},ids:{$push:"$_id"}}},{$match:{count:{$gt:1}}}])).forEach($d$$=>{console.info("employee duplication",$d$$._id,$d$$.ids);$d$$.ids.forEach(($id$$,$index$$)=>{0<$index$$&&console.info("you should delete employee",$id$$)})})):console.info("emplyeee indexing complete")});
2
+ trim:!0,maxlength:1024},device_user_id:String,ma_so_thue:{type:String,maxlength:32},phu_trach:{type:String,maxlength:1024,trim:!0},ma_doi:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},ma_to:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},nh_nv:{type:String,trim:!0,maxlength:32},ma_nh_nv:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},ma_kh:String,ten_kh:String,nguoi_danh_gia:[{ma_doi_tuong_danh_gia:String,user:String,line:Number}],ma_bp:{type:String,uppercase:!0,
3
+ trim:!0,default:"",maxlength:32},ten_bp:String,ma_kho:{type:String,uppercase:!0,trim:!0,default:"",maxlength:32},ten_kho:String,chuc_vu:{type:String,trim:!0,maxlength:1024},cong_viec:{type:String,trim:!0,maxlength:1024},cong_viec_chi_tiet:{type:String,trim:!0},trinh_do_hoc_van:String,trinh_do_chuyen_mon:String,bo_phan:[bpSchema],noi_sinh:{type:String,maxlength:1024},ngay_sinh:{type:Date},nguyen_quan:{type:String,maxlength:1024},ho_khau:{type:String,maxlength:1024},dia_chi:{type:String,maxlength:1024},
4
+ dien_thoai:{type:String,maxlength:1024},fax:{type:String,maxlength:1024},email:{type:String,maxlength:1024},website:{type:String,maxlength:1024},dan_toc:{type:String,maxlength:1024},ton_giao:{type:String,maxlength:1024},cmnd:{type:String,maxlength:1024},ngay_cap:Date,noi_cap:{type:String,maxlength:1024},gioi_tinh:{type:String,maxlength:1024},tinh_trang_hon_nhan:{type:String,maxlength:1024},quoc_tich:{type:String,maxlength:1024},lam_viec:{type:Boolean,default:!0},cham_cong:{type:Boolean,default:!0},
5
+ tinh_luong:{type:Boolean,default:!0},bhxh:{type:Boolean,default:!0},bhyt:{type:Boolean,default:!0},bhtn:{type:Boolean,default:!0},luong_co_ban:{type:Number,default:0},luong_bhxh:{type:Number,default:0},ngay_tinh_bhxh:Date,phu_cap:[],luong_thu_viec:{type:Number,default:0},thu_viec_tu_ngay:Date,thu_viec_den_ngay:Date,ngay_bat_dau_lam:Date,ngay_nghi_viec:Date,so_ngay_duoc_nghi_phep_nam:Number,ttncn_mst:String,ttncn_so_nguoi_phu_thuoc:Number,ttncn_muc_gt_phu_thuoc:Number,ttncn_so_thang_gt_ban_than:Number,
6
+ ttncn_muc_gt_ban_than:Number,so_tk_ngan_hang:String,ten_chu_tk_ngan_hang:String,phat_hanh_boi_ngan_hang:String,user:{type:String,lowercase:!0,maxlength:1024,set:function($user$$){this._previous_user=this.user;return $user$$}},group_user:String,default_password:{type:String,maxlength:1024},ghi_chu:{type:String,trim:!0,maxlength:1024},picture:String,exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String},
7
+ user_updated:{type:String},visible_to:{type:Number,default:0},visible_to_users:[String]},{toJSON:{virtuals:!0}});dmnvSchema.index({ma_nv:"text",ten_nv:"text",ma_bp:"text",ten_bp:"text",chuc_vu:"text"},{name:"dmnv_index_text"});dmnvSchema.index({status:1});dmnvSchema.index({user_created:1,visible_to:1,visible_to_users:1});dmnvSchema.index({phu_trach:1});dmnvSchema.index({ma_bp:1});dmnvSchema.index({ten_bp:1});dmnvSchema.index({ma_kh:1});dmnvSchema.index({ten_kh:1});dmnvSchema.index({chuc_vu:1});
8
+ dmnvSchema.index({id_app:1,ma_nv:1},{unique:!0});dmnvSchema.index({ten_nv:1});dmnvSchema.index({ma_so_thue:1});dmnvSchema.index({user:1});
9
+ dmnvSchema.pre("save",function($next$$){if(!this.user)return $next$$();const $self$$=this;this.isNew||this.user!=this._previous_user?mongoose.models.dmnv.countDocuments({id_app:this.id_app,user:this.user,ma_nv:{$ne:this.ma_nv}},($e$$,$count$$)=>{0<$count$$?$next$$(Error(`Ng\u01b0\u1eddi s\u1eed d\u1ee5ng '${$self$$.user}' \u0111\u00e3 \u0111\u01b0\u1ee3c g\u1eafn cho m\u1ed9t nh\u00e2n vi\u00ean kh\u00e1c`)):$next$$()}):$next$$()});const model=mongoose.models.dmnv||mongoose.model("dmnv",dmnvSchema);
10
+ model.on("index",async function($err$$){$err$$?(console.error("Employee index error",$err$$),(await model.aggregate([{$group:{_id:{id_app:"$id_app",ma_nv:"$ma_nv"},count:{$sum:1},ids:{$push:"$_id"}}},{$match:{count:{$gt:1}}}])).forEach($d$$=>{console.info("employee duplication",$d$$._id,$d$$.ids);$d$$.ids.forEach(($id$$,$index$$)=>{0<$index$$&&console.info("you should delete employee",$id$$)})})):console.info("emplyeee indexing complete")});
10
11
  model.referenceKeys={ma_nv:[{model:"chamcong",key:"ma_nv",error:"Nh\u00e2n vi\u00ean ${obj.ma_nv} - ${obj.ten_nv} \u0111\u00e3 ph\u00e1t sinh d\u1eef li\u1ec7u trong b\u1ea3ng ch\u1ea5m c\u00f4ng"},{model:"bangtinhluong",key:"ma_nv",error:"Nh\u00e2n vi\u00ean ${obj.ma_nv} - ${obj.ten_nv} \u0111\u00e3 ph\u00e1t sinh d\u1eef li\u1ec7u trong b\u1ea3ng t\u00ednh l\u01b0\u01a1ng"},{model:"socai",key:"ma_nv",error:"Nh\u00e2n vi\u00ean ${obj.ma_nv} - ${obj.ten_nv} \u0111\u00e3 ph\u00e1t sinh d\u1eef li\u1ec7u trong s\u1ed5 c\u00e1i"},
11
12
  {model:"phieudanhgia",key:"ma_nv",error:"Nh\u00e2n vi\u00ean ${obj.ma_nv} - ${obj.ten_nv} \u0111\u00e3 ph\u00e1t sinh d\u1eef li\u1ec7u trong phi\u1ebfu \u0111\u00e1nh gi\u00e1 nh\u00e2n vi\u00ean"}]};
12
13
  model.createEmployeeCode=function($id_app$$,$ma_nv$$,$lanthu$$,$callback$$){$ma_nv$$=$ma_nv$$.replace(/[^\w\s]/gi,"").split(" ").join("").toUpperCase();model.findOne({ma_nv:$ma_nv$$,id_app:$id_app$$},function($e$$,$rs$$){if($e$$)return $callback$$($e$$);if($rs$$)$lanthu$$+=1,$ma_nv$$=$ma_nv$$.substring(0,$ma_nv$$.length-$lanthu$$.toString().length)+$lanthu$$.toString(),model.createEmployeeCode($id_app$$,$ma_nv$$,$lanthu$$,$callback$$);else return $callback$$(null,$ma_nv$$)})};
@@ -1,2 +1,3 @@
1
- 'use strict';const fileSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},file:{},id_link:String,collection_link:String,group:{type:String,default:"document"},mieu_ta:{type:String,maxlength:1024},nh_file:{type:String,maxlength:1024},title_topic:{type:String,maxlength:1024},url_topic:{type:String,maxlength:1024},server:String,refresh_token:String,account:String,meta:{},is_avatar:{type:Boolean},read_image:Boolean,text_from_image:String,shared:{type:Boolean},status:{type:Boolean,default:!0},
2
- date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});fileSchema.index({id_app:1,id_link:1});fileSchema.index({shared:1});fileSchema.index({group:1});fileSchema.index({collection_link:1});fileSchema.index({mieu_ta:"text"});fileSchema.index({status:1});fileSchema.index({user_created:1,visible_to:1,visible_to_users:1});module.exports=mongoose.models.file||mongoose.model("file",fileSchema);
1
+ 'use strict';const fileSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},file:{},id_link:String,id_folder:String,collection_link:String,group:{type:String,default:"document"},mieu_ta:{type:String,maxlength:1024},nh_file:{type:String,maxlength:1024},title_topic:{type:String,maxlength:1024},url_topic:{type:String,maxlength:1024},server:String,refresh_token:String,account:String,meta:{},is_avatar:{type:Boolean},read_image:Boolean,text_from_image:String,shared:{type:Boolean},visible_to:{type:Number,
2
+ default:0},visible_to_users:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});fileSchema.index({id_app:1,id_link:1});fileSchema.index({shared:1});fileSchema.index({group:1});fileSchema.index({id_folder:1});fileSchema.index({collection_link:1});fileSchema.index({mieu_ta:"text"});fileSchema.index({status:1});
3
+ fileSchema.index({user_created:1,visible_to:1,visible_to_users:1});module.exports=mongoose.models.file||mongoose.model("file",fileSchema);
@@ -0,0 +1,3 @@
1
+ 'use strict';const folderSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},id_link:String,collection_link:String,thu_muc_goc:String,ten_thu_muc:{type:String,maxlength:1024},phu_trach:String,ma_bp:String,ma_dt:String,mieu_ta:{type:String,maxlength:1024},shared:{type:Boolean},visible_to:{type:Number,default:0},visible_to_users:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},
2
+ user_updated:{type:String,default:""}});folderSchema.index({id_app:1,id_link:1});folderSchema.index({shared:1});folderSchema.index({phu_trach:1});folderSchema.index({ma_bp:1});folderSchema.index({ma_dt:1});folderSchema.index({phu_trach:1});folderSchema.index({ten_thu_muc:1});folderSchema.index({collection_link:1});folderSchema.index({mieu_ta:"text",ten_thu_muc:"text"},{name:"folder_index_text"});folderSchema.index({status:1});folderSchema.index({user_created:1,visible_to:1,visible_to_users:1});
3
+ module.exports=mongoose.models.folder||mongoose.model("folder",folderSchema);
@@ -7,6 +7,6 @@ const hd2Schema=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_d
7
7
  ong_ba:{type:String,maxlength:1024},ma_kh:{type:String,uppercase:!0,required:!0,default:"",maxlength:32},ten_kh:String,ma_so_thue:{type:String,maxlength:1024},tk_no:{type:String,uppercase:!0,required:!0,default:"",maxlength:32},ma_hoa_don:{type:String,default:"",uppercase:!0,trim:!0,maxlength:32},ky_hieu_hoa_don:{type:String,default:"",uppercase:!0,trim:!0,maxlength:32},so_hd:{type:String,uppercase:!0,maxlength:32},so_seri:{type:String,uppercase:!0,maxlength:32},ngay_hd:{type:Date,uppercase:!0},ma_thue:{type:String,
8
8
  uppercase:!0,maxlength:32},thue_suat:{type:Number,default:0},tk_thue_co:{type:String,uppercase:!0,maxlength:32},dia_chi:{type:String,default:"",maxlength:1024},ten_vt:{type:String,default:"",maxlength:1024},dien_giai_thue:{type:String,default:"",maxlength:1024},tien_thue_dc_nt:Number,t_thue:{type:Number,default:0},t_thue_nt:{type:Number,default:0},han_tt:{type:Number,default:0},hinh_thuc_tt:{type:String,maxlength:1024},dien_giai:{type:String,default:"",maxlength:1024},exfields:Schema.Types.Mixed,
9
9
  trang_thai:{type:String,maxlength:32},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],details:{type:[detailSchema]},promotion:Schema.Types.Mixed,id_contract:{type:String,maxlength:1024},id_dh2:{type:String,maxlength:1024},ma_kho:{type:String,uppercase:!0,maxlength:32},ma_kh_hoa_hong:{type:String,
10
- uppercase:!0,maxlength:32},ty_le_hoa_hong:Number,tien_hoa_hong:Number,tk_no_hoa_hong:String,tk_co_hoa_hong:String,ty_le_ck_hd:{type:Number,default:0},tien_ck_hd:{type:Number,default:0},tk_ck:String,result_export_einvoice:Schema.Types.Mixed,ma_bp:{type:String,uppercase:!0,maxlength:32},ma_nv:{type:String,uppercase:!0,maxlength:32},ma_phi:{type:String,uppercase:!0,maxlength:32},ma_hd:{type:String,uppercase:!0,maxlength:32},ma_dt:{type:String,uppercase:!0,maxlength:32},ma_lo:{type:String,uppercase:!0,
11
- maxlength:32}});hd2Schema.validate={ma_dvcs:validator.existsDvcs,ma_nt:validator.existsNt,ngay_ct:validator.unlockBook,ma_kh:validator.existsKh,tk_no:validAccount.existsTk,ma_thue:validator.existsVat,tk_thue_co:validAccount.existsTk};hd2Schema.index({id_app:1,ma_dvcs:1,so_ct:-1,ngay_ct:-1});hd2Schema.index({dien_giai:"text",ma_kh:"text",ten_kh:"text",so_ct:"text"},{name:"hd2_index_text"});hd2Schema.index({ma_ct:1});hd2Schema.index({ma_kh:1});hd2Schema.index({ma_kho:1});hd2Schema.index({"details.ma_vt":1});
10
+ uppercase:!0,maxlength:32},ty_le_hoa_hong:Number,tien_hoa_hong:Number,tk_no_hoa_hong:String,tk_co_hoa_hong:String,tu_tinh_hoa_hong:Boolean,ty_le_ck_hd:{type:Number,default:0},tien_ck_hd:{type:Number,default:0},tk_ck:String,result_export_einvoice:Schema.Types.Mixed,ma_bp:{type:String,uppercase:!0,maxlength:32},ma_nv:{type:String,uppercase:!0,maxlength:32},ma_phi:{type:String,uppercase:!0,maxlength:32},ma_hd:{type:String,uppercase:!0,maxlength:32},ma_dt:{type:String,uppercase:!0,maxlength:32},ma_lo:{type:String,
11
+ uppercase:!0,maxlength:32}});hd2Schema.validate={ma_dvcs:validator.existsDvcs,ma_nt:validator.existsNt,ngay_ct:validator.unlockBook,ma_kh:validator.existsKh,tk_no:validAccount.existsTk,ma_thue:validator.existsVat,tk_thue_co:validAccount.existsTk};hd2Schema.index({id_app:1,ma_dvcs:1,so_ct:-1,ngay_ct:-1});hd2Schema.index({dien_giai:"text",ma_kh:"text",ten_kh:"text",so_ct:"text"},{name:"hd2_index_text"});hd2Schema.index({ma_ct:1});hd2Schema.index({ma_kh:1});hd2Schema.index({ma_kho:1});hd2Schema.index({"details.ma_vt":1});
12
12
  hd2Schema.index({id_dh2:1});hd2Schema.index({id_contract:1});hd2Schema.index({user_created:1,date_created:-1});hd2Schema.index({date_updated:-1});hd2Schema.index({status:1});hd2Schema.index({user_created:1,visible_to:1,visible_to_users:1});hd2Schema.index({trang_thai:1});module.exports=mongoose.models.hd2||mongoose.model("hd2",hd2Schema);
@@ -7,7 +7,8 @@ const model=global.mongoose.models.participant||global.mongoose.model("participa
7
7
  model.appsOfUser=async $email$$=>{let $condition$$={email:$email$$};return new Promise(($resolve$$,$reject$$)=>{model.find($condition$$).lean().exec(($e$$,$rs$$)=>{if($e$$)return $reject$$(Error($e$$.message));$resolve$$($rs$$)})})};
8
8
  model.createParticipant=($data$$,$callback$$)=>{$data$$.name=$data$$.name||$data$$.email;model.findOne({id_app:$data$$.id_app,email:$data$$.email},($e$jscomp$0$$,$rs$jscomp$0$$)=>{if($e$jscomp$0$$)return $callback$$($e$jscomp$0$$);if($rs$jscomp$0$$)return $callback$$(null,$rs$jscomp$0$$);model.create($data$$,($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)})})};
9
9
  model.asyncCreateParticipant=async $data$$=>new Promise(($resolve$$,$reject$$)=>{model.createParticipant($data$$,($e$$,$rs$$)=>{if($e$$)return $reject$$($e$$);$resolve$$($rs$$)})});
10
- model.referredUsers=async($id_app$$,$be_introduced_by_level1$$,$level$$=1)=>{$be_introduced_by_level1$$=await global.getModel("introducer").find({id_app:$id_app$$,be_introduced_by:$be_introduced_by_level1$$}).lean().exec();$be_introduced_by_level1$$=$be_introduced_by_level1$$.map($l$$=>({user:$l$$.be_introduced,by:$l$$.be_introduced_by,introduce_code:$l$$.introduce_code,date:$l$$.date_created,level:$level$$}));if(0==$be_introduced_by_level1$$.lenth)return $be_introduced_by_level1$$;let $level2$$=
11
- await Promise.all($be_introduced_by_level1$$.map($intro$$=>model.referredUsers($id_app$$,$intro$$.user,$intro$$.level+1)));return $be_introduced_by_level1$$.concat($level2$$.reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]))};
12
- const referByUsers=async($id_app$$,$be_introduced_level1$$,$level$$=1)=>{$be_introduced_level1$$=await global.getModel("introducer").find({id_app:$id_app$$,be_introduced:$be_introduced_level1$$}).lean().exec();$be_introduced_level1$$=$be_introduced_level1$$.map($l$$=>({user:$l$$.be_introduced,by:$l$$.be_introduced_by,introduce_code:$l$$.introduce_code,date:$l$$.date_created,level:$level$$}));if(0==$be_introduced_level1$$.lenth)return $be_introduced_level1$$;let $level2$$=await Promise.all($be_introduced_level1$$.map($intro$$=>
13
- referByUsers($id_app$$,$intro$$.by,$intro$$.level+1)));return $be_introduced_level1$$.concat($level2$$.reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]))};model.referByUsers=async($id_app$jscomp$3_rs$$,$be_introduced$$)=>{$id_app$jscomp$3_rs$$=(await referByUsers($id_app$jscomp$3_rs$$,$be_introduced$$)).sort(($a$$,$b$$)=>$b$$.level-$a$$.level);$id_app$jscomp$3_rs$$.forEach(($r$$,$index$$)=>{$r$$.level=$index$$+1});return $id_app$jscomp$3_rs$$};module.exports=model;
10
+ model.referredUsers=async($id_app$$,$be_introduced_by_level1$$,$level$$=1)=>{$be_introduced_by_level1$$=await global.getModel("introducer").find({id_app:$id_app$$,be_introduced_by:$be_introduced_by_level1$$}).lean().exec();$be_introduced_by_level1$$=$be_introduced_by_level1$$.filter($l$$=>$l$$.be_introduced!=$l$$.be_introduced_by).map($l$$=>({user:$l$$.be_introduced,by:$l$$.be_introduced_by,introduce_code:$l$$.introduce_code,date:$l$$.date_created,level:$level$$}));if(0==$be_introduced_by_level1$$.lenth)return $be_introduced_by_level1$$;
11
+ let $level2$$=await Promise.all($be_introduced_by_level1$$.map($intro$$=>model.referredUsers($id_app$$,$intro$$.user,$intro$$.level+1)));return $be_introduced_by_level1$$.concat($level2$$.reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]))};
12
+ const referByUsers=async($id_app$$,$be_introduced_level1$$,$level$$=1)=>{$be_introduced_level1$$=await global.getModel("introducer").find({id_app:$id_app$$,be_introduced:$be_introduced_level1$$}).lean().exec();$be_introduced_level1$$=$be_introduced_level1$$.filter($l$$=>$l$$.be_introduced!=$l$$.be_introduced_by).map($l$$=>({user:$l$$.be_introduced,by:$l$$.be_introduced_by,introduce_code:$l$$.introduce_code,date:$l$$.date_created,level:$level$$}));if(0==$be_introduced_level1$$.lenth)return $be_introduced_level1$$;
13
+ let $level2$$=await Promise.all($be_introduced_level1$$.map($intro$$=>referByUsers($id_app$$,$intro$$.by,$intro$$.level+1)));return $be_introduced_level1$$.concat($level2$$.reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]))};model.referByUsers=async($id_app$jscomp$3_rs$$,$be_introduced$$)=>{$id_app$jscomp$3_rs$$=(await referByUsers($id_app$jscomp$3_rs$$,$be_introduced$$)).sort(($a$$,$b$$)=>$b$$.level-$a$$.level);$id_app$jscomp$3_rs$$.forEach(($r$$,$index$$)=>{$r$$.level=$index$$+1});return $id_app$jscomp$3_rs$$};
14
+ module.exports=model;
@@ -6,9 +6,10 @@ tu_gio:{type:Date},den_gio:{type:Date},so_lan:Number,diem_thuong:{type:Number,de
6
6
  const ctcpbhSchema=new global.Schema({ma_cp:{type:String,uppercase:!0,required:!0},dien_giai:{type:String,maxlength:1024},tien_cp_nt:{type:Number,default:0},tien_cp:{type:Number,default:0},line:{type:Number,default:0}}),so1Schema=new global.Schema({id_app:{type:String,required:!0,maxlength:1024},ma_dvcs:{type:String,maxlength:1024},ma_ct:{type:String,default:"SO1",required:!0,uppercase:!0,maxlength:32},ma_gd:{type:String,default:"0",maxlength:32},so_ct:{type:String,uppercase:!0,trim:!0,maxlength:32},
7
7
  ngay_ct:{type:Date,default:Date.now,required:!0},ma_nt:{type:String,required:"ma_nt is required",default:"VND",trim:!0,uppercase:!0,maxlength:32},ty_gia:{type:Number,required:!0,min:0,default:1},trang_thai:{type:String,default:"1",maxlength:32},ma_kh:{type:String,uppercase:!0,maxlength:32},ten_kh:String,of_user:{type:String,maxlength:128},ma_kho:{type:String,uppercase:!0,maxlength:32},ten_kho:String,ten_nguoi_nhan:{type:String,maxlength:1024},dien_thoai:{type:String,maxlength:1024},email:{type:String,
8
8
  maxlength:1024},dia_chi:{type:String,maxlength:1024},xa_phuong:{type:String,maxlength:1024},quan_huyen:{type:String,maxlength:1024},tinh_thanh:{type:String,maxlength:1024},quoc_gia:{type:String,default:"VN",maxlength:2},post_code:{type:String,maxlength:1024},location:global.Schema.Types.Mixed,note_ship:{type:String,maxlength:1024},pt_giao_hang:{type:String,default:"1",maxlength:1024},dich_vu_giao_hang:{type:String,maxlength:1024},trang_thai_giao_hang:{type:String,maxlength:1024},ma_kiem_soat:{type:String,
9
- maxlength:1024},ly_do_that_bai:{type:String,maxlength:1024},ly_do_huy:{type:String,maxlength:1024},ngay_giao_hang:Date,ngay_hoan_thanh:Date,ngay_tra_lai:Date,user_nv_giao_hang:{type:String,maxlength:128},vi_tri_giao_hang:global.Schema.Types.Mixed,dien_giai:{type:String,default:"",maxlength:1024},exfields:global.Schema.Types.Mixed,stt_rec:String,ma_dt:{type:String,uppercase:!0,default:"",maxlength:32},profile:global.Schema.Types.Mixed,discout_code:{type:String,maxlength:32},ty_le_ck_hd:{type:Number,
10
- default:0},tien_ck_hd:{type:Number,default:0},ma_freeship:String,tien_freeship:Number,tien_phi_vc:Number,sender_email:{type:String,maxlength:128},id_trans:{type:String,maxlength:1024},paymentByPoints:{type:Number,default:0},exchangeRate:Number,tien_paymentByPoints:{type:Number,default:0},evouchers:[global.Schema.Types.Mixed],tien_evoucher:Number,tk_no_evoucher:String,tk_co_evoucher:String,da_tra:{type:Number,default:0},tien_con_lai:{type:Number,default:0},pt_thanh_toan:{type:String,maxlength:1024},
11
- note_payment:{type:String,maxlength:1024},virtual_payment_client_url:{type:String,maxlength:2024},again_link:{type:String,maxlength:2024},payment_service:String,payment_id:String,payment_getway_lang:{type:String,maxlength:1024},details:{type:[detailSchema]},ctcpbhs:[ctcpbhSchema],shared:Boolean,gio:Number,ngay:Number,thang:Number,quy:Number,nam:Number,online:Boolean,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,
12
- default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String]});so1Schema.validate={ma_nt:validator.existsNt,ngay_ct:validator.unlockBook,ma_kh:validator.existsKh,ma_kho:validVt.existsKho};so1Schema.index({id_app:1,ma_dvcs:1,so_ct:-1,ngay_ct:-1});so1Schema.index({dien_giai:"text",so_ct:"text",ma_kh:"text",ten_kh:"text",ma_kho:"text",ten_kho:"text"},{name:"so1_index_text"});so1Schema.index({ma_ct:1});so1Schema.index({ma_kh:1});so1Schema.index({ma_kho:1});
13
- so1Schema.index({"details.ma_vt":1});so1Schema.index({trang_thai:1});so1Schema.index({user_nv_giao_hang:1});so1Schema.index({user_created:1,date_created:-1});so1Schema.index({date_updated:-1});so1Schema.index({gio:1});so1Schema.index({ngay:1});so1Schema.index({thang:1});so1Schema.index({quy:1});so1Schema.index({nam:-1});so1Schema.index({status:1});so1Schema.index({online:1});so1Schema.index({user_created:1,visible_to:1,visible_to_users:1});
14
- so1Schema.pre("save",function($next$$){let $ngay_ct$$=moment(this.ngay_ct);this.gio=$ngay_ct$$.get("hours");this.ngay=$ngay_ct$$.get("dates");this.quy=$ngay_ct$$.get("quarters");this.thang=$ngay_ct$$.get("months")+1;this.nam=$ngay_ct$$.get("year");$next$$()});const model=global.mongoose.models.so1||global.mongoose.model("so1",so1Schema);model.referenceKeys={_id:[{model:"socai",key:"id_ct_goc",error:"Phi\u1ebfu n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c ho\u1ea1ch to\u00e1n"}]};module.exports=model;
9
+ maxlength:1024},ly_do_that_bai:{type:String,maxlength:1024},ly_do_huy:{type:String,maxlength:1024},ma_nv:String,ma_kh_hoa_hong:{type:String,uppercase:!0,maxlength:32},ty_le_hoa_hong:Number,tien_hoa_hong:Number,tk_no_hoa_hong:String,tk_co_hoa_hong:String,tu_tinh_hoa_hong:Boolean,ngay_giao_hang:Date,ngay_hoan_thanh:Date,ngay_tra_lai:Date,user_nv_giao_hang:{type:String,maxlength:128},vi_tri_giao_hang:global.Schema.Types.Mixed,dien_giai:{type:String,default:"",maxlength:1024},exfields:global.Schema.Types.Mixed,
10
+ stt_rec:String,ma_dt:{type:String,uppercase:!0,default:"",maxlength:32},profile:global.Schema.Types.Mixed,discout_code:{type:String,maxlength:32},ty_le_ck_hd:{type:Number,default:0},tien_ck_hd:{type:Number,default:0},ma_freeship:String,tien_freeship:Number,tien_phi_vc:Number,sender_email:{type:String,maxlength:128},id_trans:{type:String,maxlength:1024},paymentByPoints:{type:Number,default:0},exchangeRate:Number,tien_paymentByPoints:{type:Number,default:0},evouchers:[global.Schema.Types.Mixed],tien_evoucher:Number,
11
+ tk_no_evoucher:String,tk_co_evoucher:String,da_tra:{type:Number,default:0},tien_con_lai:{type:Number,default:0},pt_thanh_toan:{type:String,maxlength:1024},note_payment:{type:String,maxlength:1024},virtual_payment_client_url:{type:String,maxlength:2024},again_link:{type:String,maxlength:2024},payment_service:String,payment_id:String,payment_getway_lang:{type:String,maxlength:1024},details:{type:[detailSchema]},ctcpbhs:[ctcpbhSchema],shared:Boolean,gio:Number,ngay:Number,thang:Number,quy:Number,nam:Number,
12
+ online:Boolean,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String]});so1Schema.validate={ma_nt:validator.existsNt,ngay_ct:validator.unlockBook,ma_kh:validator.existsKh,ma_kho:validVt.existsKho};so1Schema.index({id_app:1,ma_dvcs:1,so_ct:-1,ngay_ct:-1});
13
+ so1Schema.index({dien_giai:"text",so_ct:"text",ma_kh:"text",ten_kh:"text",ma_kho:"text",ten_kho:"text"},{name:"so1_index_text"});so1Schema.index({ma_ct:1});so1Schema.index({ma_kh:1});so1Schema.index({ma_kho:1});so1Schema.index({ma_nv:1});so1Schema.index({"details.ma_vt":1});so1Schema.index({trang_thai:1});so1Schema.index({user_nv_giao_hang:1});so1Schema.index({user_created:1,date_created:-1});so1Schema.index({date_updated:-1});so1Schema.index({gio:1});so1Schema.index({ngay:1});so1Schema.index({thang:1});
14
+ so1Schema.index({quy:1});so1Schema.index({nam:-1});so1Schema.index({status:1});so1Schema.index({online:1});so1Schema.index({user_created:1,visible_to:1,visible_to_users:1});so1Schema.pre("save",function($next$$){let $ngay_ct$$=moment(this.ngay_ct);this.gio=$ngay_ct$$.get("hours");this.ngay=$ngay_ct$$.get("dates");this.quy=$ngay_ct$$.get("quarters");this.thang=$ngay_ct$$.get("months")+1;this.nam=$ngay_ct$$.get("year");$next$$()});
15
+ const model=global.mongoose.models.so1||global.mongoose.model("so1",so1Schema);model.referenceKeys={_id:[{model:"socai",key:"id_ct_goc",error:"Phi\u1ebfu n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c ho\u1ea1ch to\u00e1n"}]};module.exports=model;
@@ -4,8 +4,8 @@ await introducecode.findOne({id_app:$investment$$.id_app,introduce_code:$intro$$
4
4
  $appInfo$$.wallet_address){var $usergroup$$,$par$$=await Participant.findOne({id_app:$investment$$.id_app,email:$intro$$.be_introduced_by}).lean();$par$$&&$par$$.group_id&&($usergroup$$=await Usergroup.findOne({id_app:$investment$$.id_app,_id:$par$$.group_id}).lean());$usergroup$$||($usergroup$$={});var $period$$=await assperiod.findOne({id_app:$investment$$.id_app,id:$investment$$.id_period});$period$$||($period$$={});$period$$.ty_le_hoa_hong_groups=$period$$.ty_le_hoa_hong_groups||[];var $ty_le_hoa_hong_group$$=
5
5
  $period$$.ty_le_hoa_hong_groups.find($t$$=>$t$$.id_user_group===$usergroup$$._id);$ty_le_hoa_hong_group$$||($ty_le_hoa_hong_group$$=$period$$.ty_le_hoa_hong_groups.find($t$$=>!$t$$.id_user_group)||{});var $ty_le_hoa_hong$$=$ty_le_hoa_hong_group$$.ty_le_hoa_hong||$usergroup$$.ty_le_hoa_hong||$appInfo$$.ty_le_hoa_hong||0;var $tang_gioi_thieu_denom$$=$ty_le_hoa_hong_group$$.denom||$usergroup$$.tang_gioi_thieu_denom||$appInfo$$.tang_gioi_thieu_denom;$investment$$.ty_le_hoa_hong=$ty_le_hoa_hong$$;$investment$$.address_hoa_hong=
6
6
  $receiver$$;$investment$$.denom_hoa_hong=$tang_gioi_thieu_denom$$;$investment$$.ky_tra_hoa_hong=$period$$.ky_tra_hoa_hong;$investment$$.introduce_code=$intro$$.introduce_code}}}else console.log("user nay khong co nguoi gioi thieu",$investment$$.user_created)}catch($e$$){console.error("Khong the tinh hoa hong cho nguoi gioi thieu",$e$$)}};
7
- module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"assinvestment",{sort:{date_created:-1},notNeedRight:!0,requireOtp:$data$$=>"0"==$data$$.trang_thai||"2"==$data$$.trang_thai||"7"==$data$$.trang_thai?!1:!0,onFinding:async($user$$,$condition$$,$next$$)=>{$next$$(null,$condition$$)},onView:async($user$$,$items$$,$next$$)=>{let $network$$="MAINNET",$app$$=await global.getModel("app").findOne({_id:$user$$.current_id_app}).lean();$app$$&&$app$$.wallet_network&&
8
- configs.BLOCKCHAIN_NETWORKS[$app$$.wallet_network]&&($network$$=$app$$.wallet_network);async.mapSeries($items$$,($item$$,$cb$$)=>{setImmediate(async()=>{$item$$.wallet_address=$item$$.creator;try{if(!$item$$.id&&0!==$item$$.id||"5"==$item$$.trang_thai||"7"==$item$$.trang_thai||"9"==$item$$.trang_thai)void 0!=$item$$.id_period&&null!=$item$$.id_period&&await [$item$$].asyncJoinModel2($user$$.current_id_app,assperiod,{where:{id_period:"id"},fields:"ten_ky_han ky_han id_product gia lai_suat_cam_ket lai_suat_truoc_han cho_phep_rut_von cho_phep_chuyen_nhuong denom tg_xu_ly_rut_von co_phan id_rpt ky_tinh_lai goi_dau_tu tru_lai_da_tra han_tt".split(" ")}),
7
+ module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"assinvestment",{sort:{date_created:-1},notNeedRight:!0,requireOtp:($data$$,$options$$)=>"0"==$data$$.trang_thai||"2"==$data$$.trang_thai||"7"==$data$$.trang_thai||isSupperAdmin($options$$.user.email.toLowerCase())?!1:!0,onFinding:async($user$$,$condition$$,$next$$)=>{$next$$(null,$condition$$)},onView:async($user$$,$items$$,$next$$)=>{let $network$$="MAINNET",$app$$=await global.getModel("app").findOne({_id:$user$$.current_id_app}).lean();
8
+ $app$$&&$app$$.wallet_network&&configs.BLOCKCHAIN_NETWORKS[$app$$.wallet_network]&&($network$$=$app$$.wallet_network);async.mapSeries($items$$,($item$$,$cb$$)=>{setImmediate(async()=>{$item$$.wallet_address=$item$$.creator;try{if(!$item$$.id&&0!==$item$$.id||"5"==$item$$.trang_thai||"7"==$item$$.trang_thai||"9"==$item$$.trang_thai)void 0!=$item$$.id_period&&null!=$item$$.id_period&&await [$item$$].asyncJoinModel2($user$$.current_id_app,assperiod,{where:{id_period:"id"},fields:"ten_ky_han ky_han id_product gia lai_suat_cam_ket lai_suat_truoc_han cho_phep_rut_von cho_phep_chuyen_nhuong denom tg_xu_ly_rut_von co_phan id_rpt ky_tinh_lai goi_dau_tu tru_lai_da_tra han_tt".split(" ")}),
9
9
  void 0!=$item$$.id_product&&null!=$item$$.id_product&&await [$item$$].asyncJoinModel2($user$$.current_id_app,assproduct,{where:{id_product:"id"},fields:["ma_loai","ten_san_pham",{product_token:"token"},{gia_tri_hien_tai_san_pham:"gia_tri_hien_tai"},{tong_gia_tri_huy_dong:"tong_gia_tri"},{tong_so_token_phat_hanh:"tong_so_token"}]}),$item$$.tong_gia_tri=$item$$.gia*$item$$.so_luong,$item$$.lai_du_tinh=Math.roundBy($item$$.lai_suat_cam_ket/365/100*$item$$.tong_gia_tri*$item$$.ky_han,0),$item$$.tong_gia_tri_dao_han=
10
10
  $item$$.tong_gia_tri+$item$$.lai_du_tinh;else{var $ivs_tg_hien_tai$$=await bcQuery("investment/"+$item$$.id,$network$$);$item$$.da_dao_han=$ivs_tg_hien_tai$$.Investment.daDaoHan;$item$$.token=$ivs_tg_hien_tai$$.Investment.token;$item$$.ngay_dao_han=Number($ivs_tg_hien_tai$$.Investment.ngayDaoHan)?new Date(1E3*Number($ivs_tg_hien_tai$$.Investment.ngayDaoHan)):null;$item$$.ngay_phat_hanh=new Date(1E3*Number($ivs_tg_hien_tai$$.Investment.ngayPhatHanh));$item$$.id_product=$ivs_tg_hien_tai$$.Investment.idProduct;
11
11
  $item$$.product_token=$ivs_tg_hien_tai$$.Investment.productToken;$item$$.gia=Number($ivs_tg_hien_tai$$.Investment.gia);$item$$.so_luong=Number($ivs_tg_hien_tai$$.Investment.soLuong);$item$$.tong_gia_tri=$item$$.gia*$item$$.so_luong;$item$$.da_rut_von=Number($ivs_tg_hien_tai$$.Investment.daRutVon);$item$$.lai_suat_cam_ket=Number($ivs_tg_hien_tai$$.Investment.laiSuatCamKet);$item$$.lai_suat_truoc_han=Number($ivs_tg_hien_tai$$.Investment.laiSuatTruocHan);$item$$.ky_han=Number($ivs_tg_hien_tai$$.Investment.kyHan);