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,21 @@
|
|
|
1
|
+
const dvcs=global.getModel("dvcs"),dmvt=global.getModel("dmvt"),dmbp=global.getModel("dmbp"),customer=global.getModel("customer"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),model=global.getModel("dnm"),pn1=global.getModel("pn1"),pn9=global.getModel("pn9"),purchase_contract=global.getModel("purchase_contract"),po1=global.getModel("po1"),shipbook=global.getModel("shipbook"),vanchuyen=global.getModel("vanchuyen"),trangthai=global.getModel("trangthai"),
|
|
2
|
+
controller=require("../../controllers/controller"),hanmucton=global.getModel("hanmucton"),ckvt=require("../../libs/ckvt"),async=require("async"),ma_ct="DKB";
|
|
3
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,check_stock:!1,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();const $valid$$=async($i_user$$,$obj$$,$next$$)=>{for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){const $detail$$=$obj$$.details[$i_user$$];$detail$$.line=$i_user$$;$detail$$.tt_nt=$detail$$.tien_nt-$detail$$.tien_ck_nt;$detail$$.tt=$detail$$.tien-$detail$$.tien_ck;$obj$$.ma_nt=="VND"&&($detail$$.tien=
|
|
4
|
+
$detail$$.tien_nt,$detail$$.tien_ck=$detail$$.tien_ck_nt,$detail$$.tt=$detail$$.tt_nt)}$next$$(null,$obj$$)};$contr_router$$.creating=async($user$$,$obj$$,$next$$)=>{$obj$$.details||($obj$$.details=[]);$obj$$.id_bg2="";$obj$$.id_po1="";$obj$$.details.forEach($d$$=>{$d$$.ma_kho=$obj$$.ma_kho});if(!($user$$.current_app_info.options||{}).check_stock_max)return $next$$(null,$obj$$);let $details$$=await $obj$$.details.asyncGroupBy("ma_kho ma_vt ma_lo ma_tt1 ma_tt2 ma_tt3".split(" "),["so_luong"]);async.mapSeries($details$$,
|
|
5
|
+
async $detail$$=>{let $query_hanmucton$$={id_app:$user$$.current_id_app,ma_kho:$obj$$.ma_kho,ma_vt:$detail$$.ma_vt};$detail$$.ma_tt1&&$query_hanmucton$$.ma_tt1;$detail$$.ma_tt2&&$query_hanmucton$$.ma_tt2;$detail$$.ma_tt3&&$query_hanmucton$$.ma_tt3;var $hanmucs_ton_toi_da$$=await hanmucton.find($query_hanmucton$$).lean();if($hanmucs_ton_toi_da$$.length>0&&($hanmucs_ton_toi_da$$=$hanmucs_ton_toi_da$$.map($h$$=>$h$$.ton_toi_da||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0))){if($detail$$.so_luong>$hanmucs_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;
|
|
6
|
+
$query_hanmucton$$.ngay=new Date;if((await ckvt($query_hanmucton$$)).map($c$$=>$c$$.ton00).reduce(($a$$,$b$$)=>$a$$+$b$$,0)+$detail$$.so_luong>$hanmucs_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;}},$e$$=>{if($e$$)return $next$$($e$$);$valid$$($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$obj$$)})})};$contr_router$$.created=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.updating=
|
|
7
|
+
async function($user$$,$data$$,$obj$$,$next$$){let $ma_kho$$=$data$$.ma_kho||$obj$$.ma_kho;var $_details_details$$=$data$$.details||$obj$$.details;$_details_details$$.forEach($d$$=>{$d$$.ma_kho=$ma_kho$$});if(!($user$$.current_app_info.options||{}).check_stock_max)return $next$$(null,$data$$,$obj$$);$_details_details$$=await $_details_details$$.asyncGroupBy("ma_kho ma_vt ma_lo ma_tt1 ma_tt2 ma_tt3".split(" "),["so_luong"]);async.mapSeries($_details_details$$,async $detail$$=>{let $query_hanmucton$$=
|
|
8
|
+
{id_app:$user$$.current_id_app,ma_kho:$ma_kho$$,ma_vt:$detail$$.ma_vt};$detail$$.ma_tt1&&$query_hanmucton$$.ma_tt1;$detail$$.ma_tt2&&$query_hanmucton$$.ma_tt2;$detail$$.ma_tt3&&$query_hanmucton$$.ma_tt3;var $hanmucs$jscomp$1_ton_toi_da$$=await hanmucton.find($query_hanmucton$$).lean();if($hanmucs$jscomp$1_ton_toi_da$$.length>0&&($hanmucs$jscomp$1_ton_toi_da$$=$hanmucs$jscomp$1_ton_toi_da$$.map($h$$=>$h$$.ton_toi_da||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0))){if($detail$$.so_luong>$hanmucs$jscomp$1_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;
|
|
9
|
+
$query_hanmucton$$.ngay=new Date;if((await ckvt($query_hanmucton$$)).map($c$$=>$c$$.ton00).reduce(($a$$,$b$$)=>$a$$+$b$$,0)+$detail$$.so_luong>$hanmucs$jscomp$1_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;}},$e$$=>{if($e$$)return $next$$($e$$);$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})})};$contr_router$$.updated=function($user$$,$obj$$,$next$$){$next$$(null,
|
|
10
|
+
$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.view=function($user$$,$items$$,$fn$$){let $id_app$$=$user$$.current_id_app;async.series({dv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dvcs).joinModel($id_app$$,dvcs,[{akey:"ma_dvcs",bkey:"_id",fields:[{name:"ten_dvcs",value:"ten_dvcs"}]}],function(){$callback$$()})},kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:["ten_kh"]}],
|
|
11
|
+
function(){$callback$$()})},bp:function($callback$$){$items$$.filter($item$$=>$item$$.ma_bp).joinModel2($id_app$$,dmbp,[{where:"ma_bp",fields:["ten_bp"]}],function(){$callback$$()})},dt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback$$()})},ship:function($callback$$){$items$$.joinModel2($id_app$$,shipbook,[{where:{_id:"id_dnm"},fields:[{name:"id_shipbook",value:"_id"}]}],function(){$callback$$()})},vanchuyen:function($callback$$){$items$$.joinModel2($id_app$$,
|
|
12
|
+
vanchuyen,[{where:{_id:"id_dnm"},fields:[{name:"id_vanchuyen",value:"_id"}]}],function(){$callback$$()})},po1:function($callback$$){$items$$.joinModel2($id_app$$,po1,[{where:{_id:"id_dnm"},fields:[{name:"id_po1",value:"_id"}]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","ma_trang_thai2","ten_trang_thai2","color"]}],function(){$callback$$()})},
|
|
13
|
+
t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.t_tt=0;$r$$.t_tt_nt=0;$r$$.details&&($r$$.t_sl=$r$$.details.csum("so_luong"),$r$$.t_tien=$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"),$r$$.t_ck=$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.t_thue_nk_nt=$r$$.details.csum("tien_thue_nk_nt"),$r$$.t_thue_nk=$r$$.details.csum("tien_thue_nk"),$r$$.t_tt=$r$$.t_tien+($r$$.t_thue|0)-$r$$.t_ck+$r$$.t_thue_nk,$r$$.t_tt_nt=$r$$.t_tien_nt+
|
|
14
|
+
($r$$.t_thue_nt|0)-$r$$.t_ck_nt+$r$$.t_thue_nk_nt)});$callback$$()},details_vt:function($callback$$){async.each($items$$,function($r$$,$callback1$$){($r$$.details||[]).joinModel($id_app$$,dmvt,[{akey:"ma_vt",bkey:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"},{name:"tk_vt",value:"tk_vt"},{name:"tk_gv",value:"tk_gv"},{name:"tk_dt",value:"tk_dt"},{name:"tk_ck",value:"tk_ck"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,function($r$$,
|
|
15
|
+
$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback1$$()})},function(){$callback$$()})},contract:function($callback$$){$items$$.filter($item$$=>$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback$$()})},details_phi:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||
|
|
16
|
+
[]).filter($item$$=>$item$$.ma_phi).joinModel($id_app$$,dmphi,[{akey:"ma_phi",bkey:"ma_phi",fields:[{name:"ten_phi",value:"ten_phi"}]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){async.mapSeries($items$$,($denghimua$$,$callback$$)=>{async.series({purchase_contract:$callback$$=>{purchase_contract.find({id_app:$denghimua$$.id_app,id_dnm:$denghimua$$._id}).lean().exec(($e$$,$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_contract=$invs$$.map($p$$=>({_id:$p$$._id,
|
|
17
|
+
so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>{$denghimua_detail$$.sl_contract=$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.so_luong).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_contract=$details$$.map($d$$=>$d$$.so_luong).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})},pn1:$callback$$=>{pn1.find({id_app:$denghimua$$.id_app,
|
|
18
|
+
id_dnm:$denghimua$$._id}).lean().exec(($e$$,$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_pn1=$invs$$.map($p$$=>({_id:$p$$._id,so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>{$denghimua_detail$$.sl_da_nhap_tn=$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_da_nhap_tn=
|
|
19
|
+
$details$$.map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})},pn9:$callback$$=>{pn9.find({id_app:$denghimua$$.id_app,id_dnm:$denghimua$$._id}).lean().exec(($e$$,$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_pn9=$invs$$.map($p$$=>({_id:$p$$._id,so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>{$denghimua_detail$$.sl_da_nhap_khau=
|
|
20
|
+
$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_da_nhap_khau=$details$$.map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})}},$e$$=>{if($e$$)return $callback$$($e$$);$denghimua$$.details.forEach($detail$$=>{$detail$$.sl_da_nhap=$detail$$.sl_da_nhap_tn+$detail$$.sl_da_nhap_khau});$denghimua$$.t_sl_da_nhap=$denghimua$$.t_sl_da_nhap_tn+$denghimua$$.t_sl_da_nhap_khau;$callback$$()})},
|
|
21
|
+
()=>{$fn$$(null,$items$$)})})}};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const dvcs=global.getModel("dvcs"),account=global.getModel("account"),dmdt=global.getModel("dmdt"),dmnv=global.getModel("dmnv"),dmbp=global.getModel("dmbp"),contract=global.getModel("contract"),dmphi=global.getModel("dmphi"),model=global.getModel("dn0"),pc1=global.getModel("pc1"),trangthai=global.getModel("trangthai"),controller=require("../../controllers/controller"),async=require("async"),ma_ct="DN0",valid_detail=function($i_user$$,$obj$$,$fn$$){if($obj$$.details)for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){let $detail$$=
|
|
2
|
+
$obj$$.details[$i_user$$];$detail$$.line=$i_user$$;$obj$$.ma_nt=="VND"&&($detail$$.tien=$detail$$.tien_nt)}$fn$$(null,$obj$$)};
|
|
3
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();$contr_router$$.creating=function($user$$,$obj$$,$next$$){if(!$obj$$.details||$obj$$.details.csum("tien_nt")==0)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp chi ti\u1ebft \u0111\u1ec1 ngh\u1ecb chuy\u1ec3n l\u01b0\u01a1ng");valid_detail($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,
|
|
4
|
+
$obj$$)})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){valid_detail($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})};$contr_router$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.series({bp:function($callback$$){$items$$.filter($item$$=>$item$$.ma_bp).joinModel2($id_app$$,dmbp,[{where:"ma_bp",fields:["ten_bp"]}],function(){$callback$$()})},tk:function($callback$$){$items$$.filter($item$$=>
|
|
5
|
+
$item$$.tk_co).joinModel2($id_app$$,account,[{where:$item$$=>({tk:$item$$.tk_co}),fields:[{name:"ten_tk_co",value:"ten_tk"}]}],function(){$callback$$()})},dv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dvcs).joinModel2($id_app$$,dvcs,[{where:$item$$=>({_id:$item$$.ma_dvcs}),setFields:($item$$,$ref$$)=>{$item$$.ten_dvcs=$ref$$.ten_dvcs}}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",
|
|
6
|
+
ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},pc1:function($callback$$){$items$$.joinModel2($id_app$$,pc1,[{where:{_id:"id_dn0"},fields:[{id_pc1:"_id"},{so_ct_pc1:"so_ct"},{ngay_ct_pc1:"ngay_ct"}]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.t_tien=0;$r$$.t_tien_nt=0;$r$$.details&&($r$$.t_tien=$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"));$r$$.t_tt=$r$$.t_tien;$r$$.t_tt_nt=$r$$.t_tien_nt});
|
|
7
|
+
$callback$$()},details_tk:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).joinModel2($id_app$$,account,[{where:$item$$=>({tk:$item$$.tk_no}),fields:[{ten_tk_no:"ten_tk"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_nv:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_nv).joinModel2($id_app$$,dmnv,[{where:"ma_nv",fields:["ten_nv"]}],function(){$callback1$$()})},
|
|
8
|
+
function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_hopdong:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:$item$$=>({so_hd:$item$$.ma_hd}),fields:["ten_hd"]}],
|
|
9
|
+
function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel2($id_app$$,dmphi,[{where:"ma_phi",fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const dmvt=global.getModel("dmvt"),dmbp=global.getModel("dmbp"),customer=global.getModel("customer"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),model=global.getModel("dnm"),pn1=global.getModel("pn1"),pn9=global.getModel("pn9"),purchase_contract=global.getModel("purchase_contract"),po1=global.getModel("po1"),shipbook=global.getModel("shipbook"),vanchuyen=global.getModel("vanchuyen"),trangthai=global.getModel("trangthai"),controller=require("../../controllers/controller"),
|
|
2
|
+
hanmucton=global.getModel("hanmucton"),ckvt=require("../../libs/ckvt"),async=require("async"),ma_ct="DNM";
|
|
3
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,check_stock:!1,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();const $valid$$=async($i_user$$,$obj$$,$next$$)=>{for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){const $detail$$=$obj$$.details[$i_user$$];$detail$$.line=$i_user$$;$detail$$.tt_nt=$detail$$.tien_nt-$detail$$.tien_ck_nt;$detail$$.tt=$detail$$.tien-$detail$$.tien_ck;$obj$$.ma_nt=="VND"&&($detail$$.tien=
|
|
4
|
+
$detail$$.tien_nt,$detail$$.tien_ck=$detail$$.tien_ck_nt,$detail$$.tt=$detail$$.tt_nt)}$next$$(null,$obj$$)};$contr_router$$.creating=async($user$$,$obj$$,$next$$)=>{$obj$$.details||($obj$$.details=[]);$obj$$.id_bg2="";$obj$$.id_po1="";$obj$$.details.forEach($d$$=>{$d$$.ma_kho=$obj$$.ma_kho});if(!($user$$.current_app_info.options||{}).check_stock_max)return $next$$(null,$obj$$);let $details$$=await $obj$$.details.asyncGroupBy("ma_kho ma_vt ma_lo ma_tt1 ma_tt2 ma_tt3".split(" "),["so_luong"]);async.map($details$$,
|
|
5
|
+
async $detail$$=>{let $query_hanmucton$$={id_app:$user$$.current_id_app,ma_kho:$obj$$.ma_kho,ma_vt:$detail$$.ma_vt};$detail$$.ma_tt1&&$query_hanmucton$$.ma_tt1;$detail$$.ma_tt2&&$query_hanmucton$$.ma_tt2;$detail$$.ma_tt3&&$query_hanmucton$$.ma_tt3;var $hanmucs_ton_toi_da$$=await hanmucton.find($query_hanmucton$$).lean();if($hanmucs_ton_toi_da$$.length>0&&($hanmucs_ton_toi_da$$=$hanmucs_ton_toi_da$$.map($h$$=>$h$$.ton_toi_da||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0))){if($detail$$.so_luong>$hanmucs_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;
|
|
6
|
+
$query_hanmucton$$.ngay=new Date;if((await ckvt($query_hanmucton$$)).map($c$$=>$c$$.ton00).reduce(($a$$,$b$$)=>$a$$+$b$$,0)+$detail$$.so_luong>$hanmucs_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;}},$e$$=>{if($e$$)return $next$$($e$$);$valid$$($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$obj$$)})})};$contr_router$$.created=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.updating=
|
|
7
|
+
async function($user$$,$data$$,$obj$$,$next$$){let $ma_kho$$=$data$$.ma_kho||$obj$$.ma_kho;var $_details_details$$=$data$$.details||$obj$$.details;$_details_details$$.forEach($d$$=>{$d$$.ma_kho=$ma_kho$$});if(!($user$$.current_app_info.options||{}).check_stock_max)return $next$$(null,$data$$,$obj$$);$_details_details$$=await $_details_details$$.asyncGroupBy("ma_kho ma_vt ma_lo ma_tt1 ma_tt2 ma_tt3".split(" "),["so_luong"]);async.map($_details_details$$,async $detail$$=>{let $query_hanmucton$$={id_app:$user$$.current_id_app,
|
|
8
|
+
ma_kho:$ma_kho$$,ma_vt:$detail$$.ma_vt};$detail$$.ma_tt1&&$query_hanmucton$$.ma_tt1;$detail$$.ma_tt2&&$query_hanmucton$$.ma_tt2;$detail$$.ma_tt3&&$query_hanmucton$$.ma_tt3;var $hanmucs$jscomp$1_ton_toi_da$$=await hanmucton.find($query_hanmucton$$).lean();if($hanmucs$jscomp$1_ton_toi_da$$.length>0&&($hanmucs$jscomp$1_ton_toi_da$$=$hanmucs$jscomp$1_ton_toi_da$$.map($h$$=>$h$$.ton_toi_da||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0))){if($detail$$.so_luong>$hanmucs$jscomp$1_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;
|
|
9
|
+
$query_hanmucton$$.ngay=new Date;if((await ckvt($query_hanmucton$$)).map($c$$=>$c$$.ton00).reduce(($a$$,$b$$)=>$a$$+$b$$,0)+$detail$$.so_luong>$hanmucs$jscomp$1_ton_toi_da$$)throw`V\u1eadt t\u01b0 ${$detail$$.ma_vt} s\u1ebd v\u01b0\u1ee3t t\u1ed3n t\u1ed1i \u0111a cho ph\u00e9p`;}},$e$$=>{if($e$$)return $next$$($e$$);$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})})};$contr_router$$.updated=function($user$$,$obj$$,$next$$){$next$$(null,
|
|
10
|
+
$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.view=function($user$$,$items$$,$fn$$){let $id_app$$=$user$$.current_id_app;async.parallel({kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:["ten_kh"]}],function(){$callback$$()})},bp:function($callback$$){$items$$.filter($item$$=>$item$$.ma_bp).joinModel2($id_app$$,dmbp,[{where:"ma_bp",fields:["ten_bp"]}],function(){$callback$$()})},
|
|
11
|
+
dt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback$$()})},ship:function($callback$$){$items$$.joinModel2($id_app$$,shipbook,[{where:{_id:"id_dnm"},fields:[{name:"id_shipbook",value:"_id"}]}],function(){$callback$$()})},vanchuyen:function($callback$$){$items$$.joinModel2($id_app$$,vanchuyen,[{where:{_id:"id_dnm"},fields:[{name:"id_vanchuyen",value:"_id"}]}],function(){$callback$$()})},po1:function($callback$$){$items$$.joinModel2($id_app$$,
|
|
12
|
+
po1,[{where:{_id:"id_dnm"},fields:[{name:"id_po1",value:"_id"}]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","ma_trang_thai2","ten_trang_thai2","color"]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.t_tt=0;$r$$.t_tt_nt=0;$r$$.details&&($r$$.t_sl=$r$$.details.csum("so_luong"),$r$$.t_tien=
|
|
13
|
+
$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"),$r$$.t_ck=$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.t_thue_nk_nt=$r$$.details.csum("tien_thue_nk_nt"),$r$$.t_thue_nk=$r$$.details.csum("tien_thue_nk"),$r$$.t_tt=$r$$.t_tien+($r$$.t_thue|0)-$r$$.t_ck+$r$$.t_thue_nk,$r$$.t_tt_nt=$r$$.t_tien_nt+($r$$.t_thue_nt|0)-$r$$.t_ck_nt+$r$$.t_thue_nk_nt)});$callback$$()},details_vt:function($callback$$){async.each($items$$,function($r$$,$callback1$$){($r$$.details||
|
|
14
|
+
[]).joinModel($id_app$$,dmvt,[{akey:"ma_vt",bkey:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"},{name:"tk_vt",value:"tk_vt"},{name:"tk_gv",value:"tk_gv"},{name:"tk_dt",value:"tk_dt"},{name:"tk_ck",value:"tk_ck"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],
|
|
15
|
+
function(){$callback1$$()})},function(){$callback$$()})},contract:function($callback$$){$items$$.filter($item$$=>$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback$$()})},details_phi:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel($id_app$$,dmphi,[{akey:"ma_phi",bkey:"ma_phi",fields:[{name:"ten_phi",value:"ten_phi"}]}],function(){$callback1$$()})},
|
|
16
|
+
function(){$callback$$()})}},function(){async.mapLimit($items$$,20,($denghimua$$,$callback$$)=>{async.parallel({purchase_contract:$callback$$=>{purchase_contract.find({id_app:$denghimua$$.id_app,id_dnm:$denghimua$$._id}).lean().exec(($e$$,$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_contract=$invs$$.map($p$$=>({_id:$p$$._id,so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>
|
|
17
|
+
{$denghimua_detail$$.sl_contract=$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.so_luong).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_contract=$details$$.map($d$$=>$d$$.so_luong).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})},pn1:$callback$$=>{pn1.find({id_app:$denghimua$$.id_app,id_dnm:$denghimua$$._id}).lean().exec(($e$$,$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_pn1=$invs$$.map($p$$=>({_id:$p$$._id,so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));
|
|
18
|
+
let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>{$denghimua_detail$$.sl_da_nhap_tn=$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_da_nhap_tn=$details$$.map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})},pn9:$callback$$=>{pn9.find({id_app:$denghimua$$.id_app,id_dnm:$denghimua$$._id}).lean().exec(($e$$,
|
|
19
|
+
$invs$$)=>{if($e$$)return $callback$$($e$$);$denghimua$$.ds_pn9=$invs$$.map($p$$=>({_id:$p$$._id,so_ct:$p$$.so_ct,ngay_ct:$p$$.ngay_ct}));let $details$$=$invs$$.map($inv$$=>$inv$$.details).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$denghimua$$.details.forEach($denghimua_detail$$=>{$denghimua_detail$$.sl_da_nhap_khau=$details$$.filter($detail$$=>$detail$$.ma_vt===$denghimua_detail$$.ma_vt).map($d$$=>$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$denghimua$$.t_sl_da_nhap_khau=$details$$.map($d$$=>
|
|
20
|
+
$d$$.sl_nhap).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$callback$$()})}},$e$$=>{if($e$$)return $callback$$($e$$);$denghimua$$.details.forEach($detail$$=>{$detail$$.sl_da_nhap=$detail$$.sl_da_nhap_tn+$detail$$.sl_da_nhap_khau});$denghimua$$.t_sl_da_nhap=$denghimua$$.t_sl_da_nhap_tn+$denghimua$$.t_sl_da_nhap_khau;$callback$$()})},()=>{$fn$$(null,$items$$)})})}};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const axios=require("axios"),Moment=require("moment"),async=require("async"),PostBook=require("../../libs/post-book"),PostSocai=require("../../libs/post-socai"),Tdttno=global.getModel("tdttno"),Tdttno_tt=global.getModel("tdttno_tt"),Vatra=global.getModel("vatra"),account=global.getModel("account"),customer=global.getModel("customer"),dmnv=global.getModel("dmnv"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),salecontract=global.getModel("sale_contract"),
|
|
2
|
+
model=global.getModel("hd1"),controller=require("../../controllers/controller"),trangthai=global.getModel("trangthai"),utils=require("../../libs/utils"),ma_ct="HD1",App=global.getModel("app");
|
|
3
|
+
module.exports=function($router$$){const $contr$$=new controller($router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,kiem_tra_han_muc_cong_no:!0,sort:{ngay_ct:-1,so_ct:-1}});$contr$$.route();$contr$$.post=async function($obj$$,$fn$$,$_options$$={}){$fn$$||=function(){};let $options$$;try{$options$$=await global.getModel("options").getInfo($obj$$.id_app,{id_func:($obj$$.listinfo_code||$obj$$.ma_ct).toLowerCase()},"option")}catch($e$$){Logger.info($e$$.message,{id_func:$obj$$.ma_ct})}$options$$||={};
|
|
4
|
+
async.series({post_socai:function($callback$$){const $details_sc$$=[];$obj$$.details.forEach(function($d_detail$$){$d_detail$$={...$d_detail$$};$d_detail$$.tk_co=$d_detail$$.tk_dt;$d_detail$$.ma_kh||($d_detail$$.ma_kh=$obj$$.ma_kh);$d_detail$$.tk_no=$obj$$.tk_no;$details_sc$$.push($d_detail$$)});$obj$$.details.forEach(function($d$jscomp$1_detail$$){$d$jscomp$1_detail$$={...$d$jscomp$1_detail$$};$d$jscomp$1_detail$$.tk_no=$d$jscomp$1_detail$$.tk_ck;$d$jscomp$1_detail$$.ma_kh||($d$jscomp$1_detail$$.ma_kh=
|
|
5
|
+
$obj$$.ma_kh);$d$jscomp$1_detail$$.tk_co=$obj$$.tk_no;$d$jscomp$1_detail$$.tien_nt=$d$jscomp$1_detail$$.tien_ck_nt;$d$jscomp$1_detail$$.tien=$d$jscomp$1_detail$$.tien_ck;$d$jscomp$1_detail$$.check_balance=!1;$details_sc$$.push($d$jscomp$1_detail$$)});const $o$$={...$obj$$};$o$$.tk_co=$o$$.tk_thue_co;$o$$.tien_nt=$obj$$.details.csum("tien_thue_nt");$o$$.tien=$obj$$.details.csum("tien_thue");$o$$.dien_giai_thue&&($o$$.dien_giai=$o$$.dien_giai_thue);$details_sc$$.push($o$$);(new PostSocai($obj$$,$details_sc$$,
|
|
6
|
+
void 0,void 0,$_options$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_tdttno:function($callback$$){account.findOne({tk:$obj$$.tk_no,id_app:$obj$$.id_app},{tk_cn:1},function($error$$,$tk$$){if($error$$)return $callback$$($error$$);$tk$$?.tk_cn===!0||$options$$.post_tdtt_tm?(new PostBook($obj$$,[{...$obj$$}],Tdttno,function($detail$$,$callback$$){try{$detail$$.so_hd||($detail$$.so_hd=$obj$$.so_ct),$detail$$.ngay_hd||($detail$$.ngay_hd=$obj$$.ngay_ct),$detail$$.tien_nt=$obj$$.details.csum("tien_nt")-
|
|
7
|
+
$obj$$.details.csum("tien_ck_nt")-($obj$$.tien_ck_hd||0)+$obj$$.details.csum("tien_thue_nt"),$detail$$.tien=$obj$$.details.csum("tien")-$obj$$.details.csum("tien_ck")-($obj$$.tien_ck_hd||0)*($obj$$.ty_gia||1)+$obj$$.details.csum("tien_thue")}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):Tdttno.deleteMany({id_ct:$obj$$._id},function($error$$){$callback$$($error$$)})})},post_vatra:function($callback$$){$obj$$.ngay_hd?$obj$$.details.map($detail$$=>
|
|
8
|
+
({...$detail$$,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0,ma_thue:$detail$$.ma_thue||$obj$$.ma_thue})).filter($d$$=>$d$$.ma_thue).asyncGroupBy(["ma_thue","thue_suat","ten_vt_vat"],"tien_nt tien tien_ck tien_ck_nt tien_thue tien_thue_nt".split(" ")).then($ds$$=>{if($ds$$.length==1){let $tien_thue_nt$$=$ds$$.map($d$$=>$d$$.tien_thue_nt||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0),$tien_thue$$=$ds$$.map($d$$=>$d$$.tien_thue||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds$$[0].tien_thue_nt=
|
|
9
|
+
$tien_thue_nt$$;$ds$$[0].tien_thue=$tien_thue$$}(new PostBook($obj$$,$ds$$,Vatra,function($detail$$,$callback$$){try{$detail$$.tk_du_thue=$obj$$.tk_no,$detail$$.t_tien_nt=$detail$$.tien_nt-$detail$$.tien_ck_nt,$detail$$.t_tien=$detail$$.tien-$detail$$.tien_ck,$detail$$.t_thue_nt=$detail$$.tien_thue_nt,$detail$$.t_thue=$detail$$.tien_thue,$detail$$.ten_vt=$detail$$.ten_vt_vat||$obj$$.ten_vt||$obj$$.dien_giai}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,
|
|
10
|
+
$rs$$)})}):$callback$$()}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};const $valid$$=function($i_user$$,$obj$$,$next$$){for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){const $detail$$=$obj$$.details[$i_user$$];$detail$$.line=$i_user$$;$detail$$.tien_ck_nt=$detail$$.tien_ck_nt||0;$detail$$.tien_nt=$detail$$.tien_nt||0;$obj$$.ma_nt==="VND"&&($detail$$.tien=$detail$$.tien_nt,$detail$$.tien_ck=$detail$$.tien_ck_nt);$detail$$.tien_ck=$detail$$.tien_ck||0;$detail$$.tien=$detail$$.tien||0}let $f_tien_nt$$=
|
|
11
|
+
$obj$$.ma_nt==="VND"?0:2;$obj$$.thue_suat=$obj$$.thue_suat||0;$obj$$.details.forEach($detail$$=>{let $thue_suat$$=($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0;$detail$$.tien_thue_nt=$detail$$.tien_thue_nt_dc||utils.round(($detail$$.tien_nt-$detail$$.tien_ck_nt)*$thue_suat$$/100,$f_tien_nt$$);$detail$$.tien_thue=$detail$$.tien_thue_nt*($obj$$.ty_gia||1)});$obj$$.id_contract?salecontract.findOne({_id:$obj$$.id_contract}).lean().then($c$$=>{$c$$&&($obj$$.ma_hd=$c$$.ma_hd);$next$$(null,
|
|
12
|
+
$obj$$)}).catch($e$$=>{$next$$($e$$)}):$next$$(null,$obj$$)};$contr$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$obj$$.result_export_einvoice=null;$next$$(null,$obj$$)})};$contr$$.updating=function($user$$,$data$$,$obj$$,$next$$){Tdttno_tt.findOne({id_hd:$obj$$._id,id_app:$obj$$.id_app},function($error$$,$ct_tt$$){if($error$$)return $next$$($error$$);$ct_tt$$?$next$$(`Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$$.ma_ct||
|
|
13
|
+
"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$$.so_ct}, ng\u00e0y ${Moment($ct_tt$$.ngay_ct).format("DD/MM/YYYY")}`):$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})})};$contr$$.deleting=function($user$$,$obj$$,$next$$){Tdttno_tt.findOne({id_hd:$obj$$._id,id_app:$obj$$.id_app},function($error$$,$ct_tt$$){if($error$$)return $next$$($error$$);$ct_tt$$?$next$$(`Kh\u00f4ng th\u1ec3 xo\u00e1 phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$$.ma_ct||
|
|
14
|
+
"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$$.so_ct}, ng\u00e0y ${Moment($ct_tt$$.ngay_ct).format("DD/MM/YYYY")}`):$next$$(null,$obj$$)})};$contr$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.parallel({tk:function($callback$$){$items$$.filter($item$$=>$item$$.tk_no).joinModel($id_app$$,account,[{akey:"tk_no",bkey:"tk",fields:[{name:"ten_tk_no",value:"ten_tk"}]}],function(){$callback$$()})},dt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,
|
|
15
|
+
dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback$$()})},kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:["ten_kh","email","nh_kh"]}],function(){$callback$$()})},nv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_nv).joinModel($id_app$$,dmnv,[{akey:"ma_nv",bkey:"ma_nv",fields:[{name:"ten_nv",value:"ten_nv"}]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>
|
|
16
|
+
$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},contract:function($callback$$){$items$$.filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:{ma_hd:"so_hd"},fields:["ten_hd","ten_hd"]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.details&&($r$$.t_tien=$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"),
|
|
17
|
+
$r$$.t_ck=$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.t_thue_nt=$r$$.details.csum("tien_thue_nt"),$r$$.t_thue=$r$$.t_thue_nt*$r$$.ty_gia,$r$$.t_tt=$r$$.t_tien-$r$$.t_ck+$r$$.t_thue,$r$$.t_tt_nt=$r$$.t_tien_nt-$r$$.t_ck_nt+$r$$.t_thue_nt,$r$$.details.forEach($detail$$=>{$detail$$.dien_giai||($detail$$.dien_giai=$r$$.dien_giai)}))});$callback$$()},details_tk:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).joinModel($id_app$$,
|
|
18
|
+
account,[{akey:"tk_dt",bkey:"tk",fields:[{name:"ten_tk_dt",value:"ten_tk"}]},{akey:"tk_ck",bkey:"tk",fields:[{name:"ten_tk_ck",value:"ten_tk"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapLimit($items$$,
|
|
19
|
+
20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel($id_app$$,dmphi,[{akey:"ma_phi",bkey:"ma_phi",fields:[{name:"ten_phi",value:"ten_phi"}]}],function(){$callback1$$()})},
|
|
20
|
+
function(){$callback$$()})}},function(){$fn$$(null,$items$$)})};$contr$$.createRoute("export2viettel/:id_ct",async($req$$,$next$$)=>{try{Logger.info("Export to viettel....");const $id_app$$=$req$$.user.current_id_app,$app$$=await App.findOne({_id:$id_app$$});if(!$app$$)return Logger.info("Kh\u00f4ng tim th\u1ea5y th\u00f4ng tin coogn ty"),$next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");if(!$app$$.viettel_url_service||!$app$$.viettel_user||!$app$$.viettel_password)return Logger.info("Chua khai bao thong tin ket noi viettel"),
|
|
21
|
+
$next$$("Th\u00f4ng tin xu\u1ea5t ho\u00e1 \u0111\u01a1n Viettel ch\u01b0a \u0111\u01b0\u1ee3c khai b\u00e1o \u0111\u1ea7y \u0111\u1ee7");if(!$app$$.ma_so_thue)return Logger.info("Chua nhap ma so thue cua cong ty"),$next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");const $ct$$=await model.findOne({id_app:$id_app$$,_id:$req$$.params.id_ct}).lean();if(!$ct$$)return Logger.info("Khong tim thay chung tu"),$next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");let $transactionUuid$$=
|
|
22
|
+
$ct$$._id.toString();try{let $result_export_einvoice$$=await utils.getInvoice($app$$,$transactionUuid$$);if($result_export_einvoice$$){if($result_export_einvoice$$.errorCode)return $next$$($result_export_einvoice$$.data||$result_export_einvoice$$.description);Logger.info("\u0110\u1ed3ng b\u1ed9 hoa \u0111\u01a1n viettel");$ct$$.result_export_einvoice=$result_export_einvoice$$;await utils.updateInvoice($contr$$,$ct$$);return $next$$(null,$result_export_einvoice$$)}}catch($e$$){return Logger.error("error export to viettel",
|
|
23
|
+
$e$$),$next$$($e$$)}if($ct$$.result_export_einvoice&&$ct$$.result_export_einvoice.result&&$ct$$.result_export_einvoice.result.invoiceNo)return $next$$(null,$ct$$.result_export_einvoice);const $kh$$=await customer.findOne({id_app:$id_app$$,ma_kh:$ct$$.ma_kh})||{},$t_tien_hang$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)),$t_ck$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_ck_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)),$t_tien$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_nt-
|
|
24
|
+
$d$$.tien_ck_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)),$t_thue$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_thue_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)),$tien_ck_hd$$=$ct$$.tien_ck_hd||0;let $taxBreakdowns$$=$ct$$.details.map($detail$$=>({...$detail$$,ma_thue:$detail$$.ma_thue||$ct$$.ma_thue,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$ct$$.thue_suat)||0})).filter($d$$=>$d$$.ma_thue);if($taxBreakdowns$$.length===0)return $next$$("B\u1ea1n ch\u01b0a khai b\u00e1o thu\u1ebf");$taxBreakdowns$$=$taxBreakdowns$$.filter($d$$=>
|
|
25
|
+
$d$$.ma_thue!="KT"&&$d$$.ma_thue!="KK").map($detail$$=>({taxPercentage:$detail$$.thue_suat,taxableAmount:Math.abs($detail$$.tien_nt-$detail$$.tien_ck_nt),taxAmount:Math.abs($detail$$.tien_thue_nt)}));$taxBreakdowns$$=await $taxBreakdowns$$.asyncGroupBy("taxPercentage",["taxableAmount","taxAmount"]);const $data$$={generalInvoiceInfo:{invoiceType:$ct$$.ma_hoa_don||$app$$.ma_hoa_don||"1",templateCode:$ct$$.ky_hieu_hoa_don||$app$$.ky_hieu_hoa_don||"1/001",invoiceSeries:$ct$$.so_seri,transactionUuid:$transactionUuid$$,
|
|
26
|
+
currencyCode:"VND",adjustmentType:"1",paymentStatus:!0,cusGetInvoiceRight:!0,userName:$ct$$.user_created},buyerInfo:{buyerName:$ct$$.ong_ba||"",buyerLegalName:$ct$$.ten_kh||$kh$$.ten_kh||"",buyerTaxCode:$ct$$.ma_so_thue||$kh$$.ma_so_thue||"",buyerAddressLine:$ct$$.dia_chi||$kh$$.dia_chi||"",buyerPostalCode:"",buyerDistrictName:"",buyerCityName:"",buyerCountryCode:"",buyerPhoneNumber:$ct$$.dien_thoai||$kh$$.dien_thoai||"",buyerFaxNumber:"",buyerEmail:$kh$$.email||"",buyerBankName:"",buyerBankAccount:"",
|
|
27
|
+
buyerIdType:"",buyerIdNo:"",buyerCode:"",buyerBirthDay:""},sellerInfo:{sellerLegalName:$app$$.name,sellerTaxCode:$app$$.ma_so_thue,sellerAddressLine:$app$$.dia_chi_xuat_hoa_don||$app$$.address,sellerPhoneNumber:$app$$.phone||"",sellerEmail:$app$$.email||"",sellerBankName:$app$$.ten_ngan_hang||"",sellerBankAccount:$app$$.tai_khoan_ngan_hang||""},itemInfo:$ct$$.details.map(($detail$$,$index$$)=>{var $JSCompiler_temp_const$$=$detail$$.tien_nt<0?3:1,$JSCompiler_temp_const$jscomp$8$$=($index$$+1).toString(),
|
|
28
|
+
$JSCompiler_temp_const$jscomp$7$$=$detail$$.dien_giai,$JSCompiler_temp_const$jscomp$6$$=$detail$$.tien_nt<0?"":$detail$$.ma_dvt,$JSCompiler_temp_const$jscomp$5$$=$detail$$.tien_nt<0?void 0:$detail$$.gia_ban_nt,$JSCompiler_temp_const$jscomp$4$$=$detail$$.tien_nt<0?void 0:$detail$$.sl_xuat,$JSCompiler_temp_const$jscomp$3$$=Math.abs($detail$$.tien_nt),$JSCompiler_temp_const$jscomp$2$$=$detail$$.ty_le_ck,$JSCompiler_temp_const$jscomp$1$$=Math.abs($detail$$.tien_ck_nt),$JSCompiler_temp_const$jscomp$0$$=
|
|
29
|
+
Math.abs($detail$$.tien_nt-$detail$$.tien_ck_nt);a:{var $JSCompiler_inline_result$jscomp$10_thue_suat$$=($detail$$.ma_thue?$detail$$.thue_suat:$ct$$.thue_suat)||0;var $tien_ct_nt$$=$detail$$.tien_nt;switch($detail$$.ma_thue||$ct$$.ma_thue){case "KT":$JSCompiler_inline_result$jscomp$10_thue_suat$$=$tien_ct_nt$$<0?void 0:-2;break a;case "KK":$JSCompiler_inline_result$jscomp$10_thue_suat$$=$tien_ct_nt$$<0?void 0:-1}}return{lineNumber:$index$$+1,selection:$JSCompiler_temp_const$$,itemCode:$JSCompiler_temp_const$jscomp$8$$,
|
|
30
|
+
itemName:$JSCompiler_temp_const$jscomp$7$$,unitName:$JSCompiler_temp_const$jscomp$6$$,itemNote:"",unitPrice:$JSCompiler_temp_const$jscomp$5$$,quantity:$JSCompiler_temp_const$jscomp$4$$,itemTotalAmountWithoutTax:$JSCompiler_temp_const$jscomp$3$$,discount:$JSCompiler_temp_const$jscomp$2$$,itemDiscount:$JSCompiler_temp_const$jscomp$1$$,itemTotalAmountAfterDiscount:$JSCompiler_temp_const$jscomp$0$$,taxPercentage:$JSCompiler_inline_result$jscomp$10_thue_suat$$,taxAmount:Math.abs($detail$$.tien_thue_nt),
|
|
31
|
+
itemTotalAmountWithTax:Math.abs($detail$$.tien_nt-$detail$$.tien_ck_nt+$detail$$.tien_thue_nt),customTaxAmount:"0",batchNo:"",expDate:""}}),summarizeInfo:{sumOfTotalLineAmountWithoutTax:$t_tien_hang$$,discountAmount:$t_ck$$,settlementDiscountAmount:$tien_ck_hd$$,totalAmountWithoutTax:$t_tien$$,totalTaxAmount:$t_thue$$,totalAmountWithTax:$t_tien$$+$t_thue$$},taxBreakdowns:$taxBreakdowns$$,payments:[{paymentMethodName:$ct$$.hinh_thuc_tt||"TM"}],extAttribute:[],deliveryInfo:{},metadata:[]};$ct$$.ngay_hd||
|
|
32
|
+
($ct$$.ngay_hd=new Date);let $headers$$,$url$$,$viettel_token$$,$auth$$={username:$app$$.viettel_user.trim(),password:$app$$.viettel_password.trim()};if($app$$.viettel_version!="1"){$data$$.generalInvoiceInfo.invoiceIssuedDate=(new Date($ct$$.ngay_hd)).getTime();let $url_token$$=`${$app$$.viettel_url_service.trim()}/auth/login`;$url$$=$app$$.viettel_direct_issue?`${$app$$.viettel_url_service.trim()}/services/einvoiceapplication/api/InvoiceAPI/InvoiceWS/createInvoice/${$app$$.ma_so_thue.trim()}`:`${$app$$.viettel_url_service.trim()}/services/einvoiceapplication/api/InvoiceAPI/InvoiceWS/createOrUpdateInvoiceDraft/${$app$$.ma_so_thue.trim()}`;
|
|
33
|
+
try{$viettel_token$$=(await axios({method:"post",url:$url_token$$,data:$auth$$})).data.access_token}catch($e$$){Logger.error("error when get token viettel",$auth$$,$url_token$$);let $msg_e$$=$e$$.response?$e$$.response.data:$e$$.message;$msg_e$$&&$msg_e$$.detail&&($msg_e$$.message=$msg_e$$.detail);return $next$$($msg_e$$||$e$$.message||$e$$.error||$e$$)}$headers$$={Cookie:`"access_token":"${$viettel_token$$}"; access_token=${$viettel_token$$}; session_token=${$viettel_token$$}`,"Content-Type":"application/json"};
|
|
34
|
+
$auth$$=void 0}else $data$$.generalInvoiceInfo.invoiceIssuedDate=Moment($ct$$.ngay_hd).format("YYYY-MM-DD"),$url$$=$app$$.viettel_direct_issue?`${$app$$.viettel_url_service.trim()}/InvoiceAPI/InvoiceWS/createInvoice/${$app$$.ma_so_thue.trim()}`:`${$app$$.viettel_url_service.trim()}/InvoiceAPI/InvoiceWS/createOrUpdateInvoiceDraft/${$app$$.ma_so_thue.trim()}`;Logger.info("post to viettel...");axios({method:"post",url:$url$$,data:$app$$.viettel_version!="1"?JSON.stringify($data$$):$data$$,auth:$auth$$,
|
|
35
|
+
headers:$headers$$}).then(async $data$$=>{$data$$=$data$$.data;Logger.error("result data",$data$$);if(!$data$$)return $next$$("Kh\u00f4ng th\u1ec3 xu\u1ea5t ho\u00e1 \u0111\u01a1n");if($data$$.errorCode)return $next$$($data$$.description);$ct$$.result_export_einvoice=$data$$;$ct$$.so_hd=$ct$$.result_export_einvoice.result.invoiceNo;await model.findOneAndUpdate({_id:$ct$$._id},$ct$$);$ct$$.so_hd&&await Tdttno.updateMany({id_ct:$ct$$._id.toString(),id_app:$ct$$.id_app},{so_hd:$ct$$.so_hd});$ct$$.so_hd&&
|
|
36
|
+
await Tdttno_tt.updateMany({id_hd:$ct$$._id.toString(),id_app:$ct$$.id_app},{so_hd:$ct$$.so_hd});$ct$$.so_hd&&await Vatra.updateMany({id_ct:$ct$$._id.toString(),id_app:$ct$$.id_app},{so_hd:$ct$$.so_hd});controller.postData($ct$$,$contr$$,$e$$=>{if($e$$)return Logger.error($e$$);controller.pushNotification($contr$$,$ct$$)});$next$$(null,$data$$)}).catch($e$$=>{Logger.error("error when export invocie viettel",$e$$.response);let $msg_e$$=$e$$.response?$e$$.response.data:$e$$.message;$msg_e$$.data&&($msg_e$$.message=
|
|
37
|
+
$msg_e$$.data);$msg_e$$.detail&&($msg_e$$.message=$msg_e$$.detail);$next$$($msg_e$$||$e$$.message||$e$$.error||$e$$)})}catch($e$$){Logger.info($e$$),$next$$($e$$.message)}},{method:"GET",action_code:"add"})};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const async=require("async"),_=require("lodash"),moment=require("moment"),numeral=require("numeral"),PostBook=require("../../libs/post-book"),PostSokho=require("../../libs/post-sokho"),PostSocai=require("../../libs/post-socai"),Sokhott=global.getModel("sokhott"),Tdttno=global.getModel("tdttno"),Tdttno_tt=global.getModel("tdttno_tt"),Vatra=global.getModel("vatra"),Options=global.getModel("options"),dmvt=global.getModel("dmvt"),account=global.getModel("account"),dmkho=global.getModel("dmkho"),customer=
|
|
2
|
+
global.getModel("customer"),dmnv=global.getModel("dmnv"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),salecontract=global.getModel("sale_contract"),model=global.getModel("hd2"),controller=require("../../controllers/controller"),utils=require("../../libs/utils"),tinhhoahong=require("../../libs/tinhhoahong"),ptthanhtoan=global.getModel("ptthanhtoan"),trangthai=global.getModel("trangthai"),{QRPay}=require("vietnam-qr-pay"),ma_ct="HD2",App=global.getModel("app"),
|
|
3
|
+
blockchainconnect=require("../../libs/blockchainconnect"),spend=async($appInfo$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$,$introduce_code$$,$sub_action$$="")=>{try{await blockchainconnect.spend($appInfo$$._id,$appInfo$$.wallet_token,$appInfo$$.wallet_address,$receiver_address$$,{amount:$amount$$,denom:$denom$$,memo:$memo$$,action:"bonus",introduce_code:$introduce_code$$,sub_action:$sub_action$$})}catch($e$$){Logger.error("Error send coin",$e$$,$receiver_user$$,$receiver_address$$,
|
|
4
|
+
$amount$$,$denom$$,$memo$$)}},taothongtinchuyenkhoan=async($bank_bin_user$$,$r$$)=>{if($r$$.trang_thai==="3")if($r$$.pt_thanh_toan){var $t_thue_nt_t_tt$$=$r$$.details.csum("tien_thue_nt"),$bank_name_t_tien_ct_nt$$=$r$$.details.csum("tien_ct_nt"),$bank_account_number_tc_ck_nt$$=$r$$.details.csum("tien_ck_nt")+($r$$.tien_ck_hd||0);$t_thue_nt_t_tt$$=Math.round(($bank_name_t_tien_ct_nt$$-$bank_account_number_tc_ck_nt$$+$t_thue_nt_t_tt$$+($r$$.tien_phi_vc_nt||0))*($r$$.ty_gia||1));if($t_thue_nt_t_tt$$==
|
|
5
|
+
0)$r$$.bank_payment_info=void 0;else{var $pttt_purpose$$=await ptthanhtoan.findOne({id_app:$r$$.id_app,_id:$r$$.pt_thanh_toan,payment_service:"bank"}).lean();if($pttt_purpose$$&&$pttt_purpose$$.payment_service=="bank"&&$bank_bin_user$$.current_app_info){$bank_name_t_tien_ct_nt$$=($pttt_purpose$$.bank_configs||{}).bank_name||$bank_bin_user$$.current_app_info.ten_ngan_hang;$bank_account_number_tc_ck_nt$$=($pttt_purpose$$.bank_configs||{}).bank_account_number||$bank_bin_user$$.current_app_info.tai_khoan_ngan_hang;
|
|
6
|
+
const $bank_account_name$$=($pttt_purpose$$.bank_configs||{}).bank_account_name||$bank_bin_user$$.current_app_info.ten_chu_tai_khoan;$bank_bin_user$$=($pttt_purpose$$.bank_configs||{}).so_bin||$bank_bin_user$$.current_app_info.so_bin;$pttt_purpose$$=`TTDH ${$r$$.so_ct} ${$r$$._id.toString()}`;const $qrcode$$=QRPay.initVietQR({bankBin:$bank_bin_user$$,bankNumber:$bank_account_number_tc_ck_nt$$,amount:$t_thue_nt_t_tt$$.toString(),purpose:$pttt_purpose$$}).build();$r$$.bank_payment_info={bank_name:$bank_name_t_tien_ct_nt$$,
|
|
7
|
+
bank_bin:$bank_bin_user$$,bank_account_number:$bank_account_number_tc_ck_nt$$,bank_account_name:$bank_account_name$$,amount:$t_thue_nt_t_tt$$,purpose:$pttt_purpose$$,qrcode:$qrcode$$}}else $r$$.bank_payment_info=void 0}}else $r$$.bank_payment_info=void 0},tinhGiaChuaThue=($obj$$,$detail$$)=>{let $f_tien_nt$$=$obj$$.ma_nt=="VND"?0:3,$thue_suat$$=($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0;$detail$$.gia_ban_ct_nt||($detail$$.tien_thue_nt?($detail$$.gia_ban_ct_nt=$detail$$.gia_ban_nt,
|
|
8
|
+
$detail$$.tien_ct_nt=$detail$$.tien_nt,$detail$$.tien_ct=Math.round($detail$$.tien_ct_nt*$obj$$.ty_gia),$detail$$.gia_ban_nt=$detail$$.gia_ban_ct_nt*(1+$detail$$.thue_suat/100)):($detail$$.gia_ban_ct_nt=utils.round($detail$$.gia_ban_nt/(1+$thue_suat$$/100),5),$detail$$.tien_ct_nt=utils.round($detail$$.gia_ban_ct_nt*$detail$$.sl_xuat,$f_tien_nt$$),$detail$$.tien_ct=Math.round($detail$$.tien_ct_nt*$obj$$.ty_gia)));$detail$$.tien_ck_nt=$detail$$.tien_ck_nt||0;$detail$$.ty_le_ck&&($detail$$.tien_ck_nt=
|
|
9
|
+
utils.round($detail$$.tien_ct_nt*$detail$$.ty_le_ck/100,$f_tien_nt$$));$detail$$.tien_thue_nt=$detail$$.tien_thue_nt_dc||utils.round(($detail$$.tien_ct_nt-$detail$$.tien_ck_nt)*$thue_suat$$/100,$f_tien_nt$$);$detail$$.tien_nt=$detail$$.tien_ct_nt-$detail$$.tien_ck_nt+$detail$$.tien_thue_nt};
|
|
10
|
+
module.exports=function($router$$){const $contr$$=new controller($router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,kiem_tra_han_muc_cong_no:!0,sort:{ngay_ct:-1,so_ct:-1},onFinding:($user$$,$condition$$,$next$$)=>{$next$$(null,$condition$$)},onFound:($user$$,$condition$$,$items$$,$next$$)=>{$next$$(null,$items$$)}});$contr$$.route();$contr$$.reposting=async($user$$,$obj$$)=>{$obj$$.user_created||($obj$$.user_created=$user$$.email);let $d$$=moment($obj$$.ngay_ct).subtract(1,"months").toDate();await $obj$$.details.asyncJoinModel2($user$$.current_id_app,
|
|
11
|
+
dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.combo=$ref$$.combo||[]}});await $obj$$.details.asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$d$$.getFullYear(),thang:$d$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$obj$$.details.forEach($d$$=>{$d$$.tien_ct=Math.round(($d$$.tien_ct_nt||0)*($obj$$.ty_gia||0));$d$$.tt_nt=($d$$.tien_ct_nt||0)-($d$$.tien_ck_nt||0);$d$$.tt=($d$$.tien_ct||0)-($d$$.tien_ck||0);$d$$.combo&&$d$$.combo.length>
|
|
12
|
+
0&&($d$$.combo.forEach($c$$=>{$c$$.sl_xuat_1_combo=$c$$.sl_xuat;$c$$.sl_xuat=$c$$.sl_xuat_1_combo*$d$$.sl_xuat;$c$$.tien_hang=$c$$.tien_hang_nt=0}),$d$$.gia_mua=$d$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0));$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0)});await tinhhoahong($obj$$,$user$$);await model.updateOne({_id:$obj$$._id},{user_created:$obj$$.user_created,details:$obj$$.details})};$contr$$.saving=async($user$$,$obj$$)=>{$obj$$.warranty_policy_id==
|
|
13
|
+
""&&delete $obj$$.warranty_policy_id;$obj$$.ma_kho_npp="";$obj$$.of_user="";var $cust_kho_npp$$=$obj$$.ma_kh?await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh}).lean():void 0;$cust_kho_npp$$&&$cust_kho_npp$$.of_user&&($cust_kho_npp$$=await global.getModel("dmkho").findOne({id_app:$obj$$.id_app,user_npp:$cust_kho_npp$$.of_user,la_kho_npp:!0}).lean())&&($obj$$.ma_kho_npp=$cust_kho_npp$$.ma_kho,$obj$$.of_user=$cust_kho_npp$$.user_npp);$obj$$.user_created||($obj$$.user_created=$user$$.email);
|
|
14
|
+
$obj$$.details.forEach($d$$=>{$d$$.sl_xuat=utils.round($d$$.sl_xuat,4);$d$$.tt_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt;$d$$.tt=$d$$.tien_ct-$d$$.tien_ck;$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0)});$obj$$.ma_nv_giao_hang&&!$obj$$.user_nv_giao_hang&&($obj$$.user_nv_giao_hang=(await global.getModel("dmnv").findOne({id_app:$obj$$.id_app,ma_nv:$obj$$.ma_nv_giao_hang}).lean())?.user);!$obj$$.ma_nv_giao_hang&&$obj$$.user_nv_giao_hang&&($obj$$.ma_nv_giao_hang=(await global.getModel("dmnv").findOne({id_app:$obj$$.id_app,
|
|
15
|
+
user:$obj$$.user_nv_giao_hang}).lean())?.ma_nv);await tinhhoahong($obj$$,$user$$);await taothongtinchuyenkhoan($user$$,$obj$$)};$contr$$.post=async($obj$$,$fn$$,$_options$$={})=>{$fn$$||=function(){};const $appInfo$$=await global.getModel("app").findOne({_id:$obj$$.id_app}).lean();let $kho$$=await dmkho.findOne({id_app:$obj$$.id_app,ma_kho:$obj$$.ma_kho}).lean()||{},$options$$;try{$options$$=await Options.getInfo($obj$$.id_app,{id_func:($obj$$.listinfo_code||$obj$$.ma_ct).toLowerCase()},"option")}catch($e$$){Logger.info($e$$.message,
|
|
16
|
+
{id_func:$obj$$.ma_ct})}$options$$||={};await $obj$$.details.asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["gia_mua,tk_tl"]});let $product_details$$=$obj$$.details.map($detail$$=>{$detail$$.tien_nt=$detail$$.tien_nt||0;$detail$$.tien=$detail$$.tien||0;$detail$$.nxt=2;return $detail$$.combo&&$detail$$.combo.length>0?$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$detail$$.gia_ban_nt||($item$$.gia_ban_nt=0,$item$$.gia_nt=0,$item$$.tien_nt=0,$item$$.tien=
|
|
17
|
+
0,$item$$.tien_ck_nt=0,$item$$.tien_ck=0);$item$$.ma_kho=$item$$.ma_kho||$detail$$.ma_kho;$item$$.nxt=2;delete $item$$.px_gia_dd;return $item$$}):[$detail$$]}).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);$obj$$.details.forEach($d$$=>{$d$$.promotion&&$d$$.promotion.details_km&&$d$$.promotion.details_km.forEach($p$$=>{if($p$$.ma_vt&&$p$$.sl_km){let $_p$$={};_.extend($_p$$,$p$$,{sl_xuat:$p$$.sl_km});$product_details$$.push($_p$$)}})});$obj$$.promotion&&$obj$$.promotion.forEach($p$$=>{if($p$$.ma_vt&&$p$$.sl_km){let $_p$$=
|
|
18
|
+
{};_.extend($_p$$,$p$$,{sl_xuat:$p$$.sl_km});$product_details$$.push($_p$$)}});let $product_details_npp$$=$obj$$.ma_kho_npp?_.cloneDeep($product_details$$):[];$product_details_npp$$.forEach($detail$$=>{$detail$$.nxt=1;$detail$$.sl_nhap=$detail$$.sl_xuat;$detail$$.gia_von_nt=$detail$$.gia_ban_nt;$detail$$.gia_von=$detail$$.gia_ban;$detail$$.tien_nhap_nt=$detail$$.tien_nt-($detail$$.tien_ck_nt||0);$detail$$.tien_nhap=$detail$$.tien-($detail$$.tien_ck||0);$detail$$.tk_co=$obj$$.tk_co;$detail$$.ma_kho=
|
|
19
|
+
$obj$$.ma_kho_npp;$detail$$.sl_xuat=0;$detail$$.sl_xuat_qd=0;$detail$$.tien_xuat=$detail$$.tien_xuat_nt=0});await $product_details$$.filter($d$$=>!$d$$.ma_dvt).asyncJoinModel2($obj$$.id_app,"dmvt",{where:"ma_vt",fields:["ma_dvt","tk_vt","tk_tl"]});await $product_details$$.filter($d$$=>!$d$$.tk_vt).asyncJoinModel2($obj$$.id_app,"dmvt",{where:"ma_vt",fields:["tk_vt","tk_tl"]});await ($obj$$.details||[]).filter($d$$=>!$d$$.tk_gv).asyncJoinModel2($obj$$.id_app,"dmvt",{where:"ma_vt",fields:["tk_gv"]});
|
|
20
|
+
let $ket_qua_post_sokho$$;async.series({phu_cap:$callback$$=>{setImmediate(async()=>{let $details_phu_cap$$=_.cloneDeep(($obj$$.details||[]).filter($d$$=>$d$$.luong_tho&&$d$$.tg_tk));$details_phu_cap$$.length==0&&($details_phu_cap$$=_.cloneDeep(($obj$$.details||[]).filter($d$$=>$d$$.luong_tho)));for(var $cust$jscomp$1_d$jscomp$9_phu_cap_cust$$ of $details_phu_cap$$)$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ma_nv=$obj$$.ma_nv_giao_hang||$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ma_nv,$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.thang=
|
|
21
|
+
(new Date($obj$$.ngay_ct)).getMonth()+1,$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.nam=(new Date($obj$$.ngay_ct)).getFullYear(),$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ten_phu_cap=$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ten_phu_cap||$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ten_vt,$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.tien=$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.luong_tho;if($obj$$.ma_kh&&($cust$jscomp$1_d$jscomp$9_phu_cap_cust$$=await global.getModel("customer").findOne({id_app:$obj$$.id_app,
|
|
22
|
+
ma_kh:$obj$$.ma_kh,phu_cap:{$gte:0}}).lean())){var $t_phu_cap_t_sl_xuat$$=($obj$$.details||[]).map($r$$=>$r$$.sl_xuat||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$t_phu_cap_t_sl_xuat$$*=$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.phu_cap;const $phu_cap_cust$$={ma_nv:$obj$$.ma_nv_giao_hang,thang:(new Date($obj$$.ngay_ct)).getMonth()+1,nam:(new Date($obj$$.ngay_ct)).getFullYear(),ten_phu_cap:$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ten_phu_cap||"Ph\u1ee5 c\u1ea5p theo kh\u00e1ch h\u00e0ng",tien:$t_phu_cap_t_sl_xuat$$*
|
|
23
|
+
($obj$$.phu_xe?.5:1)};$details_phu_cap$$.push($phu_cap_cust$$);$obj$$.phu_xe&&($cust$jscomp$1_d$jscomp$9_phu_cap_cust$$={ma_nv:$obj$$.phu_xe,thang:(new Date($obj$$.ngay_ct)).getMonth()+1,nam:(new Date($obj$$.ngay_ct)).getFullYear(),ten_phu_cap:$cust$jscomp$1_d$jscomp$9_phu_cap_cust$$.ten_phu_cap||"Ph\u1ee5 c\u1ea5p theo kh\u00e1ch h\u00e0ng",tien:$t_phu_cap_t_sl_xuat$$/2},$details_phu_cap$$.push($cust$jscomp$1_d$jscomp$9_phu_cap_cust$$))}(new PostBook($obj$$,$details_phu_cap$$,global.getModel("phucap"),
|
|
24
|
+
async($detail$$,$callback$$)=>{$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})},post_tdttno:function($callback$$){account.findOne({tk:$obj$$.tk_no,id_app:$obj$$.id_app},{tk_cn:1},async function($d_chinh_error$$,$tk$$){if($d_chinh_error$$)return $callback$$($d_chinh_error$$);if($tk$$?.tk_cn===!0||$options$$.post_tdtt_tm){const $ma_kh_no$$=$obj$$.ma_kh_no||$obj$$.ma_kh;let $kh_bo_xung$$=($obj$$.details||[]).filter($d$$=>($d$$.ma_kh_no||$d$$.ma_kh)&&($d$$.ma_kh_no||$d$$.ma_kh)!=
|
|
25
|
+
$ma_kh_no$$);$kh_bo_xung$$.forEach($d$$=>{$d$$.tien_nt=($d$$.tien_ct_nt||0)-($d$$.tien_ck_nt||0)+($d$$.tien_thue_nt||0);$d$$.tien=$d$$.tien_nt*$obj$$.ty_gia;$d$$.ma_kh=$d$$.ma_kh_no||$d$$.ma_kh});$kh_bo_xung$$=await $kh_bo_xung$$.asyncGroupBy(["ma_kh"],["tien_nt","tien"]);const $bao_hiem$$=[];$obj$$.tien_bh_chi&&$obj$$.ma_kh_bh&&($d_chinh_error$$={...$obj$$},$d_chinh_error$$.ma_kh=$obj$$.ma_kh_bh,$d_chinh_error$$.tien_nt=$obj$$.tien_bh_chi,$d_chinh_error$$.tien=$d_chinh_error$$.tien_bh_chi*($obj$$.ty_gia||
|
|
26
|
+
1),$bao_hiem$$.push($d_chinh_error$$));$d_chinh_error$$=[{...$obj$$}];$d_chinh_error$$.forEach($detail$$=>{$detail$$.ma_kh=$ma_kh_no$$;$detail$$.tien_nt=Math.max(0,$obj$$.details.csum("tien_ct_nt")-$obj$$.details.csum("tien_ck_nt")-($obj$$.tien_ck_hd||0)+$obj$$.details.csum("tien_thue_nt")+($obj$$.tien_phi_vc_nt||0)-$kh_bo_xung$$.csum("tien_nt")-$bao_hiem$$.csum("tien_nt"));$detail$$.tien=$detail$$.tien_nt*$obj$$.ty_gia});(new PostBook($obj$$,[...$kh_bo_xung$$,...$bao_hiem$$,...$d_chinh_error$$].filter($d$$=>
|
|
27
|
+
$d$$.tien_nt),Tdttno,function($detail$$,$callback$$){try{$detail$$.so_hd||($detail$$.so_hd=$obj$$.so_ct),$detail$$.ngay_hd||($detail$$.ngay_hd=$obj$$.ngay_ct)}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})}else Tdttno.deleteMany({id_ct:$obj$$._id},function($error$$){$callback$$($error$$)})})},post_sokho:$callback$$=>{async.series({kt:$callback$$=>{$options$$.not_post_sokho?$callback$$():(new PostSokho($obj$$,[...$product_details$$],
|
|
28
|
+
async($detail$$,$callback$$)=>{$detail$$.nxt=$detail$$.nxt||2;$detail$$.tk_no=$obj$$.tk_no;$detail$$.ma_kho=$detail$$.ma_kho||$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);$ket_qua_post_sokho$$=$rs$$.rs_sokho;$callback$$(null,$rs$$)})},npp:$callback$$=>{$options$$.not_post_sokho?$callback$$():(new PostBook($obj$$,$product_details_npp$$,global.getModel("sokhonpp"),async($detail$$,$callback$$)=>{$detail$$.tk_no=$obj$$.tk_no;$detail$$.ma_kho=$detail$$.ma_kho||
|
|
29
|
+
$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},tt:$callback$$=>{$options$$.post_sokhott?(new PostBook($obj$$,$product_details$$,Sokhott,async($detail$$,$callback$$)=>{$detail$$.nxt=$detail$$.nxt||2;$detail$$.tk_no=$obj$$.tk_no;$detail$$.ma_kho=$detail$$.ma_kho||$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):$callback$$()}},($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)})},post_vatra:function($callback$$){(async()=>{if($obj$$.ngay_hd||
|
|
30
|
+
$obj$$.vatras&&$obj$$.vatras.length>0){let $details_vatra$$=($obj$$.vatras||[]).filter($v$$=>$v$$.ma_thue);if($obj$$.ngay_hd){var $d$$=$obj$$.details.map($detail$$=>({...$detail$$,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0,ma_thue:$detail$$.ma_thue||$obj$$.ma_thue,tien_thue_nt:$detail$$.tien_thue_nt||0,tien_thue:$detail$$.tien_thue||0})).filter($d$$=>$d$$.ma_thue);await $d$$.filter($r$$=>!$r$$.tk_thue_co&&$r$$.ma_thue).asyncJoinModel2($obj$$.id_app,"vat",{where:"ma_thue",
|
|
31
|
+
fields:["tk_thue_co"]});$d$$=await $d$$.asyncGroupBy(["ma_thue","thue_suat","ten_vt_vat","tk_thue_co"],"tien_ct_nt tien_ct tien_nt tien tien_ck tien_ck_nt tien_thue tien_thue_nt".split(" "));$d$$.forEach($detail$$=>{try{$detail$$.tk_du_thue=$obj$$.tk_no,$detail$$.t_tien_nt=($detail$$.tien_ct_nt||0)-($detail$$.tien_ck_nt||0),$detail$$.t_tien=($detail$$.tien_ct||0)-($detail$$.tien_ck||0),$detail$$.t_thue_nt=$detail$$.tien_thue_nt,$detail$$.t_thue=$detail$$.tien_thue,$detail$$.ten_vt=$detail$$.ten_vt_vat||
|
|
32
|
+
$obj$$.ten_vt||$obj$$.dien_giai}catch($e$$){Logger.error($e$$,$obj$$)}});$details_vatra$$=[...$details_vatra$$,...$d$$]}(new PostBook($obj$$,$details_vatra$$,Vatra,($detail$$,$callback$$)=>{$detail$$={...$detail$$};$detail$$.ten_vt=$detail$$.ten_vt||$obj$$.dien_giai;$callback$$($detail$$)})).run(function($e$$,$rs$$){$e$$&&Logger.error("[hd2][post vatra]",$e$$,JSON.stringify($details_vatra$$,null,2));$callback$$($e$$,$rs$$)})}else $callback$$()})()},post_socai:function($callback$$){setImmediate(async()=>
|
|
33
|
+
{let $details$$=[];$options$$.hoach_toan_ck_vt?($obj$$.details.forEach(function($d$jscomp$16_detail$$){$d$jscomp$16_detail$$={...$d$jscomp$16_detail$$};$d$jscomp$16_detail$$.tien_nt=$d$jscomp$16_detail$$.tien_ct_nt;$d$jscomp$16_detail$$.tien=$d$jscomp$16_detail$$.tien_ct?$d$jscomp$16_detail$$.tien_ct:utils.round($d$jscomp$16_detail$$.tien_ct_nt*$obj$$.ty_gia,0);$d$jscomp$16_detail$$.tk_co=$d$jscomp$16_detail$$.tk_dt||$kho$$.tk_dt||$options$$.tk_dt;$d$jscomp$16_detail$$.ma_kh||($d$jscomp$16_detail$$.ma_kh=
|
|
34
|
+
$obj$$.ma_kh);$d$jscomp$16_detail$$.tk_no=$obj$$.tk_no;$details$$.push($d$jscomp$16_detail$$)}),($obj$$.details||[]).filter($d$$=>$d$$.tien_ck_nt).forEach(function($d$jscomp$18_detail$$){$d$jscomp$18_detail$$={...$d$jscomp$18_detail$$};$d$jscomp$18_detail$$.tk_no=$d$jscomp$18_detail$$.tk_ck||$obj$$.tk_ck||$kho$$.tk_ck||$options$$.tk_ck;$d$jscomp$18_detail$$.ma_kh||($d$jscomp$18_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$18_detail$$.tk_co=$obj$$.tk_no;$d$jscomp$18_detail$$.tien_nt=$d$jscomp$18_detail$$.tien_ck_nt;
|
|
35
|
+
$d$jscomp$18_detail$$.tien=$d$jscomp$18_detail$$.tien_ck;$d$jscomp$18_detail$$.ma_kh_no=$d$jscomp$18_detail$$.ma_kh||$obj$$.ma_kh;$d$jscomp$18_detail$$.ma_kh_co=$obj$$.ma_kh_no||$d$jscomp$18_detail$$.ma_kh||$obj$$.ma_kh;$d$jscomp$18_detail$$.check_balance=!1;$details$$.push($d$jscomp$18_detail$$)})):$obj$$.details.forEach(function($d$jscomp$19_detail$$){$d$jscomp$19_detail$$={...$d$jscomp$19_detail$$};$d$jscomp$19_detail$$.tien_nt=$d$jscomp$19_detail$$.tien_ct_nt-($d$jscomp$19_detail$$.tien_ck_nt||
|
|
36
|
+
0);$d$jscomp$19_detail$$.tien=utils.round($d$jscomp$19_detail$$.tien_nt*$obj$$.ty_gia,0);$d$jscomp$19_detail$$.tk_co=$d$jscomp$19_detail$$.tk_dt||$kho$$.tk_dt||$options$$.tk_dt;$d$jscomp$19_detail$$.ma_kh||($d$jscomp$19_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$19_detail$$.tk_no=$obj$$.tk_no;$details$$.push($d$jscomp$19_detail$$)});if($obj$$.tien_ck_hd){var $o_tt$jscomp$1_tt$$={};$o_tt$jscomp$1_tt$$.tk_no=$obj$$.tk_ck||$kho$$.tk_ck||$options$$.tk_ck;$o_tt$jscomp$1_tt$$.tk_co=$obj$$.tk_no;$o_tt$jscomp$1_tt$$.tien_nt=
|
|
37
|
+
$obj$$.tien_ck_hd;$o_tt$jscomp$1_tt$$.tien=$o_tt$jscomp$1_tt$$.tien_nt*($obj$$.ty_gia||1);$o_tt$jscomp$1_tt$$.ma_kh_no=$obj$$.ma_kh;$o_tt$jscomp$1_tt$$.ma_kh_co=$obj$$.ma_kh_no||$obj$$.ma_kh;$o_tt$jscomp$1_tt$$.check_balance=!1;$details$$.push($o_tt$jscomp$1_tt$$)}$obj$$.tien_bh_chi&&$obj$$.ma_kh_bh&&$obj$$.ma_kh!=$obj$$.ma_kh_bh&&($o_tt$jscomp$1_tt$$={},$o_tt$jscomp$1_tt$$.tk_no=$obj$$.tk_no,$o_tt$jscomp$1_tt$$.tk_co=$obj$$.tk_no,$o_tt$jscomp$1_tt$$.tien_nt=$obj$$.tien_bh_chi,$o_tt$jscomp$1_tt$$.tien=
|
|
38
|
+
$o_tt$jscomp$1_tt$$.tien_bh_chi*($obj$$.ty_gia||1),$o_tt$jscomp$1_tt$$.ma_kh_no=$obj$$.ma_kh_bh,$o_tt$jscomp$1_tt$$.ma_kh_co=$obj$$.ma_kh,$o_tt$jscomp$1_tt$$.check_balance=!1,$details$$.push($o_tt$jscomp$1_tt$$));$obj$$.thu_nhap_ctv&&$obj$$.ma_ctv&&(($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_ctv).forEach($r$$=>{$r$$.tk_cp_ctv=$r$$.tk_cp_ctv||$obj$$.tk_cp_ctv||$kho$$.tk_cp_ctv||$options$$.tk_cp_ctv||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_cn_ctv=$r$$.tk_cn_ctv||
|
|
39
|
+
$obj$$.tk_cn_ctv||$kho$$.tk_cn_ctv||$options$$.tk_cn_ctv||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await ($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_ctv).asyncGroupBy(["tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_cp_ctv;$tt$$.tk_co=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv;$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_ctv;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng c\u1ed9ng t\u00e1c vi\u00ean c\u1ea5p 1";
|
|
40
|
+
$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.thu_nhap_ctv2&&$obj$$.ma_ctv2&&(($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_ctv2).forEach($r$$=>{$r$$.tk_cp_ctv=$r$$.tk_cp_ctv||$obj$$.tk_cp_ctv||$kho$$.tk_cp_ctv||$options$$.tk_cp_ctv||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_cn_ctv=$r$$.tk_cn_ctv||$obj$$.tk_cn_ctv||$kho$$.tk_cn_ctv||$options$$.tk_cn_ctv||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await ($obj$$.details||
|
|
41
|
+
[]).filter($r$$=>$r$$.tien_hoa_hong_ctv2).asyncGroupBy(["tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv2"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_cp_ctv;$tt$$.tk_co=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv2;$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_ctv2;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng c\u00f4ng t\u00e1c vi\u00ean c\u1ea5p 2";$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong&&$obj$$.ma_kh_hoa_hong&&
|
|
42
|
+
(($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong).forEach($r$$=>{$r$$.tk_no_hoa_hong=$r$$.tk_no_hoa_hong||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong=$r$$.tk_co_hoa_hong||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await ($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong).asyncGroupBy(["tk_no_hoa_hong","tk_co_hoa_hong"],["tien_hoa_hong"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong;$tt$$.tk_co=$r$$.tk_co_hoa_hong;
|
|
43
|
+
$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_kh_hoa_hong;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng";$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_gt&&$obj$$.ma_kh_hoa_hong_gt&&(($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_gt).forEach($r$$=>{$r$$.tk_no_hoa_hong_gt=$r$$.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong_gt||
|
|
44
|
+
$kho$$.tk_no_hoa_hong_gt||$options$$.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_gt=$r$$.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong_gt||$kho$$.tk_co_hoa_hong_gt||$options$$.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await ($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_gt).asyncGroupBy(["tk_no_hoa_hong_gt","tk_co_hoa_hong_gt"],["tien_hoa_hong_gt"])).forEach($r$$=>{let $tt$$={};
|
|
45
|
+
$tt$$.tk_no=$r$$.tk_no_hoa_hong_gt;$tt$$.tk_co=$r$$.tk_co_hoa_hong_gt;$tt$$.tien_nt=$r$$.tien_hoa_hong_gt;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_kh_hoa_hong_gt;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng gi\u1edbi thi\u1ec7u";$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_kho&&$obj$$.ma_kh_hoa_hong_kho&&(($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_kho).forEach($r$$=>
|
|
46
|
+
{$r$$.tk_no_hoa_hong_kho=$r$$.tk_no_hoa_hong_kho||$obj$$.tk_no_hoa_hong_kho||$kho$$.tk_no_hoa_hong_kho||$options$$.tk_no_hoa_hong_kho||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_kho=$r$$.tk_co_hoa_hong_kho||$obj$$.tk_co_hoa_hong_kho||$kho$$.tk_co_hoa_hong_kho||$options$$.tk_co_hoa_hong_kho||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await ($obj$$.details||[]).filter($r$$=>$r$$.tien_hoa_hong_kho).asyncGroupBy(["tk_no_hoa_hong_kho",
|
|
47
|
+
"tk_co_hoa_hong_kho"],["tien_hoa_hong_kho"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_kho;$tt$$.tk_co=$r$$.tk_co_hoa_hong_kho;$tt$$.tien_nt=$r$$.tien_hoa_hong_kho;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_kh_hoa_hong_kho;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng cho ch\u1ee7 kho";$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_ql&&$obj$$.ma_kh_hoa_hong_ql&&
|
|
48
|
+
($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ql).forEach($r$$=>{$r$$.tk_no_hoa_hong_ql=$r$$.tk_no_hoa_hong_ql||$obj$$.tk_no_hoa_hong_ql||$kho$$.tk_no_hoa_hong_ql||$options$$.tk_no_hoa_hong_ql||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_ql=$r$$.tk_co_hoa_hong_ql||$obj$$.tk_co_hoa_hong_ql||$kho$$.tk_co_hoa_hong_ql||$options$$.tk_co_hoa_hong_ql||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>
|
|
49
|
+
$r$$.tien_hoa_hong_ql).asyncGroupBy(["tk_no_hoa_hong_ql","tk_co_hoa_hong_ql"],["tien_hoa_hong_ql"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_ql;$tt$$.tk_co=$r$$.tk_co_hoa_hong_ql;$tt$$.tien_nt=$r$$.tien_hoa_hong_ql;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh_no=$tt$$.ma_kh_co=$obj$$.ma_kh_hoa_hong_ql;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng cho \u0111i\u1ec1u h\u00e0nh kinh doanh";$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&
|
|
50
|
+
$details$$.push($tt$$)}));$o_tt$jscomp$1_tt$$={...$obj$$};$o_tt$jscomp$1_tt$$.tk_no=$obj$$.tk_no;$o_tt$jscomp$1_tt$$.tk_co=$obj$$.tk_thue_co;$o_tt$jscomp$1_tt$$.tien_nt=$obj$$.details.csum("tien_thue_nt");$o_tt$jscomp$1_tt$$.tien=$o_tt$jscomp$1_tt$$.tien_nt*$o_tt$jscomp$1_tt$$.ty_gia;$o_tt$jscomp$1_tt$$.dien_giai_thue&&($o_tt$jscomp$1_tt$$.dien_giai=$o_tt$jscomp$1_tt$$.dien_giai_thue);$details$$.push($o_tt$jscomp$1_tt$$);if($obj$$.vatras&&$obj$$.vatras.length>0)for(var $o$jscomp$1_o$$ of $obj$$.vatras)$o$jscomp$1_o$$.tk_no=
|
|
51
|
+
$obj$$.tk_no,$o$jscomp$1_o$$.tk_co=$o$jscomp$1_o$$.tk_thue_co,$o$jscomp$1_o$$.tien_nt=$o$jscomp$1_o$$.t_thue_nt,$o$jscomp$1_o$$.tien=$o$jscomp$1_o$$.t_thue,$o$jscomp$1_o$$.dien_giai_thue&&($o$jscomp$1_o$$.dien_giai=$o$jscomp$1_o$$.dien_giai_thue),$details$$.push($o$jscomp$1_o$$);$obj$$.tk_phi_vc=$obj$$.tk_phi_vc||$options$$.tk_phi_vc;$obj$$.tk_phi_vc&&($o$jscomp$1_o$$={...$obj$$},$o$jscomp$1_o$$.tk_no=$obj$$.tk_no,$o$jscomp$1_o$$.tk_co=$obj$$.tk_phi_vc,$o$jscomp$1_o$$.tien_nt=$obj$$.tien_phi_vc_nt,
|
|
52
|
+
$o$jscomp$1_o$$.tien=$o$jscomp$1_o$$.tien_nt*$o$jscomp$1_o$$.ty_gia,$o$jscomp$1_o$$.dien_giai="Ph\u00ed giao h\u00e0ng",$details$$.push($o$jscomp$1_o$$));const $details_giavon$$=[];($ket_qua_post_sokho$$||[]).filter($r$$=>$r$$.nxt!=1).forEach(function($detail$$){$detail$$.toObject&&($detail$$=$detail$$.toObject());$detail$$={...$detail$$};$detail$$.tk_no=$detail$$.tk_gv;$detail$$.ma_kh||($detail$$.ma_kh=$obj$$.ma_kh);$detail$$.tk_co=$detail$$.tk_vt;$detail$$.tien_nt=$detail$$.tien_xuat_nt;$detail$$.tien=
|
|
53
|
+
$detail$$.tien_xuat;$details_giavon$$.push($detail$$)});async.series({xdtk:$callback$$=>{$details_giavon$$.joinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["tk_vt","gia_mua","tk_gv"]},()=>{$details_giavon$$.forEach($s$$=>{$s$$.tk_co||($s$$.tk_co=$s$$.tk_vt||$options$$.tk_vt);$s$$.tk_no||($s$$.tk_no=$s$$.tk_gv||$options$$.tk_gv);$s$$.ma_nt="VND";$s$$.ty_gia=1});$callback$$()})}},async()=>{$details_giavon$$.forEach($d$$=>{$d$$.ma_kh_no=$d$$.ma_kh||$obj$$.ma_kh;$d$$.ma_kh_co=$d$$.ma_kh||$obj$$.ma_kh});
|
|
54
|
+
$details$$=$details$$.concat($details_giavon$$);(new PostSocai($obj$$,$details$$,void 0,void 0,$_options$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})})},thanhtoanhoahongnv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong||!$obj$$.tien_hoa_hong||!$obj$$.user_nv||!$obj$$.chuyen_ngay)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_nhan_vien$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),
|
|
55
|
+
username:$obj$$.user_nv,wallet_type:8});$wallet_nhan_vien$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_nv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_nhan_vien$$.address,$amount$$,$denom$$,
|
|
56
|
+
$memo$$,"","2");$obj$$.da_chuyen_hoa_hong=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})},thanhtoanhoahonggt:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_gt||!$obj$$.tien_hoa_hong_gt||!$obj$$.user_gt||!$obj$$.chuyen_ngay_gt)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_gt$$=
|
|
57
|
+
await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_gt,wallet_type:8});$wallet_gt$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_gt,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_gt,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,
|
|
58
|
+
$obj$$.be_introduced,$wallet_gt$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_gt=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_gt:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})},thanhtoanhoahongctv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_ctv||!$obj$$.thu_nhap_ctv||!$obj$$.user_ctv||!$obj$$.chuyen_ngay_ctv)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&
|
|
59
|
+
$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){if($obj$$.user_ctv&&$obj$$.thu_nhap_ctv){let $wallet_ctv$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ctv,wallet_type:8});$wallet_ctv$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_ctv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.thu_nhap_ctv,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;
|
|
60
|
+
await spend($appInfo$$,$obj$$.be_introduced,$wallet_ctv$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2")}if($obj$$.user_ctv2&&$obj$$.thu_nhap_ctv2){let $wallet_ctv2$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ctv2,wallet_type:8});$wallet_ctv2$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_ctv2,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.thu_nhap_ctv2,$denom$$=$appInfo$$.tang_gioi_thieu_denom,
|
|
61
|
+
$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_ctv2$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2")}$obj$$.da_chuyen_hoa_hong_ctv=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_ctv:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})},thanhtoanhoahongql:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_ql||
|
|
62
|
+
!$obj$$.tien_hoa_hong_ql||!$obj$$.user_ql||!$obj$$.chuyen_ngay_ql)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_ql$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ql,wallet_type:8});$wallet_ql$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_ql,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=
|
|
63
|
+
$obj$$.tien_hoa_hong_ql,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_ql$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_ql=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_ql:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
64
|
+
$e$$)}$callback$$()})},thanhtoanhoahongchukho:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_kho||!$obj$$.tien_hoa_hong_kho||!$obj$$.user_kho||!$obj$$.chuyen_ngay_kho)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_kho$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_kho,wallet_type:8});$wallet_kho$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
65
|
+
$obj$$.user_kho,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_kho,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_kho$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_kho=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_kho:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
66
|
+
$e$$)}$callback$$()})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};const $valid$$=function($i_user$$,$obj$$,$next$$){$obj$$.thue_suat=$obj$$.thue_suat||0;$obj$$.tien_phi_vc_nt=$obj$$.tien_phi_vc_nt||0;$obj$$.tien_phi_vc=utils.round($obj$$.tien_phi_vc_nt*$obj$$.ty_gia,0);$obj$$.details.forEach($detail$$=>{tinhGiaChuaThue($obj$$,$detail$$)});$obj$$.vatras=($obj$$.vatras||[]).filter($d$$=>$d$$);$obj$$.vatras.forEach($d$$=>{$d$$.t_tien=utils.round($d$$.t_tien_nt*($obj$$.ty_gia||1),0);$d$$.t_thue=utils.round($d$$.t_thue_nt*
|
|
67
|
+
($obj$$.ty_gia||1),0)});for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){const $detail$$=$obj$$.details[$i_user$$];$detail$$.line=$i_user$$;$detail$$.tien_ck_nt=$detail$$.tien_ck_nt||0;$detail$$.tien_thue_nt=$detail$$.tien_thue_nt||0;$detail$$.tien=utils.round($detail$$.tien_nt*$obj$$.ty_gia,0);$detail$$.tien_ct=utils.round($detail$$.tien_ct_nt*$obj$$.ty_gia,0);$detail$$.gia_ban=utils.round($detail$$.gia_ban_nt*$obj$$.ty_gia,0);$detail$$.tien_ck=utils.round($detail$$.tien_ck_nt*$obj$$.ty_gia,
|
|
68
|
+
0);$detail$$.tien_thue=utils.round($detail$$.tien_thue_nt*$obj$$.ty_gia,0);$detail$$.tien_xuat=$detail$$.tien_xuat_nt}$obj$$.id_contract?salecontract.findOne({_id:$obj$$.id_contract,id_app:$obj$$.id_app}).lean().then($c$$=>{$c$$&&($obj$$.ma_hd=$c$$.ma_hd);$next$$(null,$obj$$)}).catch($e$$=>{$next$$($e$$)}):$next$$(null,$obj$$)};$contr$$.creating=async function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,async function($error$$){if($error$$)return $next$$($error$$);
|
|
69
|
+
await $obj$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.combo=$ref$$.combo||[];$item$$.ma_thue||($item$$.ma_thue=$ref$$.ma_thue);$item$$.ten_vt=$ref$$.ten_vt;$item$$.status_vt=$ref$$.status;$item$$.gia_mua=$ref$$.gia_mua_tmp}});$error$$=($obj$$.details||[]).filter($d$$=>!$d$$.status_vt);if($error$$.length>0)return $next$$(`C\u00e1c m\u1eb7t h\u00e0ng sau \u0111\u00e3 ng\u1eebng kinh doanh ho\u1eb7c kh\u00f4ng t\u1ed3n t\u1ea1i trong h\u1ec7 th\u1ed1ng : ${$error$$.map($d$$=>
|
|
70
|
+
$d$$.ten_vt||$d$$.ma_vt).join(",")}`);let $ngay_nay_thang_truoc$$=moment($obj$$.ngay_ct).subtract(1,"months").toDate(),$details$$=[];$obj$$.details.forEach($d$$=>{$d$$.combo&&$d$$.combo.length>0?$details$$=[...$details$$,...$d$$.combo]:$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,gia:{$gt:0},nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1}),
|
|
71
|
+
fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,gia:{$gt:0},nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1}),fields:[{gia_mua:"gia"}]});$obj$$.details.filter($d$$=>$d$$.combo&&$d$$.combo.length>0).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item$$=>
|
|
72
|
+
{$item$$.sl_xuat_1_combo=$item$$.sl_xuat;$item$$.sl_xuat=$item$$.sl_xuat_1_combo*$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=0;$item$$.tien=$item$$.tien_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*($item$$.tien_ck_nt||0);$item$$.tt=$item$$.tt_nt=$item$$.tien_nt-($item$$.tien_ck_nt||0);return{...$item$$}});$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||
|
|
73
|
+
0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$obj$$.result_export_einvoice=null;$next$$(null,$obj$$)})};$contr$$.updating=async function($user$$,$data$$,$obj$$,$next$$){$data$$.details||($data$$.details=$obj$$.details);$data$$.ngay_ct=$data$$.ngay_ct||$obj$$.ngay_ct;await $data$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{let $old_combo$$=($item$$.combo||[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat})),$new_combo$$=($ref$$.combo||
|
|
74
|
+
[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat}));_.isEqual($old_combo$$,$new_combo$$)||($item$$.combo=$ref$$.combo||[]);$item$$.gia_mua=$ref$$.gia_mua_tmp}});let $ngay_nay_thang_truoc$$=moment($data$$.ngay_ct).subtract(1,"months").toDate(),$details$$=[];$data$$.details.forEach($d$$=>{$d$$.combo&&$d$$.combo.length>0?$details$$=$details$$.concat($d$$.combo):$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,
|
|
75
|
+
id_app:$obj$$.id_app,gia:{$gt:0},nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1}),fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,gia:{$gt:0},nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1}),fields:[{gia_mua:"gia"}]});
|
|
76
|
+
$data$$.details.filter($d$$=>$d$$.combo&&$d$$.combo.length>0).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item$$=>{$item$$.sl_xuat_1_combo==void 0&&($item$$.sl_xuat_1_combo=$item$$.sl_xuat||0);$item$$.sl_xuat=$item$$.sl_xuat_1_combo*$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=0;$item$$.tien=$item$$.tien_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*
|
|
77
|
+
($item$$.tien_ck_nt||0);$item$$.tt=$item$$.tt_nt=$item$$.tien_nt-($item$$.tien_ck_nt||0);return{...$item$$}});$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});const $ct_tt$$=await Tdttno_tt.findOne({id_hd:$obj$$._id,id_app:$obj$$.id_app}).lean();if($ct_tt$$)return $next$$(`Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$$.ma_ct||"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$$.so_ct}, ng\u00e0y ${moment($ct_tt$$.ngay_ct).format("DD/MM/YYYY")}`);
|
|
78
|
+
$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})};$contr$$.deleting=async function($ct_tt$jscomp$1_user$$,$obj$$,$next$$){($ct_tt$jscomp$1_user$$=await Tdttno_tt.findOne({id_hd:$obj$$._id,id_app:$obj$$.id_app}).lean())?$next$$(`Kh\u00f4ng th\u1ec3 xo\u00e1 phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$jscomp$1_user$$.ma_ct||"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$jscomp$1_user$$.so_ct}, ng\u00e0y ${moment($ct_tt$jscomp$1_user$$.ngay_ct).format("DD/MM/YYYY")}`):
|
|
79
|
+
$next$$(null,$obj$$)};$contr$$.on("saved",async function($_obj_obj$$){$_obj_obj$$.id_dh2&&(await global.getModel("dh2").updateMany({_id:$_obj_obj$$.id_dh2,id_app:$_obj_obj$$.id_app},{id_hd2:$_obj_obj$$._id.toString(),trang_thai:"7"}),($_obj_obj$$=await global.getModel("dh2").findOne({_id:$_obj_obj$$.id_dh2}))&&controller.postData($_obj_obj$$,global.controllers.DH2,$e$$=>{$e$$&&Logger.error($e$$)}))});$contr$$.on("deleted",async function($_obj$jscomp$1_obj$$){$_obj$jscomp$1_obj$$.id_dh2&&(await global.getModel("dh2").updateMany({_id:$_obj$jscomp$1_obj$$.id_dh2,
|
|
80
|
+
id_app:$_obj$jscomp$1_obj$$.id_app,id_pxh:{$in:[null,"",void 0]}},{id_hd2:"",trang_thai:"3"}),await global.getModel("dh2").updateMany({_id:$_obj$jscomp$1_obj$$.id_dh2,id_app:$_obj$jscomp$1_obj$$.id_app,id_pxh:{$nin:[null,"",void 0]}},{id_hd2:"",trang_thai:"6"}),($_obj$jscomp$1_obj$$=await global.getModel("dh2").findOne({_id:$_obj$jscomp$1_obj$$.id_dh2,id_app:$_obj$jscomp$1_obj$$.id_app}))&&controller.postData($_obj$jscomp$1_obj$$,global.controllers.DH2,$e$$=>{$e$$&&Logger.error($e$$)}))});$contr$$.view=
|
|
81
|
+
function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.parallel({dt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback$$()})},kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:["ten_kh","email","nh_kh"]}],function(){$callback$$()})},ghn:function($callback$$){$items$$.filter($item$$=>$item$$.tinh_thanh&&
|
|
82
|
+
$item$$.quan_huyen&&$item$$.xa_phuong).joinModel2(null,"xaphuong",[{where:{tinh_thanh:"ten_tinh_thanh",quan_huyen:"ten_quan_huyen",xa_phuong:"ten_xa_phuong"},fields:["provinceid_ghn","districtid_ghn","wardcode_ghn"]}],function(){$callback$$()})},nv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_nv).joinModel($id_app$$,dmnv,[{akey:"ma_nv",bkey:"ma_nv",setFields:($item$$,$ref$$)=>{$item$$.ma_bp||($item$$.ma_bp=$ref$$.ma_bp);$item$$.ten_nv=$ref$$.ten_nv}}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>
|
|
83
|
+
$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},contract:function($callback$$){$items$$.filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:{ma_hd:"so_hd"},fields:["ten_hd","ten_hd"]}],function(){$callback$$()})},cong_no:function($callback$$){setImmediate(async()=>{try{const $id_hds$$=$items$$.map($i$$=>$i$$._id.toString()),$congnos$$=await global.getModel("tdttno").getBalance({id_app:$id_app$$,
|
|
84
|
+
id_hd:{$in:$id_hds$$}});for(let $item$$ of $items$$){let $invoice$$=$congnos$$.find($c$$=>$c$$.id_ct.toString()==$item$$._id.toString());if($invoice$$&&($item$$.da_thanh_toan_nt=$invoice$$.da_thanh_toan_nt,$item$$.da_thanh_toan=$invoice$$.da_thanh_toan,$item$$.con_lai_nt=$invoice$$.con_lai_nt,$item$$.con_lai=$invoice$$.con_lai,$item$$.con_lai_nt)){let $t_invoice$$={sel:!1,id_tdtt:$invoice$$._id,line:$invoice$$.line,id_hd:$invoice$$.id_ct,so_hd:$invoice$$.so_hd||$invoice$$.so_ct,ngay_hd:$invoice$$.ngay_hd||
|
|
85
|
+
$invoice$$.ngay_ct,tien_hd_nt:$invoice$$.tien_nt};$t_invoice$$.ma_nt_hd=$invoice$$.ma_nt;$t_invoice$$.ty_gia_hd=$invoice$$.ty_gia;$t_invoice$$.ma_kh=$invoice$$.ma_kh;$t_invoice$$.ma_kho=$invoice$$.ma_kho;$t_invoice$$.dien_giai=$invoice$$.dien_giai;$t_invoice$$.tien_nt=0;$t_invoice$$.tien=0;$t_invoice$$.thanh_toan_qd=0;$t_invoice$$.tk_co=$invoice$$.tk_no;$t_invoice$$.da_thanh_toan_nt=$invoice$$.da_thanh_toan_nt;$t_invoice$$.da_thanh_toan=$invoice$$.da_thanh_toan;$t_invoice$$.con_lai_nt=$invoice$$.con_lai_nt;
|
|
86
|
+
$t_invoice$$.con_lai=$invoice$$.con_lai;$item$$.theo_doi_thanh_toan=$t_invoice$$}}$callback$$()}catch($e$$){$callback$$($e$$)}})},t_tien:function($callback$$){for(let $r$$ of $items$$)$r$$.details&&($r$$.details.forEach($d$$=>{$d$$.tien_tinh_thue_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt;$d$$.tien_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt+$d$$.tien_thue_nt;$d$$.tien=Math.round($d$$.tien_nt*$r$$.ty_gia)}),$r$$.t_sl=$r$$.details.csum("sl_xuat"),$r$$.t_thue=$r$$.details.csum("tien_thue"),$r$$.t_thue_nt=$r$$.details.csum("tien_thue_nt"),
|
|
87
|
+
$r$$.t_tien=$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"),$r$$.t_tien_ct=$r$$.details.csum("tien_ct"),$r$$.t_tien_ct_nt=$r$$.details.csum("tien_ct_nt"),$r$$.t_ck=$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.tc_ck_nt=$r$$.t_ck_nt+($r$$.tien_ck_hd||0),$r$$.tc_ck=$r$$.t_ck+($r$$.tien_ck_hd||0)*$r$$.ty_gia,$r$$.t_tt_nt=$r$$.t_tien_ct_nt-$r$$.tc_ck_nt+$r$$.t_thue_nt+($r$$.tien_phi_vc_nt||0),$r$$.t_tt=Math.round($r$$.t_tt_nt*$r$$.ty_gia||1,0),$r$$.t_tien_xuat=
|
|
88
|
+
$r$$.details.csum("tien_xuat"),$r$$.t_tien_xuat_nt=$r$$.details.csum("tien_xuat_nt"),$r$$.tien_hoa_hong=$r$$.details.csum("tien_hoa_hong"),$r$$.tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt"),$r$$.tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql"),$r$$.tien_hoa_hong_kho=$r$$.details.csum("tien_hoa_hong_kho"),$r$$.thu_nhap_ctv=$r$$.details.csum("tien_hoa_hong_ctv"),$r$$.thu_nhap_ctv2=$r$$.details.csum("tien_hoa_hong_ctv2"));$callback$$()},details_kho:function($callback$$){async.map($items$$,
|
|
89
|
+
function($r$$,$callback$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kho).joinModel2($id_app$$,dmkho,[{where:"ma_kho",fields:["ten_kho"]}],function(){$callback$$()})},function(){$callback$$()})},details_vt:function($callback$$){async.map($items$$,function($voucher$$,$callback1$$){(async()=>{const $details$$=$voucher$$.details||[];await $details$$.asyncJoinModel2($id_app$$,dmvt,[{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.ten_vt=$ref$$.ten_vt;$item$$.tk_tl=$ref$$.tk_tl;$item$$.trong_luong=
|
|
90
|
+
$item$$.trong_luong||$ref$$.trong_luong;$item$$.chieu_sau=$item$$.chieu_sau||$ref$$.chieu_sau;$item$$.chieu_rong=$item$$.chieu_rong||$ref$$.chieu_rong;$item$$.chieu_cao=$item$$.chieu_cao||$ref$$.chieu_cao;$item$$.ma_tt1_yn=$ref$$.ma_tt1_yn;$item$$.ma_tt2_yn=$ref$$.ma_tt2_yn;$item$$.ma_tt3_yn=$ref$$.ma_tt3_yn;$item$$.ma_lo_yn=$ref$$.ma_lo_yn;$item$$.kl_nl=$ref$$.kl_nl;$item$$.ma_nvt||($item$$.ma_nvt=$ref$$.ma_nvt);$item$$.ma_nvt2||($item$$.ma_nvt2=$ref$$.ma_nvt2);$item$$.ma_nvt3||($item$$.ma_nvt3=
|
|
91
|
+
$ref$$.ma_nvt3)}}]);await $details$$.filter($d$$=>$d$$.ma_nvt).asyncJoinModel2($id_app$$,"dmnvt",[{where:{ma_nvt:"_id"},setFields:($item$$,$nh_vt_ref$$)=>{$item$$.ten_nvt=$nh_vt_ref$$.ten_nvt;$item$$.ten_nvt&&($nh_vt_ref$$=`nh_vt_${$item$$.ten_nvt}`,$voucher$$[$nh_vt_ref$$]=($voucher$$[$nh_vt_ref$$]||0)+$item$$.sl_xuat)}}]);$callback1$$()})()},function(){$callback$$()})},details_csck:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.id_cs_ck).joinModel2($id_app$$,
|
|
92
|
+
"dmchietkhau",[{where:{id_cs_ck:"_id"},setFields:($item$$,$ref$$)=>{$item$$.ten_chietkhau=$ref$$.ten_chietkhau}}],function(){$callback1$$()})},function(){$callback$$()})},details_tt1:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.ma_tt1).joinModel2($id_app$$,"dmtt",[{where:{ma_vt:"ma_vt",ma_tt1:"ma_tt"},setFields:($item$$,$ref$$)=>{$item$$.thuoc_tinh=$ref$$;$item$$.nh_tt||($item$$.nh_tt=$ref$$.nh_tt)}}],function(){$callback1$$()})},function(){$callback$$()})},
|
|
93
|
+
details_dt:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:{ma_hd:"so_hd"},fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback1$$()})},
|
|
94
|
+
function(){$callback$$()})},details_phi:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel2($id_app$$,dmphi,[{where:"ma_phi",fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})},details_chietkhau:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.id_cs_ck).joinModel2($id_app$$,"dmchietkhau",[{where:{id_cs_ck:"_id"},fields:["ma_chietkhau",
|
|
95
|
+
"ten_chietkhau"]}],function(){$callback1$$()})},function(){$callback$$()})}},async function(){$fn$$(null,$items$$)})};$contr$$.createRoute("export2viettel/:id_ct",async($req$$,$next$$)=>{var $ct_id_app$$=$req$$.user.current_id_app;const $app$$=await App.findOne({_id:$ct_id_app$$});if(!$app$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");if(!$app$$.ma_so_thue)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");$ct_id_app$$=await model.findOne({id_app:$ct_id_app$$,
|
|
96
|
+
_id:$req$$.params.id_ct}).lean();if(!$ct_id_app$$)return $next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");try{let $rs$$=await utils.exportInvoice($app$$,$ct_id_app$$,$req$$.query.check_data);$next$$(null,$rs$$)}catch($e$$){$next$$({error:$e$$.message||$e$$.error||$e$$})}},{method:"GET"});$contr$$.createRoute("export2viettel/:id_ct",async($req$$,$next$$)=>{var $ct$jscomp$1_id_app$$=$req$$.user.current_id_app;const $app$$=await App.findOne({_id:$ct$jscomp$1_id_app$$});if(!$app$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");
|
|
97
|
+
if(!$app$$.ma_so_thue)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");$ct$jscomp$1_id_app$$=await model.findOne({id_app:$ct$jscomp$1_id_app$$,_id:$req$$.params.id_ct}).lean();if(!$ct$jscomp$1_id_app$$)return $next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");try{let $body$$=$req$$.body||{};Logger.info("[vo-hd2] export2viettel",$body$$);$body$$.vatras&&($ct$jscomp$1_id_app$$.vatras=$body$$.vatras);$body$$.export_yn!=void 0&&($ct$jscomp$1_id_app$$.export_yn=
|
|
98
|
+
$body$$.export_yn);let $rs$$=await utils.exportInvoice($app$$,$ct$jscomp$1_id_app$$,$req$$.query.check_data);$next$$(null,$rs$$)}catch($e$$){$next$$({error:$e$$.message||$e$$.error||$e$$})}},{method:"POST"});$contr$$.createRoute("export/invoice/:id_ct",async($req$$,$next$$)=>{var $ct$jscomp$2_id_app$$=$req$$.user.current_id_app;const $app$$=await App.findOne({_id:$ct$jscomp$2_id_app$$});if(!$app$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");if(!$app$$.ma_so_thue)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");
|
|
99
|
+
$ct$jscomp$2_id_app$$=await model.findOne({id_app:$ct$jscomp$2_id_app$$,_id:$req$$.params.id_ct}).lean();if(!$ct$jscomp$2_id_app$$)return $next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");try{let $rs$$=await utils.exportInvoice($app$$,$ct$jscomp$2_id_app$$,$req$$.query.check_data);$next$$(null,$rs$$)}catch($e$$){$next$$({error:$e$$.message||$e$$.error||$e$$})}},{method:"GET",action_code:"add"});$contr$$.createRoute("export/invoice/:id_ct",async($req$$,$next$$)=>{var $ct$jscomp$3_id_app$$=
|
|
100
|
+
$req$$.user.current_id_app;const $app$$=await App.findOne({_id:$ct$jscomp$3_id_app$$});if(!$app$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");if(!$app$$.ma_so_thue)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");$ct$jscomp$3_id_app$$=await model.findOne({id_app:$ct$jscomp$3_id_app$$,_id:$req$$.params.id_ct}).lean();if(!$ct$jscomp$3_id_app$$)return $next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");try{let $body$$=$req$$.body||
|
|
101
|
+
{};$body$$.vatras&&($ct$jscomp$3_id_app$$.vatras=$body$$.vatras);$body$$.export_yn!=void 0&&($ct$jscomp$3_id_app$$.export_yn=$body$$.export_yn);let $rs$$=await utils.exportInvoice($app$$,$ct$jscomp$3_id_app$$,$req$$.query.check_data);$next$$(null,$rs$$)}catch($e$$){$next$$({error:$e$$.message||$e$$.error||$e$$})}},{method:"POST",action_code:"add"});$contr$$.createRoute("import/invoice",async($req$$,$next$$)=>{var $invoices_tu_ngay$$=$req$$.query.tu_ngay;let $den_ngay$$=$req$$.query.den_ngay;if(!$invoices_tu_ngay$$||
|
|
102
|
+
!$den_ngay$$)return $next$$("C\u1ea7n cung c\u1ea5p \u0111i\u1ec1u ki\u1ec7n tu_ngay,den_ngay");const $id_app$$=$req$$.user.current_id_app,$app$$=await App.findOne({_id:$id_app$$});if(!$app$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");const $voucher_options$$=(await global.getModel("options").findOne({id_app:$id_app$$,id_func:$contr$$.name},{option:1}).lean()||{}).option||{};if(!$voucher_options$$.ma_kho)return $next$$("B\u1ea1n c\u1ea7n c\u1eadp nh\u1eadt tu\u1ef3 ch\u1ecdn m\u00e3 kho m\u1eb7c \u0111\u1ecbnh trong tu\u1ef3 ch\u1ecdn c\u1ee7a ch\u1ee9ng t\u1eeb");
|
|
103
|
+
if(!$voucher_options$$.tk_no)return $next$$("B\u1ea1n c\u1ea7n c\u1eadp nh\u1eadt tu\u1ef3 ch\u1ecdn t\u00e0i kho\u1ea3n n\u1ee3 m\u1eb7c \u0111\u1ecbnh trong tu\u1ef3 ch\u1ecdn c\u1ee7a ch\u1ee9ng t\u1eeb");if(!$voucher_options$$.tk_vt)return $next$$("B\u1ea1n c\u1ea7n c\u1eadp nh\u1eadt tu\u1ef3 ch\u1ecdn t\u00e0i v\u1eadt t\u01b0 m\u1eb7c \u0111\u1ecbnh trong tu\u1ef3 ch\u1ecdn c\u1ee7a ch\u1ee9ng t\u1eeb");if(!$voucher_options$$.tk_gv)return $next$$("B\u1ea1n c\u1ea7n c\u1eadp nh\u1eadt tu\u1ef3 ch\u1ecdn t\u00e0i kho\u1ea3n gi\u00e1 v\u1ed1n m\u1eb7c \u0111\u1ecbnh trong tu\u1ef3 ch\u1ecdn c\u1ee7a ch\u1ee9ng t\u1eeb");
|
|
104
|
+
if(!$voucher_options$$.tk_dt)return $next$$("B\u1ea1n c\u1ea7n c\u1eadp nh\u1eadt tu\u1ef3 ch\u1ecdn t\u00e0i kho\u1ea3n doanh thu m\u1eb7c \u0111\u1ecbnh trong tu\u1ef3 ch\u1ecdn c\u1ee7a ch\u1ee9ng t\u1eeb");try{$invoices_tu_ngay$$=new Date($invoices_tu_ngay$$);$den_ngay$$=new Date($den_ngay$$);let $invoices_vnpt$$=await utils.getInvoices($app$$,{tu_ngay:$invoices_tu_ngay$$,den_ngay:$den_ngay$$});$invoices_tu_ngay$$=[];for(let $ivn$$ of $invoices_vnpt$$)await model.findOne({id_app:$id_app$$,id_invoice:$ivn$$.id_invoice}).lean()||
|
|
105
|
+
($ivn$$.ma_kh=$ivn$$.ma_kh||$ivn$$.ten_kh.replace(/[^\w\s]/gi,"").split(" ").join("").toUpperCase().substring(0,32),$ivn$$.trang_thai="5",$invoices_tu_ngay$$.push($ivn$$));let $khs$$=await $invoices_tu_ngay$$.asyncGroupBy(["ma_kh","ten_kh","dia_chi","ma_so_thue","dien_thoai"],[]);for(let $kh$$ of $khs$$)$kh$$.id_app=$id_app$$,$kh$$.ma_kh||($kh$$.ma_kh=$kh$$.ten_kh.replace(/[^\w\s]/gi,"").split(" ").join("").toUpperCase()),await global.getModel("customer").asyncCreateCustomer($kh$$);let $vts$$=await $invoices_tu_ngay$$.map($i$$=>
|
|
106
|
+
$i$$.details||[]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]).asyncGroupBy(["ma_vt","ten_vt","ma_dvt"],[]),$dvts$$=await $vts$$.asyncGroupBy(["ma_dvt"],[]);for(let $dvt$$ of $dvts$$)$dvt$$.id_app=$id_app$$,$dvt$$.ten_dvt=$dvt$$.ma_dvt,$dvt$$.status=!0,$dvt$$.user_created=$req$$.user.email,await global.getModel("dmdvt").findOne({ma_dvt:$dvt$$.ma_dvt,id_app:$dvt$$.id_app}).lean()||(Logger.info("create dvt",$dvt$$),await global.getModel("dmdvt").create($dvt$$));for(let $vt$$ of $vts$$)$vt$$.id_app=$id_app$$,
|
|
107
|
+
$vt$$.status=!0,$vt$$.user_created=$req$$.user.email,$vt$$.tk_vt=$voucher_options$$.tk_vt,$vt$$.tk_dt=$voucher_options$$.tk_dt,$vt$$.tk_gv=$voucher_options$$.tk_gv,await global.getModel("dmvt").findOne({ma_vt:$vt$$.ma_vt,id_app:$vt$$.id_app}).lean()||(Logger.info("create product",$vt$$),await global.getModel("dmvt").create($vt$$),await global.getModel("dmqddvt").create({id_app:$id_app$$,status:!0,ma_vt:$vt$$.ma_vt,ma_dvt:$vt$$.ma_dvt,tu:1,ma:1}));$contr$$.import($req$$.user,$id_app$$,$invoices_tu_ngay$$,
|
|
108
|
+
($e$$,$rs$$)=>$next$$($e$$,$rs$$))}catch($e$$){return $next$$($e$$.error||$e$$.messate||$e$$)}},{method:"GET",action_code:"add"})};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const PostBook=require("../../libs/post-book"),PostSocai=require("../../libs/post-socai"),PostSokho=require("../../libs/post-sokho"),utils=require("../../libs/utils"),Sokhott=global.getModel("sokhott"),Vatra=global.getModel("vatra"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),customer=global.getModel("customer"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),model=global.getModel("hd3"),controller=require("../../controllers/controller"),
|
|
2
|
+
async=require("async"),ma_ct="HD3";
|
|
3
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,check_stock:!1,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();$contr_router$$.post=async function($obj$$,$fn$$){$fn$$||=function(){};$obj$$.details.forEach($detail$$=>{$detail$$.tien_ct_nt||($detail$$.gia_ban_ct_nt=$detail$$.gia_ban_nt,$detail$$.tien_ct_nt=$detail$$.tien_nt,$detail$$.tien_ct=$detail$$.tien,$detail$$.tien_ck_nt=0,$detail$$.tien_ck=0,$detail$$.thue_suat=
|
|
4
|
+
$detail$$.thue_suat||0,$detail$$.tien_thue_nt=$detail$$.tien_thue_nt||0,$detail$$.gia_ban_nt=$detail$$.gia_ban_ct_nt*(1+$detail$$.thue_suat/100))});let $product_details$$=[...$obj$$.details].map($detail$$=>$detail$$.combo&&$detail$$.combo.length>0?$detail$$.combo.map($item_combo$$=>{$item_combo$$=$item_combo$$.toObject?$item_combo$$.toObject():{...$item_combo$$};$item_combo$$.ma_kho=$detail$$.ma_kho;$item_combo$$.pn_gia_tb=$detail$$.pn_gia_tb;return $item_combo$$}):[$detail$$]).reduce(($a$$,$b$$)=>
|
|
5
|
+
$a$$.concat($b$$),[]);await $product_details$$.filter($d$$=>!$d$$.ma_dvt).asyncJoinModel2($obj$$.id_app,"dmvt",{where:"ma_vt",fields:"ma_dvt"});let $details_thue$$=$obj$$.details.map($detail$$=>({...$detail$$,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0,ma_thue:$detail$$.ma_thue||$obj$$.ma_thue,tien_thue_nt:$detail$$.tien_thue_nt||0,tien_thue:$detail$$.tien_thue||0})).filter($d$$=>$d$$.ma_thue);await $details_thue$$.filter($r$$=>!$r$$.tk_thue_co&&$r$$.ma_thue).asyncJoinModel2($obj$$.id_app,
|
|
6
|
+
"vat",{where:"ma_thue",fields:["tk_thue_co"]});async.series({post_tdttno:$callback$$=>{setImmediate(async()=>{var $hds_tdttno_tt$$=[...(new Set(($obj$$.details||[]).filter($d$$=>$d$$.id_hd).map($d$$=>$d$$.id_hd)))];if($hds_tdttno_tt$$.length==0)return $callback$$();$hds_tdttno_tt$$=(await global.getModel("tdttno").getBalance({id_app:$obj$$.id_app,id_hd:{$in:$hds_tdttno_tt$$}})).map($invoice$$=>{let $t_invoice$$={sel:!1,id_tdtt:$invoice$$._id,line:$invoice$$.line,id_hd:$invoice$$.id_ct,so_hd:$invoice$$.so_hd||
|
|
7
|
+
$invoice$$.so_ct,ngay_hd:$invoice$$.ngay_hd||$invoice$$.ngay_ct,tien_hd_nt:$invoice$$.tien_nt};$t_invoice$$.ma_nt_hd=$invoice$$.ma_nt;$t_invoice$$.ty_gia_hd=$invoice$$.ty_gia;$t_invoice$$.ma_kh=$invoice$$.ma_kh;$t_invoice$$.dien_giai=$invoice$$.dien_giai;$t_invoice$$.tk_co=$invoice$$.tk_no;$t_invoice$$.da_thanh_toan_nt=$invoice$$.da_thanh_toan_nt;$t_invoice$$.da_thanh_toan=$invoice$$.da_thanh_toan;$t_invoice$$.con_lai_nt=$invoice$$.con_lai_nt;$t_invoice$$.con_lai=$invoice$$.con_lai;$t_invoice$$.tien_nt=
|
|
8
|
+
$obj$$.details.filter($d$$=>$d$$.id_hd===$t_invoice$$.id_hd).map($d$$=>$d$$.tien_nt||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$t_invoice$$.tien=$t_invoice$$.tien_nt*$obj$$.ty_gia;$t_invoice$$.thanh_toan_qd=$t_invoice$$.tien/$t_invoice$$.ty_gia_hd;return $t_invoice$$});(new PostBook($obj$$,$hds_tdttno_tt$$,global.getModel("tdttno_tt"),function($tdttno$$,$callback$$){$callback$$($tdttno$$)})).run(function($e$$,$details$$){if($e$$)return $callback$$($e$$);async.map($details$$,($detail$$,$callback$$)=>{$detail$$.con_lai_nt<=
|
|
9
|
+
$detail$$.thanh_toan_qd?global.getModel("tdttno").updateOne({_id:$detail$$.id_tdtt.toString()},{tat_toan:!0},($error$$,$result$$)=>{$callback$$($error$$,$result$$)}):$callback$$(null,$detail$$)},($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)})})})},post_sokho:function($callback$$){(new PostSokho($obj$$,$product_details$$,async function($detail$$,$callback$$){$detail$$.nxt=1;$detail$$.tk_co=$obj$$.tk_co;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_sokhott:function($callback$$){(new PostBook($obj$$,
|
|
10
|
+
$product_details$$,Sokhott,async function($detail$$,$callback$$){$detail$$.nxt=1;$detail$$.tk_co=$obj$$.tk_co;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_vatra:function($callback$$){(async()=>{$obj$$.ngay_hd?$details_thue$$.length==0&&$obj$$.so_hd&&$obj$$.ngay_hd&&$obj$$.ma_thue&&$obj$$.t_thue_nt?(new PostBook($obj$$,[{...$obj$$}],Vatra,function($obj$$,$callback$$){$obj$$.tk_du_thue=$obj$$.tk_co;$obj$$.t_tien_nt=-($obj$$.details.csum("tien_ct_nt")-$obj$$.details.csum("tien_ck_nt"));
|
|
11
|
+
$obj$$.t_tien=-($obj$$.details.csum("tien_ct")-$obj$$.details.csum("tien_ck"));$obj$$.t_thue_nt=0-$obj$$.t_thue_nt;$obj$$.t_thue=0-$obj$$.t_thue;$obj$$.ten_vt||($obj$$.ten_vt=$obj$$.dien_giai);$callback$$($obj$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):$details_thue$$.asyncGroupBy(["ma_thue","thue_suat","ten_vt_vat","tk_thue_co"],"tien_ct_nt tien_ct tien_ck_nt tien_ck tien_thue tien_thue_nt tien_nt tien".split(" ")).then($ds$$=>{if($ds$$.length==1){let $tien_thue_nt$$=$ds$$.map($d$$=>
|
|
12
|
+
$d$$.tien_thue_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0),$tien_thue$$=$ds$$.map($d$$=>$d$$.tien_thue).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$tien_thue_nt$$==0&&$tien_thue$$==0&&($tien_thue_nt$$=$obj$$.t_thue_nt||0,$tien_thue$$=$obj$$.t_thue||0);$ds$$[0].tien_thue_nt=$tien_thue_nt$$;$ds$$[0].tien_thue=$tien_thue$$}(new PostBook($obj$$,$ds$$,Vatra,function($detail$$,$callback$$){try{$detail$$.tk_du_thue=$obj$$.tk_co,$detail$$.t_tien_nt=-($detail$$.tien_ct_nt-$detail$$.tien_ck_nt),$detail$$.t_tien=-($detail$$.tien_ct-
|
|
13
|
+
$detail$$.tien_ck),$detail$$.t_thue_nt=0-$detail$$.tien_thue_nt,$detail$$.t_thue=0-$detail$$.tien_thue,$detail$$.ten_vt=$detail$$.ten_vt_vat||$obj$$.ten_vt||$obj$$.dien_giai}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})}):$callback$$()})()},post_socai:function($callback$$){(async()=>{const $details_sc$$=[];if($details_thue$$.length===0&&$obj$$.t_thue_nt&&$obj$$.tk_thue_co){const $o$$={...$obj$$};$o$$.tk_co=$obj$$.tk_co;$o$$.tk_no=
|
|
14
|
+
$obj$$.tk_thue_co;$o$$.tien_nt=Math.abs($obj$$.t_thue_nt);$o$$.tien=Math.abs($obj$$.t_thue);$o$$.dien_giai_thue&&($o$$.dien_giai=$o$$.dien_giai_thue);$details_sc$$.push($o$$)}else $details_thue$$.forEach($v_vatra$$=>{$v_vatra$$={...$v_vatra$$};$v_vatra$$.tk_co=$obj$$.tk_co;$v_vatra$$.tk_no=$v_vatra$$.tk_thue_co;$v_vatra$$.tien_nt=$v_vatra$$.tien_thue_nt;$v_vatra$$.tien=$v_vatra$$.tien_thue;$details_sc$$.push($v_vatra$$)});$obj$$.details.forEach(function($d$jscomp$10_detail$$){$d$jscomp$10_detail$$=
|
|
15
|
+
{...$d$jscomp$10_detail$$};$d$jscomp$10_detail$$.tien_ct_nt||($d$jscomp$10_detail$$.tien_ct_nt=$d$jscomp$10_detail$$.tien_nt,$d$jscomp$10_detail$$.tien_ct=$d$jscomp$10_detail$$.tien);$d$jscomp$10_detail$$.tk_no=$d$jscomp$10_detail$$.tk_tl||"52131";$d$jscomp$10_detail$$.ma_kh||($d$jscomp$10_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$10_detail$$.tk_co=$obj$$.tk_co||"1111";$d$jscomp$10_detail$$.tien_nt=$d$jscomp$10_detail$$.tien_ct_nt-($d$jscomp$10_detail$$.tien_ck_nt||0);$d$jscomp$10_detail$$.tien=$d$jscomp$10_detail$$.tien_ct-
|
|
16
|
+
($d$jscomp$10_detail$$.tien_ck||0);$details_sc$$.push($d$jscomp$10_detail$$)});[...$product_details$$].forEach(function($d$jscomp$11_detail$$){$d$jscomp$11_detail$$={...$d$jscomp$11_detail$$};$d$jscomp$11_detail$$.tk_no=$d$jscomp$11_detail$$.tk_vt||"1561";$d$jscomp$11_detail$$.ma_kh||($d$jscomp$11_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$11_detail$$.tk_co=$d$jscomp$11_detail$$.tk_gv||"6321";$d$jscomp$11_detail$$.tien_nt=$d$jscomp$11_detail$$.tien_nhap_nt;$d$jscomp$11_detail$$.tien=$d$jscomp$11_detail$$.tien_nhap;
|
|
17
|
+
$details_sc$$.push($d$jscomp$11_detail$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv&&$r$$.ma_ctv).asyncGroupBy(["ma_ctv","tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_cp_ctv;$tt$$.tk_no=$r$$.tk_cn_ctv;$tt$$.ma_kh=$r$$.ma_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv2&&$r$$.ma_ctv2).asyncGroupBy(["ma_ctv2",
|
|
18
|
+
"tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv2"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_cp_ctv;$tt$$.tk_no=$r$$.tk_cn_ctv;$tt$$.ma_kh=$r$$.ma_ctv2;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv2;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong&&$r$$.ma_kh_hoa_hong).asyncGroupBy(["ma_kh_hoa_hong","tk_no_hoa_hong","tk_co_hoa_hong"],["tien_hoa_hong"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong;$tt$$.tk_no=
|
|
19
|
+
$r$$.tk_co_hoa_hong;$tt$$.ma_kh=$r$$.ma_kh_hoa_hong;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_gt&&$r$$.ma_kh_hoa_hong_gt).asyncGroupBy(["ma_kh_hoa_hong_gt","tk_no_hoa_hong_gt","tk_co_hoa_hong_gt"],["tien_hoa_hong_gt"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong_gt;$tt$$.tk_no=$r$$.tk_co_hoa_hong_gt;
|
|
20
|
+
$tt$$.ma_kh=$r$$.ma_kh_hoa_hong_gt;$tt$$.tien_nt=$r$$.tien_hoa_hong_gt;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ql&&$r$$.ma_kh_hoa_hong_ql).asyncGroupBy(["ma_kh_hoa_hong_ql","tk_no_hoa_hong_ql","tk_co_hoa_hong_ql"],["tien_hoa_hong_ql"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong_ql;$tt$$.tk_no=$r$$.tk_co_hoa_hong_ql;$tt$$.ma_kh=$r$$.ma_kh_hoa_hong_ql;
|
|
21
|
+
$tt$$.tien_nt=$r$$.tien_hoa_hong_ql;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_kho&&$r$$.ma_kh_hoa_hong_kho).asyncGroupBy(["ma_kh_hoa_hong_kho","tk_no_hoa_hong_kho","tk_co_hoa_hong_kho"],["tien_hoa_hong_kho"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong_kho;$tt$$.tk_no=$r$$.tk_co_hoa_hong_kho;$tt$$.ma_kh=$r$$.ma_kh_hoa_hong_kho;$tt$$.tien_nt=
|
|
22
|
+
$r$$.tien_hoa_hong_kho;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(new PostSocai($obj$$,$details_sc$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})()}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};const $valid$$=function($f_tien_nt_i_user$$,$obj$$,$next$$){for($f_tien_nt_i_user$$=0;$f_tien_nt_i_user$$<$obj$$.details.length;$f_tien_nt_i_user$$++){const $detail$$=$obj$$.details[$f_tien_nt_i_user$$];$detail$$.tien_ct_nt||
|
|
23
|
+
($detail$$.gia_ban_ct_nt=$detail$$.gia_ban_nt,$detail$$.tien_ct_nt=$detail$$.tien_nt,$detail$$.tien_ck_nt=0,$detail$$.thue_suat=$detail$$.thue_suat||0,$detail$$.tien_thue_nt=$detail$$.tien_thue_nt||0,$detail$$.gia_ban_nt=$detail$$.gia_ban_ct_nt*(1+$detail$$.thue_suat/100));$detail$$.tien_ck_nt=$detail$$.tien_ck_nt||0;$detail$$.tien_thue_nt=$detail$$.tien_thue_nt||0;$detail$$.tien_nt=$detail$$.tien_ct_nt+$detail$$.tien_thue_nt-$detail$$.tien_ck_nt;$detail$$.line=$f_tien_nt_i_user$$;$detail$$.tien_ct=
|
|
24
|
+
utils.round($detail$$.tien_ct_nt*$obj$$.ty_gia,0);$detail$$.tien=utils.round($detail$$.tien_nt*$obj$$.ty_gia,0);$detail$$.tien_ck=utils.round($detail$$.tien_ck_nt*$obj$$.ty_gia,0);$detail$$.tien_thue=utils.round($detail$$.tien_thue_nt*$obj$$.ty_gia,0);$detail$$.tien_nhap=$detail$$.tien_nhap_nt}$obj$$.details.find($d$$=>$d$$.tien_thue_nt)?($obj$$.t_thue_nt=$obj$$.details.csum("tien_thue_nt"),$obj$$.t_thue=utils.round($obj$$.t_thue_nt*($obj$$.ty_gia||1),0)):$obj$$.thue_suat&&!$obj$$.t_thue_nt&&($f_tien_nt_i_user$$=
|
|
25
|
+
$obj$$.ma_nt==="VND"?0:2,$obj$$.t_thue_nt=utils.round(($obj$$.details.csum("tien_ct_nt")-$obj$$.details.csum("tien_ck_nt"))*$obj$$.thue_suat/100,$f_tien_nt_i_user$$),$obj$$.t_thue=utils.round($obj$$.t_thue_nt*($obj$$.ty_gia||1),0));$next$$(null,$obj$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,async function($error$$){if($error$$)return $next$$($error$$);await $obj$$.details.asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",
|
|
26
|
+
fields:["combo"]});$obj$$.details.filter($d$$=>$d$$.combo).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item_combo$$=>{$item_combo$$=$item_combo$$.toObject?$item_combo$$.toObject():{...$item_combo$$};$item_combo$$.sl_nhap_1_combo=$item_combo$$.sl_xuat||0;delete $item_combo$$.sl_xuat;delete $item_combo$$.tien_xuat;delete $item_combo$$.tien_xuat_nt;delete $item_combo$$.px_gia_dd;$item_combo$$.sl_nhap=$item_combo$$.sl_nhap_1_combo*$detail$$.sl_nhap;$item_combo$$.tien_nhap=$item_combo$$.tien_nhap_nt=
|
|
27
|
+
$item_combo$$.sl_nhap*($item_combo$$.gia_von_nt||0);$item_combo$$.tien=$item_combo$$.tien_nt=$item_combo$$.sl_nhap*($item_combo$$.gia_ban_nt||0);$item_combo$$.tien_ck=$item_combo$$.tien_ck_nt=$item_combo$$.sl_nhap*($item_combo$$.tien_ck_nt||0);return $item_combo$$})});$next$$(null,$obj$$)})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){$data$$.details=$data$$.details||$obj$$.details;$valid$$($user$$,$data$$,async function($error$$){if($error$$)return $next$$($error$$);await $data$$.details.asyncJoinModel2($obj$$.id_app,
|
|
28
|
+
dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.combo&&$item$$.combo.length!=0?$ref$$.combo&&$ref$$.combo.forEach($c$$=>{let $cb$$=$item$$.combo.find($ci$$=>$ci$$.ma_vt===$c$$.ma_vt);$cb$$?$cb$$.sl_nhap_1_combo=$c$$.sl_xuat||0:$item$$.combo.push($c$$)}):$item$$.combo=$ref$$.combo}});$data$$.details.filter($d$$=>$d$$.combo).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item_combo$$=>{$item_combo$$=$item_combo$$.toObject?$item_combo$$.toObject():{...$item_combo$$};$item_combo$$.sl_nhap_1_combo==
|
|
29
|
+
void 0&&($item_combo$$.sl_nhap_1_combo=$item_combo$$.sl_xuat||0);delete $item_combo$$.sl_xuat;delete $item_combo$$.tien_xuat;delete $item_combo$$.tien_xuat_nt;delete $item_combo$$.px_gia_dd;$item_combo$$.sl_nhap=$item_combo$$.sl_nhap_1_combo*$detail$$.sl_nhap;$item_combo$$.tien_nhap=$item_combo$$.tien_nhap_nt=$item_combo$$.sl_nhap*($item_combo$$.gia_von_nt||0);$item_combo$$.tien=$item_combo$$.tien_nt=$item_combo$$.sl_nhap*($item_combo$$.gia_ban_nt||0);$item_combo$$.tien_ck=$item_combo$$.tien_ck_nt=
|
|
30
|
+
$item_combo$$.sl_nhap*($item_combo$$.tien_ck_nt||0);return $item_combo$$})});$next$$(null,$data$$,$obj$$)})};$contr_router$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.parallel({kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:[{name:"ten_kh",value:"ten_kh"}]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.details||($r$$.details=[]);$r$$.details.forEach($d$$=>
|
|
31
|
+
{if(!$d$$.tien_ct_nt){$d$$.gia_ban_ct_nt=$d$$.gia_ban_nt;$d$$.tien_ct_nt=$d$$.tien_nt;$d$$.tien_ck_nt=$d$$.tien_ck_nt||0;let $thue_suat$$=$d$$.thue_suat||0;$d$$.tien_thue_nt=$d$$.tien_thue_nt||0;$d$$.gia_ban_nt=$d$$.gia_ban_ct_nt*(1+$thue_suat$$/100);$d$$.tien_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt+$d$$.tien_thue_nt}});$r$$.t_thue_ra=$r$$.details.csum("tien_thue");$r$$.t_thue_ra_nt=$r$$.details.csum("tien_thue_nt");$r$$.t_sl=$r$$.details.csum("sl_nhap");$r$$.t_ck=$r$$.details.csum("tien_ck");$r$$.t_ck_nt=
|
|
32
|
+
$r$$.details.csum("tien_ck_nt");$r$$.t_tien=$r$$.details.csum("tien");$r$$.t_tien_nt=$r$$.details.csum("tien_nt");$r$$.t_tien_ct=$r$$.details.csum("tien_ct");$r$$.t_tien_ct_nt=$r$$.details.csum("tien_ct_nt");$r$$.t_tt=$r$$.t_tien_ct-$r$$.t_ck+$r$$.t_thue_ra;$r$$.t_tt_nt=$r$$.t_tien_ct_nt-$r$$.t_ck_nt+$r$$.t_thue_ra_nt;$r$$.t_tien_nhap=$r$$.details.csum("tien_nhap");$r$$.t_tien_nhap_nt=$r$$.details.csum("tien_nhap_nt")});$callback$$()},details_hd2:function($callback$$){async.map($items$$,function($r$$,
|
|
33
|
+
$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.id_hd&&!$d$$.so_ct_hd).joinModel2($id_app$$,"hd2",[{where:{id_hd:"_id"},fields:[{name:"so_ct_hd",value:"so_ct"},{name:"ngay_ct_hd",value:"ngay_ct"},{name:"ma_ct_hd",value:"ma_ct"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_pbl:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.id_hd&&!$d$$.so_ct_hd).joinModel2($id_app$$,"pbl",[{where:{id_hd:"_id"},fields:[{name:"so_ct_hd",
|
|
34
|
+
value:"so_ct"},{name:"ngay_ct_hd",value:"ngay_ct"},{name:"ma_ct_hd",value:"ma_ct"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_so1:function($callback$$){async.map($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.id_hd&&!$d$$.so_ct_hd).joinModel2($id_app$$,"so1",[{where:{id_hd:"_id"},fields:[{name:"so_ct_hd",value:"so_ct"},{name:"ngay_ct_hd",value:"ngay_ct"},{name:"ma_ct_hd",value:"ma_ct"}]}],function(){$callback1$$()})},function(){$callback$$()})},
|
|
35
|
+
details_vt:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).joinModel2($id_app$$,dmvt,[{where:"ma_vt",fields:["ten_vt","ma_tt1_yn","ma_tt2_yn","ma_tt3_yn","ma_lo_yn"]}],function(){$callback1$$()})},function(){$callback$$()})},details_tt1:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.ma_tt1).joinModel2($id_app$$,"dmtt",[{where:{ma_vt:"ma_vt",ma_tt1:"ma_tt"},setFields:($item$$,$ref$$)=>
|
|
36
|
+
{$item$$.thuoc_tinh=$ref$$}}],function(){$callback1$$()})},function(){$callback$$()})},details_kho:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kho).joinModel($id_app$$,dmkho,[{akey:"ma_kho",bkey:"ma_kho",fields:[{name:"ten_kho",value:"ten_kho"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>
|
|
37
|
+
$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapLimit($items$$,20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapLimit($items$$,
|
|
38
|
+
20,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel($id_app$$,dmphi,[{akey:"ma_phi",bkey:"ma_phi",fields:[{name:"ten_phi",value:"ten_phi"}]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const PostBook=require("../../libs/post-book"),PostSocai=require("../../libs/post-socai"),Tdttco=global.getModel("tdttco"),Tdttco_tt=global.getModel("tdttco_tt"),Vatvao=global.getModel("vatvao"),dmvt=global.getModel("dmvt"),dmcpmh=global.getModel("dmcpmh"),account=global.getModel("account"),customer=global.getModel("customer"),dmdt=global.getModel("dmdt"),dmnv=global.getModel("dmnv"),model=global.getModel("hd4"),controller=require("../../controllers/controller"),async=require("async"),ma_ct="HD4";
|
|
2
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,kiem_tra_han_muc_cong_no:!0,check_stock:!1,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();$contr_router$$.post=function($obj$$,$fn$$,$_options$$={}){$fn$$||=function(){};async.series({post_vatvao:function($callback$$){(new PostBook($obj$$,$obj$$.vatvaos,Vatvao,($detail$$,$callback$$)=>{$detail$$={...$detail$$};$detail$$.ten_vt=$detail$$.ten_vt||$obj$$.dien_giai||($obj$$.details||
|
|
3
|
+
[]).map($d$$=>$d$$.ten_vt).join(", ");$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_socai:function($callback$$){const $details_sc$$=[];$obj$$.vatvaos.forEach(function($v_vatvao$$){$v_vatvao$$={...$v_vatvao$$};$v_vatvao$$.tk_no=$v_vatvao$$.tk_thue_no;$v_vatvao$$.tk_co=$v_vatvao$$.tk_du_thue;$v_vatvao$$.tien_nt=$v_vatvao$$.t_thue_nt;$v_vatvao$$.tien=$v_vatvao$$.t_thue;$details_sc$$.push($v_vatvao$$)});$obj$$.details.forEach(function($d$$){($d$$.details_cp||[]).forEach($cp$$=>
|
|
4
|
+
{const $detail$$={...$d$$};$detail$$.ma_kh=$obj$$.ma_kh;$detail$$.tk_co=$obj$$.tk_co;$detail$$.tk_no=$cp$$.tk_no;$detail$$.tien_nt=$cp$$.tien_pb||0;$detail$$.tien=($cp$$.tien_pb||0)*$obj$$.ty_gia;$details_sc$$.push($detail$$)})});(new PostSocai($obj$$,$details_sc$$,void 0,void 0,$_options$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_tdttco:function($callback$$){account.findOne({tk:$obj$$.tk_co,id_app:$obj$$.id_app},{tk_cn:1},function($error$$,$tk$$){if($error$$)return $callback$$($error$$);
|
|
5
|
+
$tk$$&&$tk$$.tk_cn===!0?(new PostBook($obj$$,[{...$obj$$}],Tdttco,function($obj$$,$callback$$){$obj$$.so_hd=$obj$$.so_ct;$obj$$.ngay_hd=$obj$$.ngay_ct;$obj$$.tien_nt=$obj$$.details.csum("tien_phi_nt")+($obj$$.vatvaos||[]).csum("t_thue_nt");$obj$$.tien=$obj$$.details.csum("tien_phi")+($obj$$.vatvaos||[]).csum("t_thue");$callback$$($obj$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):Tdttco.deleteMany({id_ct:$obj$$._id},function(){$callback$$($error$$)})})}},function($e$$,$rs$$){$fn$$($e$$,
|
|
6
|
+
$rs$$)})};const $valid$$=function($i_i$jscomp$1_i$$,$obj$$,$next$$){for($i_i$jscomp$1_i$$=0;$i_i$jscomp$1_i$$<$obj$$.details.length;$i_i$jscomp$1_i$$++){var $ctcpbh_detail$jscomp$2_vatvao$$=$obj$$.details[$i_i$jscomp$1_i$$];$ctcpbh_detail$jscomp$2_vatvao$$.line=$i_i$jscomp$1_i$$;$obj$$.ma_nt=="VND"&&($ctcpbh_detail$jscomp$2_vatvao$$.tien_phi=$ctcpbh_detail$jscomp$2_vatvao$$.tien_phi_nt)}if($obj$$.vatvaos)for($i_i$jscomp$1_i$$=0;$i_i$jscomp$1_i$$<$obj$$.vatvaos.length;$i_i$jscomp$1_i$$++)$ctcpbh_detail$jscomp$2_vatvao$$=
|
|
7
|
+
$obj$$.vatvaos[$i_i$jscomp$1_i$$],$ctcpbh_detail$jscomp$2_vatvao$$.line=$i_i$jscomp$1_i$$,$obj$$.ma_nt=="VND"&&($ctcpbh_detail$jscomp$2_vatvao$$.t_thue=$ctcpbh_detail$jscomp$2_vatvao$$.t_thue_nt);if($obj$$.ctcpbhs)for($i_i$jscomp$1_i$$=0;$i_i$jscomp$1_i$$<$obj$$.ctcpbhs.length;$i_i$jscomp$1_i$$++)$ctcpbh_detail$jscomp$2_vatvao$$=$obj$$.ctcpbhs[$i_i$jscomp$1_i$$],$ctcpbh_detail$jscomp$2_vatvao$$.line=$i_i$jscomp$1_i$$,$obj$$.ma_nt=="VND"&&($ctcpbh_detail$jscomp$2_vatvao$$.tien_cp=$ctcpbh_detail$jscomp$2_vatvao$$.tien_cp_nt);
|
|
8
|
+
$next$$(null,$obj$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$obj$$)})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){Tdttco_tt.find({id_hd:$obj$$._id},function($error$$,$results$$){if($error$$)return $next$$($error$$);$results$$&&$results$$.length>0?$next$$("L\u1ed7i: Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt ch\u1ee9ng t\u1eeb n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n"):
|
|
9
|
+
$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})})};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){Tdttco_tt.find({id_hd:$obj$$._id},function($error$$,$results$$){if($error$$)return $next$$($error$$);$results$$&&$results$$.length>0?$next$$("L\u1ed7i: Kh\u00f4ng th\u1ec3 x\u00f3a ch\u1ee9ng t\u1eeb n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n"):$next$$(null,$obj$$)})};$contr_router$$.view=function($user$$,$items$$,
|
|
10
|
+
$fn$$){let $id_app$$=$user$$.current_id_app;async.series({kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel($id_app$$,customer,[{akey:"ma_kh",bkey:"ma_kh",fields:[{name:"ten_kh",value:"ten_kh"}]}],function(){$callback$$()})},dmdt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,{where:"ma_dt",fields:"ten_dt"},function(){$callback$$()})},dmnv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_nv).joinModel2($id_app$$,dmnv,{where:"ma_nv",
|
|
11
|
+
fields:"ten_nv"},function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.t_cp=0;$r$$.t_cp_nt=0;$r$$.t_thue_vao=0;$r$$.t_thue_vao_nt=0;$r$$.details&&($r$$.t_sl=$r$$.details.csum("sl_xuat"),$r$$.t_cp=$r$$.details.csum("tien_phi"),$r$$.t_cp_nt=$r$$.details.csum("tien_phi_nt"));$r$$.vatvaos&&($r$$.t_thue_vao=$r$$.vatvaos.csum("t_thue"),$r$$.t_thue_vao_nt=$r$$.vatvaos.csum("t_thue_nt"));$r$$.ctcpbhs&&($r$$.t_cp_cpb_nt=$r$$.ctcpbhs.csum("tien_cp_nt"),$r$$.t_cp_cpb=
|
|
12
|
+
$r$$.ctcpbhs.csum("tien_cp"));$r$$.t_tt=$r$$.t_cp+$r$$.t_thue_vao;$r$$.t_tt_nt=$r$$.t_cp_nt+$r$$.t_thue_vao_nt});$callback$$()},details_ct:function($callback$$){async.each($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.id_hd).joinModel2($id_app$$,"hd2",[{where:{id_hd:"_id"},fields:[{so_hd:"so_ct"},{ngay_hd:"ngay_ct"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_vt:function($callback$$){async.each($items$$,function($r$$,$callback1$$){($r$$.details||
|
|
13
|
+
[]).filter($item$$=>$item$$.ma_vt).joinModel2($id_app$$,dmvt,[{where:"ma_vt",fields:["ten_vt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_cpbh:function($callback$$){async.each($items$$,function($ctcpbhs_r$$,$callback1$$){($ctcpbhs_r$$=$ctcpbhs_r$$.ctcpbhs)?$ctcpbhs_r$$.filter($item$$=>$item$$.ma_cp).joinModel2($id_app$$,dmcpmh,[{where:"ma_cp",fields:["ten_cp"]}],function(){$callback1$$()}):$callback1$$()},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const PostBook=require("../../libs/post-book"),PostSocai=require("../../libs/post-socai"),Options=global.getModel("options"),Sokho=global.getModel("sokho"),Sokhott=global.getModel("sokhott"),Vatra=global.getModel("vatra"),dvcs=global.getModel("dvcs"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),customer=global.getModel("customer"),trangthai=global.getModel("trangthai"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),model=global.getModel("hd7"),
|
|
2
|
+
controller=require("../../controllers/controller"),ptthanhtoan=global.getModel("ptthanhtoan"),async=require("async"),ma_ct="HD7";
|
|
3
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,sort:{ngay_ct:-1,so_ct:-1}});$contr_router$$.route();$contr_router$$.post=async function($_obj_details$$,$fn$$){let $obj$$={...$_obj_details$$};$fn$$||=function(){};$_obj_details$$=[...$obj$$.details];await $_obj_details$$.asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["combo"]});let $data_post_kho$$=$_obj_details$$.map($detail$$=>$detail$$.combo&&$detail$$.combo.length>
|
|
4
|
+
0?$detail$$.combo.map($item_combo$$=>{$item_combo$$=$item_combo$$.toObject?$item_combo$$.toObject():{...$item_combo$$};$item_combo$$.sl_nhap_1_combo==void 0&&($item_combo$$.sl_nhap_1_combo=$item_combo$$.sl_xuat||0);delete $item_combo$$.sl_xuat;delete $item_combo$$.tien_xuat;delete $item_combo$$.tien_xuat_nt;delete $item_combo$$.px_gia_dd;$item_combo$$.sl_nhap=$item_combo$$.sl_nhap_1_combo*$detail$$.sl_nhap;$item_combo$$.tien_nhap=$item_combo$$.tien_nhap_nt=$item_combo$$.sl_nhap*($item_combo$$.gia_von_nt||
|
|
5
|
+
0);$item_combo$$.tien_hang=$item_combo$$.tien_hang_nt=$item_combo$$.sl_nhap*($item_combo$$.gia_ban_nt||0);$item_combo$$.tien_ck=$item_combo$$.tien_ck_nt=$item_combo$$.sl_nhap*($item_combo$$.tien_ck_nt||0);$item_combo$$.tien=$item_combo$$.tien_nt=$item_combo$$.tien_hang_nt-($item_combo$$.tien_ck_nt||0);$item_combo$$.ma_kho=$detail$$.ma_kho;return $item_combo$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]),$details_thue$$=$obj$$.details.map($detail$$=>({...$detail$$,thue_suat:($detail$$.ma_thue?
|
|
6
|
+
$detail$$.thue_suat:$obj$$.thue_suat)||0,ma_thue:$detail$$.ma_thue||$obj$$.ma_thue,tien_thue_nt:$detail$$.tien_thue_nt||0,tien_thue:$detail$$.tien_thue||0})).filter($d$$=>$d$$.ma_thue);await $details_thue$$.filter($r$$=>!$r$$.tk_thue_co&&$r$$.ma_thue).asyncJoinModel2($obj$$.id_app,"vat",{where:"ma_thue",fields:["tk_thue_co"]});async.series({post_sokho:function($callback$$){(new PostBook($obj$$,$data_post_kho$$,Sokho,async function($detail$$,$callback$$){$detail$$.nxt=1;$detail$$.tk_co=$obj$$.tk_co;
|
|
7
|
+
$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_sokhott:function($callback$$){(new PostBook($obj$$,$data_post_kho$$,Sokhott,async function($detail$$,$callback$$){$detail$$.nxt=1;$detail$$.tk_co=$obj$$.tk_co;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_vatra:function($callback$$){(async()=>{$obj$$.ngay_hd?$details_thue$$.length==0&&$obj$$.so_hd&&$obj$$.ngay_hd&&$obj$$.ma_thue&&$obj$$.t_thue_nt?(new PostBook($obj$$,[{...$obj$$}],
|
|
8
|
+
Vatra,function($obj$$,$callback$$){$obj$$.tk_du_thue=$obj$$.tk_co;$obj$$.t_tien_nt=-($obj$$.details.csum("tien_hang_ct_nt")-$obj$$.details.csum("tien_ck_nt"));$obj$$.t_tien=-($obj$$.details.csum("tien_hang_ct")-$obj$$.details.csum("tien_ck"));$obj$$.t_thue_nt=0-$obj$$.t_thue_nt;$obj$$.t_thue=0-$obj$$.t_thue;$obj$$.ten_vt||($obj$$.ten_vt=$obj$$.dien_giai);$callback$$($obj$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):$details_thue$$.asyncGroupBy(["ma_thue","thue_suat","ten_vt_vat","tk_thue_co"],
|
|
9
|
+
"tien_hang_ct_nt tien_hang_ct tien_ck_nt tien_ck tien_thue tien_thue_nt tien_nt tien".split(" ")).then($ds$$=>{if($ds$$.length==1){let $tien_thue_nt$$=$ds$$.map($d$$=>$d$$.tien_thue_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0),$tien_thue$$=$ds$$.map($d$$=>$d$$.tien_thue).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$tien_thue_nt$$==0&&$tien_thue$$==0&&($tien_thue_nt$$=$obj$$.t_thue_nt||0,$tien_thue$$=$obj$$.t_thue||0);$ds$$[0].tien_thue_nt=$tien_thue_nt$$;$ds$$[0].tien_thue=$tien_thue$$}(new PostBook($obj$$,$ds$$,Vatra,
|
|
10
|
+
function($detail$$,$callback$$){try{$detail$$.tk_du_thue=$obj$$.tk_co,$detail$$.t_tien_nt=-($detail$$.tien_hang_ct_nt-$detail$$.tien_ck_nt),$detail$$.t_tien=-($detail$$.tien_hang_ct-$detail$$.tien_ck),$detail$$.t_thue_nt=0-$detail$$.tien_thue_nt,$detail$$.t_thue=0-$detail$$.tien_thue,$detail$$.ten_vt=$detail$$.ten_vt_vat||$obj$$.ten_vt||$obj$$.dien_giai}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})}):$callback$$()})()},post_socai:function($callback$$){async.series({options:$callback$$=>
|
|
11
|
+
{Options.findOne({id_app:$obj$$.id_app,id_func:ma_ct.toLowerCase()}).lean().exec(function($error$$,$rs$$){$callback$$(null,$rs$$||{})})},kho:$callback$$=>{dmkho.findOne({id_app:$obj$$.id_app,ma_kho:$obj$$.ma_kho}).lean().exec(($e$$,$kho$$)=>{$callback$$(null,$kho$$||{})})},tk:$callback$$=>{$obj$$.details.joinModel2($obj$$.id_app,dmvt,[{where:"ma_vt",fields:[{tk_vt_def:"tk_vt"},{tk_gv_def:"tk_gv"},{tk_tl_def:"tk_tl"},{tk_dt_def:"tk_dt"}]}],function(){$obj$$.details.forEach($d$$=>{$d$$.toObject&&delete $d$$.toObject});
|
|
12
|
+
$callback$$()})},ptthanhtoan:$callback$$=>{ptthanhtoan.findOne({id_app:$obj$$.id_app,_id:$obj$$.pt_thanh_toan}).lean().exec(($e$$,$pt$$)=>{$callback$$(null,$pt$$||{})})}},async($e$jscomp$7_kho$$,$ma_kh_o_pt$jscomp$1_rs$$)=>{let $option$$=$ma_kh_o_pt$jscomp$1_rs$$.options;$e$jscomp$7_kho$$=$ma_kh_o_pt$jscomp$1_rs$$.kho;$ma_kh_o_pt$jscomp$1_rs$$=$ma_kh_o_pt$jscomp$1_rs$$.ptthanhtoan;$option$$.tk_tien=$ma_kh_o_pt$jscomp$1_rs$$.tk_tien||$e$jscomp$7_kho$$.tk_tien||$option$$.tk_tien;$option$$.tk_cn=$ma_kh_o_pt$jscomp$1_rs$$.tk_cn||
|
|
13
|
+
$e$jscomp$7_kho$$.tk_cn||$option$$.tk_cn;$option$$.tk_dt=$ma_kh_o_pt$jscomp$1_rs$$.tk_dt||$e$jscomp$7_kho$$.tk_dt||$option$$.tk_dt;$option$$.tk_tl=$ma_kh_o_pt$jscomp$1_rs$$.tk_tl||$e$jscomp$7_kho$$.tk_tl||$option$$.tk_tl;$option$$.tk_ck=$ma_kh_o_pt$jscomp$1_rs$$.tk_ck||$e$jscomp$7_kho$$.tk_ck||$option$$.tk_ck;$option$$.tk_gv=$ma_kh_o_pt$jscomp$1_rs$$.tk_gv||$e$jscomp$7_kho$$.tk_gv||$option$$.tk_gv;$option$$.tk_vt=$ma_kh_o_pt$jscomp$1_rs$$.tk_vt||$e$jscomp$7_kho$$.tk_vt||$option$$.tk_vt;if($ma_kh_o_pt$jscomp$1_rs$$=
|
|
14
|
+
$ma_kh_o_pt$jscomp$1_rs$$.ma_kh||$e$jscomp$7_kho$$.ma_kh)$option$$.ma_kh=$ma_kh_o_pt$jscomp$1_rs$$,$option$$.tk_tien=$option$$.tk_cn;const $details_sc$$=[];$details_thue$$.length===0&&$obj$$.t_thue_nt&&$obj$$.tk_thue_co?($ma_kh_o_pt$jscomp$1_rs$$={...$obj$$},$ma_kh_o_pt$jscomp$1_rs$$.tk_co=$obj$$.tk_co||$option$$.tk_tien,$ma_kh_o_pt$jscomp$1_rs$$.tk_no=$obj$$.tk_thue_co,$ma_kh_o_pt$jscomp$1_rs$$.tien_nt=Math.abs($obj$$.t_thue_nt),$ma_kh_o_pt$jscomp$1_rs$$.tien=Math.abs($obj$$.t_thue),$ma_kh_o_pt$jscomp$1_rs$$.dien_giai_thue&&
|
|
15
|
+
($ma_kh_o_pt$jscomp$1_rs$$.dien_giai=$ma_kh_o_pt$jscomp$1_rs$$.dien_giai_thue),$details_sc$$.push($ma_kh_o_pt$jscomp$1_rs$$)):$details_thue$$.forEach($v_vatra$$=>{$v_vatra$$={...$v_vatra$$};$v_vatra$$.tk_co=$obj$$.tk_co||$option$$.tk_tien;$v_vatra$$.tk_no=$v_vatra$$.tk_thue_co;$v_vatra$$.tien_nt=$v_vatra$$.tien_thue_nt;$v_vatra$$.tien=$v_vatra$$.tien_thue;$details_sc$$.push($v_vatra$$)});$obj$$.details.forEach(function($d$jscomp$6_detail$$){$d$jscomp$6_detail$$=Object.assign({},$d$jscomp$6_detail$$);
|
|
16
|
+
$d$jscomp$6_detail$$.tk_no=$option$$.tk_tl||$d$jscomp$6_detail$$.tk_tl_def;$d$jscomp$6_detail$$.ma_kh||($d$jscomp$6_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$6_detail$$.tk_co=$obj$$.tk_co||$option$$.tk_tien;$d$jscomp$6_detail$$.tien_nt=$d$jscomp$6_detail$$.tien_hang_ct_nt-$d$jscomp$6_detail$$.tien_ck_nt;$d$jscomp$6_detail$$.tien=$d$jscomp$6_detail$$.tien_hang_ct-$d$jscomp$6_detail$$.tien_ck;$details_sc$$.push($d$jscomp$6_detail$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv).asyncGroupBy(["ma_ctv",
|
|
17
|
+
"tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_cp_ctv;$tt$$.tk_no=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv;$tt$$.ma_kh=$tt$$.ma_ctv;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong).asyncGroupBy(["ma_kh_hoa_hong","tk_no_hoa_hong","tk_co_hoa_hong"],["tien_hoa_hong"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong;$tt$$.tk_no=$r$$.tk_co_hoa_hong;
|
|
18
|
+
$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$tt$$.ma_kh_hoa_hong;$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_gt).asyncGroupBy(["ma_kh_hoa_hong_gt","tk_no_hoa_hong_gt","tk_co_hoa_hong_gt"],["tien_hoa_hong_gt"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_co=$r$$.tk_no_hoa_hong_gt;$tt$$.tk_no=$r$$.tk_co_hoa_hong_gt;$tt$$.tien_nt=$r$$.tien_hoa_hong_gt;$tt$$.tien=
|
|
19
|
+
$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$tt$$.ma_kh_hoa_hong_gt;$tt$$.check_balance=!1;$tt$$.tk_no&&$tt$$.tk_co&&$tt$$.tien&&$details_sc$$.push($tt$$)});$obj$$.details.forEach(function($d$jscomp$7_detail$$){$d$jscomp$7_detail$$=Object.assign({},$d$jscomp$7_detail$$);$d$jscomp$7_detail$$.tk_no=$option$$.tk_vt||$d$jscomp$7_detail$$.tk_vt_def;$d$jscomp$7_detail$$.ma_kh||($d$jscomp$7_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$7_detail$$.tk_co=$option$$.tk_gv||$d$jscomp$7_detail$$.tk_gv_def;$d$jscomp$7_detail$$.tien_nt=
|
|
20
|
+
$d$jscomp$7_detail$$.tien_nhap_nt;$d$jscomp$7_detail$$.tien=$d$jscomp$7_detail$$.tien_nhap;$details_sc$$.push($d$jscomp$7_detail$$)});$option$$.ma_kh&&$details_sc$$.forEach($d$$=>{$d$$.ma_kh=$option$$.ma_kh});(new PostSocai($obj$$,$details_sc$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};const $valid$$=function($i_user$$,$obj$$,$next$$){for($i_user$$=0;$i_user$$<$obj$$.details.length;$i_user$$++){let $detail$$=$obj$$.details[$i_user$$];$detail$$.line=
|
|
21
|
+
$i_user$$;$detail$$.tien_nt=$detail$$.tien_hang_ct_nt-$detail$$.tien_ck_nt+($detail$$.tien_thue_nt||0);$detail$$.tien=$detail$$.tien_hang-$detail$$.tien_ck+($detail$$.tien_thue||0);$obj$$.ma_nt=="VND"&&($detail$$.tien_hang_ct=$detail$$.tien_hang_ct_nt=Math.roundBy($detail$$.tien_hang_ct_nt||0),$detail$$.tien_hang=$detail$$.tien_hang_nt=Math.roundBy($detail$$.tien_hang_nt||0),$detail$$.tien=$detail$$.tien_nt=Math.roundBy($detail$$.tien_nt||0),$detail$$.tien_ck=$detail$$.tien_ck_nt=Math.roundBy($detail$$.tien_ck_nt||
|
|
22
|
+
0),$detail$$.tien_thue=$detail$$.tien_thue_nt=Math.roundBy($detail$$.tien_thue_nt||0),$detail$$.tien_nhap=$detail$$.tien_nhap_nt=Math.roundBy($detail$$.tien_nhap_nt||0))}$next$$(null,$obj$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$obj$$)})};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);
|
|
23
|
+
$next$$(null,$data$$,$obj$$)})};$contr_router$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.series({dv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dvcs).joinModel($id_app$$,dvcs,[{akey:"ma_dvcs",bkey:"_id",fields:[{name:"ten_dvcs",value:"ten_dvcs"}]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai",
|
|
24
|
+
"color"]}],function(){$callback$$()})},kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel($id_app$$,customer,[{akey:"ma_kh",bkey:"ma_kh",fields:[{name:"ten_kh",value:"ten_kh"}]}],function(){$callback$$()})},dich_vu_giao_hang:function($callback$$){$items$$.filter($item$$=>$item$$.dich_vu_giao_hang).joinModel($id_app$$,customer,[{akey:"dich_vu_giao_hang",bkey:"ma_kh",fields:[{name:"ten_dich_vu_giao_hang",value:"ten_kh"}]}],function(){$callback$$()})},ptthanhtoan:function($callback$$){$items$$.filter($item$$=>
|
|
25
|
+
$item$$.pt_thanh_toan).joinModel2($id_app$$,ptthanhtoan,[{where:{pt_thanh_toan:"_id"},fields:{ten_pt_thanh_toan:"ten"}}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.details&&($r$$.t_sl=$r$$.details.csum("sl_nhap"),$r$$.t_tien_hang=$r$$.details.csum("tien_hang"),$r$$.t_tien_hang_nt=$r$$.details.csum("tien_hang_nt"),$r$$.t_tien_hang_ct=$r$$.details.csum("tien_hang_ct"),$r$$.t_tien_hang_ct_nt=$r$$.details.csum("tien_hang_ct_nt"),$r$$.t_ck=$r$$.details.csum("tien_ck"),
|
|
26
|
+
$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.t_thue_ra=$r$$.details.csum("tien_thue"),$r$$.t_thue_ra_nt=$r$$.details.csum("tien_thue_nt"),$r$$.t_tt=$r$$.t_tien_hang_ct-$r$$.t_ck+$r$$.t_thue_ra,$r$$.t_tt_nt=$r$$.t_tien_hang_ct_nt-$r$$.t_ck_nt+$r$$.t_thue_ra_nt,$r$$.t_tien_nhap=$r$$.details.csum("tien_nhap"),$r$$.t_tien_nhap_nt=$r$$.details.csum("tien_nhap_nt"))});$callback$$()},details_vt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).joinModel2($id_app$$,
|
|
27
|
+
dmvt,[{where:"ma_vt",fields:"ten_vt picture chieu_cao chieu_rong chieu_sau trong_luong".split(" ")}],function(){$callback1$$()})},function(){$callback$$()})},details_kho:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kho).joinModel($id_app$$,dmkho,[{akey:"ma_kho",bkey:"ma_kho",fields:[{name:"ten_kho",value:"ten_kho"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,
|
|
28
|
+
function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback1$$()})},function(){$callback$$()})},
|
|
29
|
+
details_phi:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel($id_app$$,dmphi,[{akey:"ma_phi",bkey:"ma_phi",fields:[{name:"ten_phi",value:"ten_phi"}]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|