flexbiz-server 12.7.1 → 12.7.2
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 +5 -5
- package/server/app.js +23 -348
- package/server/cluster.js +1 -5
- package/server/models/account.js +7 -0
- package/server/models/actionLog.js +2 -0
- package/server/models/afflink.js +2 -0
- package/server/models/aimemory.js +1 -0
- package/server/models/app.js +16 -0
- package/server/models/approve.js +95 -0
- package/server/models/assabcihandler.js +35 -0
- package/server/models/assbank.js +19 -0
- package/server/models/assbooking.js +4 -0
- package/server/models/assbuy.js +3 -0
- package/server/models/asscashwithdraw.js +4 -0
- package/server/models/assfindhash.js +2 -0
- package/server/models/assinvestment.js +13 -0
- package/server/models/assissue.js +2 -0
- package/server/models/asskey.js +15 -0
- package/server/models/assneedtobuy.js +6 -0
- package/server/models/assperiod.js +7 -0
- package/server/models/assproduct.js +13 -0
- package/server/models/assprofitsharing.js +4 -0
- package/server/models/assreceiver.js +2 -0
- package/server/models/assrequest.js +10 -0
- package/server/models/asssell.js +7 -0
- package/server/models/asstransaction.js +3 -0
- package/server/models/asstransfer.js +4 -0
- package/server/models/assuser_identity.js +4 -0
- package/server/models/asswithdraw.js +4 -0
- package/server/models/attend.js +2 -0
- package/server/models/banggiaban.js +8 -0
- package/server/models/bangtinhluong.js +6 -0
- package/server/models/base.js +1 -0
- package/server/models/bg1.js +9 -0
- package/server/models/bg2.js +10 -0
- package/server/models/cache.js +3 -0
- package/server/models/cacheDataReport.js +2 -0
- package/server/models/cacheSessionReport.js +5 -0
- package/server/models/calllog.js +4 -0
- package/server/models/cart.js +5 -0
- package/server/models/cddiem.js +2 -0
- package/server/models/cddt.js +3 -0
- package/server/models/cdkh.js +5 -0
- package/server/models/cdkhtheongay.js +5 -0
- package/server/models/cdnphep.js +2 -0
- package/server/models/cdtk.js +3 -0
- package/server/models/cdtktheongay.js +3 -0
- package/server/models/cdvt.js +5 -0
- package/server/models/cdvtnpp.js +6 -0
- package/server/models/cdvttheongay.js +5 -0
- package/server/models/chamcong.js +7 -0
- package/server/models/chat_message.js +2 -0
- package/server/models/chat_session.js +2 -0
- package/server/models/checkin.js +4 -0
- package/server/models/checkinactivity.js +3 -0
- package/server/models/checkinkpi.js +4 -0
- package/server/models/checkinlocation.js +2 -0
- package/server/models/chitietluongds.js +12 -0
- package/server/models/chitieukpi.js +3 -0
- package/server/models/chudethaoluan.js +3 -0
- package/server/models/ckgtluong.js +2 -0
- package/server/models/colleague.js +2 -0
- package/server/models/comment.js +4 -0
- package/server/models/congdoansx.js +4 -0
- package/server/models/congtacvien.js +4 -0
- package/server/models/congthuctinhgiaban.js +8 -0
- package/server/models/consultant.js +4 -0
- package/server/models/contract.js +6 -0
- package/server/models/counter.js +2 -0
- package/server/models/csluongtheods.js +3 -0
- package/server/models/csphucap.js +2 -0
- package/server/models/ctds.js +5 -0
- package/server/models/ctds2.js +7 -0
- package/server/models/currency.js +3 -0
- package/server/models/custom_report.js +1 -0
- package/server/models/customer.js +31 -0
- package/server/models/customer_care.js +2 -0
- package/server/models/data_list_config.js +7 -0
- package/server/models/databanle.js +8 -0
- package/server/models/datlich.js +4 -0
- package/server/models/deal.js +2 -0
- package/server/models/dh2.js +20 -0
- package/server/models/diagram.js +2 -0
- package/server/models/dinhmucsx.js +8 -0
- package/server/models/dkhoc.js +6 -0
- package/server/models/dknphep.js +2 -0
- package/server/models/dmban.js +4 -0
- package/server/models/dmbp.js +12 -0
- package/server/models/dmca.js +2 -0
- package/server/models/dmchietkhau.js +8 -0
- package/server/models/dmchietkhauhd.js +19 -0
- package/server/models/dmchinhanh.js +2 -0
- package/server/models/dmcpmh.js +2 -0
- package/server/models/dmdiemthuong.js +3 -0
- package/server/models/dmdoi.js +4 -0
- package/server/models/dmdoituongdanhgia.js +2 -0
- package/server/models/dmdt.js +8 -0
- package/server/models/dmdvt.js +3 -0
- package/server/models/dmgiaban.js +9 -0
- package/server/models/dmgiamua.js +5 -0
- package/server/models/dmgiathitruong.js +5 -0
- package/server/models/dmgiathitruong_ngay.js +2 -0
- package/server/models/dmgiathitruong_theodoi.js +2 -0
- package/server/models/dmhoahonghd.js +8 -0
- package/server/models/dmhoahongnpp.js +8 -0
- package/server/models/dmkc.js +3 -0
- package/server/models/dmkho.js +7 -0
- package/server/models/dmkhuyenmai.js +9 -0
- package/server/models/dmkhuyenmaihd.js +11 -0
- package/server/models/dmletet.js +2 -0
- package/server/models/dmlo.js +4 -0
- package/server/models/dmloaicong.js +4 -0
- package/server/models/dmloaitask.js +2 -0
- package/server/models/dmloaits.js +2 -0
- package/server/models/dmnckkm.js +4 -0
- package/server/models/dmnghiepvu.js +4 -0
- package/server/models/dmnguonvon.js +2 -0
- package/server/models/dmnhnv.js +4 -0
- package/server/models/dmnv.js +17 -0
- package/server/models/dmnvt.js +10 -0
- package/server/models/dmphi.js +3 -0
- package/server/models/dmqct.js +3 -0
- package/server/models/dmqddvt.js +3 -0
- package/server/models/dmtanggiamts.js +3 -0
- package/server/models/dmto.js +4 -0
- package/server/models/dmtt.js +6 -0
- package/server/models/dmvt.js +17 -0
- package/server/models/dmyt.js +4 -0
- package/server/models/dn0.js +13 -0
- package/server/models/dnm.js +11 -0
- package/server/models/dokho.js +2 -0
- package/server/models/domain.js +2 -0
- package/server/models/dvcs.js +3 -0
- package/server/models/ecomcategories.js +3 -0
- package/server/models/ecomcategories_cty.js +3 -0
- package/server/models/ecomproductlines.js +2 -0
- package/server/models/ecompromotion_flashsales.js +2 -0
- package/server/models/ecompromotion_freeships.js +2 -0
- package/server/models/email.js +2 -0
- package/server/models/endpoint.js +1 -0
- package/server/models/events.js +3 -0
- package/server/models/evoucher.js +5 -0
- package/server/models/experiencejourney.js +2 -0
- package/server/models/experiencejourneydata.js +4 -0
- package/server/models/experiencejourneypersona.js +3 -0
- package/server/models/experiencejourneystage.js +2 -0
- package/server/models/exportexceltemplate.js +2 -0
- package/server/models/fbconversation.js +15 -0
- package/server/models/fbmessage.js +2 -0
- package/server/models/fbpage.js +2 -0
- package/server/models/fbpost.js +2 -0
- package/server/models/fieldright.js +2 -0
- package/server/models/fifo_dk.js +2 -0
- package/server/models/fifo_lot.js +3 -0
- package/server/models/fifo_trace.js +4 -0
- package/server/models/file.js +4 -0
- package/server/models/filechunk.js +2 -0
- package/server/models/financialroadmap.js +3 -0
- package/server/models/flow.js +2 -0
- package/server/models/flowdata.js +3 -0
- package/server/models/flowpending.js +2 -0
- package/server/models/folder.js +4 -0
- package/server/models/follow.js +2 -0
- package/server/models/forminfo.js +5 -0
- package/server/models/giaoca.js +4 -0
- package/server/models/giatb.js +3 -0
- package/server/models/group.js +9 -0
- package/server/models/gt_ctgt.js +4 -0
- package/server/models/gt_hspb.js +3 -0
- package/server/models/gt_sltk.js +3 -0
- package/server/models/gt_thcppstk.js +3 -0
- package/server/models/hanmucton.js +4 -0
- package/server/models/hd1.js +11 -0
- package/server/models/hd2.js +26 -0
- package/server/models/hd3.js +17 -0
- package/server/models/hd4.js +13 -0
- package/server/models/hd7.js +17 -0
- package/server/models/hd8.js +12 -0
- package/server/models/hde.js +11 -0
- package/server/models/hmcn.js +3 -0
- package/server/models/hmcnct.js +2 -0
- package/server/models/hspbts.js +4 -0
- package/server/models/htl.js +13 -0
- package/server/models/importexceltemplate.js +2 -0
- package/server/models/introducebonus.js +4 -0
- package/server/models/introducecode.js +3 -0
- package/server/models/introducer.js +4 -0
- package/server/models/kbbtpb.js +7 -0
- package/server/models/kbmPttct.js +4 -0
- package/server/models/kbmTkgtgt.js +5 -0
- package/server/models/kbm_bcdkt_old.js +4 -0
- package/server/models/kbm_kqhdkd_old.js +3 -0
- package/server/models/kbm_lcttgt_old.js +5 -0
- package/server/models/kbm_lctttt_old.js +4 -0
- package/server/models/kbm_pttct_old.js +4 -0
- package/server/models/kbm_tkgtgt_old.js +5 -0
- package/server/models/kbmbcdkt.js +4 -0
- package/server/models/kbmbcqt.js +4 -0
- package/server/models/kbmkqhdkd.js +3 -0
- package/server/models/kbmlcttgt.js +6 -0
- package/server/models/kbmlctttt.js +4 -0
- package/server/models/kbmtmbctc.js +4 -0
- package/server/models/kehoachdtcp.js +3 -0
- package/server/models/kehoachmh.js +8 -0
- package/server/models/keyresult.js +7 -0
- package/server/models/khunghangthanhvien.js +3 -0
- package/server/models/label.js +2 -0
- package/server/models/labelinfo.js +2 -0
- package/server/models/lenhcapphat.js +8 -0
- package/server/models/lenhsx.js +8 -0
- package/server/models/lienhe.js +4 -0
- package/server/models/like_module.js +2 -0
- package/server/models/link.js +2 -0
- package/server/models/listinfo.js +1365 -0
- package/server/models/loaidiem.js +2 -0
- package/server/models/lock.js +2 -0
- package/server/models/log.js +8 -0
- package/server/models/mailaccount.js +3 -0
- package/server/models/mailgroup.js +3 -0
- package/server/models/mailreceived.js +2 -0
- package/server/models/mailsent.js +2 -0
- package/server/models/mailtemplate.js +2 -0
- package/server/models/maudanhgia.js +2 -0
- package/server/models/menuinfo.js +2 -0
- package/server/models/message.js +8 -0
- package/server/models/message2.js +4 -0
- package/server/models/message2setting.js +3 -0
- package/server/models/moduleinfo.js +4 -0
- package/server/models/momo.js +18 -0
- package/server/models/news.js +3 -0
- package/server/models/newsfeed.js +4 -0
- package/server/models/note.js +2 -0
- package/server/models/notification.js +8 -0
- package/server/models/okr.js +4 -0
- package/server/models/okrdiagram.js +3 -0
- package/server/models/onepay.js +24 -0
- package/server/models/opportunity.js +4 -0
- package/server/models/options.js +2 -0
- package/server/models/originimportid.js +1 -0
- package/server/models/otp.js +1 -0
- package/server/models/parameter.js +2 -0
- package/server/models/participant.js +21 -0
- package/server/models/partner.js +1 -0
- package/server/models/payload.js +1 -0
- package/server/models/pbl.js +16 -0
- package/server/models/pc0.js +13 -0
- package/server/models/pc1.js +14 -0
- package/server/models/pc2.js +13 -0
- package/server/models/pc3.js +13 -0
- package/server/models/pc5.js +8 -0
- package/server/models/pc6.js +14 -0
- package/server/models/pcl.js +6 -0
- package/server/models/pdn.js +9 -0
- package/server/models/pdx.js +9 -0
- package/server/models/pgh.js +5 -0
- package/server/models/phieudanhgia.js +3 -0
- package/server/models/pht.js +8 -0
- package/server/models/phucap.js +4 -0
- package/server/models/pkc.js +6 -0
- package/server/models/pkh.js +6 -0
- package/server/models/pkk.js +10 -0
- package/server/models/pkt.js +12 -0
- package/server/models/pn1.js +18 -0
- package/server/models/pn2.js +12 -0
- package/server/models/pn3.js +13 -0
- package/server/models/pn5.js +14 -0
- package/server/models/pn6.js +14 -0
- package/server/models/pn9.js +17 -0
- package/server/models/pnc.js +9 -0
- package/server/models/pnh.js +11 -0
- package/server/models/pnk.js +10 -0
- package/server/models/po1.js +19 -0
- package/server/models/ppb.js +6 -0
- package/server/models/productcode.js +2 -0
- package/server/models/profile.js +4 -0
- package/server/models/pt1.js +12 -0
- package/server/models/pt5.js +8 -0
- package/server/models/ptl.js +5 -0
- package/server/models/ptthanhtoan.js +6 -0
- package/server/models/purchase_contract.js +17 -0
- package/server/models/pxc.js +9 -0
- package/server/models/pxh.js +11 -0
- package/server/models/pxk.js +9 -0
- package/server/models/qts.js +14 -0
- package/server/models/qts_dieuchinh.js +3 -0
- package/server/models/qts_dieuchuyen.js +4 -0
- package/server/models/quanhuyen.js +2 -0
- package/server/models/reason.js +2 -0
- package/server/models/receivedinvoice.js +2 -0
- package/server/models/reportinfo.js +5 -0
- package/server/models/right.js +4 -0
- package/server/models/rpt.js +2 -0
- package/server/models/rptform.js +3 -0
- package/server/models/rptobject.js +2 -0
- package/server/models/sale_contract.js +9 -0
- package/server/models/schedule.js +18 -0
- package/server/models/schedule_log.js +2 -0
- package/server/models/shipbook.js +12 -0
- package/server/models/shortcut.js +2 -0
- package/server/models/smsaccount.js +10 -0
- package/server/models/smssend.js +2 -0
- package/server/models/so1.js +22 -0
- package/server/models/so5.js +15 -0
- package/server/models/so9.js +19 -0
- package/server/models/socai.js +28 -0
- package/server/models/socainpp.js +18 -0
- package/server/models/socaitc.js +6 -0
- package/server/models/socaitmp.js +16 -0
- package/server/models/socaitt.js +4 -0
- package/server/models/sodiemthuong.js +4 -0
- package/server/models/sokho.js +27 -0
- package/server/models/sokhocapphat.js +18 -0
- package/server/models/sokhokhongton.js +19 -0
- package/server/models/sokhonpp.js +19 -0
- package/server/models/sokhotc.js +8 -0
- package/server/models/sokhott.js +18 -0
- package/server/models/sophanbokh.js +3 -0
- package/server/models/sosanxuat.js +5 -0
- package/server/models/sotinhkh.js +2 -0
- package/server/models/spdd_ck.js +3 -0
- package/server/models/spdd_dk.js +3 -0
- package/server/models/step.js +2 -0
- package/server/models/strategicdiagram.js +3 -0
- package/server/models/strategicgoal.js +4 -0
- package/server/models/strategickpi.js +6 -0
- package/server/models/strategicobjective.js +5 -0
- package/server/models/strategicplan.js +5 -0
- package/server/models/subscribe.js +2 -0
- package/server/models/support.js +2 -0
- package/server/models/synctime.js +2 -0
- package/server/models/sys_job_queue_book_keeping.js +2 -0
- package/server/models/sysconfig.js +2 -0
- package/server/models/sysgroup.js +2 -0
- package/server/models/tableinfo.js +3 -0
- package/server/models/task.js +9 -0
- package/server/models/tc.js +2 -0
- package/server/models/tdttco.js +9 -0
- package/server/models/tdttco_tt.js +5 -0
- package/server/models/tdttno.js +9 -0
- package/server/models/tdttno_tt.js +5 -0
- package/server/models/templaterpt.js +2 -0
- package/server/models/templatestore.js +3 -0
- package/server/models/templatevoucher.js +3 -0
- package/server/models/tinhthanh.js +2 -0
- package/server/models/tokens.js +3 -0
- package/server/models/tontucthoi.js +9 -0
- package/server/models/trangthai.js +4 -0
- package/server/models/trangthaiapp.js +4 -0
- package/server/models/transaction.js +16 -0
- package/server/models/trialinfo.js +2 -0
- package/server/models/user.js +40 -0
- package/server/models/usergroup.js +7 -0
- package/server/models/vanchuyen.js +12 -0
- package/server/models/vat.js +3 -0
- package/server/models/vatra.js +6 -0
- package/server/models/vatvao.js +6 -0
- package/server/models/versioninfo.js +2 -0
- package/server/models/vietqrbanks.js +2 -0
- package/server/models/vsocai.js +6 -0
- package/server/models/wallet.js +8 -0
- package/server/models/warranty.js +3 -0
- package/server/models/warrantyclaim.js +2 -0
- package/server/models/warrantypolicy.js +1 -0
- package/server/models/workflow.js +4 -0
- package/server/models/xaphuong.js +2 -0
- package/server/models/xhd.js +10 -0
- package/server/models/ytdd_ck.js +4 -0
- package/server/models/ytdd_dk.js +4 -0
- package/server/models/zalo.js +17 -0
- package/server/modules/lists/bg-cddiem.js +6 -0
- package/server/modules/lists/bg-cddt.js +7 -0
- package/server/modules/lists/bg-cdkh.js +11 -0
- package/server/modules/lists/bg-cdnphep.js +6 -0
- package/server/modules/lists/bg-cdtk.js +9 -0
- package/server/modules/lists/bg-cdvt.js +8 -0
- package/server/modules/lists/bg-cdvtnpp.js +8 -0
- package/server/modules/lists/bg-fifo_dk.js +8 -0
- package/server/modules/lists/ls-account.js +4 -0
- package/server/modules/lists/ls-afflink.js +3 -0
- package/server/modules/lists/ls-approve.js +5 -0
- package/server/modules/lists/ls-assabcihandler.js +3 -0
- package/server/modules/lists/ls-assbank.js +3 -0
- package/server/modules/lists/ls-assbooking.js +20 -0
- package/server/modules/lists/ls-assbuy.js +8 -0
- package/server/modules/lists/ls-asscashwithdraw.js +8 -0
- package/server/modules/lists/ls-assinvestment.js +31 -0
- package/server/modules/lists/ls-assissue.js +3 -0
- package/server/modules/lists/ls-asskey.js +41 -0
- package/server/modules/lists/ls-assneedtobuy.js +10 -0
- package/server/modules/lists/ls-assperiod.js +19 -0
- package/server/modules/lists/ls-assproduct.js +9 -0
- package/server/modules/lists/ls-assprofitsharing.js +8 -0
- package/server/modules/lists/ls-assreceiver.js +3 -0
- package/server/modules/lists/ls-assrequest.js +4 -0
- package/server/modules/lists/ls-asssell.js +13 -0
- package/server/modules/lists/ls-asstransaction.js +3 -0
- package/server/modules/lists/ls-asstransfer.js +3 -0
- package/server/modules/lists/ls-assuser_identity.js +1 -0
- package/server/modules/lists/ls-asswithdraw.js +12 -0
- package/server/modules/lists/ls-bangtinhluong.js +2 -0
- package/server/modules/lists/ls-calllog.js +4 -0
- package/server/modules/lists/ls-cart.js +14 -0
- package/server/modules/lists/ls-chamcong.js +3 -0
- package/server/modules/lists/ls-chat_session.js +5 -0
- package/server/modules/lists/ls-checkin.js +24 -0
- package/server/modules/lists/ls-checkinactivity.js +8 -0
- package/server/modules/lists/ls-checkinkpi.js +3 -0
- package/server/modules/lists/ls-checkinlocation.js +1 -0
- package/server/modules/lists/ls-chitietluongds.js +4 -0
- package/server/modules/lists/ls-chitieukpi.js +1 -0
- package/server/modules/lists/ls-chudethaoluan.js +1 -0
- package/server/modules/lists/ls-ckgtluong.js +1 -0
- package/server/modules/lists/ls-comment.js +9 -0
- package/server/modules/lists/ls-congdoansx.js +3 -0
- package/server/modules/lists/ls-congtacvien.js +5 -0
- package/server/modules/lists/ls-consultant.js +2 -0
- package/server/modules/lists/ls-contract.js +7 -0
- package/server/modules/lists/ls-csluongtheods.js +1 -0
- package/server/modules/lists/ls-csphucap.js +1 -0
- package/server/modules/lists/ls-ctds.js +4 -0
- package/server/modules/lists/ls-ctds2.js +4 -0
- package/server/modules/lists/ls-currency.js +1 -0
- package/server/modules/lists/ls-customer.js +22 -0
- package/server/modules/lists/ls-customer_care.js +1 -0
- package/server/modules/lists/ls-datlich.js +9 -0
- package/server/modules/lists/ls-dckhauhaots.js +3 -0
- package/server/modules/lists/ls-deal.js +3 -0
- package/server/modules/lists/ls-diagram.js +1 -0
- package/server/modules/lists/ls-dkhoc.js +6 -0
- package/server/modules/lists/ls-dknphep.js +1 -0
- package/server/modules/lists/ls-dmban.js +4 -0
- package/server/modules/lists/ls-dmbp.js +7 -0
- package/server/modules/lists/ls-dmca.js +1 -0
- package/server/modules/lists/ls-dmchietkhau.js +19 -0
- package/server/modules/lists/ls-dmchietkhauhd.js +4 -0
- package/server/modules/lists/ls-dmchinhanh.js +1 -0
- package/server/modules/lists/ls-dmchucvu.js +2 -0
- package/server/modules/lists/ls-dmcpmh.js +1 -0
- package/server/modules/lists/ls-dmdiemthuong.js +4 -0
- package/server/modules/lists/ls-dmdoi.js +4 -0
- package/server/modules/lists/ls-dmdoituongdanhgia.js +1 -0
- package/server/modules/lists/ls-dmdt.js +11 -0
- package/server/modules/lists/ls-dmdvt.js +2 -0
- package/server/modules/lists/ls-dmgiaban.js +4 -0
- package/server/modules/lists/ls-dmgiamua.js +4 -0
- package/server/modules/lists/ls-dmgiathitruong.js +15 -0
- package/server/modules/lists/ls-dmgiathitruong_ngay.js +2 -0
- package/server/modules/lists/ls-dmgiathitruong_theodoi.js +1 -0
- package/server/modules/lists/ls-dmhoahonghd.js +1 -0
- package/server/modules/lists/ls-dmhoahongnpp.js +1 -0
- package/server/modules/lists/ls-dmkc.js +3 -0
- package/server/modules/lists/ls-dmkho.js +7 -0
- package/server/modules/lists/ls-dmkhuyenmai.js +5 -0
- package/server/modules/lists/ls-dmkhuyenmaihd.js +3 -0
- package/server/modules/lists/ls-dmletet.js +1 -0
- package/server/modules/lists/ls-dmlo.js +1 -0
- package/server/modules/lists/ls-dmloaicong.js +1 -0
- package/server/modules/lists/ls-dmloaits.js +1 -0
- package/server/modules/lists/ls-dmnckkm.js +7 -0
- package/server/modules/lists/ls-dmnghiepvu.js +1 -0
- package/server/modules/lists/ls-dmnguonvon.js +1 -0
- package/server/modules/lists/ls-dmnhnv.js +6 -0
- package/server/modules/lists/ls-dmnhtask.js +5 -0
- package/server/modules/lists/ls-dmnkh.js +6 -0
- package/server/modules/lists/ls-dmntt.js +6 -0
- package/server/modules/lists/ls-dmnv.js +14 -0
- package/server/modules/lists/ls-dmnvt.js +7 -0
- package/server/modules/lists/ls-dmphi.js +6 -0
- package/server/modules/lists/ls-dmqct.js +2 -0
- package/server/modules/lists/ls-dmqddvt.js +3 -0
- package/server/modules/lists/ls-dmtanggiamts.js +1 -0
- package/server/modules/lists/ls-dmto.js +5 -0
- package/server/modules/lists/ls-dmtt.js +7 -0
- package/server/modules/lists/ls-dmvt.js +52 -0
- package/server/modules/lists/ls-dmyt.js +1 -0
- package/server/modules/lists/ls-dokho.js +1 -0
- package/server/modules/lists/ls-dvcs.js +1 -0
- package/server/modules/lists/ls-ecomcategories.js +5 -0
- package/server/modules/lists/ls-ecomcategories_cty.js +5 -0
- package/server/modules/lists/ls-email.js +4 -0
- package/server/modules/lists/ls-events.js +3 -0
- package/server/modules/lists/ls-evoucher.js +3 -0
- package/server/modules/lists/ls-experiencejourney.js +1 -0
- package/server/modules/lists/ls-experiencejourneydata.js +3 -0
- package/server/modules/lists/ls-experiencejourneypersona.js +4 -0
- package/server/modules/lists/ls-experiencejourneystage.js +1 -0
- package/server/modules/lists/ls-fbconversation.js +2 -0
- package/server/modules/lists/ls-fbmessage.js +2 -0
- package/server/modules/lists/ls-fbpage.js +11 -0
- package/server/modules/lists/ls-fbpost.js +2 -0
- package/server/modules/lists/ls-file.js +38 -0
- package/server/modules/lists/ls-financialroadmap.js +3 -0
- package/server/modules/lists/ls-flow.js +6 -0
- package/server/modules/lists/ls-flowdata.js +1 -0
- package/server/modules/lists/ls-flowpending.js +3 -0
- package/server/modules/lists/ls-folder.js +1 -0
- package/server/modules/lists/ls-forminfo.js +1 -0
- package/server/modules/lists/ls-giaoca.js +5 -0
- package/server/modules/lists/ls-group.js +5 -0
- package/server/modules/lists/ls-hmcn.js +2 -0
- package/server/modules/lists/ls-hspbts.js +3 -0
- package/server/modules/lists/ls-introducebonus.js +4 -0
- package/server/modules/lists/ls-introducecode.js +10 -0
- package/server/modules/lists/ls-introducer.js +21 -0
- package/server/modules/lists/ls-kbm-bcdkt.js +1 -0
- package/server/modules/lists/ls-kbm-bcqt.js +5 -0
- package/server/modules/lists/ls-kbm-kqhdkd.js +1 -0
- package/server/modules/lists/ls-kbm-lcttgt.js +1 -0
- package/server/modules/lists/ls-kbm-lctttt.js +1 -0
- package/server/modules/lists/ls-kbm-pttct.js +3 -0
- package/server/modules/lists/ls-kbm-tkgtgt.js +3 -0
- package/server/modules/lists/ls-kbm-tmbctc.js +3 -0
- package/server/modules/lists/ls-kehoachdtcp.js +4 -0
- package/server/modules/lists/ls-keyresult.js +7 -0
- package/server/modules/lists/ls-khunghangthanhvien.js +1 -0
- package/server/modules/lists/ls-label.js +1 -0
- package/server/modules/lists/ls-lienhe.js +4 -0
- package/server/modules/lists/ls-like-module.js +1 -0
- package/server/modules/lists/ls-link.js +1 -0
- package/server/modules/lists/ls-loaidiem.js +1 -0
- package/server/modules/lists/ls-lock.js +1 -0
- package/server/modules/lists/ls-log.js +3 -0
- package/server/modules/lists/ls-mailaccount.js +5 -0
- package/server/modules/lists/ls-mailreceived.js +5 -0
- package/server/modules/lists/ls-mailsent.js +4 -0
- package/server/modules/lists/ls-mailtemplate.js +4 -0
- package/server/modules/lists/ls-maudanhgia.js +3 -0
- package/server/modules/lists/ls-message2.js +8 -0
- package/server/modules/lists/ls-message2setting.js +5 -0
- package/server/modules/lists/ls-news.js +7 -0
- package/server/modules/lists/ls-newsfeed.js +4 -0
- package/server/modules/lists/ls-note.js +6 -0
- package/server/modules/lists/ls-okr.js +5 -0
- package/server/modules/lists/ls-okrdiagram.js +1 -0
- package/server/modules/lists/ls-opportunity.js +5 -0
- package/server/modules/lists/ls-options.js +4 -0
- package/server/modules/lists/ls-parameter.js +3 -0
- package/server/modules/lists/ls-participant.js +12 -0
- package/server/modules/lists/ls-phieudanhgia.js +7 -0
- package/server/modules/lists/ls-phucap.js +2 -0
- package/server/modules/lists/ls-productcode.js +9 -0
- package/server/modules/lists/ls-profile.js +1 -0
- package/server/modules/lists/ls-ptthanhtoan.js +3 -0
- package/server/modules/lists/ls-qts-dieuchinh.js +2 -0
- package/server/modules/lists/ls-qts-dieuchuyen.js +8 -0
- package/server/modules/lists/ls-reason.js +1 -0
- package/server/modules/lists/ls-rpt.js +5 -0
- package/server/modules/lists/ls-rptform.js +3 -0
- package/server/modules/lists/ls-shortcut.js +1 -0
- package/server/modules/lists/ls-smsaccount.js +1 -0
- package/server/modules/lists/ls-smssend.js +3 -0
- package/server/modules/lists/ls-sosanxuat.js +4 -0
- package/server/modules/lists/ls-step.js +1 -0
- package/server/modules/lists/ls-strategicdiagram.js +1 -0
- package/server/modules/lists/ls-strategicgoal.js +3 -0
- package/server/modules/lists/ls-strategickpi.js +7 -0
- package/server/modules/lists/ls-strategicobjective.js +3 -0
- package/server/modules/lists/ls-strategicplan.js +6 -0
- package/server/modules/lists/ls-support.js +3 -0
- package/server/modules/lists/ls-task.js +28 -0
- package/server/modules/lists/ls-tc.js +1 -0
- package/server/modules/lists/ls-templaterpt.js +5 -0
- package/server/modules/lists/ls-templatevoucher.js +1 -0
- package/server/modules/lists/ls-tontucthoi.js +3 -0
- package/server/modules/lists/ls-trangthaiapp.js +3 -0
- package/server/modules/lists/ls-transaction.js +4 -0
- package/server/modules/lists/ls-usergroup.js +7 -0
- package/server/modules/lists/ls-vat.js +1 -0
- package/server/modules/lists/ls-vatra.js +5 -0
- package/server/modules/lists/ls-vatvao.js +6 -0
- package/server/modules/lists/ls-warranty.js +3 -0
- package/server/modules/lists/ls-workflow.js +1 -0
- package/server/modules/lists/ls_hanmucton.js +3 -0
- package/server/modules/lists/ls_hspb.js +4 -0
- package/server/modules/lists/ls_spdd_ck.js +3 -0
- package/server/modules/lists/ls_spdd_dk.js +3 -0
- package/server/modules/lists/ls_ytdd_ck.js +4 -0
- package/server/modules/lists/ls_ytdd_dk.js +4 -0
- package/server/modules/lists/sys-attend.js +4 -0
- package/server/modules/lists/sys-follow.js +4 -0
- package/server/modules/lists/sys-right.js +2 -0
- package/server/modules/public/app.js +4 -0
- package/server/modules/public/approve.js +37 -0
- package/server/modules/public/callin.js +7 -0
- package/server/modules/public/comment.js +5 -0
- package/server/modules/public/dmnvt.js +4 -0
- package/server/modules/public/dmvt.js +9 -0
- package/server/modules/public/file.js +11 -0
- package/server/modules/public/forminfo.js +1 -0
- package/server/modules/public/group.js +4 -0
- package/server/modules/public/introducecode.js +1 -0
- package/server/modules/public/listinfo.js +1 -0
- package/server/modules/public/media-webhook.js +1 -0
- package/server/modules/public/partner.js +1 -0
- package/server/modules/public/paymentCallback.js +32 -0
- package/server/modules/public/province.js +1 -0
- package/server/modules/public/ptthanhtoan.js +4 -0
- package/server/modules/public/subscribe.js +30 -0
- package/server/modules/public/support.js +3 -0
- package/server/modules/public/tableinfo.js +1 -0
- package/server/modules/public/trialinfo.js +4 -0
- package/server/modules/public/versioninfo.js +1 -0
- package/server/modules/reports/calc-tinhgiafifo.js +8 -0
- package/server/modules/reports/calc-tinhgiatb.js +7 -0
- package/server/modules/reports/calc-tinhgiathanh.js +7 -0
- package/server/modules/reports/calc-tinhkhauhaots.js +3 -0
- package/server/modules/reports/calc-tinhluong.js +68 -0
- package/server/modules/reports/rp-analyzedata.js +6 -0
- package/server/modules/reports/rp-assbonus.js +4 -0
- package/server/modules/reports/rp-assinterest.js +8 -0
- package/server/modules/reports/rp-assproductowners.js +3 -0
- package/server/modules/reports/rp-asssupply.js +1 -0
- package/server/modules/reports/rp-asstransferlog.js +10 -0
- package/server/modules/reports/rp-backup.js +4 -0
- package/server/modules/reports/rp-banggiatb.js +3 -0
- package/server/modules/reports/rp-bangtinhkhauhao.js +6 -0
- package/server/modules/reports/rp-baoCaoFifoKy.js +1 -0
- package/server/modules/reports/rp-baocaokhachhang.js +6 -0
- package/server/modules/reports/rp-bcdkt.js +11 -0
- package/server/modules/reports/rp-bcintroducebonus.js +4 -0
- package/server/modules/reports/rp-bckhtiemnang.js +3 -0
- package/server/modules/reports/rp-bcqt.js +85 -0
- package/server/modules/reports/rp-bkchamcong.js +5 -0
- package/server/modules/reports/rp-bkct.js +13 -0
- package/server/modules/reports/rp-bkshipbook.js +8 -0
- package/server/modules/reports/rp-bkvanchuyen.js +8 -0
- package/server/modules/reports/rp-bkvatra.js +7 -0
- package/server/modules/reports/rp-bkvatvao.js +7 -0
- package/server/modules/reports/rp-capnhatsocaitc.js +4 -0
- package/server/modules/reports/rp-cdpsdiem.js +4 -0
- package/server/modules/reports/rp-cdpsdt.js +5 -0
- package/server/modules/reports/rp-cdpskh.js +8 -0
- package/server/modules/reports/rp-cdpsnphep.js +3 -0
- package/server/modules/reports/rp-cdpstk.js +4 -0
- package/server/modules/reports/rp-chitietchitientheohoadon.js +12 -0
- package/server/modules/reports/rp-chitiettaisan.js +13 -0
- package/server/modules/reports/rp-chitietthutientheohoadon.js +13 -0
- package/server/modules/reports/rp-ckcn.js +3 -0
- package/server/modules/reports/rp-ckdiem.js +2 -0
- package/server/modules/reports/rp-cktk.js +3 -0
- package/server/modules/reports/rp-ckvt.js +10 -0
- package/server/modules/reports/rp-ckvttheokho.js +4 -0
- package/server/modules/reports/rp-ckvttheotg.js +4 -0
- package/server/modules/reports/rp-ckvttt.js +3 -0
- package/server/modules/reports/rp-congnophaithutheotuoino.js +3 -0
- package/server/modules/reports/rp-congnophaitratheotuoino.js +3 -0
- package/server/modules/reports/rp-congnosapthu.js +4 -0
- package/server/modules/reports/rp-congnosaptra.js +4 -0
- package/server/modules/reports/rp-congviectheobp.js +9 -0
- package/server/modules/reports/rp-congviectheodt.js +8 -0
- package/server/modules/reports/rp-congviectheokh.js +8 -0
- package/server/modules/reports/rp-congviectheonv.js +9 -0
- package/server/modules/reports/rp-congviectheotimeline.js +6 -0
- package/server/modules/reports/rp-ctbanle.js +15 -0
- package/server/modules/reports/rp-ctbanle2.js +20 -0
- package/server/modules/reports/rp-ctbanlectv.js +20 -0
- package/server/modules/reports/rp-ctbanlenpp.js +24 -0
- package/server/modules/reports/rp-ctdanhgianhanvien.js +8 -0
- package/server/modules/reports/rp-cthangbanbitralai.js +4 -0
- package/server/modules/reports/rp-ctmuahang.js +7 -0
- package/server/modules/reports/rp-cttralaihang.js +4 -0
- package/server/modules/reports/rp-databanle.js +10 -0
- package/server/modules/reports/rp-diemthuong.js +2 -0
- package/server/modules/reports/rp-dkcn.js +3 -0
- package/server/modules/reports/rp-dktk.js +2 -0
- package/server/modules/reports/rp-dsnhanviencm.js +9 -0
- package/server/modules/reports/rp-dsnhanvientb.js +9 -0
- package/server/modules/reports/rp-dtbanlekempk.js +12 -0
- package/server/modules/reports/rp-dtbanletheoct.js +22 -0
- package/server/modules/reports/rp-dtbanletheoctkempk.js +25 -0
- package/server/modules/reports/rp-dtbanletheokh.js +17 -0
- package/server/modules/reports/rp-dtbanletheokhnpp.js +19 -0
- package/server/modules/reports/rp-dtbanletheokho.js +15 -0
- package/server/modules/reports/rp-dtbanletheonam.js +3 -0
- package/server/modules/reports/rp-dtbanletheongay.js +1 -0
- package/server/modules/reports/rp-dtbanletheonpp.js +23 -0
- package/server/modules/reports/rp-dtbanletheonv.js +19 -0
- package/server/modules/reports/rp-dtbanletheoquy.js +3 -0
- package/server/modules/reports/rp-dtbanletheosp.js +9 -0
- package/server/modules/reports/rp-dtbanletheospnpp.js +6 -0
- package/server/modules/reports/rp-dtbanletheothang.js +3 -0
- package/server/modules/reports/rp-dtbanletheothungan.js +12 -0
- package/server/modules/reports/rp-dtbanletheovt.js +2 -0
- package/server/modules/reports/rp-dtbanletheovtnpp.js +2 -0
- package/server/modules/reports/rp-dutoanthuchitheodt.js +4 -0
- package/server/modules/reports/rp-getPXC2PNC.js +8 -0
- package/server/modules/reports/rp-getariseofaccountsbymonth.js +4 -0
- package/server/modules/reports/rp-getbtpb.js +6 -0
- package/server/modules/reports/rp-getcashbycashier.js +7 -0
- package/server/modules/reports/rp-getcschietkhau.js +5 -0
- package/server/modules/reports/rp-getdinhmuc4lenhcp.js +7 -0
- package/server/modules/reports/rp-getdinhmuc4pxk.js +9 -0
- package/server/modules/reports/rp-getdk4pht.js +8 -0
- package/server/modules/reports/rp-getdk4pkc.js +10 -0
- package/server/modules/reports/rp-getdttheoca.js +5 -0
- package/server/modules/reports/rp-getinvoice2pay.js +4 -0
- package/server/modules/reports/rp-getinvoice2receive.js +4 -0
- package/server/modules/reports/rp-getinvoice2return.js +5 -0
- package/server/modules/reports/rp-getinvoice2return_bl.js +6 -0
- package/server/modules/reports/rp-getkehoachmh4lenhcp.js +4 -0
- package/server/modules/reports/rp-getkhauhao.js +7 -0
- package/server/modules/reports/rp-getluong.js +8 -0
- package/server/modules/reports/rp-getluongchuyen.js +5 -0
- package/server/modules/reports/rp-getpn2fee.js +5 -0
- package/server/modules/reports/rp-getpn2return.js +5 -0
- package/server/modules/reports/rp-getthanhpham4pnk.js +7 -0
- package/server/modules/reports/rp-getvc2xhd.js +11 -0
- package/server/modules/reports/rp-gt_cpnvltt.js +6 -0
- package/server/modules/reports/rp-hangbanbitralai.js +5 -0
- package/server/modules/reports/rp-hangthanhvien.js +3 -0
- package/server/modules/reports/rp-hoadonbanhangtheohantt.js +5 -0
- package/server/modules/reports/rp-hoadonmuahangtheohantt.js +5 -0
- package/server/modules/reports/rp-hoahong.js +15 -0
- package/server/modules/reports/rp-kcsns.js +19 -0
- package/server/modules/reports/rp-kgchamcong.js +1 -0
- package/server/modules/reports/rp-khoaso.js +11 -0
- package/server/modules/reports/rp-kiemtrasocaitcvssocai.js +6 -0
- package/server/modules/reports/rp-kqdanhgianhanvien.js +5 -0
- package/server/modules/reports/rp-kqhdkd.js +1 -0
- package/server/modules/reports/rp-lcttgt.js +16 -0
- package/server/modules/reports/rp-lctttt.js +11 -0
- package/server/modules/reports/rp-linkslist.js +4 -0
- package/server/modules/reports/rp-phanbochitienchohoadon.js +11 -0
- package/server/modules/reports/rp-phanbothutienchohoadon.js +11 -0
- package/server/modules/reports/rp-ptbitralai.js +7 -0
- package/server/modules/reports/rp-ptcttct.js +24 -0
- package/server/modules/reports/rp-ptdonhang.js +8 -0
- package/server/modules/reports/rp-pttct.js +52 -0
- package/server/modules/reports/rp-pttctkho.js +32 -0
- package/server/modules/reports/rp-pttctkho2.js +29 -0
- package/server/modules/reports/rp-referredusers.js +5 -0
- package/server/modules/reports/rp-sctbhxh.js +4 -0
- package/server/modules/reports/rp-sctcnkh.js +11 -0
- package/server/modules/reports/rp-sctdiem.js +3 -0
- package/server/modules/reports/rp-sctdt.js +7 -0
- package/server/modules/reports/rp-sctdtcp.js +11 -0
- package/server/modules/reports/rp-sctluong.js +6 -0
- package/server/modules/reports/rp-sctthuetncn.js +4 -0
- package/server/modules/reports/rp-scttk.js +9 -0
- package/server/modules/reports/rp-sctvt.js +5 -0
- package/server/modules/reports/rp-sctvt_sl.js +5 -0
- package/server/modules/reports/rp-sctvtnpp.js +6 -0
- package/server/modules/reports/rp-sctvttt.js +5 -0
- package/server/modules/reports/rp-search.js +4 -0
- package/server/modules/reports/rp-socai.js +6 -0
- package/server/modules/reports/rp-socaitk.js +1 -0
- package/server/modules/reports/rp-sochut.js +7 -0
- package/server/modules/reports/rp-sokho.js +7 -0
- package/server/modules/reports/rp-sokhott.js +5 -0
- package/server/modules/reports/rp-sonkbh.js +5 -0
- package/server/modules/reports/rp-sonkc.js +6 -0
- package/server/modules/reports/rp-sonkct.js +5 -0
- package/server/modules/reports/rp-sonkmh.js +5 -0
- package/server/modules/reports/rp-sonktt.js +5 -0
- package/server/modules/reports/rp-soquy.js +11 -0
- package/server/modules/reports/rp-sosanhkhvatt.js +13 -0
- package/server/modules/reports/rp-sosanhkhvatt2.js +5 -0
- package/server/modules/reports/rp-sotaisan.js +13 -0
- package/server/modules/reports/rp-sotiengui.js +7 -0
- package/server/modules/reports/rp-taodinhmuctudkhoc.js +5 -0
- package/server/modules/reports/rp-thbanhangkempk.js +28 -0
- package/server/modules/reports/rp-thdanhgianhanvien.js +9 -0
- package/server/modules/reports/rp-thgt.js +6 -0
- package/server/modules/reports/rp-thnxt.js +11 -0
- package/server/modules/reports/rp-thnxt_sl.js +9 -0
- package/server/modules/reports/rp-thnxtnpp.js +10 -0
- package/server/modules/reports/rp-thnxttt.js +9 -0
- package/server/modules/reports/rp-tkbanhangtheogioithieu.js +9 -0
- package/server/modules/reports/rp-tkgioithieukh.js +4 -0
- package/server/modules/reports/rp-tkgtgt.js +76 -0
- package/server/modules/reports/rp-tkgtgt_old.js +7 -0
- package/server/modules/reports/rp-tmbctc.js +20 -0
- package/server/modules/reports/rp-tonghopbanhang.js +6 -0
- package/server/modules/reports/rp-tonghopmuahang.js +5 -0
- package/server/modules/reports/rp-tonghoptralaihang.js +5 -0
- package/server/modules/reports/rp-tongquanbanle.js +20 -0
- package/server/modules/reports/rp-tongquanbds.js +3 -0
- package/server/modules/reports/rp-tongquancongty.js +6 -0
- package/server/modules/reports/rp-tongquanctvnpp.js +12 -0
- package/server/modules/reports/rp-tongquannvbh.js +14 -0
- package/server/modules/reports/rp-tongquannvnpp.js +5 -0
- package/server/modules/reports/rp-uoctinhnvl.js +11 -0
- package/server/modules/reports/rp-wallet.js +3 -0
- package/server/modules/reports/rpt-tkdiemtichluy.js +9 -0
- package/server/modules/systems/sys-app.js +34 -0
- package/server/modules/systems/sys-colleague.js +11 -0
- package/server/modules/systems/sys-data_list_config.js +1 -0
- package/server/modules/systems/sys-domain.js +1 -0
- package/server/modules/systems/sys-ecomproductlines.js +1 -0
- package/server/modules/systems/sys-exportexceltemplate.js +1 -0
- package/server/modules/systems/sys-fieldright.js +1 -0
- package/server/modules/systems/sys-importexceltemplate.js +1 -0
- package/server/modules/systems/sys-labelinfo.js +4 -0
- package/server/modules/systems/sys-listinfo.js +10 -0
- package/server/modules/systems/sys-menuinfo.js +4 -0
- package/server/modules/systems/sys-message.js +14 -0
- package/server/modules/systems/sys-moduleinfo.js +4 -0
- package/server/modules/systems/sys-notification.js +8 -0
- package/server/modules/systems/sys-quanhuyen.js +1 -0
- package/server/modules/systems/sys-reportinfo.js +5 -0
- package/server/modules/systems/sys-rptobject.js +1 -0
- package/server/modules/systems/sys-schedule.js +10 -0
- package/server/modules/systems/sys-sysconfig.js +1 -0
- package/server/modules/systems/sys-sysgroup.js +1 -0
- package/server/modules/systems/sys-tableinfo.js +1 -0
- package/server/modules/systems/sys-templatestore.js +5 -0
- package/server/modules/systems/sys-tinhthanh.js +1 -0
- package/server/modules/systems/sys-token.js +3 -0
- package/server/modules/systems/sys-trangthai.js +3 -0
- package/server/modules/systems/sys-trialinfo.js +1 -0
- package/server/modules/systems/sys-user.js +45 -0
- package/server/modules/systems/sys-users.js +10 -0
- package/server/modules/systems/sys-versioninfo.js +1 -0
- package/server/modules/systems/sys-vietqrbanks.js +1 -0
- package/server/modules/systems/sys-xaphuong.js +1 -0
- package/server/modules/vouchers/vo-banggiaban.js +8 -0
- package/server/modules/vouchers/vo-bc1.js +34 -0
- package/server/modules/vouchers/vo-bc5.js +15 -0
- package/server/modules/vouchers/vo-bg1.js +10 -0
- package/server/modules/vouchers/vo-bg2.js +12 -0
- package/server/modules/vouchers/vo-bn1.js +36 -0
- package/server/modules/vouchers/vo-bn5.js +15 -0
- package/server/modules/vouchers/vo-dh2.js +35 -0
- package/server/modules/vouchers/vo-dinhmucsx.js +6 -0
- package/server/modules/vouchers/vo-dkb.js +21 -0
- package/server/modules/vouchers/vo-dn0.js +9 -0
- package/server/modules/vouchers/vo-dnm.js +20 -0
- package/server/modules/vouchers/vo-hd1.js +37 -0
- package/server/modules/vouchers/vo-hd2.js +108 -0
- package/server/modules/vouchers/vo-hd3.js +38 -0
- package/server/modules/vouchers/vo-hd4.js +13 -0
- package/server/modules/vouchers/vo-hd7.js +29 -0
- package/server/modules/vouchers/vo-hd8.js +29 -0
- package/server/modules/vouchers/vo-hde.js +39 -0
- package/server/modules/vouchers/vo-htl.js +11 -0
- package/server/modules/vouchers/vo-kbbtpb.js +6 -0
- package/server/modules/vouchers/vo-kehoachmh.js +11 -0
- package/server/modules/vouchers/vo-lenhcapphat.js +9 -0
- package/server/modules/vouchers/vo-lenhsx.js +12 -0
- package/server/modules/vouchers/vo-pbl.js +94 -0
- package/server/modules/vouchers/vo-pc0.js +14 -0
- package/server/modules/vouchers/vo-pc1.js +31 -0
- package/server/modules/vouchers/vo-pc2.js +25 -0
- package/server/modules/vouchers/vo-pc3.js +14 -0
- package/server/modules/vouchers/vo-pc5.js +15 -0
- package/server/modules/vouchers/vo-pc6.js +19 -0
- package/server/modules/vouchers/vo-pcl.js +7 -0
- package/server/modules/vouchers/vo-pdn.js +11 -0
- package/server/modules/vouchers/vo-pdx.js +9 -0
- package/server/modules/vouchers/vo-pgh.js +16 -0
- package/server/modules/vouchers/vo-pht.js +6 -0
- package/server/modules/vouchers/vo-pkc.js +5 -0
- package/server/modules/vouchers/vo-pkh.js +9 -0
- package/server/modules/vouchers/vo-pkk.js +12 -0
- package/server/modules/vouchers/vo-pkt.js +12 -0
- package/server/modules/vouchers/vo-pn1.js +30 -0
- package/server/modules/vouchers/vo-pn2.js +17 -0
- package/server/modules/vouchers/vo-pn3.js +18 -0
- package/server/modules/vouchers/vo-pn5.js +18 -0
- package/server/modules/vouchers/vo-pn6.js +18 -0
- package/server/modules/vouchers/vo-pn9.js +23 -0
- package/server/modules/vouchers/vo-pnc.js +19 -0
- package/server/modules/vouchers/vo-pnh.js +17 -0
- package/server/modules/vouchers/vo-pnk.js +14 -0
- package/server/modules/vouchers/vo-pnknpp.js +12 -0
- package/server/modules/vouchers/vo-po1.js +14 -0
- package/server/modules/vouchers/vo-ppb.js +8 -0
- package/server/modules/vouchers/vo-pt1.js +20 -0
- package/server/modules/vouchers/vo-pt5.js +15 -0
- package/server/modules/vouchers/vo-ptl.js +8 -0
- package/server/modules/vouchers/vo-purchase_contract.js +9 -0
- package/server/modules/vouchers/vo-pxc.js +24 -0
- package/server/modules/vouchers/vo-pxh.js +18 -0
- package/server/modules/vouchers/vo-pxk.js +15 -0
- package/server/modules/vouchers/vo-pxknpp.js +14 -0
- package/server/modules/vouchers/vo-qts.js +12 -0
- package/server/modules/vouchers/vo-sale_contract.js +11 -0
- package/server/modules/vouchers/vo-shipbook.js +17 -0
- package/server/modules/vouchers/vo-so1.js +125 -0
- package/server/modules/vouchers/vo-so5.js +57 -0
- package/server/modules/vouchers/vo-so7.js +97 -0
- package/server/modules/vouchers/vo-so9.js +119 -0
- package/server/modules/vouchers/vo-vanchuyen.js +14 -0
- package/server/modules/vouchers/vo-xhd.js +33 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const vatvao=global.getModel("vatvao"),vatra=global.getModel("vatra"),kbmtkgtgt=global.getModel("kbmTkgtgt"),{calcGrid,sumByCondition}=require("../../libs/utils"),controller=require("../../controllers/controllerRPT"),moment=require("moment"),buildHTKKXml=($reportData$$,$companyInfo$$,$headerData$$)=>{let $values$$={};"21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43".split(" ").forEach($f$$=>$values$$[`ct${$f$$}`]=0);$reportData$$.forEach($row$$=>{$row$$.ma_in_tien&&($values$$[`ct${$row$$.ma_in_tien}`]=
|
|
2
|
+
$row$$.t_tien||0);$row$$.ma_in_thue&&($values$$[`ct${$row$$.ma_in_thue}`]=$row$$.t_thue||0);$row$$.ma_so==="21"&&($values$$.ct21=$row$$.t_tien||$row$$.t_thue?"true":"false")});return`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
+
<HSoThueDTu xmlns="http://kekhaithue.gdt.gov.vn/TKhai" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
4
|
+
<HSoKhaiThue>
|
|
5
|
+
<TTinChung>
|
|
6
|
+
<maTKhai>01/GTGT</maTKhai>
|
|
7
|
+
<tenTKhai>T\u1edd khai thu\u1ebf gi\u00e1 tr\u1ecb gia t\u0103ng (01/GTGT)</tenTKhai>
|
|
8
|
+
<moTaBMau>(Ban h\u00e0nh k\u00e8m theo Th\u00f4ng t\u01b0 s\u1ed1 80/2021/TT-BTC ng\u00e0y 29 th\u00e1ng 9 n\u0103m 2021 c\u1ee7a B\u1ed9 T\u00e0i ch\u00ednh)</moTaBMau>
|
|
9
|
+
<pbanTKhaiXML>2.4.2</pbanTKhaiXML>
|
|
10
|
+
<loaiTKhai>${$headerData$$.loai_tkhai||"C"}</loaiTKhai>
|
|
11
|
+
<soLan>${$headerData$$.so_lan||0}</soLan>
|
|
12
|
+
<KyKKhaiThue>
|
|
13
|
+
<kieuKy>${$headerData$$.kieu_ky_xml}</kieuKy>
|
|
14
|
+
<kyKKhai>${$headerData$$.ky_khai}</kyKKhai>
|
|
15
|
+
<kyKKhaiTuNgay>${$headerData$$.tu_ngay_str}</kyKKhaiTuNgay>
|
|
16
|
+
<kyKKhaiDenNgay>${$headerData$$.den_ngay_str}</kyKKhaiDenNgay>
|
|
17
|
+
<kyKKhaiNgay>${$headerData$$.ky_khai}</kyKKhaiNgay>
|
|
18
|
+
</KyKKhaiThue>
|
|
19
|
+
<maCqtNoiNop>${$companyInfo$$.ma_cqt||""}</maCqtNoiNop>
|
|
20
|
+
<tenCqtNoiNop>${$companyInfo$$.ten_cqt||""}</tenCqtNoiNop>
|
|
21
|
+
<ngayLapTKhai>${$headerData$$.ngay_lap}</ngayLapTKhai>
|
|
22
|
+
<nguoiKy>${$headerData$$.nguoi_ky}</nguoiKy>
|
|
23
|
+
<ngayKy>${$headerData$$.ngay_ky}</ngayKy>
|
|
24
|
+
<nganhNgheKD>
|
|
25
|
+
<maNganhNgheKD>${$companyInfo$$.ma_nganh_kd||""}</maNganhNgheKD>
|
|
26
|
+
<tenNganhNgheKD>${$companyInfo$$.ten_nganh_kd||""}</tenNganhNgheKD>
|
|
27
|
+
</nganhNgheKD>
|
|
28
|
+
<NNT>
|
|
29
|
+
<mst>${$companyInfo$$.ma_so_thue}</mst>
|
|
30
|
+
<tenNNT>${$companyInfo$$.ten_cong_ty}</tenNNT>
|
|
31
|
+
<dchiNNT>${$companyInfo$$.dia_chi}</dchiNNT>
|
|
32
|
+
<phuongXa></phuongXa>
|
|
33
|
+
<quanHuyen></quanHuyen>
|
|
34
|
+
<tinhThanh></tinhThanh>
|
|
35
|
+
<dthoaiNNT>${$companyInfo$$.dien_thoai||""}</dthoaiNNT>
|
|
36
|
+
<emailNNT>${$companyInfo$$.email||""}</emailNNT>
|
|
37
|
+
</NNT>
|
|
38
|
+
</TTinChung>
|
|
39
|
+
<CTieuToKhai>
|
|
40
|
+
<ct21>${$values$$.ct21||"false"}</ct21>
|
|
41
|
+
<ct22>${$values$$.ct22}</ct22>
|
|
42
|
+
<ct23>${$values$$.ct23}</ct23>
|
|
43
|
+
<ct24>${$values$$.ct24}</ct24>
|
|
44
|
+
<ct25>${$values$$.ct25}</ct25>
|
|
45
|
+
<ct26>${$values$$.ct26}</ct26>
|
|
46
|
+
<ct29>${$values$$.ct29}</ct29>
|
|
47
|
+
<ct30>${$values$$.ct30}</ct30>
|
|
48
|
+
<ct31>${$values$$.ct31}</ct31>
|
|
49
|
+
<ct32>${$values$$.ct32}</ct32>
|
|
50
|
+
<ct33>${$values$$.ct33}</ct33>
|
|
51
|
+
<ct34>${$values$$.ct34}</ct34>
|
|
52
|
+
<ct35>${$values$$.ct35}</ct35>
|
|
53
|
+
<ct36>${$values$$.ct36}</ct36>
|
|
54
|
+
<ct37>${$values$$.ct37}</ct37>
|
|
55
|
+
<ct38>${$values$$.ct38}</ct38>
|
|
56
|
+
<ct39>${$values$$.ct39}</ct39>
|
|
57
|
+
<ct40>${$values$$.ct40}</ct40>
|
|
58
|
+
<ct41>${$values$$.ct41}</ct41>
|
|
59
|
+
<ct42>${$values$$.ct42}</ct42>
|
|
60
|
+
<ct43>${$values$$.ct43}</ct43>
|
|
61
|
+
</CTieuToKhai>
|
|
62
|
+
</HSoKhaiThue>
|
|
63
|
+
</HSoThueDTu>`};
|
|
64
|
+
module.exports=function($router$$){new controller($router$$,"tkgtgt",async function($req$$,$callback$$){const $query$$=$req$$.query;if(!$query$$.nam)return $callback$$({message:"B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1: nam"});var $condition_kbm_query_nam_ngayLap$$=Number($query$$.nam),$ModelSelector_kyKhai_quy_thang$$="";let $kieuKyXml$$="M";if(($query$$.kieu_ky||"T").toUpperCase()==="Q"){if(!$query$$.quy)return $callback$$({message:"Ki\u1ec3u k\u1ef3 l\u00e0 Qu\u00fd y\u00eau c\u1ea7u tham s\u1ed1: quy"});$ModelSelector_kyKhai_quy_thang$$=
|
|
65
|
+
Number($query$$.quy);if($ModelSelector_kyKhai_quy_thang$$<1||$ModelSelector_kyKhai_quy_thang$$>4)return $callback$$({message:"Qu\u00fd kh\u00f4ng h\u1ee3p l\u1ec7 (1-4)"});var $dbTuNgay_startMonthIndex$$=($ModelSelector_kyKhai_quy_thang$$-1)*3;var $dbDenNgay_endMonthIndex$$=$dbTuNgay_startMonthIndex$$+2;$dbTuNgay_startMonthIndex$$=moment({year:$condition_kbm_query_nam_ngayLap$$,month:$dbTuNgay_startMonthIndex$$,day:1}).startOf("day").toDate();$dbDenNgay_endMonthIndex$$=moment({year:$condition_kbm_query_nam_ngayLap$$,
|
|
66
|
+
month:$dbDenNgay_endMonthIndex$$}).endOf("month").endOf("day").toDate();$ModelSelector_kyKhai_quy_thang$$=`Q${$ModelSelector_kyKhai_quy_thang$$}/${$condition_kbm_query_nam_ngayLap$$}`;$kieuKyXml$$="Q"}else{if(!$query$$.thang)return $callback$$({message:"Ki\u1ec3u k\u1ef3 l\u00e0 Th\u00e1ng y\u00eau c\u1ea7u tham s\u1ed1: thang"});$ModelSelector_kyKhai_quy_thang$$=Number($query$$.thang);if($ModelSelector_kyKhai_quy_thang$$<1||$ModelSelector_kyKhai_quy_thang$$>12)return $callback$$({message:"Th\u00e1ng kh\u00f4ng h\u1ee3p l\u1ec7 (1-12)"});
|
|
67
|
+
$dbTuNgay_startMonthIndex$$=moment({year:$condition_kbm_query_nam_ngayLap$$,month:$ModelSelector_kyKhai_quy_thang$$-1,day:1}).startOf("day").toDate();$dbDenNgay_endMonthIndex$$=moment({year:$condition_kbm_query_nam_ngayLap$$,month:$ModelSelector_kyKhai_quy_thang$$-1}).endOf("month").endOf("day").toDate();$ModelSelector_kyKhai_quy_thang$$=`${$ModelSelector_kyKhai_quy_thang$$.toString().padStart(2,"0")}/${$condition_kbm_query_nam_ngayLap$$}`;$kieuKyXml$$="M"}const $id_app$$=$query$$.id_app;$condition_kbm_query_nam_ngayLap$$=
|
|
68
|
+
$query$$.ngay_lap_to_khai?moment($query$$.ngay_lap_to_khai):moment();const $ngayKy$$=$query$$.ngay_ky?moment($query$$.ngay_ky):$condition_kbm_query_nam_ngayLap$$,$headerData$$={kieu_ky_xml:$kieuKyXml$$,ky_khai:$ModelSelector_kyKhai_quy_thang$$,tu_ngay_str:moment($dbTuNgay_startMonthIndex$$).format("DD/MM/YYYY"),den_ngay_str:moment($dbDenNgay_endMonthIndex$$).format("DD/MM/YYYY"),ngay_lap:$condition_kbm_query_nam_ngayLap$$.format("YYYY-MM-DD"),ngay_ky:$ngayKy$$.format("YYYY-MM-DD"),nguoi_ky:$query$$.nguoi_ky||
|
|
69
|
+
$query$$.phu_trach||"",loai_tkhai:$query$$.loai_tkhai||"C",so_lan:$query$$.so_lan||0};try{$condition_kbm_query_nam_ngayLap$$={id_app:$id_app$$};$condition_kbm_query_nam_ngayLap$$.id_rptform=$query$$.id_rptform?$query$$.id_rptform:{$in:[void 0,null,""]};let $report$$=await kbmtkgtgt.find($condition_kbm_query_nam_ngayLap$$).sort({stt:1}).lean().exec();for(let $r$$ of $report$$)if($r$$.cach_tinh!=="2")$r$$.t_tien=$r$$.t_tien||0,$r$$.t_thue=$r$$.t_thue||0;else if($condition_kbm_query_nam_ngayLap$$={ngay_ct:{$gte:$dbTuNgay_startMonthIndex$$,
|
|
70
|
+
$lte:$dbDenNgay_endMonthIndex$$},id_app:$id_app$$},$query$$.ma_dvcs&&($condition_kbm_query_nam_ngayLap$$.ma_dvcs=$query$$.ma_dvcs),$r$$.ma_thue&&$r$$.ma_thue.length>0&&$r$$.ma_thue[0]!==""&&($condition_kbm_query_nam_ngayLap$$.ma_thue={$in:$r$$.ma_thue}),$ModelSelector_kyKhai_quy_thang$$=null,$r$$.bang_du_lieu&&$r$$.bang_du_lieu.toLowerCase()==="vatvao"?($ModelSelector_kyKhai_quy_thang$$=vatvao,$r$$.ma_tc&&$r$$.ma_tc.length>0&&$r$$.ma_tc[0]!==""&&($condition_kbm_query_nam_ngayLap$$.ma_tc={$in:$r$$.ma_tc}),
|
|
71
|
+
$r$$.tk&&$r$$.tk.length>0&&($condition_kbm_query_nam_ngayLap$$.tk_thue_no={$regex:"^"+$r$$.tk,$options:"i"})):$r$$.bang_du_lieu&&$r$$.bang_du_lieu.toLowerCase()==="vatra"&&($ModelSelector_kyKhai_quy_thang$$=vatra,$r$$.tk&&$r$$.tk.length>0&&($condition_kbm_query_nam_ngayLap$$.tk_thue_co={$regex:"^"+$r$$.tk,$options:"i"})),$ModelSelector_kyKhai_quy_thang$$){const $data$$=await sumByCondition($ModelSelector_kyKhai_quy_thang$$,["t_tien","t_thue"],$condition_kbm_query_nam_ngayLap$$);$r$$.t_thue=$r$$.phan_loai==
|
|
72
|
+
"1"||$r$$.phan_loai=="2"?$data$$.t_thue:0;$r$$.t_tien=$r$$.phan_loai=="1"||$r$$.phan_loai=="3"?$data$$.t_tien:0}calcGrid($report$$,{t_tien:function($err$$,$rlq$$){$rlq$$.phan_loai=="3"||$rlq$$.phan_loai=="1"?$rlq$$.kieu_gia_tri=="1"&&$rlq$$.t_tien<0?$rlq$$.t_tien=0:$rlq$$.kieu_gia_tri=="2"&&$rlq$$.t_tien>0?$rlq$$.t_tien=0:$rlq$$.kieu_gia_tri=="3"&&($rlq$$.t_tien=Math.abs($rlq$$.t_tien)):$rlq$$.t_tien=0},t_thue:function($err$$,$rlq$$){$rlq$$.phan_loai=="2"||$rlq$$.phan_loai=="1"?$rlq$$.kieu_gia_tri==
|
|
73
|
+
"1"&&$rlq$$.t_thue<0?$rlq$$.t_thue=0:$rlq$$.kieu_gia_tri=="2"&&$rlq$$.t_thue>0?$rlq$$.t_thue=0:$rlq$$.kieu_gia_tri=="3"&&($rlq$$.t_thue=Math.abs($rlq$$.t_thue)):$rlq$$.t_thue=0}},async function($rs$$){const $exportType$$=($req$$.query.export||"").toLowerCase();var $company_companyInfo$$=await global.getModel("app").findOne({_id:$id_app$$}).lean();if(!$company_companyInfo$$)return $callback$$({message:"Kh\u00f4ng t\u00ecm th\u1ea5y th\u00f4ng tin c\u00f4ng ty"});$company_companyInfo$$={ma_so_thue:$company_companyInfo$$.ma_so_thue||
|
|
74
|
+
$company_companyInfo$$.mst,ten_cong_ty:$company_companyInfo$$.name||$company_companyInfo$$.ten_cong_ty,dia_chi:$company_companyInfo$$.address||$company_companyInfo$$.dia_chi,ma_cqt:$company_companyInfo$$.ma_cqt,ten_cqt:$company_companyInfo$$.ten_cqt,dien_thoai:$company_companyInfo$$.phone||$company_companyInfo$$.dien_thoai,email:$company_companyInfo$$.email,ma_nganh_kd:$company_companyInfo$$.ma_nganh_kd,ten_nganh_kd:$company_companyInfo$$.ten_nganh_kd};if($exportType$$==="xml")try{const $xmlString$$=
|
|
75
|
+
buildHTKKXml($rs$$,$company_companyInfo$$,$headerData$$),$xmlBuffer$$=Buffer.from($xmlString$$,"utf-8");return $callback$$(null,$xmlBuffer$$)}catch($err$$){return $callback$$({message:"L\u1ed7i t\u1ea1o XML: "+$err$$.message})}$callback$$(null,{reportData:$rs$$,companyInfo:$company_companyInfo$$,headerData:$headerData$$})})}catch($e$$){console.error("L\u1ed7i b\u00e1o c\u00e1o thu\u1ebf:",$e$$),$callback$$($e$$)}},{cache:!1,resHandler:async($req$$,$periodStr_result$$,$res$$)=>{const {error:$error$$,
|
|
76
|
+
data:$data$$}=$periodStr_result$$;if($error$$)return $res$$.status(400).send($error$$);($req$$.query.export||"").toLowerCase()==="xml"&&($periodStr_result$$=$req$$.query.kieu_ky==="Q"?`Q${$req$$.query.quy}`:`T${$req$$.query.thang}`,$res$$.setHeader("Content-Type","application/xml"),$res$$.setHeader("Content-Disposition",`attachment; filename="01_GTGT_${$req$$.query.nam}_${$periodStr_result$$}.xml"`));$res$$.send($data$$)}})};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const vatvao=global.getModel("vatvao"),vatra=global.getModel("vatra"),kbmtkgtgt=global.getModel("kbmTkgtgt"),{calcGrid}=require("../../libs/utils"),async=require("async"),controller=require("../../controllers/controllerRPT"),moment=require("moment");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tkgtgt_old",function($kbm_query_req$$,$callback$$){const $query$$=$kbm_query_req$$.query;if(!$query$$.tu_thang||!$query$$.den_thang||!$query$$.nam)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_thang, den_thang, nam");$query$$.ma_dvcs||($query$$.ma_dvcs="");const $tu_ngay$$=moment(new Date($query$$.nam,Number($query$$.tu_thang)-1,1)).startOf("date").toDate(),$den_ngay$$=moment(new Date($query$$.nam,
|
|
3
|
+
Number($query$$.den_thang),0)).endOf("date").toDate();let $report$$;$kbm_query_req$$={id_app:$query$$.id_app};$kbm_query_req$$.id_rptform=$query$$.id_rptform?$query$$.id_rptform:{$in:[void 0,null,""]};kbmtkgtgt.find($kbm_query_req$$).lean().exec(function($error$$,$kbm$$){if($error$$)return $callback$$($error$$);$report$$=$kbm$$;async.mapLimit($report$$,20,function($r$$,$callback$$){if($r$$.cach_tinh=="1"||$r$$.phan_loai=="4")$callback$$(null,$r$$);else{const $condition$$={ngay_ct:{$gte:$tu_ngay$$,
|
|
4
|
+
$lte:$den_ngay$$},ma_dvcs:{$regex:"^"+$query$$.ma_dvcs,$options:"i"},id_app:$query$$.id_app};$r$$.ma_thue&&$r$$.ma_thue.length>0&&($r$$.ma_thue.length!=1||$r$$.ma_thue[0]!=="")&&($condition$$.ma_thue={$in:$r$$.ma_thue});$r$$.bang_du_lieu.toLowerCase()=="vatvao"?($r$$.ma_tc&&$r$$.ma_tc.length>0&&($r$$.ma_tc.length!=1||$r$$.ma_tc[0]!=="")&&($condition$$.ma_tc={$in:$r$$.ma_tc}),$r$$.tk&&$r$$.tk.length>0&&($condition$$.tk_thue_no={$regex:"^"+$r$$.tk,$options:"i"}),vatvao.find($condition$$,{t_tien:1,t_thue:1},
|
|
5
|
+
function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.t_thue=$r$$.phan_loai=="1"||$r$$.phan_loai=="2"?$rs$$.csum("t_thue"):0;$r$$.t_tien=$r$$.phan_loai=="1"||$r$$.phan_loai=="3"?$rs$$.csum("t_tien"):0;$callback$$(null,$r$$)})):($r$$.tk&&$r$$.tk.length>0&&($condition$$.tk_thue_co={$regex:"^"+$r$$.tk,$options:"i"}),vatra.find($condition$$,{t_tien:1,t_thue:1},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$r$$.t_thue=$r$$.phan_loai=="1"||$r$$.phan_loai=="2"?$rs$$.csum("t_thue"):
|
|
6
|
+
0;$r$$.t_tien=$r$$.phan_loai=="1"||$r$$.phan_loai=="3"?$rs$$.csum("t_tien"):0;$callback$$(null,$r$$)}))}},function($error$$){if($error$$)return $callback$$($error$$);calcGrid($report$$,{t_tien:function($error$$,$rlq$$){$rlq$$.phan_loai=="3"||$rlq$$.phan_loai=="1"?$rlq$$.kieu_gia_tri=="1"&&$rlq$$.t_tien<0?$rlq$$.t_tien=0:$rlq$$.kieu_gia_tri=="2"&&$rlq$$.t_tien>0?$rlq$$.t_tien=0:$rlq$$.kieu_gia_tri=="3"&&($rlq$$.t_tien=Math.abs($rlq$$.t_tien)):$rlq$$.t_tien=0},t_thue:function($error$$,$rlq$$){$rlq$$.phan_loai==
|
|
7
|
+
"2"||$rlq$$.phan_loai=="1"?$rlq$$.kieu_gia_tri=="1"&&$rlq$$.t_thue<0?$rlq$$.t_thue=0:$rlq$$.kieu_gia_tri=="2"&&$rlq$$.t_thue>0?$rlq$$.t_thue=0:$rlq$$.kieu_gia_tri=="3"&&($rlq$$.t_thue=Math.abs($rlq$$.t_thue)):$rlq$$.t_thue=0}},function($rs$$){$callback$$(null,$rs$$)})})})})};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const socai=global.getModel("socai"),cktk=require("../../libs/cktk"),dktk=require("../../libs/dktk"),kbmtmbctc=global.getModel("kbmtmbctc"),rptform=global.getModel("rptform"),async=require("async"),_=require("lodash"),utils=require("../../libs/utils"),controller=require("../../controllers/controllerRPT"),moment=require("moment"),getRegString=function($arrayTk$$){return $arrayTk$$.reg()},calcColumn=($condition_row$$,$column_name$$,$query_tk_co_tk_no$$,$callback$$)=>{let $r$$=$condition_row$$[$column_name$$];
|
|
2
|
+
if(!$r$$)return $callback$$(null,{value:0,value_nt:0,cong_thuc:""});switch($r$$.cach_tinh){case "9":$r$$.cong_thuc="";utils.getInfoFromQuery($query_tk_co_tk_no$$,$r$$.query,($e$$,$rs$$)=>{if($e$$)return $callback$$(null,$r$$);_.isNumber($rs$$)?$r$$.value=$rs$$:$r$$.value_string=$rs$$;$callback$$(null,$r$$)});break;case "2":$r$$.cong_thuc="";$condition_row$$={ngay_ct:{$gte:$query_tk_co_tk_no$$.tu_ngay,$lte:$query_tk_co_tk_no$$.den_ngay},id_app:$query_tk_co_tk_no$$.id_app};$query_tk_co_tk_no$$.ma_dvcs&&
|
|
3
|
+
($condition_row$$.ma_dvcs=$query_tk_co_tk_no$$.ma_dvcs);$query_tk_co_tk_no$$.ma_bp&&($condition_row$$.ma_bp=$query_tk_co_tk_no$$.ma_bp);$query_tk_co_tk_no$$.ma_hd&&($condition_row$$.ma_hd=$query_tk_co_tk_no$$.ma_hd);$query_tk_co_tk_no$$.ma_dt&&($condition_row$$.ma_dt=$query_tk_co_tk_no$$.ma_dt);$query_tk_co_tk_no$$.ma_sp&&($condition_row$$.ma_sp=$query_tk_co_tk_no$$.ma_sp);$query_tk_co_tk_no$$.ma_nv&&($condition_row$$.ma_nv=$query_tk_co_tk_no$$.ma_nv);$r$$.ma_phi&&($condition_row$$.ma_phi=$r$$.ma_phi);
|
|
4
|
+
$r$$.ma_kho&&($condition_row$$.ma_kho=$r$$.ma_kho);if($query_tk_co_tk_no$$=getRegString($r$$.tk_no))$condition_row$$.tk_no=$r$$.giam_tru_no?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($query_tk_co_tk_no$$=getRegString($r$$.tk_co))$condition_row$$.tk_co=$r$$.giam_tru_co&&$query_tk_co_tk_no$$?{$not:new RegExp($query_tk_co_tk_no$$)}:{$regex:$query_tk_co_tk_no$$,$options:"i"};if($r$$.dieu_kien_khac)try{$r$$.dieu_kien_khac.indexOf("{")<0&&($r$$.dieu_kien_khac=
|
|
5
|
+
"{"+$r$$.dieu_kien_khac+"}");var $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$=$r$$.dieu_kien_khac;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.indexOf("return ")<0&&($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$=`return ${$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$}`);let $dieu_kien_khac$$=utils.evalute($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,{moment,condition:$condition_row$$,
|
|
6
|
+
row:$r$$});$condition_row$$={...$condition_row$$,...$dieu_kien_khac$$}}catch($e$$){return $callback$$($e$$.toString())}socai.find($condition_row$$).lean().exec(($error$$,$rs$$)=>{if($error$$)return $callback$$($error$$);$r$$.value=$rs$$.csum("tien");$r$$.value_nt=$rs$$.csum("tien_nt");$r$$.details=$rs$$;$callback$$(null,$r$$)});break;case "5":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=
|
|
7
|
+
$query_tk_co_tk_no$$.tu_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;dktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);
|
|
8
|
+
$r$$.value=$result$$.csum("du_no00");$r$$.value_nt=$result$$.csum("du_no_nt00");$r$$.value<0&&$r$$.khong_am&&($r$$.value=0);$r$$.value_nt<0&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "6":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.tu_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=
|
|
9
|
+
$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;dktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_co00");$r$$.value_nt=$result$$.csum("du_co_nt00");$r$$.value<
|
|
10
|
+
0&&$r$$.khong_am&&($r$$.value=0);$r$$.value_nt<0&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;case "7":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.den_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=
|
|
11
|
+
$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;cktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_no00");$r$$.value_nt=$result$$.csum("du_no_nt00");$r$$.value<0&&$r$$.khong_am&&($r$$.value=0);$r$$.value_nt<0&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,
|
|
12
|
+
$r$$)});break;case "8":$r$$.cong_thuc="";$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$={...$query_tk_co_tk_no$$};$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.ngay=$query_tk_co_tk_no$$.den_ngay;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.bu_tru=$r$$.bu_tru_cong_no;$condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tk=$r$$.tk;delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.tu_ngay;
|
|
13
|
+
delete $condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$.den_ngay;cktk($condition$jscomp$1_condition$jscomp$2_condition$jscomp$3_condition$$,function($error$$,$result$$){if($error$$)return $callback$$($error$$);$r$$.value=$result$$.csum("du_co00");$r$$.value_nt=$result$$.csum("du_co_nt00");$r$$.value<0&&$r$$.khong_am&&($r$$.value=0);$r$$.value_nt<0&&$r$$.khong_am&&($r$$.value_nt=0);$callback$$(null,$r$$)});break;default:$callback$$(null,$r$$)}};
|
|
14
|
+
module.exports=function($router$$){new controller($router$$,"tmbctc",function($req$$,$callback$$){let $query$$=$req$$.query;if(!$query$$.den_ngay||!$query$$.tu_ngay||!$query$$.id_rptform)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u tham s\u1ed1 t\u1eeb ng\u00e0y(tu_ngay), \u0111\u1ebfn ng\u00e0y(den_ngay), id m\u1eabu b\u00e1o c\u00e1o");if(!global.mongoose.Types.ObjectId.isValid($query$$.id_rptform))return $callback$$("M\u1eabu b\u00e1o c\u00e1o n\u00e0y kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb");
|
|
15
|
+
(new Promise(($resolve$$,$reject$$)=>{rptform.findOne({_id:$query$$.id_rptform}).lean().exec(($e$$,$rs$$)=>{if($e$$||!$rs$$)return $reject$$($e$$);$resolve$$($rs$$)})})).then(async $_rptform$$=>{$query$$.tu_ngay=moment(new Date($query$$.tu_ngay)).startOf("date").toDate();$query$$.den_ngay=moment(new Date($query$$.den_ngay)).endOf("date").toDate();$query$$.tu_ngay_kt=new Date($query$$.tu_ngay);$query$$.tu_ngay_kt.setYear($query$$.tu_ngay_kt.getFullYear()-1);$query$$.den_ngay_kt=new Date($query$$.den_ngay);
|
|
16
|
+
$query$$.den_ngay_kt.setYear($query$$.den_ngay_kt.getFullYear()-1);let $report$$=$_rptform$$.report;$report$$&&$_rptform$$.report.length!==0||($report$$=await kbmtmbctc.find({id_rptform:$_rptform$$._id.toString()}).sort({stt:1}).lean());async.mapLimit($report$$,20,($r$$,$c1$$)=>{async.parallel({so_dau_nam:$callback$$=>{calcColumn($r$$,"so_dau_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_dau_nam_value=$rs$$.value;$r$$.so_dau_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_dau_nam_value=
|
|
17
|
+
$rs$$.cong_thuc;$callback$$()})},so_tang_trong_nam:$callback$$=>{calcColumn($r$$,"so_tang_trong_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_tang_trong_nam_value=$rs$$.value;$r$$.so_tang_trong_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_tang_trong_nam_value=$rs$$.cong_thuc;$callback$$()})},so_giam_trong_nam:$callback$$=>{calcColumn($r$$,"so_giam_trong_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_giam_trong_nam_value=$rs$$.value;$r$$.so_giam_trong_nam_value_nt=
|
|
18
|
+
$rs$$.value_nt;$r$$.cong_thuc_so_giam_trong_nam_value=$rs$$.cong_thuc;$callback$$()})},so_cuoi_nam:$callback$$=>{calcColumn($r$$,"so_cuoi_nam",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_cuoi_nam_value=$rs$$.value;$r$$.so_cuoi_nam_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_cuoi_nam_value=$rs$$.cong_thuc;$callback$$()})},so_nam_nay:$callback$$=>{calcColumn($r$$,"so_nam_nay",{...$query$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_nam_nay_value=$rs$$.value;$r$$.so_nam_nay_value_nt=
|
|
19
|
+
$rs$$.value_nt;$r$$.cong_thuc_so_nam_nay_value=$rs$$.cong_thuc;$callback$$()})},so_nam_truoc:$callback$$=>{const $_q$$={...$query$$};$_q$$.tu_ngay=$query$$.tu_ngay_kt;$_q$$.den_ngay=$query$$.den_ngay_kt;calcColumn($r$$,"so_nam_truoc",$_q$$,($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$r$$.so_nam_truoc_value=$rs$$.value;$r$$.so_nam_truoc_value_nt=$rs$$.value_nt;$r$$.cong_thuc_so_nam_truoc_value=$rs$$.cong_thuc;$callback$$()})}},()=>{$c1$$()})},function($error$$){if($error$$)return $callback$$($error$$);
|
|
20
|
+
utils.calcGrid($report$$,"so_dau_nam_value,so_tang_trong_nam_value,so_giam_trong_nam_value,so_cuoi_nam_value,so_nam_nay_value,so_nam_truoc_value",function($rs$$){$callback$$(null,$rs$$.filter($r$$=>$r$$.print!==!1))})})}).catch($e$$=>{$callback$$($e$$||"Kh\u00f4ng c\u00f3 m\u1eabu b\u00e1o c\u00e1o n\u00e0o cho b\u00e1o c\u00e1o n\u00e0y")})})};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const sokho=global.getModel("sokho"),dmvt=global.getModel("dmvt"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tonghopbanhang",($query_req$$,$callback$$)=>{const $condition$$=$query_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");$query_req$$={id_app:$condition$$.id_app,ma_ct:{$in:["PBL","SO1","HD2","HD3","HD7"]}};$query_req$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query_req$$.ma_dvcs=
|
|
3
|
+
{$regex:$condition$$.ma_dvcs,$options:"i"});$condition$$.ma_vt&&($query_req$$.ma_vt={$regex:$condition$$.ma_vt,$options:"i"});$condition$$.ma_kho&&($query_req$$.ma_kho={$regex:$condition$$.ma_kho,$options:"i"});sokho.find($query_req$$).lean().exec(($error$$,$rs$$)=>{if($error$$)return Logger.info($error$$),$callback$$($error$$);$rs$$.forEach($r$$=>{$r$$.tien_hang=$r$$.tien_hang||$r$$.tien;$r$$.nxt===1?($r$$.tien_tl=$r$$.tien,$r$$.tien_ck_tl=$r$$.tien_ck,$r$$.tien_hang=0,$r$$.tien_hang_nt=0,$r$$.tien_ck=
|
|
4
|
+
0,$r$$.tien_ck_nt=0,$r$$.tien=0,$r$$.tien_nt=0):($r$$.tien_tl=0,$r$$.tien_ck_tl=0);$r$$.tien=$r$$.tien_hang-($r$$.tien_ck||0);$r$$.tien_tl_net=$r$$.tien_tl-$r$$.tien_ck_tl});$rs$$.groupBy("ma_vt",[{name:"sl_xuat",value:"sl_xuat"},{name:"tien",value:"tien"},{name:"tien_ck",value:"tien_ck"},{name:"tien_xuat",value:"tien_xuat"},{name:"tien_nhap",value:"tien_nhap"},{name:"sl_nhap",value:"sl_nhap"},{name:"tien_tl",value:"tien_tl"},{name:"tien_ck_tl",value:"tien_ck_tl"},{name:"tien_tl_net",value:"tien_tl_net"}],
|
|
5
|
+
($error$$,$rs$$)=>{if($error$$)return Logger.info($error$$),$callback$$($error$$);var $report$$=underscore.sortBy($rs$$,$r$$=>$r$$.ma_vt),$i$$=1;$report$$.forEach($r$$=>{$r$$.stt=$i$$;$r$$.bold=!1;$r$$.doanh_thu=$r$$.tien-$r$$.tien_ck;$r$$.lai=$r$$.doanh_thu-$r$$.tien_xuat-($r$$.tien_tl-$r$$.tien_nhap);$i$$++});$report$$.joinModel2($condition$$.id_app,dmvt,[{where:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"},{name:"ma_dvt",value:"ma_dvt"}]}],()=>{$report$$.push({ten_vt:"T\u1ed5ng c\u1ed9ng",sl_xuat:$report$$.csum("sl_xuat"),
|
|
6
|
+
tien:$report$$.csum("tien"),tien_ck:$report$$.csum("tien_ck"),doanh_thu:$report$$.csum("doanh_thu"),tien_xuat:$report$$.csum("tien_xuat"),sl_nhap:$report$$.csum("sl_nhap"),tien_tl:$report$$.csum("tien_tl"),tien_ck_tl:$report$$.csum("tien_ck_tl"),tien_nhap:$report$$.csum("tien_nhap"),tien_tl_net:$report$$.csum("tien_tl_net"),lai:$report$$.csum("lai"),bold:!0});$callback$$(null,$report$$)})})})})};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const sokho=global.getModel("sokho"),dmvt=global.getModel("dmvt"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tonghopmuahang",function($query_req$$,$callback$$){const $condition$$=$query_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");$query_req$$={id_app:$condition$$.id_app,ma_ct:{$in:["PN1","PN9","PN3"]}};$query_req$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query_req$$.ma_dvcs=$condition$$.ma_dvcs);
|
|
3
|
+
$condition$$.ma_vt&&($query_req$$.ma_vt=$condition$$.ma_vt.toUpperCase());$condition$$.ma_kho&&($query_req$$.ma_kho=$condition$$.ma_kho.toUpperCase());$condition$$.ma_kh&&($query_req$$.ma_kh=$condition$$.ma_kh.toUpperCase());sokho.find($query_req$$).lean().exec(function($error$$,$rs$$){if($error$$)return Logger.info($error$$),$callback$$($error$$);$rs$$.groupBy("ma_vt",[{name:"sl_nhap",value:"sl_nhap"},{name:"tien_hang",value:"tien_hang"},{name:"tien_ck",value:"tien_ck"},{name:"tien_phi",value:"tien_phi"},
|
|
4
|
+
{name:"tien_nhap",value:"tien_nhap"}],function($error$$,$rs$$){if($error$$)return Logger.info($error$$),$callback$$($error$$);const $report$$=underscore.sortBy($rs$$,function($r$$){return $r$$.ma_vt});let $i$$=1;$report$$.forEach(function($r$$){$r$$.stt=$i$$;$r$$.bold=!1;$i$$++});$report$$.joinModel($condition$$.id_app,dmvt,[{akey:"ma_vt",bkey:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"},{name:"ma_dvt",value:"ma_dvt"}]}],function(){$report$$.push({ten_vt:"T\u1ed5ng c\u1ed9ng",sl_nhap:$report$$.csum("sl_nhap"),
|
|
5
|
+
tien_hang:$report$$.csum("tien_hang"),tien_ck:$report$$.csum("tien_ck"),tien_phi:$report$$.csum("tien_phi"),tien_nhap:$report$$.csum("tien_nhap"),bold:!0});$callback$$(null,$report$$)})})})})};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const sokho=global.getModel("sokho"),dmvt=global.getModel("dmvt"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tonghoptralaihang",function($query_req$$,$callback$$){const $condition$$=$query_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");$query_req$$={id_app:$condition$$.id_app,ma_ct:{$in:["PN5"]}};$query_req$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query_req$$.ma_dvcs={$regex:$condition$$.ma_dvcs,
|
|
3
|
+
$options:"i"});$condition$$.ma_vt&&($query_req$$.ma_vt={$regex:$condition$$.ma_vt,$options:"i"});$condition$$.ma_kho&&($query_req$$.ma_kho={$regex:$condition$$.ma_kho,$options:"i"});sokho.find($query_req$$).lean().exec(function($error$$,$rs$$){if($error$$)return Logger.info($error$$),$callback$$($error$$);$rs$$.groupBy("ma_vt",[{name:"sl_xuat",value:"sl_xuat"},{name:"tien_hang",value:"tien_hang"},{name:"tien_ck",value:"tien_ck"},{name:"tien_xuat",value:"tien_xuat"}],function($error$$,$rs$$){if($error$$)return Logger.info($error$$),
|
|
4
|
+
$callback$$($error$$);const $report$$=underscore.sortBy($rs$$,function($r$$){return $r$$.ma_vt});let $i$$=1;$report$$.forEach(function($r$$){$r$$.stt=$i$$;$r$$.bold=!1;$i$$++});$report$$.joinModel($condition$$.id_app,dmvt,[{akey:"ma_vt",bkey:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"},{name:"ma_dvt",value:"ma_dvt"}]}],function(){$report$$.push({ten_vt:"T\u1ed5ng c\u1ed9ng",sl_xuat:$report$$.csum("sl_xuat"),tien_hang:$report$$.csum("tien_hang"),tien_ck:$report$$.csum("tien_ck"),tien_xuat:$report$$.csum("tien_xuat"),
|
|
5
|
+
bold:!0});$callback$$(null,$report$$)})})})})};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const databanle=require("../../libs/databanle"),async=require("async"),underscore=require("underscore"),controller=require("../../controllers/controllerRPT"),permission=require("../../libs/permission");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquanbanle",async function($req$$,$callback$$){const $condition$$=$req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");const $query$$={id_app:$condition$$.id_app};$query$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query$$.ma_dvcs=$condition$$.ma_dvcs);if($req$$.user.current_app_info.appAdmin)$condition$$.ma_kho&&
|
|
3
|
+
($query$$.$or=[{ma_kho:$condition$$.ma_kho},{"details.ma_kho":$condition$$.ma_kho}]);else{var $condition_kh_custs_ma_khos$$=await new Promise($rs$$=>{permission.getRightByItem($req$$.user.current_id_app,global.getModel("dmkho"),$req$$.user.email,async function($e_khos$$,$_condition$$,$admin$$){if($admin$$)return $rs$$(null);$_condition$$.id_app=$condition$$.id_app;$condition$$.ma_kho&&($_condition$$.ma_kho=$condition$$.ma_kho);$e_khos$$=await global.getModel("dmkho").find($_condition$$,{ma_kho:1}).lean();
|
|
4
|
+
$rs$$($e_khos$$.map($k$$=>$k$$.ma_kho))})});$query$$.$or=[{ma_kho:{$in:$condition_kh_custs_ma_khos$$}},{"details.ma_kho":{$in:$condition_kh_custs_ma_khos$$}}]}if($condition$$.ma_kh)$query$$.ma_kh=$condition$$.ma_kh;else{$condition_kh_custs_ma_khos$$={};if($condition$$.nh_kh){var $nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition$$.id_app,$condition$$.nh_kh,{status:!0});$condition_kh_custs_ma_khos$$.nh_kh={$in:$nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$}}$condition$$.nh_kh2&&
|
|
5
|
+
($nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition$$.id_app,$condition$$.nh_kh2,{status:!0}),$condition_kh_custs_ma_khos$$.nh_kh2={$in:$nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$});$condition$$.nh_kh3&&($nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition$$.id_app,$condition$$.nh_kh3,{status:!0}),$condition_kh_custs_ma_khos$$.nh_kh3={$in:$nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$});$condition$$.nh_kh4&&
|
|
6
|
+
($nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition$$.id_app,$condition$$.nh_kh4,{status:!0}),$condition_kh_custs_ma_khos$$.nh_kh4={$in:$nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$});$condition$$.nh_kh5&&($nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$=await global.getModel("group").getAllChildrenGroup($condition$$.id_app,$condition$$.nh_kh5,{status:!0}),$condition_kh_custs_ma_khos$$.nh_kh5={$in:$nh_khs_nh_khs2_nh_khs3_nh_khs4_nh_khs5$$});Object.keys($condition_kh_custs_ma_khos$$).length>
|
|
7
|
+
0&&($condition_kh_custs_ma_khos$$.id_app=$condition$$.id_app,$condition_kh_custs_ma_khos$$=await global.getModel("customer").find($condition_kh_custs_ma_khos$$,{ma_kh:1}).lean(),$query$$.ma_kh={$in:$condition_kh_custs_ma_khos$$.map($c$$=>$c$$.ma_kh)})}$condition$$.ma_ct&&($query$$.ma_ct=$condition$$.ma_ct);$condition$$.user_hoa_hong&&($query$$.$or?$query$$.$and=[{$or:[{user_nv:$condition$$.user_hoa_hong},{user_ctv:$condition$$.user_hoa_hong},{user_ctv2:$condition$$.user_hoa_hong},{user_kho:$condition$$.user_hoa_hong},
|
|
8
|
+
{user_gt:$condition$$.user_hoa_hong},{user_ql:$condition$$.user_hoa_hong},{"details.user_nv":$condition$$.user_hoa_hong},{"details.user_ctv":$condition$$.user_hoa_hong},{"details.user_ctv2":$condition$$.user_hoa_hong},{"details.user_kho":$condition$$.user_hoa_hong},{"details.user_gt":$condition$$.user_hoa_hong},{"details.user_ql":$condition$$.user_hoa_hong}]}]:$query$$.$or=[{user_nv:$condition$$.user_hoa_hong},{user_ctv:$condition$$.user_hoa_hong},{user_ctv2:$condition$$.user_hoa_hong},{user_kho:$condition$$.user_hoa_hong},
|
|
9
|
+
{user_gt:$condition$$.user_hoa_hong},{user_ql:$condition$$.user_hoa_hong},{"details.user_nv":$condition$$.user_hoa_hong},{"details.user_ctv":$condition$$.user_hoa_hong},{"details.user_ctv2":$condition$$.user_hoa_hong},{"details.user_kho":$condition$$.user_hoa_hong},{"details.user_gt":$condition$$.user_hoa_hong},{"details.user_ql":$condition$$.user_hoa_hong}]);databanle($query$$,function($error$$,$vouchers$$,$ptthanhtoans$$){if($error$$)return $callback$$($error$$);const $thanh_toan$$=$ptthanhtoans$$.map($pt$$=>
|
|
10
|
+
({name:$pt$$.ma,value:$pt$$.ma,ma:$pt$$.ma,ten:$pt$$.ten}));async.mapLimit($vouchers$$,20,function($r$$,$callback$$){$r$$.t_sl_xuat=$r$$.details.csum("sl_xuat");$r$$.t_tien_hang=$r$$.details.csum("tien_hang");$r$$.t_tien_hang_ct=$r$$.details.csum("tien_hang_ct");$r$$.t_thue=$r$$.details.csum("tien_thue");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien=$r$$.details.csum("tien");$r$$.t_tien_cp=$r$$.details.csum("tien_cp");$r$$.tien_ck_hd=$r$$.tien_ck_hd||0;$r$$.t_tien_xuat=$r$$.details.csum("tien_xuat");
|
|
11
|
+
$r$$.t_tien_hoa_hong=$r$$.details.csum("tien_hoa_hong");$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.tien_freeship=$r$$.tien_freeship||0;$r$$.tien_phi_vc=$r$$.tien_phi_vc||0;$r$$.details_tl?($r$$.t_tien_tl=$r$$.details_tl.csum("tien_hang_ct")-$r$$.details_tl.csum("tien_ck"),$r$$.t_tien_thue_tl=$r$$.details_tl.csum("tien_thue"),$r$$.t_tien_nhap=$r$$.details_tl.csum("tien_nhap"),
|
|
12
|
+
$r$$.t_sl_nhap=$r$$.details_tl.csum("sl_nhap"),$r$$.t_tien_hoa_hong-=$r$$.details_tl.csum("tien_hoa_hong"),$r$$.t_tien_hoa_hong_gt-=$r$$.details_tl.csum("tien_hoa_hong_gt"),$r$$.t_tien_hoa_hong_ctv-=$r$$.details_tl.csum("tien_hoa_hong_ctv"),$r$$.t_tien_hoa_hong_ql-=$r$$.details_tl.csum("tien_hoa_hong_ql")):($r$$.t_tien_tl=0,$r$$.t_sl_nhap=0,$r$$.t_tien_nhap=0);$callback$$(null,$r$$)},async function($error$$,$rs$$){if($error$$)return $callback$$($error$$);await $rs$$.asyncJoinModel2($condition$$.id_app,
|
|
13
|
+
"dmkho",{where:"ma_kho",fields:["ten_kho"]});const $field_group_by$$=$req$$.query.group_by||"ten_kho";$error$$=[{name:"t_sl_xuat",value:"t_sl_xuat"},{name:"t_sl_nhap",value:"t_sl_nhap"},{name:"t_tien_hang",value:"t_tien_hang"},{name:"t_tien_hang_ct",value:"t_tien_hang_ct"},{name:"t_thue",value:"t_thue"},{name:"t_tien_cp",value:"t_tien_cp"},{name:"t_tien_ck",value:"t_tien_ck"},{name:"t_tien",value:"t_tien"},{name:"tien_ck_hd",value:"tien_ck_hd"},{name:"tien_freeship",value:"tien_freeship"},{name:"tien_phi_vc",
|
|
14
|
+
value:"tien_phi_vc"},{name:"tien_evoucher",value:"tien_evoucher"},{name:"tien_thu",value:"tien_thu"},{name:"tien_thu2",value:"tien_thu2"},{name:"tien_paymentByPoints",value:"tien_paymentByPoints"},{name:"t_tien_xuat",value:"t_tien_xuat"},{name:"t_tien_tl",value:"t_tien_tl"},{name:"t_tien_thue_tl",value:"t_tien_thue_tl"},{name:"t_tien_nhap",value:"t_tien_nhap"},{name:"phai_tra",value:"phai_tra"},{name:"t_tien_hoa_hong",value:"t_tien_hoa_hong"},{name:"t_tien_hoa_hong_gt",value:"t_tien_hoa_hong_gt"},
|
|
15
|
+
{name:"t_tien_hoa_hong_ctv",value:"t_tien_hoa_hong_ctv"},{name:"t_tien_hoa_hong_ql",value:"t_tien_hoa_hong_ql"},...$thanh_toan$$];$rs$$.groupBy($field_group_by$$,$error$$,function($error$$,$rs$$){if($error$$)return $callback$$($error$$);let $report$$=underscore.sortBy($rs$$,function($r$$){return $r$$[$field_group_by$$]});$report$$.forEach(function($r$$,$i$$){$r$$.stt=$i$$+1;$r$$.bold=!1;$r$$.t_phai_thu=$r$$.t_tien_hang_ct-($r$$.t_tien_ck||0)+($r$$.t_thue||0)+($r$$.tien_phi_vc||0)-($r$$.tien_freeship||
|
|
16
|
+
0)-($r$$.tien_ck_hd||0)-($r$$.tien_evoucher||0);$r$$.t_doanh_thu=$r$$.t_tien_hang_ct-($r$$.t_tien_ck||0)+($r$$.tien_phi_vc||0)-($r$$.tien_freeship||0)-($r$$.tien_ck_hd||0)-($r$$.tien_evoucher||0);$r$$.t_lai=$r$$.t_doanh_thu-$r$$.t_tien_xuat-($r$$.t_tien_tl-$r$$.t_tien_nhap);$r$$.t_doanh_thu_thuan=$r$$.t_doanh_thu-$r$$.t_tien_tl;$r$$.t_tien_thu=$thanh_toan$$.map($pt$$=>$r$$[$pt$$.name]||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$r$$.t_tien_paymentByPoints=$r$$.tien_paymentByPoints||0});const $tong_cong$$=
|
|
17
|
+
{[$field_group_by$$]:$report$$.length==0?"Kh\u00f4ng c\u00f3 d\u1eef li\u1ec7u":"T\u1ed5ng c\u1ed9ng",t_sl_xuat:$report$$.csum("t_sl_xuat"),t_sl_nhap:$report$$.csum("t_sl_nhap"),t_tien_hang:$report$$.csum("t_tien_hang"),t_tien_hang_ct:$report$$.csum("t_tien_hang_ct"),t_thue:$report$$.csum("t_thue"),t_tien_cp:$report$$.csum("t_tien_cp"),t_tien_ck:$report$$.csum("t_tien_ck"),t_tien:$report$$.csum("t_tien"),tien_ck_hd:$report$$.csum("tien_ck_hd"),tien_phi_vc:$report$$.csum("tien_phi_vc"),tien_freeship:$report$$.csum("tien_freeship"),
|
|
18
|
+
t_tien_tl:$report$$.csum("t_tien_tl"),t_tien_thue_tl:$report$$.csum("t_tien_thue_tl"),t_tien_xuat:$report$$.csum("t_tien_xuat"),t_tien_nhap:$report$$.csum("t_tien_nhap"),t_phai_thu:$report$$.csum("t_phai_thu"),t_doanh_thu:$report$$.csum("t_doanh_thu"),t_doanh_thu_thuan:$report$$.csum("t_doanh_thu_thuan"),tien_evoucher:$report$$.csum("tien_evoucher"),tien_thu:$report$$.csum("tien_thu"),tien_thu2:$report$$.csum("tien_thu2"),t_tien_thu:$report$$.csum("t_tien_thu"),phai_tra:$report$$.csum("phai_tra"),
|
|
19
|
+
t_tien_paymentByPoints:$report$$.csum("tien_paymentByPoints"),t_lai:$report$$.csum("t_lai"),t_tien_hoa_hong:$report$$.csum("t_tien_hoa_hong"),t_tien_hoa_hong_gt:$report$$.csum("t_tien_hoa_hong_gt"),t_tien_hoa_hong_ctv:$report$$.csum("t_tien_hoa_hong_ctv"),t_tien_hoa_hong_ql:$report$$.csum("t_tien_hoa_hong_ql"),bold:$report$$.length==0?!1:!0};$thanh_toan$$.forEach($pt$$=>{$pt$$.tong_cong=$tong_cong$$[$pt$$.name]=$report$$.csum($pt$$.name)});$report$$.push($tong_cong$$);$report$$.forEach($r$$=>{$r$$.t_tien_phai_tl=
|
|
20
|
+
$r$$.t_tien_tl+$r$$.t_tien_thue_tl});$callback$$(null,{data:$report$$,vouchers_number:$vouchers$$.filter($v$$=>$v$$.ma_ct!=="HD7"&&$v$$.ma_ct!=="HD3").map($v$$=>$v$$.so_khach||1).length,customers_number:$vouchers$$.filter($v$$=>$v$$.ma_ct!=="HD7"&&$v$$.ma_ct!=="HD3").map($v$$=>$v$$.so_khach||1).reduce(($a$$,$b$$)=>$a$$+$b$$,0),thanh_toan:$thanh_toan$$.filter($t$$=>$t$$.tong_cong)})})})})},{cache:!0,cache_time:5})};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const async=require("async"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquanbds",async function($req$$,$callback$$){const $id_app$$=$req$$.query.id_app;async.parallel({sl_sp:$callback$$=>{setImmediate(async()=>{let $sl_sp$$=await global.getModel("dmvt").countDocuments({id_app:$id_app$$});$callback$$(null,$sl_sp$$)})},sl_kh:$callback$$=>{setImmediate(async()=>{let $sl_kh$$=await global.getModel("customer").countDocuments({id_app:$id_app$$});$callback$$(null,$sl_kh$$)})}},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);
|
|
3
|
+
$callback$$(null,$rs$$)})},{cache:!0,cache_time:5})};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const pstk=require("../../libs/pstk"),cktk=require("../../libs/cktk"),controller=require("../../controllers/controllerRPT"),async=require("async"),underscore=require("underscore"),moment=require("moment");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquancongty",async function($req$$,$callback$$){const $query$$=$req$$.query;$query$$.tu_ngay||($query$$.tu_ngay=moment().startOf("month").toDate());$query$$.den_ngay||($query$$.den_ngay=moment().endOf("month").toDate());let $tk_ps$$=$query$$.tk_ps||["511","632"],$tk_ck$$=$query$$.tk_ck||["111","112","131","331"];async.parallel({ps:function($callback$$){setImmediate(()=>{let $condition$$={id_app:$query$$.id_app},$tk$$=$tk_ps$$;if(underscore.isArray($tk$$)){let $tks$$;
|
|
3
|
+
$tk$$.forEach(function($t$$){$tks$$=$tks$$?$tks$$+"|^"+$t$$:"^"+$t$$});$tks$$||="^";$tk$$={$regex:$tks$$,$options:"i"}}else $tk$$={$regex:"^"+$tk$$,$options:"i"};$condition$$.tk=$tk$$;$query$$.ma_dvcs&&($condition$$.ma_dvcs={$regex:$query$$.ma_dvcs,$options:"i"});$condition$$.ngay_ct={$gte:$query$$.tu_ngay,$lte:$query$$.den_ngay};$query$$.ma_kho&&($condition$$.ma_kho=$query$$.ma_kho);pstk($condition$$,function($error$$,$result$$){if($error$$)return Logger.error("Kh\u00f4ng th\u1ec3 t\u00ednh ph\u00e1t sinh t\u00e0i kho\u1ea3n",
|
|
4
|
+
$error$$,$condition$$),$callback$$($error$$);$result$$.forEach(function($r$$){$r$$.ck_no=0;$r$$.ck_co=0;$r$$.ck_no_nt=0;$r$$.ck_co_nt=0});$callback$$(null,$result$$)})})},ck:function($callback$$){setImmediate(()=>{let $condition$$={};underscore.extend($condition$$,$query$$);$condition$$.ngay=$query$$.den_ngay;$condition$$.tk=$tk_ck$$;cktk($condition$$,function($error$$,$result$$){if($error$$)return Logger.error("Kh\u00f4ng th\u1ec3 t\u00ednh cu\u1ed1i k\u1ef3 t\u00e0i kho\u1ea3n",$error$$,$condition$$),
|
|
5
|
+
$callback$$($error$$);$result$$.forEach(function($r$$){$r$$.ps_no=0;$r$$.ps_co=0;$r$$.ps_no_nt=0;$r$$.ps_co_nt=0;$r$$.ck_no=$r$$.du_no00;$r$$.ck_co=$r$$.du_co00;$r$$.ck_no_nt=$r$$.du_no_nt00;$r$$.ck_co_nt=$r$$.du_co_nt00});$callback$$(null,$result$$)})})}},async($data_err$$,$rs$$)=>{if($data_err$$)return $callback$$($data_err$$);$data_err$$=$rs$$.ps.concat($rs$$.ck);$data_err$$=await $data_err$$.asyncGroupBy("tk",[{name:"ps_no",value:"ps_no"},{name:"ps_co",value:"ps_co"},{name:"ps_no_nt",value:"ps_no_nt"},
|
|
6
|
+
{name:"ps_co_nt",value:"ps_co_nt"},{name:"ck_no",value:"ck_no"},{name:"ck_co",value:"ck_co"},{name:"ck_no_nt",value:"ck_no_nt"},{name:"ck_co_nt",value:"ck_co_nt"}]);$callback$$(null,$data_err$$)})},{cache:!0,cache_time:5})};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const databanlenpp=require("../../libs/databanlenpp"),async=require("async"),moment=require("moment"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquanctvnpp",async function($m_m$$,$callback$$){const $condition$$=$m_m$$.query;$condition$$.tu_ngay||($m_m$$=moment(),$condition$$.nam&&$m_m$$.set("year",Number($condition$$.nam)),$condition$$.thang?($m_m$$.set("month",Number($condition$$.thang)-1),$condition$$.tu_ngay=$m_m$$.startOf("month").toDate()):$condition$$.tu_ngay=$m_m$$.startOf("year").toDate());$condition$$.den_ngay||($m_m$$=moment(),$condition$$.nam&&$m_m$$.set("year",Number($condition$$.nam)),
|
|
3
|
+
$condition$$.thang?($m_m$$.set("month",Number($condition$$.thang)-1),$condition$$.den_ngay=$m_m$$.endOf("month").toDate()):$condition$$.den_ngay=$m_m$$.endOf("year").toDate());const $query$$={id_app:$condition$$.id_app};$query$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query$$.ma_dvcs=$condition$$.ma_dvcs);$condition$$.ma_kho&&($query$$.ma_kho=$condition$$.ma_kho);$condition$$.ma_ct&&($query$$.ma_ct=$condition$$.ma_ct);$condition$$.user_hoa_hong&&($query$$.$and||
|
|
4
|
+
($query$$.$and=[]),$query$$.$and.push({$or:[{user_nv:$condition$$.user_hoa_hong},{user_ctv:$condition$$.user_hoa_hong},{user_ctv2:$condition$$.user_hoa_hong},{user_kho:$condition$$.user_hoa_hong},{user_gt:$condition$$.user_hoa_hong},{user_ql:$condition$$.user_hoa_hong},{"details.user_nv":$condition$$.user_hoa_hong},{"details.user_ctv":$condition$$.user_hoa_hong},{"details.user_ctv2":$condition$$.user_hoa_hong},{"details.user_kho":$condition$$.user_hoa_hong},{"details.user_gt":$condition$$.user_hoa_hong},
|
|
5
|
+
{"details.user_ql":$condition$$.user_hoa_hong}]}));$condition$$.ma_nv=$condition$$.ma_nv||$condition$$.user_hoa_hong;async.series({npp:$cb$$=>{databanlenpp($query$$,function($error$$,$rs$$){$cb$$($error$$,$rs$$)})}},($error$$,$rs$$)=>{if($error$$)return $callback$$($error$$);async.mapLimit($rs$$.npp,20,function($r$$,$callback$$){$r$$.t_tien_hang_ct=$r$$.details.csum("tien_hang_ct");$r$$.t_thue=$r$$.details.csum("tien_thue");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien_cp=$r$$.details.csum("tien_cp");
|
|
6
|
+
$r$$.tien_ck_hd=$r$$.tien_ck_hd||0;$r$$.t_tien_hoa_hong=$r$$.details.csum("tien_hoa_hong");$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ctv2=$r$$.details.csum("tien_hoa_hong_ctv2");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.t_tien_hoa_hong_kho=$r$$.details.csum("tien_hoa_hong_kho");$r$$.thang=(new Date($r$$.ngay_ct)).getMonth()+1;$r$$.nam=(new Date($r$$.ngay_ct)).getFullYear();
|
|
7
|
+
$condition$$.chi_hien_chua_post_sokho?global.getModel("sokho").find({id_ct:$r$$._id}).lean().then($rs$$=>{$r$$.t_sl_xuat_kho=$rs$$.map($r$$=>$r$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$(null,$r$$)}):$callback$$(null,$r$$)},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$condition$$.chi_hien_chua_post_sokho&&($rs$$=$rs$$.filter($r$$=>!$r$$.t_sl_xuat_kho));let $data_orgin$$=[...$rs$$],$t_doanh_thu_thuan$$=0;$rs$$.forEach($tl$$=>{$t_doanh_thu_thuan$$=$t_doanh_thu_thuan$$+
|
|
8
|
+
($tl$$.t_tien_hang_ct||0)-($tl$$.t_tien_ck||0)+($tl$$.tien_phi_vc||0)-($tl$$.tien_freeship||0)-($tl$$.tien_ck_hd||0)-($tl$$.tien_evoucher||0);$t_doanh_thu_thuan$$-=($tl$$.details_tl||[]).csum("tien_hang_ct")-($tl$$.details_tl||[]).csum("tien_ck");($tl$$.details_tl||[]).forEach($r$$=>{$r$$.t_tien_hoa_hong=0-$r$$.tien_hoa_hong;$r$$.t_tien_hoa_hong_ql=0-$r$$.tien_hoa_hong_ql;$r$$.t_tien_hoa_hong_ctv=0-$r$$.tien_hoa_hong_ctv;$r$$.t_tien_hoa_hong_ctv2=0-($r$$.tien_hoa_hong_ctv2||0);$r$$.t_tien_hoa_hong_gt=
|
|
9
|
+
0-$r$$.tien_hoa_hong_gt;$r$$.t_tien_hoa_hong_kho=0-$r$$.tien_hoa_hong_kho;$r$$.thang=(new Date($tl$$.ngay_ct)).getMonth()+1;$r$$.nam=(new Date($tl$$.ngay_ct)).getFullYear();$data_orgin$$.push($r$$)})});var $data_t_tien_hoa_hong_gt$$=$data_orgin$$.map($r$$=>{let $_r$$=[];$r$$.user_nv&&$r$$.t_tien_hoa_hong&&$_r$$.push({user_hoa_hong:$r$$.user_nv,t_tien_hoa_hong:$r$$.t_tien_hoa_hong,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ql&&$r$$.t_tien_hoa_hong_ql&&$_r$$.push({user_hoa_hong:$r$$.user_ql,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ql,
|
|
10
|
+
thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ctv&&$r$$.t_tien_hoa_hong_ctv&&$_r$$.push({user_hoa_hong:$r$$.user_ctv,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ctv,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ctv2&&$r$$.t_tien_hoa_hong_ctv2&&$_r$$.push({user_hoa_hong:$r$$.user_ctv2,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ctv2,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_kho&&$r$$.t_tien_hoa_hong_kho&&$_r$$.push({user_hoa_hong:$r$$.user_kho,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_kho,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_gt&&
|
|
11
|
+
$r$$.t_tien_hoa_hong_gt&&$_r$$.push({user_hoa_hong:$r$$.user_gt,t_tien_hoa_hong_gt:$r$$.t_tien_hoa_hong_gt,thang:$r$$.thang,nam:$r$$.nam});return $_r$$}).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$data_t_tien_hoa_hong_gt$$=[...$data_t_tien_hoa_hong_gt$$];$condition$$.user_hoa_hong&&($data_t_tien_hoa_hong_gt$$=$data_t_tien_hoa_hong_gt$$.filter($r$$=>$r$$.user_hoa_hong==$condition$$.user_hoa_hong));$error$$=[];$rs$$=$data_t_tien_hoa_hong_gt$$.csum("t_tien_hoa_hong");$data_t_tien_hoa_hong_gt$$=$data_t_tien_hoa_hong_gt$$.csum("t_tien_hoa_hong_gt");
|
|
12
|
+
$error$$.push({nam:"T\u1ed5ng c\u1ed9ng",t_doanh_thu_thuan:$t_doanh_thu_thuan$$,t_tien_hoa_hong:$rs$$,t_tien_hoa_hong_gt:$data_t_tien_hoa_hong_gt$$,t_cong:$rs$$+$data_t_tien_hoa_hong_gt$$,bold:!0});$callback$$(null,$error$$)})})})};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const databanle=require("../../libs/databanle"),async=require("async"),moment=require("moment"),{kpistatus}=require("../../libs/kpistatus"),controller=require("../../controllers/controllerRPT"),_=require("lodash");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquannvbh",async function($m_m$$,$callback$$){const $condition$$=$m_m$$.query;$condition$$.tu_ngay||($m_m$$=moment(),$condition$$.nam&&$m_m$$.set("year",Number($condition$$.nam)),$condition$$.thang?($m_m$$.set("month",Number($condition$$.thang)-1),$condition$$.tu_ngay=$m_m$$.startOf("month").toDate()):$condition$$.tu_ngay=$m_m$$.startOf("year").toDate());$condition$$.den_ngay||($m_m$$=moment(),$condition$$.nam&&$m_m$$.set("year",Number($condition$$.nam)),
|
|
3
|
+
$condition$$.thang?($m_m$$.set("month",Number($condition$$.thang)-1),$condition$$.den_ngay=$m_m$$.endOf("month").toDate()):$condition$$.den_ngay=$m_m$$.endOf("year").toDate());const $query$$={id_app:$condition$$.id_app};$query$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query$$.ma_dvcs=$condition$$.ma_dvcs);$condition$$.ma_kho&&($query$$.ma_kho=$condition$$.ma_kho);$condition$$.ma_ct&&($query$$.ma_ct=$condition$$.ma_ct);$condition$$.user_hoa_hong&&($query$$.$and||
|
|
4
|
+
($query$$.$and=[]),$query$$.$and.push({$or:[{user_nv:$condition$$.user_hoa_hong},{user_ctv:$condition$$.user_hoa_hong},{user_ctv2:$condition$$.user_hoa_hong},{user_kho:$condition$$.user_hoa_hong},{user_gt:$condition$$.user_hoa_hong},{user_ql:$condition$$.user_hoa_hong},{"details.user_nv":$condition$$.user_hoa_hong},{"details.user_ctv":$condition$$.user_hoa_hong},{"details.user_ctv2":$condition$$.user_hoa_hong},{"details.user_kho":$condition$$.user_hoa_hong},{"details.user_gt":$condition$$.user_hoa_hong},
|
|
5
|
+
{"details.user_ql":$condition$$.user_hoa_hong}]}));$condition$$.ma_nv=$condition$$.ma_nv||$condition$$.user_hoa_hong;async.series({cty:$cb$$=>{databanle($query$$,function($error$$,$rs$$){$cb$$($error$$,$rs$$)})},kpi:$cb$$=>{let $_condition$$=_.cloneDeep($condition$$);$_condition$$.tu_thang=(new Date($_condition$$.tu_ngay)).getMonth()+1;$_condition$$.tu_nam=(new Date($_condition$$.tu_ngay)).getFullYear();$_condition$$.den_thang=(new Date($_condition$$.den_ngay)).getMonth()+1;$_condition$$.den_nam=
|
|
6
|
+
(new Date($_condition$$.den_ngay)).getFullYear();if($_condition$$.tu_nam!=$_condition$$.den_nam)return $cb$$("\u0110i\u1ec1u ki\u1ec7n t\u1eeb ng\u00e0y-\u0111\u1ebfn ng\u00e0y kh\u00f4ng h\u1ee3p l\u1ec7");$_condition$$.nam=$_condition$$.den_nam;$_condition$$.ct_theo||($_condition$$.ct_theo="thang");kpistatus($_condition$$).then(async $data_rs$$=>{$data_rs$$=$data_rs$$.rows.filter($r$$=>$r$$.ma_nv);$data_rs$$.forEach($r$$=>{$r$$.t_tien_hoa_hong_kpi=$r$$.t_tien_hoa_hong||0});await $data_rs$$.asyncJoinModel2($_condition$$.id_app,
|
|
7
|
+
"dmnv",{where:"ma_nv",fields:[{user_hoa_hong:"user"}]});$cb$$(null,$data_rs$$)}).catch($e$$=>{Logger.error($e$$);$cb$$($e$$)})}},($error$$,$rs$$)=>{if($error$$)return $callback$$($error$$);let $kpi$$=$rs$$.kpi;async.mapLimit($rs$$.cty,20,function($r$$,$callback$$){$r$$.t_tien_hang_ct=$r$$.details.csum("tien_hang_ct");$r$$.t_thue=$r$$.details.csum("tien_thue");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien_cp=$r$$.details.csum("tien_cp");$r$$.tien_ck_hd=$r$$.tien_ck_hd||0;$r$$.t_tien_hoa_hong=
|
|
8
|
+
$r$$.details.csum("tien_hoa_hong");$r$$.t_tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt");$r$$.t_tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv");$r$$.t_tien_hoa_hong_ctv2=$r$$.details.csum("tien_hoa_hong_ctv2");$r$$.t_tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql");$r$$.t_tien_hoa_hong_kho=$r$$.details.csum("tien_hoa_hong_kho");$r$$.thang=(new Date($r$$.ngay_ct)).getMonth()+1;$r$$.nam=(new Date($r$$.ngay_ct)).getFullYear();$condition$$.chi_hien_chua_post_sokho?global.getModel("sokho").find({id_ct:$r$$._id}).lean().then($rs$$=>
|
|
9
|
+
{$r$$.t_sl_xuat_kho=$rs$$.map($r$$=>$r$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$(null,$r$$)}):$callback$$(null,$r$$)},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$condition$$.chi_hien_chua_post_sokho&&($rs$$=$rs$$.filter($r$$=>!$r$$.t_sl_xuat_kho));let $data_orgin$$=[...$rs$$],$t_doanh_thu_thuan$$=0;$rs$$.forEach($tl$$=>{$t_doanh_thu_thuan$$=$t_doanh_thu_thuan$$+($tl$$.t_tien_hang_ct||0)-($tl$$.t_tien_ck||0)+($tl$$.tien_phi_vc||0)-($tl$$.tien_freeship||0)-($tl$$.tien_ck_hd||
|
|
10
|
+
0)-($tl$$.tien_evoucher||0);$t_doanh_thu_thuan$$-=($tl$$.details_tl||[]).csum("tien_hang_ct")-($tl$$.details_tl||[]).csum("tien_ck");($tl$$.details_tl||[]).forEach($r$$=>{$r$$.t_tien_hoa_hong=0-$r$$.tien_hoa_hong;$r$$.t_tien_hoa_hong_ql=0-$r$$.tien_hoa_hong_ql;$r$$.t_tien_hoa_hong_ctv=0-$r$$.tien_hoa_hong_ctv;$r$$.t_tien_hoa_hong_ctv2=0-($r$$.tien_hoa_hong_ctv2||0);$r$$.t_tien_hoa_hong_gt=0-$r$$.tien_hoa_hong_gt;$r$$.t_tien_hoa_hong_kho=0-$r$$.tien_hoa_hong_kho;$r$$.thang=(new Date($tl$$.ngay_ct)).getMonth()+
|
|
11
|
+
1;$r$$.nam=(new Date($tl$$.ngay_ct)).getFullYear();$data_orgin$$.push($r$$)})});var $data$$=$data_orgin$$.map($r$$=>{let $_r$$=[];$r$$.user_nv&&$r$$.t_tien_hoa_hong&&$_r$$.push({user_hoa_hong:$r$$.user_nv,t_tien_hoa_hong:$r$$.t_tien_hoa_hong,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ql&&$r$$.t_tien_hoa_hong_ql&&$_r$$.push({user_hoa_hong:$r$$.user_ql,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ql,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ctv&&$r$$.t_tien_hoa_hong_ctv&&$_r$$.push({user_hoa_hong:$r$$.user_ctv,
|
|
12
|
+
t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ctv,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_ctv2&&$r$$.t_tien_hoa_hong_ctv2&&$_r$$.push({user_hoa_hong:$r$$.user_ctv2,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_ctv2,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_kho&&$r$$.t_tien_hoa_hong_kho&&$_r$$.push({user_hoa_hong:$r$$.user_kho,t_tien_hoa_hong:$r$$.t_tien_hoa_hong_kho,thang:$r$$.thang,nam:$r$$.nam});$r$$.user_gt&&$r$$.t_tien_hoa_hong_gt&&$_r$$.push({user_hoa_hong:$r$$.user_gt,t_tien_hoa_hong_gt:$r$$.t_tien_hoa_hong_gt,
|
|
13
|
+
thang:$r$$.thang,nam:$r$$.nam});return $_r$$}).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$data$$=[...$data$$,...$kpi$$];$condition$$.user_hoa_hong&&($data$$=$data$$.filter($r$$=>$r$$.user_hoa_hong==$condition$$.user_hoa_hong));$error$$=[];$rs$$=$data$$.csum("t_tien_hoa_hong");let $t_tien_hoa_hong_gt$$=$data$$.csum("t_tien_hoa_hong_gt");$data$$=$data$$.csum("t_tien_hoa_hong_kpi");$error$$.push({nam:"T\u1ed5ng c\u1ed9ng",t_doanh_thu_thuan:$t_doanh_thu_thuan$$,t_tien_hoa_hong:$rs$$,t_tien_hoa_hong_gt:$t_tien_hoa_hong_gt$$,
|
|
14
|
+
t_tien_hoa_hong_kpi:$data$$,t_cong:$rs$$+$t_tien_hoa_hong_gt$$+$data$$,bold:!0});$callback$$(null,$error$$)})})})};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const thnxt=require("../../libs/thnxtnpp"),databanle=require("../../libs/dtbanletheonpp"),controller=require("../../controllers/controllerRPT"),async=require("async"),permission=require("../../libs/permission");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tongquannvnpp",async function($req$$,$callback$$){const $query$$=$req$$.query;if(!$query$$.tu_ngay||!$query$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: tu_ngay,den_ngay");$query$$.groupby=["ma_kho"];delete $query$$.user_hoa_hong;if(!$req$$.user.current_app_info.appAdmin){let $ma_khos$$=await new Promise($rs$$=>{permission.getRightByItem($req$$.user.current_id_app,global.getModel("dmkho"),
|
|
3
|
+
$req$$.user.email,async function($e_khos$$,$_condition$$,$admin$$){if($admin$$)return $rs$$(null);$_condition$$.id_app=$query$$.id_app;$query$$.ma_kho&&($_condition$$.ma_kho=$query$$.ma_kho);$e_khos$$=await global.getModel("dmkho").find($_condition$$,{ma_kho:1}).lean();$rs$$($e_khos$$.map($k$$=>$k$$.ma_kho))})});$query$$.ma_kho=$ma_khos$$}async.series({tonkho:$callback2$$=>{thnxt($query$$,function($error$$,$ton_kho$$){if($error$$)return $callback2$$($error$$);$callback2$$(null,$ton_kho$$)},$log$$=>
|
|
4
|
+
{Logger.info($log$$)})},doanhthu:$callback2$$=>{databanle($req$$.user,$query$$,function($error$$,$dt$$){if($error$$)return $callback2$$($error$$);$callback2$$(null,$dt$$)})}},async($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$e$$=$rs$$.tonkho.concat($rs$$.doanhthu);$e$$=await $e$$.asyncGroupBy(["ma_kho"],["ton_dau","sl_nhap","sl_xuat","ton_cuoi","t_doanh_thu_thuan"]);await $e$$.asyncJoinModel2($req$$.user.current_id_app,"dmkho",{where:"ma_kho",fields:["user_npp","ten_kho"]});$callback$$(null,$e$$)})},
|
|
5
|
+
{stream:!1})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const lenhsx=global.getModel("lenhsx"),dinhmucsx=global.getModel("dinhmucsx"),lenhcapphat=global.getModel("lenhcapphat"),sale_contract=global.getModel("sale_contract"),dmvt=global.getModel("dmvt"),async=require("async"),utils=require("../../libs/utils"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"uoctinhnvl",function($query_lenhsx_req$$,$callback$$){const $condition$$=$query_lenhsx_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u t\u1eeb ng\u00e0y, \u0111\u1ebfn ng\u00e0y");$query_lenhsx_req$$={id_app:$condition$$.id_app,ngay_bat_dau:{$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay}};$condition$$.id_lenhsx&&($query_lenhsx_req$$._id=$condition$$.id_lenhsx);
|
|
3
|
+
$condition$$.id_contract&&($query_lenhsx_req$$.id_contract=$condition$$.id_contract);lenhsx.find($query_lenhsx_req$$).lean().exec(($e$$,$_lenhsxs$$)=>{if($e$$)return Logger.info("uoctinhnvl,eror",$e$$),$callback$$($e$$);async.mapLimit($_lenhsxs$$,20,($_lenhsx$$,$callback$$)=>{$_lenhsx$$.details.joinModel2($condition$$.id_app,dinhmucsx,{where:{id_dinhmucsx:"_id"},fields:{details_dm:"details",so_luong_dm:"so_luong"}},function(){$_lenhsx$$.details.filter($d$$=>$d$$.details_dm).forEach($d_lenhsx$$=>{$d_lenhsx$$.details_dm=
|
|
4
|
+
$d_lenhsx$$.details_dm.filter($dm$$=>(!$dm$$.ma_tt1_sp||$dm$$.ma_tt1_sp===$d_lenhsx$$.ma_tt1_sp)&&(!$dm$$.ma_tt2_sp||$dm$$.ma_tt2_sp===$d_lenhsx$$.ma_tt2_sp)&&(!$dm$$.ma_tt3_sp||$dm$$.ma_tt3_sp===$d_lenhsx$$.ma_tt3_sp));$d_lenhsx$$.details_dm.forEach($d_dinhmucsx$$=>{$d_dinhmucsx$$.sl_dinh_muc=$d_dinhmucsx$$.ma_sp=$d_lenhsx$$.ma_sp;$d_dinhmucsx$$.ma_dvt_sp=$d_lenhsx$$.ma_dvt_sp;$d_dinhmucsx$$.ma_tt1_sp=$d_lenhsx$$.ma_tt1_sp;$d_dinhmucsx$$.ma_tt2_sp=$d_lenhsx$$.ma_tt2_sp;$d_dinhmucsx$$.ma_tt3_sp=$d_lenhsx$$.ma_tt3_sp;
|
|
5
|
+
$d_dinhmucsx$$.id_dinhmucsx=$d_lenhsx$$.id_dinhmucsx/($d_lenhsx$$.so_luong_dm||1);$d_dinhmucsx$$.id_lenhsx=$_lenhsx$$._id.toString();$d_dinhmucsx$$.so_ct_lenhsx=$_lenhsx$$.so_ct.toString();$d_dinhmucsx$$.id_contract=$_lenhsx$$.id_contract;$d_dinhmucsx$$.sl_sx=$d_lenhsx$$.sl_sx;$d_dinhmucsx$$.sl_nhu_cau_chua_hao_hut=utils.round($d_dinhmucsx$$.loai_dinh_muc===1?$d_dinhmucsx$$.sl_sx*$d_dinhmucsx$$.sl_dinh_muc:$d_dinhmucsx$$.sl_dinh_muc,2);$d_dinhmucsx$$.sl_hao_hut=utils.round($d_dinhmucsx$$.sl_nhu_cau_chua_hao_hut*
|
|
6
|
+
$d_dinhmucsx$$.ty_le_hao_hut/100,2);$d_dinhmucsx$$.sl_nhu_cau=$d_dinhmucsx$$.sl_nhu_cau_chua_hao_hut+$d_dinhmucsx$$.sl_hao_hut;$d_dinhmucsx$$.sl_da_cap_phat=0;$d_dinhmucsx$$.sl_ke_hoach=$d_dinhmucsx$$.sl_nhu_cau-$d_dinhmucsx$$.sl_da_cap_phat;$d_dinhmucsx$$.sl_contract=0;$d_dinhmucsx$$.sl_da_nhap=0;$d_dinhmucsx$$.gia=0;$d_dinhmucsx$$.gia_nt=0;$d_dinhmucsx$$.tien=0;$d_dinhmucsx$$.tien_nt=0;$d_dinhmucsx$$.thue_suat=0;$d_dinhmucsx$$.thue=0;$d_dinhmucsx$$.thue_nt=0})});$callback$$()})},$e$$=>{if($e$$)return $callback$$($e$$);
|
|
7
|
+
let $chitiet_kehoach$$=$_lenhsxs$$.map($_lenhsx$$=>$_lenhsx$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]).map($d$$=>$d$$.details_dm).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]).filter($d$$=>$d$$);async.mapLimit($chitiet_kehoach$$,20,($chitiet$$,$callback$$)=>{lenhcapphat.find({id_lenhsx:$chitiet$$.id_lenhsx}).lean().exec(($e$$,$_lenhcapphats$$)=>{if($e$$)return $callback$$($e$$);$chitiet$$.sl_da_cap_phat=$_lenhcapphats$$.map($_l$$=>$_l$$.details.filter($d$$=>$d$$.ma_sp==$chitiet$$.ma_sp&&$d$$.ma_vt===
|
|
8
|
+
$chitiet$$.ma_vt&&(!$d$$.ma_tt1&&!$chitiet$$.ma_tt1||$d$$.ma_tt1===$chitiet$$.ma_tt1)&&(!$d$$.ma_tt2&&!$chitiet$$.ma_tt2||$d$$.ma_tt2===$chitiet$$.ma_tt2)&&(!$d$$.ma_tt3&&!$chitiet$$.ma_tt3||$d$$.ma_tt3===$chitiet$$.ma_tt3)&&(!$d$$.ma_tt1_sp&&!$chitiet$$.ma_tt1_sp||$d$$.ma_tt1_sp===$chitiet$$.ma_tt1_sp)&&(!$d$$.ma_tt2_sp&&!$chitiet$$.ma_tt2_sp||$d$$.ma_tt2_sp===$chitiet$$.ma_tt2_sp)&&(!$d$$.ma_tt3_sp&&!$chitiet$$.ma_tt3_sp||$d$$.ma_tt3_sp===$chitiet$$.ma_tt3_sp)&&(!$d$$.ma_cum_chi_tiet&&!$chitiet$$.ma_cum_chi_tiet||
|
|
9
|
+
$d$$.ma_cum_chi_tiet===$chitiet$$.ma_cum_chi_tiet)&&(!$d$$.ten_cum_chi_tiet&&!$chitiet$$.ten_cum_chi_tiet||$d$$.ten_cum_chi_tiet===$chitiet$$.ten_cum_chi_tiet)&&(!$d$$.ma_cong_doan&&!$chitiet$$.ma_cong_doan||$d$$.ma_cong_doan===$chitiet$$.ma_cong_doan)).csum("so_luong")).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$chitiet$$.sl_ke_hoach=$chitiet$$.sl_nhu_cau-$chitiet$$.sl_da_cap_phat;$chitiet$$.sl_ke_hoach<0&&($chitiet$$.sl_ke_hoach=0);$callback$$()})},$e$$=>{if($e$$)return $callback$$($e$$);async.parallel([$callback$$=>
|
|
10
|
+
{$chitiet_kehoach$$.joinModel2($condition$$.id_app,dmvt,[{where:"ma_vt",fields:"ten_vt"},{where:{ma_sp:"ma_vt"},fields:{ten_sp:"ten_vt"}}],()=>{$callback$$()})},$callback$$=>{$chitiet_kehoach$$.joinModel2($condition$$.id_app,sale_contract,[{where:{id_contract:"_id"},fields:{so_ct_contract:"so_ct"}}],()=>{$callback$$()})}],()=>{let $rs$$=$chitiet_kehoach$$.filter($c$$=>$c$$.sl_nhu_cau>0),$line$$=0;for($line$$=0;$line$$<$rs$$.length;$line$$++)$rs$$[$line$$].line=$line$$,delete $rs$$[$line$$]._id,delete $rs$$[$line$$].$$hashKey;
|
|
11
|
+
$callback$$(null,$rs$$)})})})})})};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const ckdiem=require("../../libs/ckdiem"),Wallet=global.getModel("wallet"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"wallet",($req$$,$callback$$)=>{const $condition$$=$req$$.query;$condition$$.email=$req$$.user.email;ckdiem($condition$$,async($_wallet_error$$,$report$$)=>{if($_wallet_error$$)return $callback$$($_wallet_error$$);let $publicKey$$;try{$publicKey$$=await Wallet.getPublicKey($condition$$.id_app,$condition$$.email)}catch($e$$){return $callback$$($e$$.message)}$_wallet_error$$={balance:$report$$.map($a$$=>$a$$.ton00).reduce(($a$$,$b$$)=>$a$$+
|
|
3
|
+
$b$$,0),publicKey:$publicKey$$};$callback$$(null,$_wallet_error$$)})});new controller($router$$,"wallet/info",async($req$$,$callback$$)=>{const $condition$$={};$req$$.query.email&&($condition$$.email=$req$$.query.email);$condition$$.id_app=$req$$.user.current_id_app;try{const $ws$$=await Wallet.find($condition$$,{email:1,publicKey:1});$callback$$(null,$ws$$)}catch($e$$){$callback$$($e$$.message)}})};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const databanle=require("../../libs/databanle"),dmkh=global.getModel("customer"),transaction=global.getModel("transaction"),async=require("async"),controller=require("../../controllers/controllerRPT");
|
|
2
|
+
module.exports=function($router$$){new controller($router$$,"tkdiemtichluy",async($query_req$$,$callback$$)=>{const $condition$$=$query_req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1:tu_ngay,den_ngay");$query_req$$={id_app:$condition$$.id_app};$query_req$$.ngay_ct={$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay};$condition$$.ma_dvcs&&($query_req$$.ma_dvcs=$condition$$.ma_dvcs);$condition$$.ma_kh&&
|
|
3
|
+
($query_req$$.ma_kh=$condition$$.ma_kh);$condition$$.ma_kho&&($query_req$$.ma_kho=$condition$$.ma_kho);$condition$$.ma_ct&&($query_req$$.ma_ct=$condition$$.ma_ct);$query_req$$.show_bonus_points=!0;databanle($query_req$$,function($error$$,$rs$$){if($error$$)return $callback$$($error$$);async.mapLimit($rs$$,20,function($r$$,$callback$$){$r$$.t_sl_xuat=$r$$.details.csum("sl_xuat");$r$$.t_tien_hang=$r$$.details.csum("tien_hang");$r$$.t_tien_ck=$r$$.details.csum("tien_ck");$r$$.t_tien=$r$$.details.csum("tien");
|
|
4
|
+
$r$$.t_tien_cp=$r$$.details.csum("tien_cp");$r$$.tien_ck_hd=$r$$.tien_ck_hd?$r$$.tien_ck_hd:0;$r$$.t_tien_xuat=$r$$.details.csum("tien_xuat");$r$$.details_tl?($r$$.t_tien_tl=$r$$.details_tl.csum("tien"),$r$$.t_tien_nhap=$r$$.details_tl.csum("tien_nhap"),$r$$.t_sl_nhap=$r$$.details_tl.csum("sl_nhap")):($r$$.t_tien_tl=0,$r$$.t_sl_nhap=0,$r$$.t_tien_nhap=0);$r$$.t_so_bill=$r$$.so_ct!=="HD7"?1:0;$callback$$(null,$r$$)},function($error$$,$rs$$){if($error$$)return $callback$$($error$$);$rs$$.groupBy("ma_kh",
|
|
5
|
+
[{name:"t_so_bill",value:"t_so_bill"},{name:"t_sl_xuat",value:"t_sl_xuat"},{name:"t_tien_hang",value:"t_tien_hang"},{name:"t_tien_cp",value:"t_tien_cp"},{name:"t_tien_ck",value:"t_tien_ck"},{name:"t_tien",value:"t_tien"},{name:"tien_ck_hd",value:"tien_ck_hd"},{name:"t_tien_xuat",value:"t_tien_xuat"},{name:"t_sl_nhap",value:"t_sl_nhap"},{name:"t_tien_tl",value:"t_tien_tl"},{name:"t_tien_nhap",value:"t_tien_nhap"},{name:"t_bonus_points",value:"bonus_points"},{name:"t_used_points",value:"used_points"}],
|
|
6
|
+
async($error$$,$report$$)=>{if($error$$)return $callback$$($error$$);$report$$.forEach(($r$$,$i$$)=>{$r$$.stt=$i$$+1;$r$$.bold=!1;$r$$.t_doanh_thu=$r$$.t_tien-$r$$.tien_ck_hd;$r$$.t_doanh_thu_thuan=$r$$.t_doanh_thu-$r$$.t_tien_tl;$r$$.t_lai=$r$$.t_doanh_thu-$r$$.t_tien_xuat-($r$$.t_tien_tl-$r$$.t_tien_nhap)});await Promise.all($report$$.map(async $r$$=>{$r$$.t_bonus_points=await transaction.in($r$$.ma_kh.toLowerCase(),$condition$$.den_ngay);$r$$.t_used_points=await transaction.out($r$$.ma_kh.toLowerCase(),
|
|
7
|
+
$condition$$.den_ngay);$r$$.balance_points=await transaction.balance($r$$.ma_kh.toLowerCase(),$condition$$.den_ngay);return $r$$}));$report$$=$report$$.filter($r$$=>$r$$.t_bonus_points!=0||$r$$.t_used_points!=0||$r$$.balance_points!=0);await $report$$.asyncJoinModel2($condition$$.id_app,dmkh,[{where:"ma_kh",fields:["ten_kh","dia_chi"]}]);$report$$.push({ten_kh:"T\u1ed5ng c\u1ed9ng",t_so_bill:$report$$.csum("t_so_bill"),t_sl_xuat:$report$$.csum("t_sl_xuat"),t_tien_hang:$report$$.csum("t_tien_hang"),
|
|
8
|
+
t_tien_cp:$report$$.csum("t_tien_cp"),t_tien_ck:$report$$.csum("t_tien_ck"),t_tien:$report$$.csum("t_tien"),tien_ck_hd:$report$$.csum("tien_ck_hd"),t_tien_xuat:$report$$.csum("t_tien_xuat"),t_doanh_thu:$report$$.csum("t_doanh_thu"),t_doanh_thu_thuan:$report$$.csum("t_doanh_thu_thuan"),t_sl_nhap:$report$$.csum("t_sl_nhap"),t_tien_nhap:$report$$.csum("t_tien_nhap"),t_tien_tl:$report$$.csum("t_tien_tl"),t_lai:$report$$.csum("t_lai"),t_bonus_points:$report$$.csum("t_bonus_points"),t_used_points:$report$$.csum("t_used_points"),
|
|
9
|
+
t_balance_points:$report$$.csum("balance_points"),bold:!0});$callback$$(null,$report$$)})})})})};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const model=global.getModel("app"),Participant=global.getModel("participant"),User=global.getModel("user"),UserGroup=global.getModel("usergroup"),Customer=global.getModel("customer"),Trangthai=global.getModel("trangthai"),_Notification=global.getModel("notification"),underscore=require("underscore"),async=require("async"),{isSupperAdmin,isMobilePhone}=require("../../libs/utils"),permission=require("../../libs/permission"),controller=require("../../controllers/controller"),fs=require("fs"),path=require("path"),
|
|
2
|
+
StaticPool=require("../../libs/WorkerStaticPool"),{encrypt}=require("../../libs/utils"),calcTimeExpired=$item$$=>{$item$$.expire_date?($item$$.so_ngay_con_lai=Math.roundBy(($item$$.expire_date-new Date)/864E5,0),$item$$.so_ngay_con_lai<0&&($item$$.so_ngay_con_lai=0)):$item$$.so_ngay_con_lai=0},getParticipantInfo=async($user$$,$item$$,$callback$$)=>{let $_ps$$=await Participant.getPar($user$$,$item$$);$item$$.appAdmin=$_ps$$.admin;$item$$.group_id=$_ps$$.group_id;$item$$.phu_trach_nhom=($_ps$$.group||
|
|
3
|
+
{}).phu_trach==$user$$.email;$item$$.par=$_ps$$;$callback$$()},createUserOwner=async($obj$$,$next$$)=>{var $_p_owner$$=$obj$$.owner;if($_p_owner$$&&$obj$$.user_created!==$_p_owner$$){$_p_owner$$=$_p_owner$$.toLowerCase();let $user$$=await User.findOne({email:$_p_owner$$});if(!$user$$){$user$$=new User;$user$$.email=$_p_owner$$;$user$$.name=$_p_owner$$.split("@")[0];$user$$.local={};$user$$.local.email=$user$$.email;$user$$.local.name=$user$$.name;$user$$.local.picture="/images/avatar.jpg";$user$$.local.password=
|
|
4
|
+
$user$$.generateHash($user$$.email+($obj$$.default_password||$user$$.email+"@123456"));try{await $user$$.save();let $_p$$={email:$_p_owner$$,name:$_p_owner$$.split("@")[0],admin:!0,active:!0,cancel:!1,id_app:$obj$$._id.toString()};await Participant.asyncCreateParticipant($_p$$)}catch($e$$){Logger.error("[createUserOwner] create participant for owner user ",$_p_owner$$,$e$$)}}}$_p_owner$$={email:$obj$$.user_created,name:$obj$$.user_created.split("@")[0],admin:!0,active:!0,cancel:!1,id_app:$obj$$._id.toString()};
|
|
5
|
+
try{await Participant.asyncCreateParticipant($_p_owner$$)}catch($e$$){Logger.error("[create participant for created user ]",$obj$$.user_created,$e$$)}try{await Participant.asyncCreateParticipant({email:"public",name:"Public",admin:!1,active:!0,cancel:!1,id_app:$obj$$._id.toString()})}catch($e$$){Logger.error("[create public participant]",$e$$)}$next$$(null,$obj$$)};
|
|
6
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"app",{unique:["app_code"],require_id_app:!1,sort:{name:1}});$contr_router$$.route();$contr_router$$.found=($user$$,$condition$$,$items$$,$fn$$)=>{async.mapLimit($items$$,20,($item$$,$callback$$)=>{calcTimeExpired($item$$);$callback$$()},$e$$=>{$e$$&&Logger.error($e$$);$fn$$(null,$items$$)})};$contr_router$$.view=function($user$$,$items$$,$fn$$){$items$$.forEach($item$$=>{$item$$.trang_thai=$item$$.trang_thai||
|
|
7
|
+
"0"});async.parallel({trangthai:$callback$$=>{$items$$.joinModel2(null,Trangthai,{where:$item$$=>({ma_ct:"APP",ma_trang_thai:$item$$.trang_thai}),fields:["ten_trang_thai","color"]},()=>{$callback$$()})},show_gia_von_va_nguoi_duyet:$callback$$=>{async.map($items$$,($item$$,$callback$$)=>{$item$$.options=$item$$.options||{};$item$$.show_gia_von=!0;$callback$$()},()=>{$callback$$()})},storageUsage:$callback$$=>{global.storageUsage?async.map($items$$,($item$$,$callback$$)=>{global.storageUsage.getTotalUsageByApp($item$$._id.toString()).then($rs$$=>
|
|
8
|
+
{$item$$.storage_usage=$rs$$;$callback$$()}).catch($e$$=>{Logger.error("[app] kh\u00f4ng th\u1ec3 l\u1ea5y th\u00f4ng tin dung l\u01b0\u1ee3ng \u0111\u00e3 s\u1eed d\u1ee5ng",$e$$);$callback$$()})},()=>{$callback$$()}):$callback$$()},get_par_info:$callback$$=>{async.mapLimit($items$$,20,($item$$,$callback$$)=>{getParticipantInfo($user$$,$item$$,()=>{$item$$.appAdmin||(delete $item$$.viettel_user,delete $item$$.viettel_password,delete $item$$.viettel_url_service,delete $item$$.vnpt_user,delete $item$$.vnpt_password,
|
|
9
|
+
delete $item$$.vnpt_url_service,delete $item$$.easy_user,delete $item$$.easy_password,delete $item$$.easy_url_service,delete $item$$.zalo_app_id,delete $item$$.zalo_secret_key,delete $item$$.zalo_code,delete $item$$.zalo_oa_id,delete $item$$.zalo_code_verifier,delete $item$$.zalo_code_challenge,delete $item$$.zalo_access_token,delete $item$$.zalo_refresh_token,delete $item$$.google_credentials,delete $item$$.wallet_address,delete $item$$.wallet_token,delete $item$$.voiip_access_token,delete $item$$.sip_password,
|
|
10
|
+
delete $item$$.email_host,delete $item$$.email_port,delete $item$$.email_secure,delete $item$$.email_authMethod,delete $item$$.email_user,delete $item$$.email_pass,delete $item$$.email_name,delete $item$$.zalo_app_id,delete $item$$.zalo_secret_key,delete $item$$.zalo_code,delete $item$$.zalo_oa_id,delete $item$$.zalo_access_token,delete $item$$.zalo_refresh_token,delete $item$$.google_credentials,delete $item$$.vnpt_user,delete $item$$.vnpt_password,delete $item$$.vnpt_url_service);$callback$$()})},
|
|
11
|
+
()=>{$callback$$()})}},function(){$items$$.forEach(function($item$$){calcTimeExpired($item$$)});$fn$$(null,$items$$)})};$contr_router$$.getting=async($user$$,$id_p$$,$next$$)=>{($id_p$$=await Participant.findOne({id_app:$id_p$$,email:$user$$.email}).lean())&&$id_p$$.cancel!==!0?$next$$():(Logger.error("[sys-app][getting]participant info of",$user$$.email,$id_p$$),$next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n truy c\u1eadp c\u00f4ng ty n\u00e0y"))};$contr_router$$.finding=async($user$$,$condition$$,
|
|
12
|
+
$next$$)=>{try{var $_appsOfUser_or1$$=await Participant.appsOfUser($user$$.email);$_appsOfUser_or1$$=$_appsOfUser_or1$$.map($p$$=>$p$$.id_app);let $user_created_condition$$={user_created:$user$$.email};$_appsOfUser_or1$$=[{_id:{$in:$_appsOfUser_or1$$}},$user_created_condition$$];let $or2$$=$condition$$.$or;delete $condition$$.$or;$or2$$?$condition$$.$and=[{$or:$_appsOfUser_or1$$},{$or:$or2$$}]:$condition$$.$or=$_appsOfUser_or1$$;$condition$$.working||(isSupperAdmin($user$$.email.toLowerCase())?delete $user_created_condition$$.user_created:
|
|
13
|
+
underscore.contains(configs.admins,$user$$.email)&&($user_created_condition$$.user_created={$nin:["invncur@gmail.com","admin"]}));delete $condition$$.working;$user$$.token_id_app&&($condition$$._id=$user$$.token_id_app);$user$$.token_id_apps&&$user$$.token_id_apps.length>0&&($condition$$._id={$in:$user$$.token_id_apps});$next$$(null,$condition$$)}catch($e$$){Logger.error("[sys-app] finding:",$e$$),$next$$($e$$.message||$e$$.error||$e$$)}};$contr_router$$.creating=async function($user$$,$obj$$,$next$$){if($user$$.token_id_app||
|
|
14
|
+
$user$$.token_id_apps&&$user$$.token_id_apps.length>0)return $next$$({error:"Kh\u00f4ng th\u1ec3 t\u1ea1o c\u00f4ng ty m\u1edbi v\u1edbi m\u1eadt kh\u1ea9u b\u1ea1n \u0111ang s\u1eed d\u1ee5ng. H\u00e3y \u0111\u0103ng nh\u1eadp b\u1eb1ng m\u1eadt kh\u1ea9u ch\u00ednh c\u1ee7a b\u1ea1n \u0111\u1ec3 t\u1ea1o c\u00f4ng ty m\u1edbi"});if(!$user$$.admin){var $now_sl_da_tao$$=await model.countDocuments({user_created:$user$$.email});$user$$=await global.getModel("user").findOne({email:$user$$.email}).lean();
|
|
15
|
+
if($now_sl_da_tao$$>=($user$$?.so_luong_db||1))return $next$$("S\u1ed1 l\u01b0\u1ee3ng c\u00f4ng ty b\u1ea1n c\u00f3 th\u1ec3 kh\u1edfi t\u1ea1o \u0111\u00e3 h\u1ebft.");delete $obj$$.allow_modules;delete $obj$$.trang_thai;delete $obj$$.sale_online;delete $obj$$.dung_luong_duoc_su_dung;delete $obj$$.so_tai_lieu_duoc_su_dung}if(!$obj$$.ngay_dn)return $next$$(Error("Ng\u00e0y \u0111\u1ea7u n\u0103m t\u00e0i ch\u00ednh kh\u00f4ng \u0111\u01b0\u1ee3c tr\u1ed1ng"));$obj$$.ngay_ks||($obj$$.ngay_ks=new Date("2000-01-01"));
|
|
16
|
+
$obj$$.ngay_ky1||($obj$$.ngay_ky1=new Date);$now_sl_da_tao$$=new Date;$now_sl_da_tao$$.setMonth($now_sl_da_tao$$.getMonth()+1);$obj$$.expire_date=new Date($now_sl_da_tao$$);$obj$$.nam_bd=$obj$$.ngay_ky1.getFullYear();$obj$$.options=$obj$$.options||{};$obj$$.ai_api_key&&!$obj$$.ai_api_key.startsWith("flexbiz::")&&($obj$$.ai_api_key="flexbiz::"+encrypt($obj$$.ai_api_key));$next$$(null,$obj$$)};$contr_router$$.created=function($user$$,$obj$$,$next$$){Logger.warn("\ud83d\udd25[app][created] Kh\u1edfi t\u1ea1o d\u1eef li\u1ec7u cho c\u00f4ng ty m\u1edbi...");
|
|
17
|
+
require("../../libs/initDatabase").init($obj$$._id,async $error$$=>{if($error$$)return Logger.error("[app][created] Kh\u00f4ng th\u1ec3 kh\u1edfi t\u1ea1o d\u1eef li\u1ec7u cho c\u00f4ng ty m\u1edbi. L\u1ed7i:"+$error$$),$next$$(`Kh\u00f4ng th\u1ec3 kh\u1edfi t\u1ea1o d\u1eef li\u1ec7u cho c\u00f4ng ty m\u1edbi. L\u1ed7i: ${$error$$.message||$error$$.error||$error$$}`);Logger.warn("\u2705 [app][created] \u0111\u00e3 kh\u1edfi t\u1ea1o xong d\u1eef li\u1ec7u cho c\u00f4ng ty m\u1edbi");createUserOwner($obj$$,
|
|
18
|
+
$e$$=>{if($e$$)return Logger.error("[app][created] Kh\u00f4ng th\u1ec3 kh\u1edfi t\u1ea1o ng\u01b0\u1eddi d\u00f9ng cho c\u00f4ng ty m\u1edbi. L\u1ed7i:",$e$$),$next$$(`Kh\u00f4ng th\u1ec3 kh\u1edfi t\u1ea1o ng\u01b0\u1eddi d\u00f9ng cho c\u00f4ng ty m\u1edbi. L\u1ed7i: ${$e$$.message||$e$$.error||$e$$}`);Logger.warn("\u2705 [app][created] \u0111\u00e3 t\u1ea1o xong c\u00f4ng ty m\u1edbi");$next$$(null,$obj$$)})})};$contr_router$$.updating=async function($user$$,$data$$,$obj$$,$next$$){delete $data$$.ngay_ks;
|
|
19
|
+
$user$$.admin||(delete $data$$.allow_modules,delete $data$$.expire_date,delete $data$$.trang_thai,delete $data$$.sale_online,delete $data$$.menu_code,delete $data$$.ai_api_key,delete $obj$$.dung_luong_duoc_su_dung,delete $obj$$.so_tai_lieu_duoc_su_dung);$data$$.ai_api_key&&!$data$$.ai_api_key.startsWith("flexbiz::")&&($data$$.ai_api_key="flexbiz::"+encrypt($data$$.ai_api_key));permission.isAdmin($obj$$._id,$user$$.email,function($e$$,$admin$$){if(!$admin$$&&!$user$$.admin)return $next$$($user$$.email+
|
|
20
|
+
" have not permission");$data$$.ngay_ky1&&($data$$.nam_bd=(new Date($data$$.ngay_ky1)).getFullYear());$data$$.options&&Object.keys($data$$.options).length===0&&delete $data$$.options;$data$$.options=$data$$.options?{...$obj$$.options,...$data$$.options}:$obj$$.options||{};$next$$(null,$data$$,$obj$$)})};$contr_router$$.updated=function($user$$,$obj$$,$next$$){createUserOwner($obj$$,$e$$=>{$e$$&&Logger.error($e$$);$next$$(null,$obj$$)})};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){if($user$$.email!=
|
|
21
|
+
$obj$$.user_created&&!$user$$.admin)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n x\u00f3a c\u00f4ng ty n\u00e0y");$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){async.mapLimit(fs.readdirSync(path.dirname(path.dirname(__dirname))+"/models").filter($f$$=>$f$$.indexOf(".js")>0),20,($file$$,$callback$$)=>{try{let $_model$$=global.getModel(""+$file$$);underscore.has($_model$$.schema.paths,"id_app")?$_model$$.deleteMany({id_app:$obj$$._id},()=>{Logger.info("Deleted ",
|
|
22
|
+
$file$$,"id_app",$obj$$._id);$callback$$()}):$callback$$()}catch($e$$){Logger.error("Can't delete mode",$file$$,"error:",$e$$.message),$callback$$()}},()=>{$next$$(null,$obj$$)})};$contr_router$$.router.route($contr_router$$.route_name+"/backup/:id").get(function($req$$,$res$$){let $email$$=$req$$.user.email,$id_app$$=$req$$.params.id;permission.isAdmin($id_app$$,$email$$,function($backupWorkerFile_e$$,$admin$$){if(!$admin$$)return $res$$.status(400).send({error:"Ch\u1ec9 admin m\u1edbi c\u00f3 quy\u1ec1n backup d\u1eef li\u1ec7u c\u1ee7a c\u00f4ng ty"});
|
|
23
|
+
global.backupPool||($backupWorkerFile_e$$=path.dirname(path.dirname(__dirname))+"/workers/backupApp.js",global.backupPool=new StaticPool($backupWorkerFile_e$$,0,1,18E5));global.getModel("log").create({id_app:$id_app$$,id_func:"app",action:"BACKUP",data:{dateFrom:$req$$.query.dateFrom,dateTo:$req$$.query.dateTo,backup_app_info:$req$$.query.backup_app_info}},$req$$.user.email,$req$$.user_agent,$req$$);global.backupPool.exec({id:$id_app$$,user:$email$$,dateFrom:$req$$.query.dateFrom,dateTo:$req$$.query.dateTo,
|
|
24
|
+
backup_app_info:$req$$.query.backup_app_info,configs:{database:global.configs.database}},$response$$=>{if($response$$.error)return $res$$.status(400).send($response$$.error);Logger.info("[app][backup]",JSON.stringify($response$$,null,2));$res$$.sendFile($response$$.file)})})});$contr_router$$.router.route($contr_router$$.route_name+"/restore/:id").post(async function($req$$,$res$$){let $fileZip$$;$req$$.files&&$req$$.files.backup&&$req$$.files.backup.path?$fileZip$$=$req$$.files.backup.path:$req$$.body&&
|
|
25
|
+
$req$$.body.file_from_server&&fs.existsSync($req$$.body.file_from_server)&&($fileZip$$=$req$$.body.file_from_server);if(!$fileZip$$)return $res$$.status(400).send("Kh\u00f4ng t\u00ecm th\u1ea5y file backup");let $email$$=$req$$.user.email,$id_app$$=$req$$.params.id;permission.isAdmin($id_app$$,$email$$,function($backupWorkerFile$jscomp$1_e$$,$admin$$){if(!$admin$$)return $res$$.status(400).send({error:"Ch\u1ec9 admin m\u1edbi c\u00f3 quy\u1ec1n restore d\u1eef li\u1ec7u c\u1ee7a c\u00f4ng ty"});global.backupPool||
|
|
26
|
+
($backupWorkerFile$jscomp$1_e$$=path.dirname(path.dirname(__dirname))+"/workers/backupApp.js",global.backupPool=new StaticPool($backupWorkerFile$jscomp$1_e$$,0,1,18E5));global.backupPool.exec({id:$id_app$$,user:$email$$,configs:{database:global.configs.database}},$response$$=>{if($response$$.error)return $res$$.status(400).send($response$$.error);global.getModel("log").create({id_app:$id_app$$,id_func:"app",action:"RESTORE",data:{backup_file:path.dirname(path.dirname(__dirname))+"/backup/"+$response$$.file,
|
|
27
|
+
restore_file:$fileZip$$}},$req$$.user.email,$req$$.user_agent,$req$$);global.restorePool||($response$$=path.dirname(path.dirname(__dirname))+"/workers/restoreApp.js",global.restorePool=new StaticPool($response$$,0,1,18E5));global.restorePool.exec({id:$id_app$$,user:$email$$,file:$fileZip$$,configs:{database:global.configs.database}},$response$$=>{$response$$.error?(Logger.error("[restore data] l\u1ed7i khi restore data",$response$$.error),_Notification.createNotification($email$$,$email$$,$response$$.error,
|
|
28
|
+
$response$$.error,null,null,!0,$req$$.access_token,!0)):(Logger.info("[restore data] \u0111\u00e3 ho\u00e0n th\u00e0nh restore d\u1eef li\u1ec7u. \u0110ang g\u1eedi email th\u00f4ng b\u00e1o k\u1ebft qu\u1ea3"),_Notification.createNotification($email$$,$email$$,$response$$.result,$response$$.result,null,null,!0,$req$$.access_token,!0))});$res$$.send("Ch\u01b0\u01a1ng tr\u00ecnh \u0111ang th\u1ef1c hi\u1ec7n. Xin ch\u1edd trong gi\u00e2y l\u00e1t")})})});$contr_router$$.router.route($contr_router$$.route_name+
|
|
29
|
+
"/apps/:email_owner").get(async function($query_req$$,$res$$){var $_appsOfUser$jscomp$1_email$$=$query_req$$.params.email_owner;if(!underscore.contains(configs.admins,$query_req$$.user.email)&&!isSupperAdmin($query_req$$.user.email.toLowerCase()))return $res$$.status(403).send("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n truy c\u1eadp t\u00ednh n\u0103ng n\u00e0y");$query_req$$={};$_appsOfUser$jscomp$1_email$$.toLowerCase()!="all"&&($_appsOfUser$jscomp$1_email$$=await Participant.appsOfUser($_appsOfUser$jscomp$1_email$$),
|
|
30
|
+
$_appsOfUser$jscomp$1_email$$=$_appsOfUser$jscomp$1_email$$.map($p$$=>$p$$.id_app),$query_req$$._id={$in:$_appsOfUser$jscomp$1_email$$});model.find($query_req$$).lean().exec(function($error$$,$apps$$){if($error$$)return $res$$.status(400).send($error$$);$apps$$.forEach(function($item$$){calcTimeExpired($item$$)});$res$$.send($apps$$)})});$contr_router$$.router.route($contr_router$$.route_name+"/remove/:id").get(async($app_req$$,$res$$)=>{var $id_app$jscomp$2_p$$=$app_req$$.params.id;let $email$$=
|
|
31
|
+
$app_req$$.user.email;$app_req$$=await model.findById($id_app$jscomp$2_p$$);if(!$app_req$$)return $res$$.status(400).send("C\u00f4ng ty n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i");$app_req$$.participants&&($app_req$$.participants=$app_req$$.participants.filter($p$$=>$p$$.email!==$email$$),$app_req$$.save(()=>{}));if($id_app$jscomp$2_p$$=await Participant.findOne({id_app:$id_app$jscomp$2_p$$,email:$email$$}))await Participant.deleteOne({_id:$id_app$jscomp$2_p$$._id}),$id_app$jscomp$2_p$$=`${$id_app$jscomp$2_p$$.name} (${$email$$}) \u0111\u00e3 r\u1eddi kh\u1ecfi c\u00f4ng ty ${$app_req$$.name}`,
|
|
32
|
+
_Notification.createNotification($email$$,$app_req$$.user_created,$id_app$jscomp$2_p$$,$id_app$jscomp$2_p$$);$res$$.send("ok")});$contr_router$$.router.route($contr_router$$.route_name+"/join/:id/:group").get(async($req$$,$res$$)=>{let $id_app$$=$req$$.params.id,$group_id$$=$req$$.params.group,$email$$=$req$$.user.email,$user$$=$req$$.user,$app$$=await model.findById($id_app$$);if(!$app$$)return $res$$.status(400).send("C\u00f4ng ty n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i");if(!await Participant.findOne({id_app:$id_app$$,
|
|
33
|
+
email:$email$$})&&$group_id$$&&global.mongoose.Types.ObjectId.isValid($group_id$$))try{if(!await UserGroup.findOne({_id:$group_id$$,is_customer_group:!0}))return $res$$.status(400).send("Nh\u00f3m kh\u00e1ch h\u00e0ng kh\u00f4ng t\u1ed3n t\u1ea1i");Participant.createParticipant({id_app:$id_app$$,email:$email$$,name:$user$$.name,group_id:$group_id$$,active:!0},$cust_e$$=>{if($cust_e$$)return $res$$.status(400).send("can't add user",$user$$.email,"to company",$app$$.name);$cust_e$$={ten_kh:$user$$.name,
|
|
34
|
+
email:$user$$.email,id_app:$id_app$$,user_created:$user$$.email,user_updated:$user$$.email,kh_yn:!0,of_user:$user$$.email};isMobilePhone($user$$.email,["vi-VN"])&&($cust_e$$.dien_thoai=$user$$.email);try{Customer.asyncCreateCustomer($cust_e$$)}catch($e$$){Logger.info("Auto create new customer with error:",$e$$.message)}$res$$.send("ok")})}catch($e$$){$res$$.status(400).send($e$$.message)}$res$$.send("ok")})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const model=global.getModel("colleague"),app=global.getModel("app"),User=global.getModel("user"),_Notification=global.getModel("notification"),emailer=require("../../libs/email"),loadTemplate=require("../../libs/load-template"),underscore=require("underscore"),async=require("async"),controller=require("../../controllers/controller"),validator=require("validator"),{onAfterCommit}=require("../../libs/sessionContext");
|
|
2
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"colleague",{require_id_app:!1,unique:["email_owner","email"]});$contr_router$$.route();$contr_router$$.view=function($user$$,$result$$,$fn$$){$result$$.joinModel(void 0,User,[{akey:"email",bkey:"email",fields:[{name:"name",value:"name"},{name:"picture",value:"picture"}]},{akey:"email_owner",bkey:"email",fields:[{name:"name_owner",value:"name"},{name:"picture_owner",value:"picture"}]}],function(){$result$$.forEach(function($r$$){$r$$.picture||
|
|
3
|
+
($r$$.picture="/images/avatar.jpg");$r$$.name||($r$$.name=$r$$.email);$r$$.picture_owner||($r$$.picture_owner="/images/avatar.jpg");$r$$.name_owner||($r$$.name_owner=$r$$.email_owner);$r$$.user=$user$$;$r$$.email_owner==$user$$.email?($r$$.email_coll=$r$$.email,$r$$.picture_coll=$r$$.picture,$r$$.name_coll=$r$$.name):($r$$.email_coll=$r$$.email_owner,$r$$.picture_coll=$r$$.picture_owner,$r$$.name_coll=$r$$.name_owner)});$fn$$(null,$result$$)})};$contr_router$$.getting=function($user$$,$id$$,$next$$,
|
|
4
|
+
$obj$$){if($obj$$.email_owner!=$user$$.email)return $next$$("Kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p");$next$$()};$contr_router$$.finding=function($user$$,$condition$$,$next$$){$condition$$.me&&($user$$.me=!0,delete $condition$$.me);$condition$$.$or?($condition$$.$and=[{$or:$condition$$.$or},{$or:[{email_owner:$user$$.email},{$and:[{email:$user$$.email},{cancel:!1}]}]}],delete $condition$$.$or):$condition$$.$or=[{email_owner:$user$$.email},{$and:[{email:$user$$.email},{cancel:!1}]}];$next$$(null,
|
|
5
|
+
$condition$$)};$contr_router$$.found=function($user$$,$condition$$,$items$$,$next$$){$user$$.me&&$items$$.push({email:$user$$.email,email_owner:$user$$.email});$next$$(null,$items$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.email_owner=$user$$.email;if(!validator.isEmail($obj$$.email))return $next$$("L\u1ed7i: Email n\u00e0y kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb");$next$$(null,$obj$$)};$contr_router$$.created=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email,
|
|
6
|
+
$obj$$.id_app);onAfterCommit(()=>{User.findOne({email:$obj$$.email_owner},{name:1},function($error$$,$u$$){$u$$&&loadTemplate("thu moi gia nhap nhom.html",{receiver_name:$obj$$.email,sender_name:$u$$.name},function($error$$,$html$$){if($error$$)return Logger.info($error$$);$html$$&&emailer.sendHtml({to:{name:$obj$$.email,address:$obj$$.email},subject:"Th\u01b0 m\u1eddi tham gia nh\u00f3m l\u00e0m vi\u1ec7c",html:$html$$},function($error$$){$error$$&&Logger.error("Khong the gui email thon tin tai khoan cho nguoi dung\n"+
|
|
7
|
+
$error$$)})})})});$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){if($user$$.email!=$obj$$.email_owner)return $next$$("Kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p");$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){onAfterCommit(()=>{app.find({user_created:$user$$.email,participants:{$elemMatch:{email:$obj$$.email}}},function($error$$,$results$$){async.each($results$$,function($a$$,$callback$$){var $participants$$=underscore.reject($a$$.participants,
|
|
8
|
+
function($p$$){return $p$$.email==$obj$$.email});app.findByIdAndUpdate($a$$._id,{participants:$participants$$},function($error$$){if($error$$)return $callback$$($error$$);$callback$$()})},function($error$$){$error$$&&Logger.error($error$$)})})});$next$$(null,$obj$$)};$contr_router$$.router.route($contr_router$$.route_name+"/active/:id").get(function($req$$,$res$$){var $id$$=$req$$.params.id,$email$$=$req$$.user.email;model.findOne({_id:$id$$,email:$email$$,active:!1,cancel:!1},function($error$$,$coll$$){if($error$$)return $res$$.send(400,
|
|
9
|
+
$error$$);$coll$$?($coll$$.active=!0,$coll$$.save(function($err$$){if($err$$)return $res$$.send(400,$err$$);_Notification.createNotification($email$$,$coll$$.email_owner,"Ch\u1ea5p nh\u1eadn gia nh\u1eadp m\u1ea1ng c\u1ee7a b\u1ea1n","\u0111\u00e3 ch\u1ea5p nh\u1eadn gia nh\u1eadp m\u1ea1ng c\u1ee7a b\u1ea1n");$res$$.send("ok")})):$res$$.send(400,"Not found colleague "+$id$$)})});$contr_router$$.router.route($contr_router$$.route_name+"/notaccept/:id").get(function($req$$,$res$$){var $id$$=$req$$.params.id,
|
|
10
|
+
$email$$=$req$$.user.email;model.findOne({_id:$id$$,email:$email$$},function($error$$,$coll$$){if($error$$)return $res$$.send(400,$error$$);$coll$$?($coll$$.active=!1,$coll$$.cancel=!0,$coll$$.save(function($err$$){if($err$$)return $res$$.send(400,$err$$);_Notification.createNotification($email$$,$coll$$.email_owner,"Kh\u00f4ng ch\u1ea5p nh\u1eadn gia nh\u1eadp m\u1ea1ng c\u1ee7a b\u1ea1n","\u0111\u00e3 kh\u00f4ng ch\u1ea5p nh\u1eadn gia nh\u1eadp m\u1ea1ng c\u1ee7a b\u1ea1n");$res$$.send("ok")})):
|
|
11
|
+
$res$$.send(400,"Not found colleague "+$id$$)})})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("data_list_config"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"data_list_config",{sort:{moduleCode:1},require_id_app:!1,unique:["moduleCode"]})).route()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("domain"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"domain",{require_id_app:!1,unique:["domain"],onFinding:($user$$,$condition$$,$next$$)=>{$user$$.admin?$next$$(null,$condition$$):$next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n truy c\u1eadp th\u00f4ng tin n\u00e0y")}})).route()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("ecomproductlines"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"ecomproductlines",{require_id_app:!1,unique:["ma_nganh_hang"],sort:{stt:1},onFinding:($user$$,$condition$$,$next$$)=>{$condition$$.id_app&&($condition$$.$or=[{id_apps:{$exists:!1}},{id_apps:[]},{id_apps:$condition$$.id_app}]);delete $condition$$.id_app;$next$$(null,$condition$$)}})).route()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("exportexceltemplate"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"exportexceltemplate",{require_id_app:!1,sort:{code:1,stt:1}})).route()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("fieldright"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"fieldright",{require_id_app:!1,unique:["ma_ct","field_name"],sort:{ma_ct:1}})).route()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("importexceltemplate"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"importexceltemplate",{require_id_app:!1,sort:{code:1,stt:1}})).route()};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const model=global.getModel("labelinfo"),controller=require("../../controllers/controller"),underscore=require("underscore");
|
|
2
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"labelinfo",{require_id_app:!1,unique:["labelid","textid"],sort:{labelid:1},onView:async($user$$,$items$$,$next$$)=>{$next$$(null,$items$$)}});$contr_router$$.deleting=function($user$$,$obj$$,$fn$$){const {admins:$admins$$}=configs;underscore.contains($admins$$,$user$$.email)?$fn$$(null,$obj$$):$fn$$("B\u1ea1n kh\u00f4ng th\u1ec3 x\u00f3a n\u1ed9i dung n\u00e0y")};$contr_router$$.creating=async($user$$,$data$$,
|
|
3
|
+
$fn$$)=>{if($data$$.textv.length>2024)return $fn$$("Nh\u00e3 qu\u00e1 d\u00e0i");$data$$.labelid=$data$$.labelid||$data$$.textv;const {admins:$admins$$}=configs;underscore.contains($admins$$,$user$$.email)||$user$$.email==="public"?$fn$$(null,$data$$):$fn$$("B\u1ea1n kh\u00f4ng th\u1ec3 t\u1ea1o label")};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$fn$$){const {admins:$admins$$}=configs;underscore.contains($admins$$,$user$$.email)?$fn$$(null,$data$$,$obj$$):$fn$$("B\u1ea1n kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt n\u1ed9i dung n\u00e0y")};
|
|
4
|
+
$contr_router$$.route()};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const model=global.getModel("listinfo"),controller=require("../../controllers/controller"),{isSupperAdmin}=require("../../libs/utils"),underscore=require("underscore"),async=require("async"),{onAfterCommit}=require("../../libs/sessionContext");
|
|
2
|
+
module.exports=function($router$$){(new controller($router$$,model,"listinfo",{sort:{code:1},require_id_app:!1,unique:["code"],onFinding:($$or_endpoints_user$$,$condition$$,$next$$)=>{$condition$$.is_endpoint&&($$or_endpoints_user$$=Object.values(global.controllers).filter($v$$=>$condition$$.require_id_app&&$v$$.options.require_id_app==0?!1:!0).map($v$$=>$v$$.name.toLowerCase()),delete $condition$$.require_id_app,delete $condition$$.is_endpoint,$condition$$.code&&($$or_endpoints_user$$=$$or_endpoints_user$$.filter($e$$=>
|
|
3
|
+
$e$$==$condition$$.code)),$$or_endpoints_user$$=[{api_code:{$in:$$or_endpoints_user$$}},{code:{$in:$$or_endpoints_user$$}}],$condition$$.$or?$condition$$.$and?$condition$$.$and.push({$or:$$or_endpoints_user$$}):$condition$$.$and=[{$or:$$or_endpoints_user$$},{...$condition$$}]:$condition$$.$or=$$or_endpoints_user$$);delete $condition$$.is_endpoint;Logger.info("condition listinfo",JSON.stringify($condition$$,null,2));$next$$(null,$condition$$)},onCreating:($user$$,$obj$$,$next$$)=>{if(!underscore.contains(configs.admins,
|
|
4
|
+
$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$obj$$)},onUpdating:($user$$,$data$$,$obj$$,$next$$)=>{if($data$$.code&&$data$$.code!==$obj$$.code&&$obj$$.create_model)return $next$$("Kh\u00f4ng th\u1ec3 s\u1eeda code c\u1ee7a danh m\u1ee5c n\u00e0y");if($obj$$.allow_users&&$obj$$.allow_users.split(",").indexOf($user$$.email)>=0)return $next$$(null,$data$$,$obj$$);const {subAdmins:$subAdmins$$,
|
|
5
|
+
admins:$usersAdmin$$}=configs;if($subAdmins$$.indexOf($user$$.email)>=0){for(let $key$$ in $data$$)$key$$!="fields"&&delete $data$$[$key$$];return $next$$(null,$data$$,$obj$$)}if(!underscore.contains($usersAdmin$$,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase())&&($obj$$.allow_users||"").indexOf($user$$.email)<0)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$data$$,$obj$$)},onCreated:($user$$,$obj$$,$next$$)=>{onAfterCommit(()=>
|
|
6
|
+
{$obj$$.create_model&&(Logger.info("created listinfo",$obj$$.code),model.createController(global.routerAPI,$obj$$),global.getModel("user").socketSendToOtherServer("system","listinfo_updated",{listinfo_id:$obj$$._id}))});$next$$(null,$obj$$)},onUpdated:($user$$,$obj$$,$next$$)=>{onAfterCommit(()=>{$obj$$.create_model&&(Logger.info("updated listinfo",$obj$$.code),model.createController(global.routerAPI,$obj$$),global.getModel("user").socketSendToOtherServer("system","listinfo_updated",{listinfo_id:$obj$$._id}))});
|
|
7
|
+
$next$$(null,$obj$$)},onDeleting:($user$$,$obj$$,$next$$)=>{if($obj$$.user_created!==$user$$.email&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$obj$$)},onView:($user$$,$items$$,$next$$)=>{const {admins:$usersAdmin$$,subAdmins:$subAdmins$$}=configs;!underscore.contains($usersAdmin$$,$user$$.email)&&$subAdmins$$.indexOf($user$$.email)<0&&!isSupperAdmin($user$$.email.toLowerCase())&&($items$$=
|
|
8
|
+
$items$$.filter($i$$=>$i$$.code!="listinfo"&&$i$$.code!="reportinfo"&&$i$$.code!="moduleinfo"&&$i$$.code!="menuinfo"));async.map($items$$,($item$$,$callback$$)=>{setImmediate(async()=>{await ($item$$.fields||[]).filter($field$$=>$field$$.ref_model).asyncJoinModel2(null,"listinfo",{where:{ref_model:"code"},fields:[{ref_api:"api_code"}]});let $schema$$;$item$$.require_id_app==="false"&&($item$$.require_id_app=!1);$item$$.require_id_app==="true"&&($item$$.require_id_app=!0);$item$$.not_need_right===
|
|
9
|
+
"false"&&($item$$.not_need_right=!1);$item$$.not_need_right==="true"&&($item$$.not_need_right=!0);if($item$$.mother_code){let [$code$$,$child$$,$child2$$,$child3$$]=$item$$.mother_code.split("/");var $_model__model$$=global.mongoose.models[$code$$];$_model__model$$&&($schema$$=$_model__model$$.schema)&&$child$$&&$schema$$.paths[$child$$]&&($schema$$=$schema$$.paths[$child$$].schema)&&$child2$$&&$schema$$.paths[$child2$$]&&($schema$$=$schema$$.paths[$child2$$].schema)&&$child3$$&&$schema$$.paths[$child3$$]&&
|
|
10
|
+
($schema$$=$schema$$.paths[$child3$$].schema)}else if($_model__model$$=global.mongoose.models[$item$$.code])$schema$$=$_model__model$$.schema;$schema$$&&($item$$.fields||[]).forEach($field$$=>{var $maxlength_path$$=$schema$$.paths[$field$$.name];$maxlength_path$$&&$field$$.type==="String"&&($maxlength_path$$=$maxlength_path$$.options.maxlength||4E3,$field$$.maxlength=$field$$.maxlength||$maxlength_path$$)});$callback$$()})},()=>{$next$$(null,$items$$)})}})).route()};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const model=global.getModel("menuinfo"),underscore=require("underscore"),controller=require("../../controllers/controller"),{isSupperAdmin}=require("../../libs/utils");
|
|
2
|
+
module.exports=function($router$$){(new controller($router$$,model,"menuinfo",{sort:{code:1},require_id_app:!1,unique:["code"],onFinding:($user$$,$condition$$,$next$$)=>{$next$$(null,$condition$$)},onCreating:($user$$,$obj$$,$next$$)=>{if(!underscore.contains(configs.admins,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$obj$$)},onUpdating:($user$$,$data$$,$obj$$,$next$$)=>
|
|
3
|
+
{if(!underscore.contains(configs.admins,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$data$$,$obj$$)},onCreated:($user$$,$obj$$,$next$$)=>{$next$$(null,$obj$$)},onUpdated:($user$$,$obj$$,$next$$)=>{$next$$(null,$obj$$)},onDeleting:($user$$,$obj$$,$next$$)=>{if($obj$$.user_created!==$user$$.email&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");
|
|
4
|
+
$next$$(null,$obj$$)},onView:($user$$,$items$$,$next$$)=>{$next$$(null,$items$$)}})).route()};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const model=global.getModel("message"),User=global.getModel("user"),async=require("async"),controller=require("../../controllers/controller"),{onAfterCommit}=require("../../libs/sessionContext");
|
|
2
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"message",{require_id_app:!1,sort:{date_created:1}});$contr_router$$.route();$contr_router$$.view=function($user$$,$result$$,$fn$$){$result$$.joinModel(void 0,User,[{akey:"email_sender",bkey:"email",fields:[{name:"name_sender",value:"name"},{name:"picture_sender",value:"picture"}]},{akey:"email_receiver",bkey:"email",fields:[{name:"name_receiver",value:"name"},{name:"picture_receiver",value:"picture"}]}],
|
|
3
|
+
function(){$result$$.forEach(function($r$$){$r$$.picture_sender||($r$$.picture_sender="/images/avatar.jpg");$r$$.name_sender||($r$$.name_sender=$r$$.email_sender);$r$$.picture_receiver||($r$$.picture_receiver="/images/avatar.jpg");$r$$.name_receiver||($r$$.name_receiver=$r$$.email_receiver)});$fn$$(null,$result$$)})};$contr_router$$.getting=function($user$$,$id$$,$next$$,$obj$$){if($obj$$.email_owner!=$user$$.email)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");
|
|
4
|
+
$obj$$.read||model.findByIdAndUpdate($obj$$._id,{$set:{read:!0}},function($error$$){if($error$$)return Logger.info($error$$);global.alertMessage($user$$.email)});$next$$()};$contr_router$$.finding=function($user$$,$condition$$,$next$$){$condition$$.$or=[{email_owner:$user$$.email}];$next$$(null,$condition$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.email_sender=$user$$.email;$obj$$.email_owner=$user$$.email;$obj$$.read=!0;$next$$(null,$obj$$)};$contr_router$$.created=function($user$$,
|
|
5
|
+
$obj$$,$next$$){onAfterCommit(()=>{var $obj_receiver$$=new model;$obj_receiver$$.email_sender=$obj$$.email_sender;$obj_receiver$$.email_receiver=$obj$$.email_receiver;$obj_receiver$$.email_owner=$obj$$.email_receiver;$obj_receiver$$.content=$obj$$.content;$obj_receiver$$.image=$obj$$.image;$obj_receiver$$.audio=$obj$$.audio;$obj_receiver$$.video=$obj$$.video;$obj_receiver$$.location=$obj$$.location;$obj_receiver$$.object=$obj$$.object;$obj_receiver$$.id_origin=$obj$$._id.toString();$obj_receiver$$.save(function($error$$){if($error$$)return Logger.info($error$$);
|
|
6
|
+
model.sendMessage($obj_receiver$$);global.alertMessage($obj$$.email_receiver)});$obj$$.email_receiver.indexOf("guest@")>=0&&configs.supportUsers.forEach(function($u$$){$u$$!==$user$$.email&&model.createMessage($obj$$.email_sender,$u$$,$obj$$.title,$obj$$.content)})});$next$$(null,$obj$$)};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){return $next$$(Error("Updating message is not allowed"))};$contr_router$$.updated=function($user$$,$obj$$,$next$$){global.alertMessage($obj$$.email_owner);
|
|
7
|
+
$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){global.alertMessage($obj$$.email_owner);$next$$(null,$obj$$)};$contr_router$$.router.route($contr_router$$.route_name+"/colleague/latest").get(function($req$$,$res$$,$next$$){model.find({email_receiver:$req$$.user.email,read:!1}).sort({date_created:-1}).lean().exec(function($error$$,$results$$){if($error$$)return $next$$($error$$);if($results$$){var $messages$$=
|
|
8
|
+
[],$senders$$={};$results$$.forEach(function($k$$){$senders$$[$k$$.email_sender]||($messages$$.push($k$$),$senders$$[$k$$.email_sender]=1)});$messages$$.joinModel(void 0,User,[{akey:"email_sender",bkey:"email",fields:[{name:"name_sender",value:"name"},{name:"picture_sender",value:"picture"}]},{akey:"email_receiver",bkey:"email",fields:[{name:"name_receiver",value:"name"},{name:"picture_receiver",value:"picture"}]}],function(){$messages$$.forEach(function($m$$){$m$$.name_sender||($m$$.name_sender=
|
|
9
|
+
$m$$.title);$m$$.picture_sender||($m$$.picture_sender="/images/avatar.jpg")});$res$$.send($messages$$)})}else $res$$.send([])})});$contr_router$$.router.route($contr_router$$.route_name+"/chat/:email_dt").get(function($req$$,$res$$,$next$$){var $email_dt_query$$=$req$$.params.email_dt;if($email_dt_query$$==$req$$.user.email)return $res$$.send([]);var $condition$$={email_owner:$req$$.user.email};$condition$$.$or=[{email_receiver:$email_dt_query$$},{email_sender:$email_dt_query$$}];let $sort$$;if($req$$.query.sort)try{$sort$$=
|
|
10
|
+
JSON.parse($req$$.query.sort)}catch($e$$){$sort$$={date_created:1}}else $sort$$={date_created:1};$email_dt_query$$=model.find($condition$$);$condition$$=$req$$.query.page;let $limit$$=$req$$.query.limit;$limit$$&&=Number($limit$$);$condition$$?($limit$$||=10,$email_dt_query$$.skip((Number($condition$$)-1)*$limit$$).limit($limit$$)):$limit$$&&$email_dt_query$$.limit($limit$$);$email_dt_query$$.sort($sort$$).exec(($error$$,$results$$)=>{if($error$$)return $next$$($error$$);if($results$$){var $messages$$=
|
|
11
|
+
[];$results$$.forEach(function($r$$){$r$$.read===!1&&($r$$.set("read",!0),$r$$.save(function($error$$){if($error$$)return console($error$$);global.alertMessage($req$$.user.email)}));$messages$$.push($r$$.toObject())});$messages$$.joinModel(void 0,User,[{akey:"email_sender",bkey:"email",fields:[{name:"name_sender",value:"name"},{name:"picture_sender",value:"picture"}]},{akey:"email_receiver",bkey:"email",fields:[{name:"name_receiver",value:"name"},{name:"picture_receiver",value:"picture"}]}],function(){$messages$$.forEach(function($r$$){$r$$.picture_sender||
|
|
12
|
+
($r$$.picture_sender="/images/avatar.jpg");$r$$.picture_receiver||($r$$.picture_receiver="/images/avatar.jpg")});$res$$.send($messages$$)})}else $res$$.send([])})});$contr_router$$.router.route($contr_router$$.route_name+"/colleague/list").get(function($req$$,$res$$,$next$$){model.find({email_owner:$req$$.user.email}).lean().exec(function($error$$,$messages$$){if($error$$)return $next$$($error$$);$messages$$=$messages$$.map($m$$=>{$m$$.email=$m$$.email_sender===$req$$.user.email?$m$$.email_receiver:
|
|
13
|
+
$m$$.email_sender;return $m$$}).filter($m$$=>$m$$.email!==$m$$.email_owner);$messages$$.groupBy(["email_owner","email"],[],function($e$$,$colls$$){if($e$$)return $next$$($e$$);$colls$$.joinModel2(void 0,User,{where:{email:"email"},fields:["name","picture"]},function(){async.mapLimit($colls$$,20,($coll$$,$callback$$)=>{$coll$$.picture=$coll$$.picture||"/images/avatar.jpg";model.find({email_owner:$req$$.user.email,$or:[{email_sender:$coll$$.email},{email_receiver:$coll$$.email}]}).sort({date_created:-1,
|
|
14
|
+
read:-1}).limit(1).lean().exec(($e$$,$msg$$)=>{$msg$$&&$msg$$.length===1?($coll$$.latest_message=$msg$$[0].content,$coll$$.latest_message_id=$msg$$[0]._id,$coll$$.latest_message_date=$msg$$[0].date_created,$coll$$.latest_message_read=$msg$$[0].read):($coll$$.latest_message="",$coll$$.latest_message_id="",$coll$$.latest_message_date=null);$callback$$()})},()=>{$res$$.send($colls$$)})},{cache:!1})})})})};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const model=global.getModel("moduleinfo"),underscore=require("underscore"),controller=require("../../controllers/controller"),{isSupperAdmin}=require("../../libs/utils"),{isValidObjectId}=require("mongoose");
|
|
2
|
+
module.exports=function($router$$){(new controller($router$$,model,"moduleinfo",{sort:{stt:1},require_id_app:!1,unique:["app","code"],onFinding:async($appInfo_user$$,$condition$$,$next$$)=>{$condition$$.id_app&&isValidObjectId($condition$$.id_app)&&($appInfo_user$$=await global.getModel("app").findOne({_id:$condition$$.id_app},{menu_code:1}).lean())&&$appInfo_user$$.menu_code&&($condition$$.app=$appInfo_user$$.menu_code);delete $condition$$.id_app;$next$$(null,$condition$$)},onCreating:($user$$,$obj$$,
|
|
3
|
+
$next$$)=>{if(!underscore.contains(configs.admins,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$obj$$)},onUpdating:($user$$,$data$$,$obj$$,$next$$)=>{if(!underscore.contains(configs.admins,$user$$.email)&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$data$$,$obj$$)},
|
|
4
|
+
onCreated:($user$$,$obj$$,$next$$)=>{$next$$(null,$obj$$)},onUpdated:($user$$,$obj$$,$next$$)=>{$next$$(null,$obj$$)},onDeleting:($user$$,$obj$$,$next$$)=>{if($obj$$.user_created!==$user$$.email&&!isSupperAdmin($user$$.email.toLowerCase()))return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");$next$$(null,$obj$$)},onView:($user$$,$items$$,$next$$)=>{$next$$(null,$items$$)}})).route()};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const model=global.getModel("notification"),User=global.getModel("user"),underscore=require("underscore"),controller=require("../../controllers/controller"),async=require("async"),{onAfterCommit}=require("../../libs/sessionContext");
|
|
2
|
+
module.exports=function($contr_router$$){const $usersAdmin$$=configs.admins;$contr_router$$=new controller($contr_router$$,model,"notification",{require_id_app:!1,sort:{date_created:-1}});$contr_router$$.route();$contr_router$$.view=function($user$$,$result$$,$fn$$){$result$$.joinModel(void 0,User,[{akey:"email_sender",bkey:"email",fields:[{name:"name_sender",value:"name"},{name:"picture_sender",value:"picture"}]},{akey:"email_receiver",bkey:"email",fields:[{name:"name_receiver",value:"name"},{name:"picture_receiver",
|
|
3
|
+
value:"picture"}]}],function(){$result$$.forEach(function($r$$){$r$$.picture_sender||($r$$.picture_sender="/images/avatar.jpg");$r$$.name_sender||($r$$.name_sender=$r$$.email_sender);$r$$.picture_receiver||($r$$.picture_receiver="/images/avatar.jpg");$r$$.name_receiver||($r$$.name_receiver=$r$$.email_receiver)});$fn$$(null,$result$$)})};$contr_router$$.getting=function($user$$,$id$$,$next$$,$obj$$){if($obj$$.email_owner!=$user$$.email)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n th\u1ef1c hi\u1ec7n thao t\u00e1c n\u00e0y");
|
|
4
|
+
$next$$()};$contr_router$$.finding=function($user$$,$condition$$,$next$$){$condition$$.$or=[{email_owner:$user$$.email}];$next$$(null,$condition$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.email_sender=$user$$.email;$obj$$.email_owner=$user$$.email;$obj$$.read=!0;$next$$(null,$obj$$)};$contr_router$$.created=function($user$$,$obj$$,$next$$){onAfterCommit(()=>{const $obj_receiver$$=new model;$obj_receiver$$.email_sender=$obj$$.email_sender;$obj_receiver$$.email_receiver=$obj$$.email_receiver;
|
|
5
|
+
$obj_receiver$$.email_owner=$obj$$.email_receiver;$obj_receiver$$.content=$obj$$.content;$obj_receiver$$.save(function($error$$){if($error$$)return Logger.info($error$$);global.alertNotification($obj$$.email_receiver,$obj$$.exfields?.id_app);User.emitEvent($obj$$.email_receiver,"notify:new",{_id:$obj$$._id,sender:$obj$$.email_sender,content:$obj$$.content})})});$next$$(null,$obj$$)};$contr_router$$.updated=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email_receiver,$obj$$.exfields?.id_app);
|
|
6
|
+
User.emitEvent($obj$$.email_receiver,"notify:update",{_id:$obj$$._id,sender:$obj$$.email_sender,content:$obj$$.content});$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=function($user$$,$obj$$,$next$$){global.alertNotification($obj$$.email_owner,$obj$$.exfields?.id_app);$next$$(null,$obj$$)};$contr_router$$.createRoute("broadcast/all",function($q_req$$,$callback$$){let $body$$=$q_req$$.body;if(!$body$$||!$body$$.title||
|
|
7
|
+
!$body$$.message)return $callback$$("error: Notification is empty");if(!underscore.contains($usersAdmin$$,$q_req$$.user.email))return $callback$$("Not permission");$q_req$$={};$body$$.to&&($q_req$$.email={$in:$body$$.to.split(",")});User.find($q_req$$,{email:1}).lean().then(function($us$$){async.mapLimit($us$$,20,($u$$,$callback$$)=>{model.createNotification("SYSTEM",$u$$.email,$body$$.title,$body$$.message,$e$$=>{$callback$$($e$$)},!0)},$e$$=>{if($e$$)return $callback$$($e$$);$callback$$(null,"broadcast is sent")})}).catch($e$$=>
|
|
8
|
+
{$callback$$($e$$)})},{method:"POST"});$contr_router$$.createRoute("read/all",async function($req$$,$callback$$){try{let $query$$={email_owner:$req$$.user.email,read:{$ne:!0}};$req$$.query.id_app&&($query$$["exfields.id_app"]=$req$$.query.id_app);await model.updateMany($query$$,{read:!0});global.alertNotification($req$$.user.email,$req$$.query.id_app);$callback$$(null,{result:"ok"})}catch($e$$){$callback$$($e$$)}},{method:"GET"})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const model=global.getModel("quanhuyen"),controller=require("../../controllers/controller");module.exports=function($router$$){(new controller($router$$,model,"quanhuyen",{require_id_app:!1,unique:["ten_tinh_thanh","ten_quan_huyen"],sort:{stt:1}})).route()};
|