> 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/gia-thanh-1/dau-62-con-du.md).

# ĐẦU 62 CÒN DƯ

## BIỂU HIỆN

* Sau khi chạy giá thành, đầu 62 vẫn còn dư
* Sử dụng giá thành sản xuất giản đơn

## NGUYÊN NHÂN SƠ BỘ

* TH1: Nhóm phân bổ không có tiêu thức nên không thể phân bổ
* TH2: Giá thành bị quay vòng: Thường bị với đơn vị có giá thành sản xuất giản đơn nhiều cấp sản phẩm

## GIẢI PHÁP

### TH1. Nhóm phân bổ không có tiêu thức nên không thể phân bổ

* Chạy giá thành tuần tự từng bước để xem rơi vào nhóm nào
* Kiểm tra tiêu thức đang áp dụng cho nhóm kết chuyển
* NSD có thể đổi tiêu thức phù hợp. Lưu ý, nên áp dụng xuyên suốt tiêu thức trong năm tài chính

### TH2. Giá thành bị quay vòng trường hợp giá thành nhiều cấp

* Nguyên tắc là nguyên liệu xuất cho sản phẩm phải có cấp bé hơn. Ví dụ, Bán thành phẩm cấp 3 thì xuất dùng ra cho Bán thành phẩm cấp 4. Nếu xuất bán thành phẩm cấp 3 để dùng cho Bán thành cấp 2 hoặc 3 thì sẽ bị giá vốn quay vòng, tài khoản 62 sẽ bị dư.
* kỹ thuật sử dụng câu lệnh sau để dò tìm&#x20;

```sql
-- tạo ra bảng danh sách sản phẩm theo thứ tự cấp (stt)
with cte_capsanpham as (
select  ma,sanphams,ROW_NUMBER() over(order by buockc) as stt
from BuocKC
where cap=0 and buockc<>0 and sanphams<>''
)
--select * from cte_capsanpham
-- tạo ra bảng kết quả có vấn đề. 
-- lưu ý, thay đổi điều kiện ngày cho phù hợp 
SELECT dx.ngay,dx.chungtu
,vattu.ma as vattuMa,vattu.ten as VattuTen,dx.vattu,csp_xuat.stt as spCapVattu
,sanpham.ma as sanphamMa,sanpham.ten as sanphamTen,dx.SanPham, csp_nhap.stt as spCapSanpham
,dx.tkno,dx.tkco,dx.DienGiai
,dx.nghiepvu, nghiepvu.VIETNAM
FROM 
(
select * from dulieuketoan 
where tkco like '15%' and tkco not like '154%' and (tkno like '62%' or tkno like '154%') -- điều kiện lọc tài khoản nhóm xuất kho ghi nhận chi phí
and loaidl=0 and nghiepvu>0 -- loại bút toán kết chuyển
and ngay>= '01/01/2025' and ngay<= '12/31/2025' -- thời gian
and GVTC=0 -- nếu gvtc = 0 là bị quay vòng. =1 thì giá đích danh rồi thì không sao.
) dx
join vattu on dx.VatTu = vattu.vattu -- lấy mã,tên vattu
join sanpham on dx.SanPham = sanpham.vattu -- lấy mã,tên sanpham
join nghiepvu on dx.NghiepVu = nghiepvu.NghiepVu
JOIN cte_capsanpham csp_xuat ON ',' + csp_xuat.sanphams + ',' LIKE '%,' + CAST(dx.VatTu AS VARCHAR) + ',%' -- lấy cấp vật tư
JOIN cte_capsanpham csp_nhap ON ',' + csp_nhap.sanphams + ',' LIKE '%,' + CAST(dx.SanPham AS VARCHAR) + ',%' -- lấy cấp sản phẩm
WHERE csp_xuat.stt >= csp_nhap.stt -- lấy các bút toán có cấp vật tư >= cấp sản phẩm ( nvl phải có cấp thấp hơn sản phẩm)
order by dx.Ngay,dx.ChungTu
```


---

# 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/gia-thanh-1/dau-62-con-du.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.
