> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/convert-du-lieu/misa-version-desktop.md).

# MISA VERSION DESKTOP

## Ý nghĩa chức năng

Dùng để convert số liệu từ misa desktop sang Dtech

## Quy trình chung

* Sử dụng chức năng convert của phần mềm
* Kết nối data Misa là nguồn: Thông tin user và mk theo tệp tài liệu
* Kết nối data Dtech là đích
* Bấm nút convert ( tích chọn đầu kỳ)
* Cập nhật lại trạm: Để phần mềm reset lại danh mục mới nhất
* Kiểm tra danh mục:
  * Vattu: các cột tài khoản
  * Taisan: các cột tài khoản
  * Phanbo: Các cột tài khoản
  * Dulieuketoan: Cột tài khoản nợ, có
* Chạy lệnh Sql để xử lý lại một số nội dung:&#x20;
  * Update nghiepvu dựa theo left(chungtu,3)
  * Update keyct
  * Update psco cho các dòng nào là bút toán thêm. Nếu không update thì sẽ bị các lỗi sau:
    * không in được phiếu nhập, bán, chi tiền: do tính toán sai liên quan bút toán thêm
    * F2 lên giao diện sẽ lên cả bút toán thêm và sẽ bị báo đỏ cột tài khoản&#x20;
    * Giao diện xem trước dữ liệu bị hiển thị thừa và sum cột sẽ bị sai, dẫn tới khách hàng hiểu sai, bị double dữ liệu hoặc sai số tiền

```sql
--- Some code
----delete dulieuketoan where loaidl=-99  ---- lệnh xoá của data đặc thù, không quan tâm
----select importinfor,* from dulieuketoan where importinfor<>'' --- lệnh kiểm tra dữ liệu convert misa
-----I. Câu lệnh kiểm tra xem: các nghiệp vụ phát sinh trên dữ liệu, và có sử dụng btthems
----- lưu ý: importinfor đánh dấu dữ liệu convert misa bằng ký tự 'misa'
----- câu lệnh dưới đang trả về các nghiệp vụ: 101, 301, 501, 1013 ( với dữ liệu khác thì chạy và lấy ra nghiepvu liên quan để kiểm tra tiếp phía dưới)
select nghiepvu from 
(
select T1.*, T2.no, T2.co, T2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
)T group by T.nghiepvu

----II. Chạy từng nghiepvu. Chạy câu select để kiểm tra trước khi chạy câu update 
----1. nhập kho nội địa
select T1.*, T2.*
--update t1 set t1.psco = t2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=101 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
order by t1.ngay, t1.chungtu


update t1 set t1.psco = t2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=101 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
where t2.nghiepvu is not null


----2. bán hàng nội địa; 301 ; btthems vat = 9
select T1.*, T2.*
from 
	(select ngay,chungtu,sohd,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=301 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
order by t1.ngay, t1.chungtu


update t1 set t1.psco = t2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=301 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null


----3. chi tiền mặt ; 501
select T1.*, T2.*
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=501 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
order by t1.ngay, t1.chungtu


update t1 set t1.psco = t2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=501 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null

----4. Ghi tăng chi phí trả trước; 1013
select T1.*, T2.*
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=1013 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
order by t1.ngay, t1.chungtu


update t1 set t1.psco = t2.btthems
from 
	(select ngay,chungtu,tkno,tkco,nghiepvu,psco from dulieuketoan where nghiepvu=1013 and importinfor='misa')T1 left join
	(select ghichu,no,co,btthems,nghiepvu from btthems )T2 on T1.nghiepvu = T2.nghiepvu and (t1.tkno = t2.no or t1.tkco = t2.co)
--where t2.nghiepvu is null -- kiểm tra các dòng bút toán mẹ. tránh trường hợp ghép thiếu
where t2.nghiepvu is not null
```

## Cập nhật Nghiệp vụ trên DTECH  doanh nghiệp dựa vào chứng từ MISA - Doanh Nghiệp

