flexbiz-server 12.5.35 → 12.5.37

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.5.35",
5
+ "version": "12.5.37",
6
6
  "author": {
7
7
  "name": "Van Truong Pham",
8
8
  "email": "invncur@gmail.com"
@@ -1,268 +1,12 @@
1
- const dmvt = global.getModel('dmvt');
2
- const sokho = global.getModel('sokho');
3
- const hanmucton = global.getModel('hanmucton');
4
- const ckvtcapphat = require('./ckvtcapphat');
5
- const utils = require('./utils');
6
- const async = require('async');
7
- const _ = require("lodash");
8
- const moment = require("moment");
9
- module.exports = async (condition, fn)=> {
10
- if(!fn) fn = ()=>{}
11
- //kiem tra dieu kien
12
- if (!condition.ngay && condition.den_ngay) {
13
- condition.ngay = condition.den_ngay;
14
- }
15
- //lay dieu kien
16
- ////don vi co so
17
- let ma_dvcs = condition.ma_dvcs;
18
- /////kho
19
- let ma_kho = condition.ma_kho;
20
- ////vat tu
21
- let ma_vt = condition.ma_vt;
22
- //
23
-
24
- if(_.isString(ma_vt) && ma_vt.indexOf('[') >= 0 && ma_vt.indexOf(']') > 0 ){
25
- try {
26
- ma_vt = JSON.parse(ma_vt);
27
- if(ma_vt.length==0) ma_vt = undefined;
28
-
29
- } catch (e) {console.error(e)}
30
- }
31
-
32
- if (ma_vt && _.isArray(ma_vt)) {
33
- let _ma_vt = Object.assign(ma_vt);
34
- ma_vt = {$in:_ma_vt};
35
- }
36
-
37
- let id_app = condition.id_app;
38
- //Xác định sổ cân đối tk và điều kiện thời gian
39
- let app = await global.getModel("app").findOne({_id:condition.id_app},{ngay_ks:1}).lean();
40
- if(!app) return fn("Công ty không tồn tại");
41
- let ngay = moment(condition.ngay).endOf("date").toDate();
42
- //let ngay_ks = moment(app.ngay_ks).endOf("date").toDate();
43
- //lấy ngày khoá sổ gần nhất
44
- let ngay_ks = ((await global.getModel('cdvttheongay').findOne({id_app,den_ngay:{$lte:moment(ngay).startOf("date").toDate()}},{den_ngay:1}).sort({den_ngay:-1}).lean())||{}).den_ngay;
45
- if(ngay_ks) ngay_ks = moment(ngay_ks).endOf("date").toDate();
46
- //let ngay_tinh_dn = moment(condition.tu_ngay || condition.ngay).startOf("date").toDate();
47
- let ngay_tinh_dn = condition.tu_ngay && new Date(condition.tu_ngay) < ngay? moment(condition.tu_ngay).endOf("date").toDate() : ngay;
48
- let ngay_dn = moment(ngay_tinh_dn).startOf("year").toDate();
49
- let nam;
50
- let cdvt;
51
- //if(!ngay_ks || (ngay_tinh_dn<ngay_chua_ks || ngay_dn>=ngay_chua_ks)){
52
- if(!ngay_ks || ngay_ks<ngay_dn){
53
- cdvt = global.getModel('cdvt');
54
- nam = ngay_tinh_dn.getFullYear();
55
- }else{
56
- cdvt = global.getModel('cdvttheongay');
57
- ngay_dn = moment(ngay_ks).startOf("date").add(1,"days").toDate();
58
- }
59
- //
60
- return new Promise((resolve,reject)=>{
61
- async.parallel({
62
- //capphat
63
- ckcapphat:(callback)=>{
64
- setImmediate(()=>{
65
- ckvtcapphat(condition,(e,rs)=>{
66
- callback(e,rs);
67
- })
68
- })
69
-
70
- },
71
- //dau nam
72
- dn: (callback) => {
73
- setImmediate(()=>{
74
- const c_dk = {id_app};
75
- if(nam){
76
- c_dk.nam = nam;
77
- }else{
78
- console.log("lay cdvt theo ngay khoa so",ngay_ks);
79
- c_dk.den_ngay = ngay_ks;
80
- }
81
- if (ma_kho) {
82
- c_dk.ma_kho = ma_kho;
83
- }
84
- if (ma_dvcs) {
85
- c_dk.ma_dvcs = ma_dvcs;
86
- }
87
- if (ma_vt) {
88
- c_dk.ma_vt = ma_vt;
89
- }
90
- if (condition.ma_lo) c_dk.ma_lo = condition.ma_lo;
91
- if (condition.han_sd) c_dk.han_sd = condition.han_sd;
92
- if (condition.ma_tt1) c_dk.ma_tt1 = condition.ma_tt1;
93
- if (condition.ma_tt2) c_dk.ma_tt2 = condition.ma_tt2;
94
- if (condition.ma_tt3) c_dk.ma_tt3 = condition.ma_tt3;
95
- //Tìm
96
- cdvt.find(c_dk).lean().then((results)=> {
97
- callback(null, results);
98
- }).catch(error=>{
99
- callback(error);
100
- })
101
- })
102
- },
103
- //han muc ton
104
- hanmucton: (callback) => {
105
- setImmediate(()=>{
106
- const c_dk = {
107
- id_app: id_app
108
- };
109
- if (ma_kho) {
110
- c_dk.ma_kho = ma_kho;
111
- }
112
- if (ma_dvcs) {
113
- c_dk.ma_dvcs = ma_dvcs;
114
- }
115
- if (ma_vt) {
116
- c_dk.ma_vt = ma_vt;
117
- }
118
- if (condition.ma_lo)
119
- c_dk.ma_lo = condition.ma_lo;
120
- if (condition.han_sd)
121
- c_dk.han_sd = condition.han_sd;
122
-
123
- if (condition.ma_tt1)
124
- c_dk.ma_tt1 = condition.ma_tt1;
125
- if (condition.ma_tt2)
126
- c_dk.ma_tt2 = condition.ma_tt2;
127
- if (condition.ma_tt3)
128
- c_dk.ma_tt3 = condition.ma_tt3;
129
- hanmucton.find(c_dk).lean().then((results)=> {
130
- callback(null, results);
131
- }).catch(error=>{
132
- callback(error);
133
- })
134
- })
135
- },
136
- //phat sinh
137
- ps: (callback) => {
138
- setImmediate(()=>{
139
- const query = {
140
- id_app: id_app,
141
- ngay_ct: {
142
- $gte: ngay_dn,
143
- $lte: ngay
144
- }
145
- };
146
- if (ma_kho) {
147
- query.ma_kho = ma_kho;
148
- }
149
- if (ma_dvcs) {
150
- query.ma_dvcs = ma_dvcs;
151
- }
152
- if (ma_vt) {
153
- query.ma_vt = ma_vt;
154
- }
155
- if (condition.ma_lo)
156
- query.ma_lo = condition.ma_lo;
157
- if (condition.han_sd)
158
- query.han_sd = condition.han_sd;
159
-
160
- if (condition.ma_tt1)
161
- query.ma_tt1 = condition.ma_tt1;
162
- if (condition.ma_tt2)
163
- query.ma_tt2 = condition.ma_tt2;
164
- if (condition.ma_tt3)
165
- query.ma_tt3 = condition.ma_tt3;
166
-
167
- if(condition.id_ct){
168
- query.id_ct = {$ne:condition.id_ct}
169
- }
170
- //Tìm
171
- sokho.find(query,{ma_vt:1,ma_kho:1,ma_tt1:1,ma_tt2:1,ma_tt3:1,sl_nhap:1,sl_xuat:1,sl_nhap_qd:1,sl_xuat_qd:1,tien_nhap:1,tien_xuat:1}).inTxn().lean().then((pss)=>{
172
- //lay theo so luong quy doi
173
- pss = pss.map(ps=>{
174
- ps.sl_nhap = utils.round(ps.sl_nhap_qd,4);
175
- ps.sl_xuat =utils.round(ps.sl_xuat_qd,4);
176
- return ps;
177
- })
178
- callback(null, pss);
179
- }).catch(error=>{
180
- callback(error);
181
- })
182
- })
183
- },
184
- ton_kho_mac_dinh:(callback)=>{
185
- setImmediate(()=>{
186
- let query = {
187
- id_app: id_app,
188
- ton_kho_mac_dinh:{$nin:[null,undefined,0]}
189
- };
190
- if (ma_vt) {
191
- query.ma_vt = ma_vt;
192
- }
193
- dmvt.find(query,{ma_vt:1,ton_kho_mac_dinh:1}).lean().then((rs)=>{
194
- callback(null, rs);
195
- }).catch(error=>{
196
- console.error(error);
197
- })
198
- })
199
-
200
- }
201
- }, (error, results) => {
202
- if (error) {
203
- fn(error);
204
- return reject(new Error(error));
205
- }
206
- let ckcapphat = results.ckcapphat.map(c=>{
207
- c.ton00_capphat = c.ton00;
208
- c.du00_capphat = c.du00;
209
-
210
- c.ton00=0;
211
- c.du00=0;
212
-
213
- return c;
214
- })
215
- let data = results.dn.concat(results.ps).concat(ckcapphat).concat(results.ton_kho_mac_dinh).concat(results.hanmucton);
216
-
217
- let groupBy = condition.groupBy || condition.groupby;
218
- if (!groupBy) groupBy = ['ma_vt'];
219
- if(_.isString(groupBy)){
220
- if (groupBy.indexOf('[') >= 0) {
221
- try {
222
- groupBy = JSON.parse(groupBy);
223
- } catch (e) {console.error(e)}
224
- }else{
225
- groupBy = groupBy.split(",");
226
- }
227
- }
228
-
229
- let sumFields = [
230
- 'sl_nhap',
231
- 'sl_xuat',
232
- 'ton00',
233
- 'du00',
234
- 'ton00_capphat',
235
- 'du00_capphat',
236
- 'tien_nhap',
237
- 'tien_xuat',
238
- 'ton_kho_mac_dinh',
239
- 'ton_toi_thieu',
240
- 'ton_toi_da'
241
- ];
242
- data.groupBy(groupBy, sumFields, (e, groups) => {
243
- if (e){
244
- fn(e);
245
- return reject(new Error(e));
246
- }
247
- setImmediate(()=>{
248
- for (let r of groups) {
249
- r.ton00 = utils.round(r.ton00 + r.sl_nhap - r.sl_xuat, 4);
250
- r.du00 = Math.roundBy(r.du00, 0) + Math.roundBy(r.tien_nhap, 0) - Math.roundBy(r.tien_xuat, 0);
251
- r.sl_nhap = 0;
252
- r.sl_xuat = 0;
253
- r.tien_nhap = 0;
254
- r.tien_xuat = 0;
255
- r.ton = r.ton00 - (r.ton00_capphat>0?r.ton00_capphat:0);
256
- r.du = r.du00 - (r.du00_capphat>0?r.du00_capphat:0);
257
-
258
- }
259
- fn(null, groups);
260
- resolve(groups);
261
- })
262
-
263
- })
264
-
265
- });
266
- })
267
-
268
- };
1
+ const dmvt=global.getModel("dmvt"),sokho=global.getModel("sokho"),hanmucton=global.getModel("hanmucton"),ckvtcapphat=require("./ckvtcapphat"),utils=require("./utils"),async=require("async"),_=require("lodash"),moment=require("moment");
2
+ module.exports=async($condition$$,$fn$$)=>{$fn$$||=()=>{};!$condition$$.ngay&&$condition$$.den_ngay&&($condition$$.ngay=$condition$$.den_ngay);let $ma_dvcs$$=$condition$$.ma_dvcs,$ma_kho$$=$condition$$.ma_kho,$ma_vt$$=$condition$$.ma_vt;if(_.isString($ma_vt$$)&&$ma_vt$$.indexOf("[")>=0&&$ma_vt$$.indexOf("]")>0)try{$ma_vt$$=JSON.parse($ma_vt$$),$ma_vt$$.length==0&&($ma_vt$$=void 0)}catch($e$$){console.error($e$$)}$ma_vt$$&&_.isArray($ma_vt$$)&&($ma_vt$$={$in:Object.assign($ma_vt$$)});let $id_app$$=
3
+ $condition$$.id_app;if(!await global.getModel("app").findOne({_id:$condition$$.id_app},{ngay_ks:1}).lean())return $fn$$("C\u00f4ng ty kh\u00f4ng t\u1ed3n t\u1ea1i");let $ngay$$=moment($condition$$.ngay).endOf("date").toDate(),$ngay_ks$$=(await global.getModel("cdvttheongay").findOne({id_app:$id_app$$,den_ngay:{$lte:moment($ngay$$).startOf("date").toDate()}},{den_ngay:1}).sort({den_ngay:-1}).lean()||{}).den_ngay;$ngay_ks$$&&=moment($ngay_ks$$).endOf("date").toDate();let $ngay_tinh_dn$$=$condition$$.tu_ngay&&
4
+ new Date($condition$$.tu_ngay)<$ngay$$?moment($condition$$.tu_ngay).endOf("date").toDate():$ngay$$,$ngay_dn$$=moment($ngay_tinh_dn$$).startOf("year").toDate(),$nam$$,$cdvt$$;!$ngay_ks$$||$ngay_ks$$<$ngay_dn$$?($cdvt$$=global.getModel("cdvt"),$nam$$=$ngay_tinh_dn$$.getFullYear()):($cdvt$$=global.getModel("cdvttheongay"),$ngay_dn$$=moment($ngay_ks$$).startOf("date").add(1,"days").toDate());return new Promise(($resolve$$,$reject$$)=>{async.parallel({ckcapphat:$callback$$=>{setImmediate(()=>{ckvtcapphat($condition$$,
5
+ ($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)})})},dn:$callback$$=>{setImmediate(()=>{const $c_dk$$={id_app:$id_app$$};$nam$$?$c_dk$$.nam=$nam$$:(console.log("lay cdvt theo ngay khoa so",$ngay_ks$$),$c_dk$$.den_ngay=$ngay_ks$$);$ma_kho$$&&($c_dk$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($c_dk$$.ma_dvcs=$ma_dvcs$$);$ma_vt$$&&($c_dk$$.ma_vt=$ma_vt$$);$condition$$.ma_lo&&($c_dk$$.ma_lo=$condition$$.ma_lo);$condition$$.han_sd&&($c_dk$$.han_sd=$condition$$.han_sd);$condition$$.ma_tt1&&($c_dk$$.ma_tt1=$condition$$.ma_tt1);
6
+ $condition$$.ma_tt2&&($c_dk$$.ma_tt2=$condition$$.ma_tt2);$condition$$.ma_tt3&&($c_dk$$.ma_tt3=$condition$$.ma_tt3);$cdvt$$.find($c_dk$$).lean().then($results$$=>{$callback$$(null,$results$$)}).catch($error$$=>{$callback$$($error$$)})})},hanmucton:$callback$$=>{setImmediate(()=>{const $c_dk$$={id_app:$id_app$$};$ma_kho$$&&($c_dk$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($c_dk$$.ma_dvcs=$ma_dvcs$$);$ma_vt$$&&($c_dk$$.ma_vt=$ma_vt$$);$condition$$.ma_lo&&($c_dk$$.ma_lo=$condition$$.ma_lo);$condition$$.han_sd&&
7
+ ($c_dk$$.han_sd=$condition$$.han_sd);$condition$$.ma_tt1&&($c_dk$$.ma_tt1=$condition$$.ma_tt1);$condition$$.ma_tt2&&($c_dk$$.ma_tt2=$condition$$.ma_tt2);$condition$$.ma_tt3&&($c_dk$$.ma_tt3=$condition$$.ma_tt3);hanmucton.find($c_dk$$).lean().then($results$$=>{$callback$$(null,$results$$)}).catch($error$$=>{$callback$$($error$$)})})},ps:$callback$$=>{setImmediate(()=>{const $query$$={id_app:$id_app$$,ngay_ct:{$gte:$ngay_dn$$,$lte:$ngay$$}};$ma_kho$$&&($query$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($query$$.ma_dvcs=
8
+ $ma_dvcs$$);$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$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$$.id_ct&&($query$$.id_ct={$ne:$condition$$.id_ct});sokho.find($query$$,{ma_vt:1,ma_kho:1,ma_tt1:1,ma_tt2:1,ma_tt3:1,sl_nhap:1,sl_xuat:1,sl_nhap_qd:1,sl_xuat_qd:1,
9
+ tien_nhap:1,tien_xuat:1}).inTxn().lean().then($pss$$=>{$pss$$=$pss$$.map($ps$$=>{$ps$$.sl_nhap=utils.round($ps$$.sl_nhap_qd,4);$ps$$.sl_xuat=utils.round($ps$$.sl_xuat_qd,4);return $ps$$});$callback$$(null,$pss$$)}).catch($error$$=>{$callback$$($error$$)})})},ton_kho_mac_dinh:$callback$$=>{setImmediate(()=>{let $query$$={id_app:$id_app$$,ton_kho_mac_dinh:{$nin:[null,void 0,0]}};$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);dmvt.find($query$$,{ma_vt:1,ton_kho_mac_dinh:1}).lean().then($rs$$=>{$callback$$(null,
10
+ $rs$$)}).catch($error$$=>{console.error($error$$)})})}},($ckcapphat_error$$,$data_results$$)=>{if($ckcapphat_error$$)return $fn$$($ckcapphat_error$$),$reject$$(Error($ckcapphat_error$$));$ckcapphat_error$$=$data_results$$.ckcapphat.map($c$$=>{$c$$.ton00_capphat=$c$$.ton00;$c$$.du00_capphat=$c$$.du00;$c$$.ton00=0;$c$$.du00=0;return $c$$});$data_results$$=$data_results$$.dn.concat($data_results$$.ps).concat($ckcapphat_error$$).concat($data_results$$.ton_kho_mac_dinh).concat($data_results$$.hanmucton);
11
+ ($ckcapphat_error$$=$condition$$.groupBy||$condition$$.groupby)||($ckcapphat_error$$=["ma_vt"]);if(_.isString($ckcapphat_error$$))if($ckcapphat_error$$.indexOf("[")>=0)try{$ckcapphat_error$$=JSON.parse($ckcapphat_error$$)}catch($e$$){console.error($e$$)}else $ckcapphat_error$$=$ckcapphat_error$$.split(",");$data_results$$.groupBy($ckcapphat_error$$,"sl_nhap sl_xuat ton00 du00 ton00_capphat du00_capphat tien_nhap tien_xuat ton_kho_mac_dinh ton_toi_thieu ton_toi_da".split(" "),($e$$,$groups$$)=>{if($e$$)return $fn$$($e$$),
12
+ $reject$$(Error($e$$));setImmediate(()=>{for(let $r$$ of $groups$$)$r$$.ton00=utils.round($r$$.ton00+$r$$.sl_nhap-$r$$.sl_xuat,4),$r$$.du00=Math.roundBy($r$$.du00,0)+Math.roundBy($r$$.tien_nhap,0)-Math.roundBy($r$$.tien_xuat,0),$r$$.sl_nhap=0,$r$$.sl_xuat=0,$r$$.tien_nhap=0,$r$$.tien_xuat=0,$r$$.ton=$r$$.ton00-($r$$.ton00_capphat>0?$r$$.ton00_capphat:0),$r$$.du=$r$$.du00-($r$$.du00_capphat>0?$r$$.du00_capphat:0);$fn$$(null,$groups$$);$resolve$$($groups$$)})})})})};
@@ -1,6 +1,6 @@
1
1
  const sokhocapphat=global.getModel("sokhocapphat"),utils=require("./utils"),async=require("async"),underscore=require("underscore"),moment=require("moment");
2
2
  module.exports=function($condition$$,$fn$$){!$condition$$.ngay&&$condition$$.den_ngay&&($condition$$.ngay=$condition$$.den_ngay);let $ma_dvcs$$=$condition$$.ma_dvcs,$ma_kho$$=$condition$$.ma_kho,$ma_vt$$=$condition$$.ma_vt;$ma_vt$$&&underscore.isArray($ma_vt$$)&&($ma_vt$$={$in:Object.assign($ma_vt$$)});let $ngay$$=moment($condition$$.ngay).endOf("date").toDate(),$id_app$$=$condition$$.id_app;async.series({dn:$callback$$=>{$callback$$(null,[])},ps:$callback$$=>{const $query$$={id_app:$id_app$$,ngay_ct:{$lte:$ngay$$}};
3
- $ma_kho$$&&($query$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($query$$.ma_dvcs=$ma_dvcs$$);$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$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$$.id_ct&&($query$$.id_ct={$ne:$condition$$.id_ct});sokhocapphat.find($query$$).lean().then(function($pss$$){$pss$$=
3
+ $ma_kho$$&&($query$$.ma_kho=$ma_kho$$);$ma_dvcs$$&&($query$$.ma_dvcs=$ma_dvcs$$);$ma_vt$$&&($query$$.ma_vt=$ma_vt$$);$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$$.id_ct&&($query$$.id_ct={$ne:$condition$$.id_ct});sokhocapphat.find($query$$).inTxn().lean().then(function($pss$$){$pss$$=
4
4
  $pss$$.map($ps$$=>{$ps$$.sl_nhap=utils.round($ps$$.sl_nhap_qd,4);$ps$$.sl_xuat=utils.round($ps$$.sl_xuat_qd,4);return $ps$$});$callback$$(null,$pss$$)}).catch($error$$=>{$callback$$($error$$)})}},($data_error$$,$groupBy_results$$)=>{if($data_error$$)$fn$$($data_error$$);else{$data_error$$=$groupBy_results$$.dn.concat($groupBy_results$$.ps);($groupBy_results$$=$condition$$.groupBy)||($groupBy_results$$=["ma_vt"]);if(underscore.isString($groupBy_results$$))if($groupBy_results$$.indexOf("[")>=0)try{$groupBy_results$$=
5
5
  JSON.parse($groupBy_results$$)}catch($e$$){console.error($e$$)}else $groupBy_results$$=$groupBy_results$$.split(",");$data_error$$.groupBy($groupBy_results$$,"sl_nhap sl_xuat ton00 du00 tien_nhap tien_xuat".split(" "),($e$$,$groups$$)=>{if($e$$)return $fn$$($e$$);for(let $r$$ of $groups$$)$r$$.ton00=utils.round($r$$.ton00+$r$$.sl_nhap-$r$$.sl_xuat,4),$r$$.du00=Math.roundBy($r$$.du00,0)+Math.roundBy($r$$.tien_nhap,0)-Math.roundBy($r$$.tien_xuat,0),$r$$.sl_nhap=0,$r$$.sl_xuat=0,$r$$.tien_nhap=0,$r$$.tien_xuat=
6
6
  0;$fn$$(null,$groups$$)})}})};
@@ -8,16 +8,16 @@ $resolve$$($details$$)})};
8
8
  post.prototype.remove=function($callback$$=()=>{}){let $master$$=this.master;$master$$&&$master$$.toObject&&($master$$=$master$$.toObject());if(!$master$$._id)return $callback$$();let $query_delete$$={id_ct:$master$$._id.toString(),id_app:$master$$.id_app};this.options.queryDelete&&($query_delete$$={...$query_delete$$,...this.options.queryDelete,id_app:$master$$.id_app});async.series({sks:$callback$$=>{setImmediate(()=>{global.getModel("sokho").find({id_ct:$master$$._id.toString()}).lean().then(function($sks$$){$callback$$(null,$sks$$)}).catch($e$$=>
9
9
  {$callback$$($e$$)})})}},async($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);await global.getModel("sokho").deleteMany($query_delete$$);await global.getModel("sokhonpp").deleteMany($query_delete$$);await global.getModel("sokhokhongton").deleteMany($query_delete$$);$rs$$.sks.length>0&&tontucthoi.tinhTonTucThoi($rs$$.sks,$e$$=>{$e$$&&console.error("[post-sokho] T\u00ednh t\u1ed3n t\u1ee9c th\u1eddi sau khi xo\u00e1 sokho c\u1ee7a v\u1eadt t\u01b0",$e$$)});$callback$$()})};
10
10
  post.prototype.run=async function($callback$$=()=>{}){if(!this.details)return console.error("details not exists"),$callback$$(null);if(!this.master||!this.master._id)return console.error("masters not exists",this.master),$callback$$(null);let $master$$=this.master;$master$$.toObject&&($master$$=$master$$.toObject());let $details$$=await this.runPrepare(this.prepare,this.details);await $details$$.asyncJoinModel2($master$$.id_app,Dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.tk_vt||($item$$.tk_vt=
11
- $ref$$.tk_vt);$item$$.tk_gv||($item$$.tk_gv=$ref$$.tk_gv);$item$$.tg_tk=$ref$$.tg_tk;$item$$.xk_nvl=$ref$$.xk_nvl}});if(($master$$.ma_ct||"").toUpperCase()!=="PKK"){var $ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=[...(new Set($details$$.map($d$$=>$d$$.ma_kho||$master$$.ma_kho)))];if($ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=await global.getModel("dmkho").findOne({id_app:$master$$.id_app,lock:!0,ma_kho:{$in:$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$}}).lean())return $callback$$(`Kho ${$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.ten_kho} \u0111\u00e3 b\u1ecb kho\u00e1`)}$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=
12
- $details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.nxt==2);for(var $i$jscomp$1_i$$=0;$i$jscomp$1_i$$<$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.length;$i$jscomp$1_i$$++)$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].dinh_muc_nvl=await dinhmucsx($master$$.id_app,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_vt,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_tt1,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].sl_xuat,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_dvt);
13
- $details$$=$details$$.filter($d$$=>$d$$.tg_tk||$d$$.dinh_muc_nvl&&$d$$.dinh_muc_nvl.length>0);$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=$details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.dinh_muc_nvl&&$p$$.dinh_muc_nvl.length>0);for($i$jscomp$1_i$$=0;$i$jscomp$1_i$$<$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.length;$i$jscomp$1_i$$++){const $p$$=$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$];let $he_so_qd$$=1,$qd$$=await global.getModel("dmqddvt").findOne({id_app:$master$$.id_app,
14
- ma_vt:$p$$.ma_vt,ma_dvt:$p$$.ma_dvt}).lean();$qd$$&&($he_so_qd$$=$qd$$.mau?$qd$$.tu/$qd$$.mau:$qd$$.ty_le_qd);let $sl_sp$$=$p$$.sl_xuat*$he_so_qd$$;$p$$.dinh_muc_nvl=$p$$.dinh_muc_nvl.map($d$$=>{$d$$.nxt=$p$$.nxt;$d$$.ma_sp=$p$$.ma_vt;$d$$.sl_sp=$sl_sp$$;$d$$.ma_tt1_sp=$p$$.ma_tt1;$d$$.ma_tt2_sp=$p$$.ma_tt2;$d$$.ma_tt3_sp=$p$$.ma_tt3;$d$$.ma_kho=$p$$.ma_kho;return $d$$});$p$$.dinh_muc_nvl=$p$$.dinh_muc_nvl.filter($p$$=>$p$$.tg_tk)}$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=$details$$.filter($p$$=>
15
- !$p$$.xk_nvl||!$p$$.dinh_muc_nvl||$p$$.dinh_muc_nvl.length===0);$i$jscomp$1_i$$=$details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.dinh_muc_nvl&&$p$$.dinh_muc_nvl.length>0).map($p$$=>$p$$.dinh_muc_nvl).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$details$$=[...$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$,...$i$jscomp$1_i$$];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$$=>
16
- {$detail$$.ma_kho=$detail$$.ma_kho||$master$$.ma_kho;$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=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,
17
- round))});let $nam$$=(new Date($master$$.ngay_ct)).getFullYear(),$thang$$=(new Date($master$$.ngay_ct)).getMonth()+1;await new Promise($rs$$=>{async.map($details$$.filter($p$$=>$p$$.tg_tk&&($p$$.sl_xuat&&!$p$$.px_gia_dd||$p$$.sl_nhap&&$p$$.pn_gia_tb)&&$p$$.sl_xuat),($p$$,$callback$$)=>{setImmediate(async()=>{let $he_so_qd$$=1;var $giatb_qd$$=await global.getModel("dmqddvt").findOne({id_app:$master$$.id_app,ma_vt:$p$$.ma_vt,ma_dvt:$p$$.ma_dvt}).lean();$giatb_qd$$&&($he_so_qd$$=$giatb_qd$$.mau?$giatb_qd$$.tu/
18
- $giatb_qd$$.mau:$giatb_qd$$.ty_le_qd);$giatb_qd$$={ma_vt:$p$$.ma_vt,nam:$nam$$,thang:$thang$$,ma_kho:{$in:[$p$$.ma_kho,"",null]}};if($giatb_qd$$=await global.getModel("giatb").findOne($giatb_qd$$).sort({ma_kho:-1}).lean())$p$$.gia_von_nt=$p$$.gia_von=($giatb_qd$$.gia||0)*$he_so_qd$$,$p$$.tien_xuat_nt=$p$$.tien_xuat=($p$$.sl_xuat||0)*$p$$.gia_von_nt,$p$$.tien_nhap_nt=$p$$.tien_nhap=($p$$.sl_nhap||0)*$p$$.gia_von_nt,$callback$$();else{let $condition$$={id_app:$master$$.id_app,ma_vt:$p$$.ma_vt,ma_kho:$p$$.ma_kho};
19
- $condition$$.tu_ngay=moment($master$$.ngay_ct).startOf("month").toDate();$condition$$.den_ngay=moment($master$$.ngay_ct).endOf("month").toDate();tinhgiatb($condition$$,($e$$,$giatb$$)=>{$e$$&&console.error("[postSokho] Kh\u00f4ng th\u1ec3 t\u00ednh gi\u00e1 trung b\u00ecnh",$e$$.message||$e$$.error||$e$$,$condition$$);$p$$.gia_von_nt=$rs$$?$p$$.gia_von=($giatb$$.gia||0)*$he_so_qd$$:$p$$.gia_von=0;$p$$.tien_xuat_nt=$p$$.tien_xuat=($p$$.sl_xuat||0)*$p$$.gia_von_nt;$p$$.tien_nhap_nt=$p$$.tien_nhap=($p$$.sl_nhap||
20
- 0)*$p$$.gia_von_nt;$callback$$()})}})},()=>{$rs$$()})});$details$$=$details$$.map(($detail$$,$line$$)=>{$detail$$.id_ct=$master$$._id.toString();$detail$$.ma_ct=$master$$.ma_ct;$detail$$.so_ct=$master$$.so_ct;$detail$$.ngay_ct=$master$$.ngay_ct;for(let $attr$$ in global.getModel("sokho").schema.paths)if($attr$$!="id_ct"&&$attr$$!="_id"&&$attr$$!="__v"&&$attr$$!="date_updated"&&$attr$$!="date_created"){let $v$$=$detail$$[$attr$$];$v$$!==void 0&&$v$$!==null&&$v$$!==""||$v$$===0||$master$$[$attr$$]===
21
- void 0||($detail$$[$attr$$]=$master$$[$attr$$])}$detail$$.line=$line$$;delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});await $details$$.asyncJoinModel2($master$$.id_app,"dmkho",{where:"ma_kho",fields:"la_kho_npp"});this.remove(async $error$$=>{if($error$$)return console.error("[postSokho] error delete data post",$error$$.message||$error$$.error||$error$$,$master$$.so_ct,$master$$.ma_ct),$callback$$($error$$);if($details$$.length==0)return $callback$$(null,[]);
22
- try{let $data_sokho$$=$details$$.filter($d$$=>$d$$.tg_tk&&!$d$$.la_kho_npp),$rs_sokho$$=await global.getModel("sokho").create($data_sokho$$),$data_sokhonpp$$=$details$$.filter($d$$=>$d$$.tg_tk&&$d$$.la_kho_npp),$rs_sokhnpp$$=await global.getModel("sokhonpp").create($data_sokhonpp$$),$data_sokhokhongton$$=$details$$.filter($d$$=>$d$$.tg_tk==0),$rs_sokhokhongton$$=await global.getModel("sokhokhongton").create($data_sokhokhongton$$);$callback$$(null,{rs_sokho:$rs_sokho$$,rs_sokhnpp:$rs_sokhnpp$$,rs_sokhokhongton:$rs_sokhokhongton$$});
23
- $rs_sokho$$&&setImmediate(()=>{tontucthoi.tinhTonTucThoi($rs_sokho$$,$e$$=>{$e$$&&console.error("L\u1ed7i t\u00ednh t\u1ed3n t\u1ee9c th\u1eddi v\u1eadt t\u01b0",$rs_sokho$$,$e$$.message||$e$$.error||$e$$,$master$$.so_ct,$master$$.ma_ct)})})}catch($e$$){console.error("[postSokho] \u0110\u00e3 c\u00f3 l\u1ed7i khi post sokho",$e$$),$callback$$($e$$)}})};module.exports=post;
11
+ $ref$$.tk_vt);$item$$.tk_gv||($item$$.tk_gv=$ref$$.tk_gv);$item$$.tg_tk=$ref$$.tg_tk;$item$$.xk_nvl=$ref$$.xk_nvl}});if(($master$$.ma_ct||"").toUpperCase()!=="PKK"){var $ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=[...(new Set($details$$.map($d$$=>$d$$.ma_kho||$master$$.ma_kho)))];if($ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=await global.getModel("dmkho").findOne({id_app:$master$$.id_app,lock:!0,ma_kho:{$in:$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$}}).lean())return $callback$$(`Kho ${$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.ten_kho} \u0111\u00e3 b\u1ecb kho\u00e1`)}if(["HD2",
12
+ "SO1","PBL"].indexOf($master$$.ma_ct)>=0){$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=$details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.nxt==2);for(var $i$jscomp$1_i$$=0;$i$jscomp$1_i$$<$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.length;$i$jscomp$1_i$$++)$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].dinh_muc_nvl=await dinhmucsx($master$$.id_app,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_vt,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_tt1,
13
+ $ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].sl_xuat,$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$].ma_dvt)}$details$$=$details$$.filter($d$$=>$d$$.tg_tk||$d$$.dinh_muc_nvl&&$d$$.dinh_muc_nvl.length>0);$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=$details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.dinh_muc_nvl&&$p$$.dinh_muc_nvl.length>0);for($i$jscomp$1_i$$=0;$i$jscomp$1_i$$<$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$.length;$i$jscomp$1_i$$++){const $p$$=$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$[$i$jscomp$1_i$$];
14
+ let $he_so_qd$$=1,$qd$$=await global.getModel("dmqddvt").findOne({id_app:$master$$.id_app,ma_vt:$p$$.ma_vt,ma_dvt:$p$$.ma_dvt}).lean();$qd$$&&($he_so_qd$$=$qd$$.mau?$qd$$.tu/$qd$$.mau:$qd$$.ty_le_qd);let $sl_sp$$=$p$$.sl_xuat*$he_so_qd$$;$p$$.dinh_muc_nvl=$p$$.dinh_muc_nvl.map($d$$=>{$d$$.nxt=$p$$.nxt;$d$$.ma_sp=$p$$.ma_vt;$d$$.sl_sp=$sl_sp$$;$d$$.ma_tt1_sp=$p$$.ma_tt1;$d$$.ma_tt2_sp=$p$$.ma_tt2;$d$$.ma_tt3_sp=$p$$.ma_tt3;$d$$.ma_kho=$p$$.ma_kho;return $d$$});$p$$.dinh_muc_nvl=$p$$.dinh_muc_nvl.filter($p$$=>
15
+ $p$$.tg_tk)}$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$=$details$$.filter($p$$=>!$p$$.xk_nvl||!$p$$.dinh_muc_nvl||$p$$.dinh_muc_nvl.length===0);$i$jscomp$1_i$$=$details$$.filter($p$$=>$p$$.xk_nvl&&$p$$.dinh_muc_nvl&&$p$$.dinh_muc_nvl.length>0).map($p$$=>$p$$.dinh_muc_nvl).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$details$$=[...$ds_kho_kho_locked_ps_kg_dm_sp_co_dm_sp_xk_nvl$$,...$i$jscomp$1_i$$];await $details$$.asyncJoinModel2($master$$.id_app,global.getModel("dmqddvt"),{where:{ma_vt:"ma_vt",
16
+ ma_dvt:"ma_dvt"},fields:["tu","mau",{he_so_qd:"ty_le_qd"}]});$details$$.forEach($detail$$=>{$detail$$.ma_kho=$detail$$.ma_kho||$master$$.ma_kho;$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=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,
17
+ round),$detail$$.sl_nhap_qd=utils.round(($detail$$.sl_nhap||0)*$detail$$.he_so_qd,round))});let $nam$$=(new Date($master$$.ngay_ct)).getFullYear(),$thang$$=(new Date($master$$.ngay_ct)).getMonth()+1;await new Promise($rs$$=>{async.map($details$$.filter($p$$=>$p$$.tg_tk&&($p$$.sl_xuat&&!$p$$.px_gia_dd||$p$$.sl_nhap&&$p$$.pn_gia_tb)&&$p$$.sl_xuat),($p$$,$callback$$)=>{setImmediate(async()=>{let $he_so_qd$$=1;var $giatb_qd$$=await global.getModel("dmqddvt").findOne({id_app:$master$$.id_app,ma_vt:$p$$.ma_vt,
18
+ ma_dvt:$p$$.ma_dvt}).lean();$giatb_qd$$&&($he_so_qd$$=$giatb_qd$$.mau?$giatb_qd$$.tu/$giatb_qd$$.mau:$giatb_qd$$.ty_le_qd);$giatb_qd$$={ma_vt:$p$$.ma_vt,nam:$nam$$,thang:$thang$$,ma_kho:{$in:[$p$$.ma_kho,"",null]}};if($giatb_qd$$=await global.getModel("giatb").findOne($giatb_qd$$).sort({ma_kho:-1}).lean())$p$$.gia_von_nt=$p$$.gia_von=($giatb_qd$$.gia||0)*$he_so_qd$$,$p$$.tien_xuat_nt=$p$$.tien_xuat=($p$$.sl_xuat||0)*$p$$.gia_von_nt,$p$$.tien_nhap_nt=$p$$.tien_nhap=($p$$.sl_nhap||0)*$p$$.gia_von_nt,
19
+ $callback$$();else{let $condition$$={id_app:$master$$.id_app,ma_vt:$p$$.ma_vt,ma_kho:$p$$.ma_kho};$condition$$.tu_ngay=moment($master$$.ngay_ct).startOf("month").toDate();$condition$$.den_ngay=moment($master$$.ngay_ct).endOf("month").toDate();tinhgiatb($condition$$,($e$$,$giatb$$)=>{$e$$&&console.error("[postSokho] Kh\u00f4ng th\u1ec3 t\u00ednh gi\u00e1 trung b\u00ecnh",$e$$.message||$e$$.error||$e$$,$condition$$);$p$$.gia_von_nt=$rs$$?$p$$.gia_von=($giatb$$.gia||0)*$he_so_qd$$:$p$$.gia_von=0;$p$$.tien_xuat_nt=
20
+ $p$$.tien_xuat=($p$$.sl_xuat||0)*$p$$.gia_von_nt;$p$$.tien_nhap_nt=$p$$.tien_nhap=($p$$.sl_nhap||0)*$p$$.gia_von_nt;$callback$$()})}})},()=>{$rs$$()})});$details$$=$details$$.map(($detail$$,$line$$)=>{$detail$$.id_ct=$master$$._id.toString();$detail$$.ma_ct=$master$$.ma_ct;$detail$$.so_ct=$master$$.so_ct;$detail$$.ngay_ct=$master$$.ngay_ct;for(let $attr$$ in global.getModel("sokho").schema.paths)if($attr$$!="id_ct"&&$attr$$!="_id"&&$attr$$!="__v"&&$attr$$!="date_updated"&&$attr$$!="date_created"){let $v$$=
21
+ $detail$$[$attr$$];$v$$!==void 0&&$v$$!==null&&$v$$!==""||$v$$===0||$master$$[$attr$$]===void 0||($detail$$[$attr$$]=$master$$[$attr$$])}$detail$$.line=$line$$;delete $detail$$.toObject;delete $detail$$._id;delete $detail$$.__v;return $detail$$});await $details$$.asyncJoinModel2($master$$.id_app,"dmkho",{where:"ma_kho",fields:"la_kho_npp"});this.remove(async $error$$=>{if($error$$)return console.error("[postSokho] error delete data post",$error$$.message||$error$$.error||$error$$,$master$$.so_ct,
22
+ $master$$.ma_ct),$callback$$($error$$);if($details$$.length==0)return $callback$$(null,[]);try{let $data_sokho$$=$details$$.filter($d$$=>$d$$.tg_tk&&!$d$$.la_kho_npp),$rs_sokho$$=await global.getModel("sokho").create($data_sokho$$),$data_sokhonpp$$=$details$$.filter($d$$=>$d$$.tg_tk&&$d$$.la_kho_npp),$rs_sokhnpp$$=await global.getModel("sokhonpp").create($data_sokhonpp$$),$data_sokhokhongton$$=$details$$.filter($d$$=>$d$$.tg_tk==0),$rs_sokhokhongton$$=await global.getModel("sokhokhongton").create($data_sokhokhongton$$);
23
+ $callback$$(null,{rs_sokho:$rs_sokho$$,rs_sokhnpp:$rs_sokhnpp$$,rs_sokhokhongton:$rs_sokhokhongton$$});$rs_sokho$$&&setImmediate(()=>{tontucthoi.tinhTonTucThoi($rs_sokho$$,$e$$=>{$e$$&&console.error("L\u1ed7i t\u00ednh t\u1ed3n t\u1ee9c th\u1eddi v\u1eadt t\u01b0",$rs_sokho$$,$e$$.message||$e$$.error||$e$$,$master$$.so_ct,$master$$.ma_ct)})})}catch($e$$){console.error("[postSokho] \u0110\u00e3 c\u00f3 l\u1ed7i khi post sokho",$e$$),$callback$$($e$$)}})};module.exports=post;