From 547a7894b874ee27914b42083273e17b371413ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A5=98=ED=98=B8=EC=84=B1?= Date: Mon, 22 Jun 2026 20:28:21 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 쿼리/Template/POR 소요예산 변경하기.sql | 13 +- .../Template/실행예산투입실적금액수정하기.sql | 406 ++++++++++++++++++ 쿼리/Template/인건비반영제거하기.sql | 158 +++++++ 쿼리/Template/자금일보조회.sql | 33 ++ 쿼리/Template/프로젝트별기간투입상세조회.sql | 173 ++++++++ 쿼리/Template/회계장부_판관_원가_증빙조회.sql | 67 +++ 쿼리/Template/회계장부조회.sql | 44 ++ 7 files changed, 889 insertions(+), 5 deletions(-) create mode 100644 쿼리/Template/실행예산투입실적금액수정하기.sql create mode 100644 쿼리/Template/인건비반영제거하기.sql create mode 100644 쿼리/Template/자금일보조회.sql create mode 100644 쿼리/Template/프로젝트별기간투입상세조회.sql create mode 100644 쿼리/Template/회계장부_판관_원가_증빙조회.sql create mode 100644 쿼리/Template/회계장부조회.sql diff --git a/쿼리/Template/POR 소요예산 변경하기.sql b/쿼리/Template/POR 소요예산 변경하기.sql index 8ddefac..e533931 100644 --- a/쿼리/Template/POR 소요예산 변경하기.sql +++ b/쿼리/Template/POR 소요예산 변경하기.sql @@ -1,8 +1,8 @@ -- ========================================== -- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] --- 작 성 자: [요청자 이름을 기록합니다.] --- 작업목적: [쿼리 작성 및 실행 목적 설명] --- 요청자/티켓번호: [요청 부서 또는 이슈 번호를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [이미 집행된 발주의뢰서의 금액을 실제 투입금액으로 변경할 경우 사용합니다.] +-- 요청자/티켓번호: [요청 부서 / 요청자 또는 이슈 번호를 기록합니다.] -- ========================================== declare @por_no char(8), @por_seq int @@ -13,13 +13,16 @@ set @por_no = 'P2506009' set @amt = 4698297087 set @por_seq = 1 --- [1] 대상 데이터 검증 (조회) +-- [1] 대상 데이터 검증 (조회) : 발주의뢰서 금액 변경 전 데이터 확인 권장 select * from HPOIMS.dbo.gm_por_detail where por_no = @por_no and por_seq = @por_seq -- [2] 발주의뢰서 금액 변경(수정/삭제 시 주석 처리 후 공유 권장) +/* update HPOIMS.dbo.gm_por_detail set unitp = @amt, amt = @amt, w_unitp = @amt, w_amt = @amt, t_amt = @amt where por_no = @por_no and por_seq = @por_seq +*/ -- [3] 발주의뢰서 금액 변경에 따른 실행예산 투입실적금액 변경(수정/삭제 시 주석 처리 후 공유 권장) +/* update HPOIMS.dbo.ys_pbudget set @@ -104,4 +107,4 @@ on and a.main <> 'AB00' and a.curr = 'WON' and ROUND(isnull(a.x_amt,0)*a.base_rate,0) <> (b.soyo_amt+b.input_amt) - +*/ diff --git a/쿼리/Template/실행예산투입실적금액수정하기.sql b/쿼리/Template/실행예산투입실적금액수정하기.sql new file mode 100644 index 0000000..2c1d268 --- /dev/null +++ b/쿼리/Template/실행예산투입실적금액수정하기.sql @@ -0,0 +1,406 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [실행예산 소요예산 = 구매청구서 금액 + 직접비 금액 비교하여 다른 것 조회하여 내용 확인 후 수정합니다.] +-- 요청자/티켓번호: [사업부서의 요청 혹은 주기적으로 실행하여 데이터를 일치 시킵니다.] +-- ========================================== + +-- [1] 원화인 경우 실행예산 소요예산 = 구매청구서 금액 + 직접비 금액 비교하여 다른 것 조회하기 +select + a.* + , a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) x_amt + , (b.soyo_amt+b.input_amt) + , a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) - (b.soyo_amt+b.input_amt) +from + HPOIMS.dbo.ys_pbudget a +join +( + select + * + from + ( + select + a.pjt_no, a.main, a.sub, a.bud_seq + , sum(a.bud_amt) bud_amt + , sum(a.bud_x_amt) bud_x_amt + , sum(a.bud_e_amt) bud_e_amt + , sum(a.soyo_amt) soyo_amt + , sum(a.input_amt) input_amt + from + ( + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = ISNULL(a.closing_yn,'N') + , bud_amt = round(ISNULL(a.amt*a.base_rate,0),0) + , bud_x_amt = round(ISNULL(a.x_amt*a.base_rate,0),0) + , bud_e_amt = round(ISNULL(a.e_amt*a.base_rate,0),0) + , soyo_amt = 0 + , input_amt = 0 + FROM + HPOIMS.dbo.ys_pbudget a + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 +-- , soyo_amt = SUM(ISNULL(a.amt,0)*ISNULL(b.base_rate,1) + CASE WHEN b.fob IS NULL THEN 0 ELSE FLOOR(ISNULL(a.amt,0)*ISNULL(b.fob,1)*b.base_rate) END) + , soyo_amt = SUM(ISNULL(a.w_amt,0)) + , input_amt = 0 + FROM + HPOIMS.dbo.gm_por_detail a + left outer join + HPOIMS.dbo.ys_project_rate b + on + a.pjt_no = b.pjt_no and a.curr = b.curr + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = 0 +-- , input_amt = SUM(ISNULL(a.amt,0)*ISNULL(b.base_rate,1) + CASE WHEN b.fob IS NULL THEN 0 ELSE FLOOR(ISNULL(a.amt,0)*ISNULL(b.fob,1)*b.base_rate) END) + , input_amt = SUM(ISNULL(a.amt,0)) + FROM + HPOIMS.dbo.ys_direct_cost a + left outer join + HPOIMS.dbo.ys_project_rate b + on + a.pjt_no = b.pjt_no and a.curr = b.curr + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a +-- where +-- (a.bud_x_amt*a.base_rate) <> (a.soyo_amt+a.input_amt) + +) b +on + a.pjt_no = b.pjt_no + and a.main = b.main + and a.sub = b.sub + and a.bud_seq = b.bud_seq + and a.pjt_no like '%' + and a.main <> 'AB00' + and a.curr = 'WON' + and ROUND(isnull(a.x_amt,0)*a.base_rate,0) <> (b.soyo_amt+b.input_amt) + +-- and a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) +-- <> +-- (b.soyo_amt+b.input_amt) +-- and abs((a.x_amt*a.base_rate) - (b.soyo_amt+b.input_amt)) > 1 +-- and a.item_name = 'ManDay 지원비' + +-- [2] 외자인 경우 실행예산 소요예산 = 구매청구서 금액 + 직접비 금액 비교하여 다른 것 조회하기 +select + a.* + , round(a.x_amt*a.base_rate,-1) + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) x_amt + , (b.soyo_amt+b.input_amt) + , a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) - (b.soyo_amt+b.input_amt) +from + HPOIMS.dbo.ys_pbudget a +join +( + select + * + from + ( + select + a.pjt_no, a.main, a.sub, a.bud_seq + , sum(a.bud_amt) bud_amt + , sum(a.bud_x_amt) bud_x_amt + , sum(a.bud_e_amt) bud_e_amt + , sum(a.soyo_amt) soyo_amt + , sum(a.input_amt) input_amt + from + ( + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = ISNULL(a.closing_yn,'N') + , bud_amt = round(ISNULL(a.amt*a.base_rate,0),0) + , bud_x_amt = round(ISNULL(a.x_amt*a.base_rate,0),0) + , bud_e_amt = round(ISNULL(a.e_amt*a.base_rate,0),0) + , soyo_amt = 0 + , input_amt = 0 + FROM + HPOIMS.dbo.ys_pbudget a + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 +-- , soyo_amt = SUM(ISNULL(a.amt,0)*ISNULL(b.base_rate,1) + CASE WHEN b.fob IS NULL THEN 0 ELSE FLOOR(ISNULL(a.amt,0)*ISNULL(b.fob,1)*b.base_rate) END) + , soyo_amt = SUM(ISNULL(a.w_amt,0)) + , input_amt = 0 + FROM + HPOIMS.dbo.gm_por_detail a + left outer join + HPOIMS.dbo.ys_project_rate b + on + a.pjt_no = b.pjt_no and a.curr = b.curr + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = 0 +-- , input_amt = SUM(ISNULL(a.amt,0)*ISNULL(b.base_rate,1) + CASE WHEN b.fob IS NULL THEN 0 ELSE FLOOR(ISNULL(a.amt,0)*ISNULL(b.fob,1)*b.base_rate) END) + , input_amt = SUM(ISNULL(a.amt,0)) + FROM + HPOIMS.dbo.ys_direct_cost a + left outer join + HPOIMS.dbo.ys_project_rate b + on + a.pjt_no = b.pjt_no and a.curr = b.curr + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a +-- where +-- (a.bud_x_amt*a.base_rate) <> (a.soyo_amt+a.input_amt) + +) b +on + a.pjt_no = b.pjt_no + and a.main = b.main + and a.sub = b.sub + and a.bud_seq = b.bud_seq + and a.pjt_no like 'V%' + and a.main <> 'AB00' +-- and a.curr = 'WON' +-- and a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) +-- <> +-- (b.soyo_amt+b.input_amt) + and round(a.x_amt*a.base_rate, -1) + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) <> (b.soyo_amt+b.input_amt) + and abs(a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) - (b.soyo_amt+b.input_amt)) > 1 +-- and a.item_name = 'ManDay 지원비' + +/* + +-- 실행예산 소요예산 = 구매청구서 금액 + 직접비 금액 비교하여 다른 것 업데이트 하기 +begin tran + +update + HPOIMS.dbo.ys_pbudget +set + x_amt = (b.soyo_amt+b.input_amt) +from + HPOIMS.dbo.ys_pbudget a +join +( + select + * + from + ( + select + a.pjt_no, a.main, a.sub, a.bud_seq + , sum(a.bud_amt) bud_amt + , sum(a.bud_x_amt) bud_x_amt + , sum(a.bud_e_amt) bud_e_amt + , sum(a.soyo_amt) soyo_amt + , sum(a.input_amt ) input_amt + from + ( + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = ISNULL(a.closing_yn,'N') + , bud_amt = ISNULL(a.amt,0) + , bud_x_amt = ISNULL(a.x_amt,0) + , bud_e_amt = ISNULL(a.e_amt,0) + , soyo_amt = 0 + , input_amt = 0 + FROM + HPOIMS.dbo.ys_pbudget a + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = SUM(ISNULL(a.w_amt,0)) + , input_amt = 0 + FROM + HPOIMS.dbo.gm_por_detail a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = 0 + , input_amt = SUM(ISNULL(a.amt,0)) + FROM + HPOIMS.dbo.ys_direct_cost a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + where + a.bud_x_amt <> (a.soyo_amt+a.input_amt) +) b +on + a.pjt_no = b.pjt_no + and a.main = b.main + and a.sub = b.sub + and a.bud_seq = b.bud_seq + and a.pjt_no like '%' + and a.main <> 'AB00' + and a.curr = 'WON' + and ROUND(isnull(a.x_amt,0)*a.base_rate,0) <> (b.soyo_amt+b.input_amt) + +commit tran + +rollback tran + + +begin tran + +update + HPOIMS.dbo.ys_pbudget +set + x_amt = (b.soyo_amt+b.input_amt) +from + HPOIMS.dbo.ys_pbudget a +join +( + select + * + from + ( + select + a.pjt_no, a.main, a.sub, a.bud_seq + , sum(a.bud_amt) bud_amt + , sum(a.bud_x_amt) bud_x_amt + , sum(a.bud_e_amt) bud_e_amt + , sum(a.soyo_amt) soyo_amt + , sum(a.input_amt ) input_amt + from + ( + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = ISNULL(a.closing_yn,'N') + , bud_amt = ISNULL(a.amt,0) + , bud_x_amt = ISNULL(a.x_amt,0) + , bud_e_amt = ISNULL(a.e_amt,0) + , soyo_amt = 0 + , input_amt = 0 + FROM + HPOIMS.dbo.ys_pbudget a + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = SUM(ISNULL(a.w_amt,0)) + , input_amt = 0 + FROM + HPOIMS.dbo.gm_por_detail a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = 0 + , input_amt = SUM(ISNULL(a.amt,0)) + FROM + HPOIMS.dbo.ys_direct_cost a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a +-- where +-- a.bud_x_amt <> (a.soyo_amt+a.input_amt) +) b +on + + a.pjt_no = b.pjt_no + and a.main = b.main + and a.sub = b.sub + and a.bud_seq = b.bud_seq + and a.pjt_no like '%' + and a.main <> 'AB00' + and a.curr = 'WON' + and ROUND(isnull(a.x_amt,0)*a.base_rate,0) <> (b.soyo_amt+b.input_amt) + +-- and a.pjt_no like 'B%' + and ROUND(a.x_amt*a.base_rate,0) <> (b.soyo_amt+b.input_amt) + +-- and a.x_amt*a.base_rate + round(((a.x_amt*a.base_rate) * isnull((select fob from HPOIMS.dbo.ys_project_rate where pjt_no = a.pjt_no and curr = a.curr),0)),0) +-- <> +-- (b.soyo_amt+b.input_amt) + +rollback tran +*/ diff --git a/쿼리/Template/인건비반영제거하기.sql b/쿼리/Template/인건비반영제거하기.sql new file mode 100644 index 0000000..ea71b19 --- /dev/null +++ b/쿼리/Template/인건비반영제거하기.sql @@ -0,0 +1,158 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [인건비 일괄 입력된 자료가 중복되거나 잘못 입력된 경우 삭제하고 실행예산 투입실적금액을 변경할 경우 사용합니다.] +-- 요청자/티켓번호: [요청 부서 / 요청자 또는 이슈 번호를 기록합니다.] +-- ========================================== + +declare @yy char(4), @mm char(2) + +-- [0] 변경할 데이터 설정 +select @yy = '2022', @mm = '10' + +-- [1] 인건비, 직접경비, 경상비 데이터 검증 (조회) : 중복 여부 미리 확인 권장 +select * from GA.dbo.ga_pay where yy = @yy and mm = @mm +select * from HPOIMS.dbo.ys_direct_cost where jcost_desc like @yy + '년 '+ @mm + '월%(AUTO)' +select * from HPOIMS.dbo.ks_indirect_cost where jcost_desc like @yy + '년 '+ @mm + '월%(AUTO)' + +-- [2] 인건비/직접경비/경상비 일괄입력된 데이터 삭제(수정/삭제 시 주석 처리 후 공유 권장) +/* +delete from GA.dbo.ga_pay where yy = @yy and mm = @mm +delete from HPOIMS.dbo.ys_direct_cost where jcost_desc like @yy + '년 '+ @mm + '월%(AUTO)' +delete from HPOIMS.dbo.ks_indirect_cost where jcost_desc like @yy + '년 '+ @mm + '월%(AUTO)' +*/ + +-- [3] 인건비/직접경비/경상비 삭제에 따른 실행예산 투입실적금액 변경(수정/삭제 시 주석 처리 후 공유 권장) +/* +update + HPOIMS.dbo.ys_pbudget +set + x_amt = (b.soyo_amt+b.input_amt) +from + HPOIMS.dbo.ys_pbudget a +join +( + select + * + from + ( + select + a.pjt_no, a.main, a.sub, a.bud_seq + , sum(a.bud_amt) bud_amt + , sum(a.bud_x_amt) bud_x_amt + , sum(a.bud_e_amt) bud_e_amt + , sum(a.soyo_amt) soyo_amt + , sum(a.input_amt ) input_amt + from + ( + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = ISNULL(a.closing_yn,'N') + , bud_amt = ISNULL(a.amt,0) + , bud_x_amt = ISNULL(a.x_amt,0) + , bud_e_amt = ISNULL(a.e_amt,0) + , soyo_amt = 0 + , input_amt = 0 + FROM + HPOIMS.dbo.ys_pbudget a + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = SUM(ISNULL(a.w_amt,0)) + , input_amt = 0 + FROM + HPOIMS.dbo.gm_por_detail a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + + UNION ALL + SELECT + pjt_no = a.pjt_no + , main = a.main + , sub = a.sub + , bud_seq = a.bud_seq + , closing_yn = '' + , bud_amt = 0 + , bud_x_amt = 0 + , bud_e_amt = 0 + , soyo_amt = 0 + , input_amt = SUM(ISNULL(a.amt,0)) + FROM + HPOIMS.dbo.ys_direct_cost a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + GROUP BY + a.pjt_no, a.main, a.sub, a.bud_seq + ) a + where + a.bud_x_amt <> (a.soyo_amt+a.input_amt) +) b +on + a.pjt_no = b.pjt_no + and a.main = b.main + and a.sub = b.sub + and a.bud_seq = b.bud_seq + and a.pjt_no like '%' + and a.main <> 'AB00' + and a.curr = 'WON' + and ROUND(isnull(a.x_amt,0)*a.base_rate,0) <> (b.soyo_amt+b.input_amt) + + +update + HPOIMS.dbo.ks_budget +set + budget_use = b.amt +from + HPOIMS.dbo.ks_budget a +join +( + select + a.* + from + ( + select + a.dept_cd, a.year, a.month, a.main_cd, a.sub_cd, isnull(a.budget_use,0) budget_use , isnull(b.amt,0) amt + from + HPOIMS.dbo.ks_budget a + left outer join + ( + select + dept_cd, year, month, main_cd, sub_cd, sum(amt) amt + from + HPOIMS.dbo.ks_indirect_cost + where + ctr_yn = 'Y' + group by + dept_cd, year, month, main_cd, sub_cd + ) b + on + a.dept_cd = b.dept_cd + and a.year = b.year + and a.month = b.month + and a.main_cd = b.main_cd + and a.sub_cd = b.sub_cd + ) a + where + a.budget_use <> a.amt +) b +on + a.dept_cd = b.dept_cd + and a.year = b.year + and a.month = b.month + and a.main_cd = b.main_cd + and a.sub_cd = b.sub_cd + and a.year >= '2019' + +*/ \ No newline at end of file diff --git a/쿼리/Template/자금일보조회.sql b/쿼리/Template/자금일보조회.sql new file mode 100644 index 0000000..3ec02e5 --- /dev/null +++ b/쿼리/Template/자금일보조회.sql @@ -0,0 +1,33 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [기간에 대한 자금집행내역을 조회하여 다량의 자료를 엑셀파일로 제공합니다.] +-- 요청자/티켓번호: [회계부서의 요청에 따라 제공합니다.] +-- ========================================== + +declare @fr_date char(8), @to_date char(8) + +-- [0] 변경할 데이터 설정 +select @fr_date = '20240101', @to_date = '20241231' + +-- [1] 해당 기간의 자금집행내역을 조회 +select + a.magam_dt, a.seq, a.pjt_no + , pjt_name = (select pjt_name from HPOIMS.dbo.ys_project where pjt_no = a.pjt_no) + , dept_code = isnull(a.costcd, a.dept_cd) + , dept_name = (select dept_nm from HRM.dbo.hr_dept where dept_cd = isnull(a.costcd, a.dept_cd)) + , a.ven_code + , ven_name = (select ven_name from HPOIMS.dbo.gm_vendor where a.ven_code = ven_code) + , a.acntcode + , acnt_name = (select (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2018' and substring(a.acntcode,1,5)+'00' = acntcode) +'-'+ replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2018' and a.acntcode = acntcode) + , a.contents + , slpamt = (case when a.money_type = '0' then a.slpamt else 0 end) + , vatamt = (case when a.money_type = '0' then a.vatamt else 0 end) + , slpamt2 = (case when a.money_type = '1' then a.slpamt else 0 end) + , vatamt2 = (case when a.money_type = '1' then a.vatamt else 0 end) +from + ACC.dbo.t23a14 a +where + a.magam_dt between @fr_date and @to_date +order by + a.magam_dt, a.seq diff --git a/쿼리/Template/프로젝트별기간투입상세조회.sql b/쿼리/Template/프로젝트별기간투입상세조회.sql new file mode 100644 index 0000000..313a3e5 --- /dev/null +++ b/쿼리/Template/프로젝트별기간투입상세조회.sql @@ -0,0 +1,173 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [기간이 긴 경우 많은 데이터를 조회할 때 실무자의 요청에 의해 조회하여 엑셀파일로 제공합니다.] +-- 요청자/티켓번호: [요청 부서 / 요청자 또는 이슈 번호를 기록합니다.] +-- ========================================== +declare + @f_year CHAR(4) + , @f_month CHAR(2) + , @t_year CHAR(4) + , @t_month CHAR(2) + , @pjt_no VARCHAR(8) + , @suju_bumun_dae VARCHAR(12) + , @suju_bumun_jung VARCHAR(12) + +select @f_year = '2015', @f_month = '01', @t_year = '2020', @t_month = '12', @pjt_no = 'V121T606%', @suju_bumun_dae='%', @suju_bumun_jung='%' + +SET NOCOUNT ON + + DECLARE @f_date DATETIME -- FROM Date + DECLARE @t_date DATETIME -- To Date + + SET @f_date = @f_month + '/' + '01' + '/' + @f_year + SET @t_date = @t_month + '/' + '01' + '/' + @t_year + SET @t_date = DATEADD(month,1,@t_date) + SET @t_date = @t_date - 1 + --print @f_date + --print @t_date + + IF(@f_date > @t_date) + BEGIN + RAISERROR ('FROM Date가 To Date 보다 큼니다. 확인하여 주십시요', 16, 1) + -- RETURN -1 + END + + DECLARE @t_TAB TABLE ( + pjt_no CHAR(8) -- 공사번호 + , yymm CHAR(8) -- 투입연월 + , main CHAR(4) + , sub CHAR(4) + , bud_seq INT + , s_amt DECIMAL(12,0) -- 소요예산 + , g_amt DECIMAL(12,0) -- 기성투입실적 + , d_amt DECIMAL(12,0) -- 직접투입실적 + , m_amt DECIMAL(12,0) -- MD투입실적 + , t_amt DECIMAL(12,0) -- 총투입실적 + ) + + INSERT INTO + @t_TAB + -- 직접경비(소요예산, 투입실적) + SELECT + pjt_no=A.pjt_no -- 공사번호 + , yymm = SUBSTRING(CONVERT(CHAR(8),A.bud_date,112), 1,6) + , main = A.main + , sub = A.sub + , bud_seq = A.bud_seq + , s_amt=SUM(A.app_rate*A.amt) -- 소요예산 + , g_amt = 0 + , d_amt = SUM(CASE WHEN A.main = 'AB29' AND A.sub = 'A2B' THEN 0 ELSE A.app_rate*A.amt END) -- 투입실적 + , m_amt = SUM(CASE WHEN A.main = 'AB29' AND A.sub = 'A2B' THEN A.app_rate*A.amt END) -- 투입실적 + , t_amt=SUM(A.app_rate*A.amt) -- 투입실적 + FROM + HPOIMS.dbo.ys_direct_cost A + JOIN + HPOIMS.dbo.ys_project B + ON + A.pjt_no = B.pjt_no + WHERE + A.bud_date >= @f_date + AND A.bud_date <= @t_date + AND ISNULL(A.cont_no,'') = '' -- 기성처리분은 제외시키다. + AND ISNULL(A.ctr_yn,'') = 'Y' -- 통제분만 포함 시킨다. + AND A.pjt_no LIKE @pjt_no + '%' -- 2007.03.07 Add + AND ISNULL(B.suju_bumun_dae,'') LIKE @suju_bumun_dae + '%' + AND ISNULL(B.suju_bumun_jung,'') LIKE @suju_bumun_jung + '%' + GROUP BY + A.pjt_no, SUBSTRING(CONVERT(CHAR(8),A.bud_date,112), 1,6), A.main, A.sub, A.bud_seq + + INSERT INTO + @t_TAB + -- 기성신청정보 + SELECT + pjt_no=A.pjt_no + , yymm = A.year+A.month + , main = A.main + , sub = A.sub + , bud_seq = A.bud_seq + , s_amt=0 + , g_amt=SUM(gs_amt) + , d_amt=0 + , m_amt = 0 + , t_amt=SUM(gs_amt) + FROM + HPOIMS.dbo.uvw_gs_po_input A + JOIN + HPOIMS.dbo.ys_project B + ON + A.pjt_no = B.pjt_no + WHERE + (A.month+'/28/'+ A.year) >= @f_date + AND (A.month+'/28/'+ A.year) <= @t_date + AND A.pjt_no LIKE @pjt_no + '%' -- 2007.03.07 Add + AND ISNULL(B.suju_bumun_dae,'') LIKE @suju_bumun_dae + '%' + AND ISNULL(B.suju_bumun_jung,'') LIKE @suju_bumun_jung + '%' + GROUP BY + A.pjt_no, A.year+A.month, A.main, A.sub, A.bud_seq + + INSERT INTO @t_TAB + -- 외자입고정보 + SELECT + pjt_no=A.pjt_no + , yymm = A.year+A.month + , main = A.main + , sub = A.sub + , bud_seq = A.bud_seq + , s_amt=0 + , g_amt=SUM(A.rec_amt) + , d_amt=0 + , m_amt=0 + , t_amt=SUM(A.rec_amt) + FROM + HPOIMS.dbo.uvw_im_po_input A + JOIN + HPOIMS.dbo.ys_project B + ON + A.pjt_no = B.pjt_no + WHERE + (A.month+'/28/'+ A.year) >= @f_date + AND (A.month+'/28/'+ A.year) <= @t_date + AND A.pjt_no LIKE @pjt_no + '%' -- 2007.03.07 Add + AND ISNULL(B.suju_bumun_dae,'') LIKE @suju_bumun_dae + '%' + AND ISNULL(B.suju_bumun_jung,'') LIKE @suju_bumun_jung + '%' + GROUP BY + A.pjt_no, A.year+A.month, A.main, A.sub, A.bud_seq + + SELECT + [공사번호]=A.pjt_no + , [공사명] =(SELECT x.pjt_name FROM HPOIMS.dbo.ys_project x WHERE x.pjt_no = A.pjt_no) + , [연월] = A.yymm + , A.main, A.sub, A.bud_seq + , [예산명]=(select item_name from HPOIMS.dbo.ys_pbudget where A.pjt_no = pjt_no and A.main = main and A.sub = replace(sub,' ', '') and A.bud_seq = bud_seq) + , [총투입금액]=ISNULL(A.t_amt,0) + , [부문]=(B.bumun_gbn ) + FROM + ( + SELECT + pjt_no=x.pjt_no + , yymm = x.yymm + , main = x.main + , sub = x.sub + , bud_seq = x.bud_seq + , s_amt=SUM(x.s_amt) + , g_amt=SUM(x.g_amt) + , d_amt=SUM(x.d_amt) + , m_amt=SUM(x.m_amt) + , t_amt=SUM(x.t_amt) + FROM + @t_TAB x + GROUP BY + x.pjt_no, x.yymm, x.main, x.sub, x.bud_seq + ) A + LEFT OUTER JOIN + ( + SELECT pjt_no, bumun_gbn=(SELECT fname FROM SYS.dbo.cm_codes WHERE type = 'YS14' and code = bumun_gbn) FROM HPOIMS.dbo.ys_project WHERE bumun_gbn IS NOT NULL + ) B + ON + A.pjt_no = B.pjt_no + ORDER BY + A.pjt_no, A.yymm, A.main, A.sub, A.bud_seq + + +SET NOCOUNT OFF \ No newline at end of file diff --git a/쿼리/Template/회계장부_판관_원가_증빙조회.sql b/쿼리/Template/회계장부_판관_원가_증빙조회.sql new file mode 100644 index 0000000..1d5d6ba --- /dev/null +++ b/쿼리/Template/회계장부_판관_원가_증빙조회.sql @@ -0,0 +1,67 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [회계년도에 대한 원가, 판관비 전표를 조회하여 다량의 자료를 엑셀파일로 제공합니다.] +-- 요청자/티켓번호: [회계부서의 요청에 따라 제공합니다.] +-- ========================================== + +declare @fr_date char(8), @to_date char(8) + +-- [0] 변경할 데이터 설정 +select @fr_date = '20240101', @to_date = '20241231' + +-- [1] 해당 기간의 경비와 판관비 전표 내역을 조회 +select + a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and substring(a.acntcode, 1, 5)+'00' = acntcode) + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and a.acntcode = acntcode) + , a.apvdramt, a.apvcramt + , replace(a. slpfree, '"',''), a.pjtno + , pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no) + , a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code) + , case when a.billchk = '1' then '영수증' when a.billchk = '2' then '세금계산서' when a.billchk = '3' then '기타증빙' else '증빙없음' end billchk_nm +from + ACC.dbo.t23a10 a +where + a.area = '9' + and a.apvdate between @fr_date and @to_date + and a.acntcode is not null + and substring(a.acntcode,1,1) in ('6','9') +order by + a.apvdate, a.apvnum, a.apvseq + +-- [2] 해당 기간의 경비 전표 내역을 조회 +select + a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and substring(a.acntcode, 1, 5)+'00' = acntcode) + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and a.acntcode = acntcode) + , a.apvdramt, a.apvcramt + , replace(a. slpfree, '"',''), a.pjtno + , pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no) + , a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code) + , case when a.billchk = '1' then '영수증' when a.billchk = '2' then '세금계산서' when a.billchk = '3' then '기타증빙' else '증빙없음' end billchk_nm +from + ACC.dbo.t23a10 a +where + a.area = '9' + and a.apvdate between @fr_date and @to_date + and a.acntcode is not null + and a.acntcode like '9%' +order by + a.apvdate, a.apvnum, a.apvseq + +-- [3] 해당 기간의 법인카드 전표 내역을 증빙으로 구분하여 조회 +select + a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and substring(a.acntcode, 1, 5)+'00' = acntcode) + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = '2024' and a.acntcode = acntcode) + , a.apvdramt, a.apvcramt + , replace(a. slpfree, '"',''), a.pjtno + , pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no) + , a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code) + , case when a.billchk = '1' then '영수증' when a.billchk = '2' then '세금계산서' when a.billchk = '3' then '기타증빙' else '증빙없음' end billchk_nm +from + ACC.dbo.t23a10 a +where + area+apvdate+apvnum in (select area+apvdate+apvnum from ACC.dbo.t23a10 where area = '9' and apvdate between @fr_date and @to_date and acntcode = '2100502' and dr_cr = '2') + and dr_cr = '1' diff --git a/쿼리/Template/회계장부조회.sql b/쿼리/Template/회계장부조회.sql new file mode 100644 index 0000000..fc3449e --- /dev/null +++ b/쿼리/Template/회계장부조회.sql @@ -0,0 +1,44 @@ +-- ========================================== +-- 작업일자: YYYY-MM-DD [쿼리 작성 및 실행 날짜를 기록합니다.] +-- 작 성 자: [실행자 이름을 기록합니다.] +-- 작업목적: [기간에 대한 회계 장부 전체를 조회하여 다량의 자료를 엑셀파일로 제공합니다.] +-- 요청자/티켓번호: [회계부서의 요청에 따라 제공합니다.] +-- ========================================== + +declare @fr_date char(8), @to_date char(8), @yy char(4) + +-- [0] 변경할 데이터 설정 +select @fr_date = '20240101', @to_date = '20241231', @yy = '2024' + +-- [1] 해당 기간의 회계 장부 내역을 조회 +select + a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and substring(a.acntcode, 1, 5)+'00' = acntcode) + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and a.acntcode = acntcode) + , a.apvdramt, a.apvcramt + , replace(a. slpfree, '"',''), a.pjtno + , pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no) + , a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code), a.hyundae +from + ACC.dbo.t23a10 a +where + a.area = '9' + and a.apvdate between @fr_date and @to_date + and a.acntcode is not null + and a.hyundae = '2' +union all +select + a.apvdate, a.apvnum, a.apvseq, a.dtcode, dtname=(select dept_nm from HRM.dbo.hr_dept where dept_cd = a.dtcode), a.acntcode + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and substring(a.acntcode, 1, 5)+'00' = acntcode) + , acntname = (select replace(acntname, ' ', '') from ACC.dbo.t23c10 where c10_yy = @yy and a.acntcode = acntcode) + , a.apvdramt, a.apvcramt + , replace(a. slpfree, '"',''), a.pjtno + , pjtname=(select pjt_name from HPOIMS.dbo.ys_project where a.pjtno = pjt_no) + , a.vendorcd, venname=(select replace(ven_name,'"','') from HPOIMS.dbo.gm_vendor where a.vendorcd = ven_code), a.hyundae +from + ACC.dbo.t23a10 a +where + a.area = '9' + and a.apvdate between @fr_date and @to_date + and a.acntcode is not null + and a.hyundae = '1'