```sql
select Left(ChungTu,3) as ChungTu,Max(ChungTu) as Vidu from DuLieuKeToan
Group by Left(ChungTu,3) 


-- PNVK => 702
-- BH
Update DuLieuKeToan
set NghiepVu=301
where ChungTu like 'BH%' and Nghiepvu=702
-- NK
Update DuLieuKeToan
set NghiepVu=101
where ChungTu like 'NK%' and Nghiepvu=702

--PC

Update DuLieuKeToan
set NghiepVu=501
where ChungTu like 'PC%' and Nghiepvu=702

-- NTT

Update DuLieuKeToan
set NghiepVu=405
where ChungTu like 'NTT%' and Nghiepvu=702

-- XK

Update DuLieuKeToan
set NghiepVu=202
where ChungTu like 'XK%' and Nghiepvu=702

-- PT

Update DuLieuKeToan
set NghiepVu=401
where ChungTu like 'PT%' and Nghiepvu=702


--NVK ==> 702

-- KH

Update DuLieuKeToan
set NghiepVu=621
where ChungTu like 'KH%' and Nghiepvu=702

-- UNC

Update DuLieuKeToan
set NghiepVu=505
where ChungTu like 'UNC%' and Nghiepvu=702

-- PBC

Update DuLieuKeToan
set NghiepVu=1014
where ChungTu like 'PBC%' and Nghiepvu=702


--- BTL: Hàng bán bị trả lại
-- TT200 là 105, TT133 là 1071
Update DuLieuKeToan
set NghiepVu=105
where ChungTu like 'BTL%' and Nghiepvu=702
```

## Cập nhật Lý do, nghiệp vụ DTECH88 - Convert MISA Doanh nghiệp sang bản Dtech88 cho HKD

```sql
--- Update bút toán doanh số

Update DuLieuKeToan
set NghiepVu=301,NganhNghe=2,
DinhKhoanTuDong=37,TKno='1311',TKCo='91111'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'BH%'


--Update kho cho but toan ban hang
Update DuLieuKeToan
set Kho=3
where ngay>='01/01/2022'
and NghiepVu=301
and Chungtu like 'BH%'

--- Update bút toán gia von xuat kho

Update DuLieuKeToan
set NghiepVu=301,NganhNghe=2,
DinhKhoanTuDong=37,TKno='91121',TKCo='1523'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'XK%'

-- update kho nhan ve =0
Update DuLieuKeToan
set khoo=0
where ngay>='01/01/2022'
and NghiepVu=301
and Chungtu like 'XK%' and khoo>0

--- Update nhạp kho

Update DuLieuKeToan
set NghiepVu=101,DinhKhoanTuDong=26,
TkNo='1523',TKCo='33181'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'NK%'


--- Update chiet khau mua hang

Update DuLieuKeToan
set NghiepVu=101,DinhKhoanTuDong=26,
TkNo='1523',TKCo='33181',Psno= -Psno
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'MGG%'

-- Nhap mua dịch vu
Update DuLieuKeToan
set NghiepVu=101,DinhKhoanTuDong=123,
TkNo='91128',TKCo='33181'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'MDV%'


--- Update Thu tien ngan hang

Update DuLieuKeToan
set NghiepVu=405,DinhKhoanTuDong=72,
TkNo='1112',TKCo='1311'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'NTTK%'

--- Update Thu tien tien

Update DuLieuKeToan
set NghiepVu=401,DinhKhoanTuDong=3,
TkNo='1111',TKCo='1311'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'PT%'

--- Update chi tien ngan hang

Update DuLieuKeToan
set NghiepVu=505,DinhKhoanTuDong=60,
TkNo='33181',TKCo='1112'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'UNC%'

--- Update chi tien mat

Update DuLieuKeToan
set NghiepVu=501,DinhKhoanTuDong=12,
TkNo='1112',TKCo='1111'
where ngay>='01/01/2022'
and NghiepVu=702
and Chungtu like 'PC%'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://kythuat.dtechvn.com/convert-du-lieu/misa-version-desktop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
