20080507
20080530
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetBeforStock]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetBeforStock]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetNowStock]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetNowStock]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO




/****** 개체: 사용자 정의 함수 dbo.GetCommonCode    스크립트 날짜: 2006-09-01 오후 2:22:59 ******/
CREATE FUNCTION GetBeforStock
( @cd_store varchar(4),
  @cd_menu varchar(14),
  @ymd_stock varchar(8))
RETURNS int AS  
BEGIN 
	declare @stock1   int
	declare @stock2   int
	declare @stock3   int

	select @stock1 = isnull(qty_base,0)
	  from sl_stock_month
	 where cd_store =@cd_store
	   and cd_menu = @cd_menu
	   and ym_stock = substring(@ymd_stock,1,6)

	select @stock2 = sum(isnull(qty_buy,0))
	  from sl_buy_d
	 where cd_store =@cd_store
	   and cd_goods = @cd_menu
	   and ymd_buy > substring(@ymd_stock,1,6)+'00'
                and ymd_buy < @ymd_stock

	select @stock3 = sum(isnull(a.qty_sale,0))
	  from sl_sale_d a, sl_sale_h b
	 where a.cd_store = b.cd_store
	     and a.ymd_sale = b.ymd_sale
	     and a.no_pos    = b.no_pos
	     and a.no_rcp     = b.no_rcp 
	     and b.ds_sale    <> 'V'
	     and a.cd_store =@cd_store
	     and a.cd_menu = @cd_menu
	     and a.ymd_sale > substring(@ymd_stock,1,6)+'00'
                  and a.ymd_sale < @ymd_stock
	
    set @stock1 = isnull(@stock1,0)
    set @stock2 = isnull(@stock2,0)
    set @stock3 = isnull(@stock3,0)
    return ( @stock1 + @stock2 - @stock3 )
END



























GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE FUNCTION GetNowStock
( @cd_store varchar(4),
  @cd_goods varchar(20),
  @ymd_stock varchar(8))
RETURNS int AS  
BEGIN 
	declare @stock1   int
	declare @stock2   int
	declare @stock3   int

	select @stock1 = isnull(qty_base,0)
	  from sl_stock_month
	 where cd_store =@cd_store
	   and cd_menu = @cd_goods
	   and ym_stock = substring(@ymd_stock,1,6)

	select @stock2 = sum(isnull(qty_buy,0))
	  from sl_buy_d
	 where cd_store =@cd_store
	   and cd_goods = @cd_goods
	   and ymd_buy > substring(@ymd_stock,1,6)+'00'
                and ymd_buy <= @ymd_stock

	select @stock3 = sum(t.sale_stock)
	   from
	        (
		select sum(isnull(qty_sale,0)) as sale_stock
		  from sl_sale_d a, ms_goods b, sl_sale_h c
		where a.cd_store = b.cd_store 
		    and a.cd_menu = b.cd_menu
	                 and a.cd_store   = c.cd_store
	                 and a.ymd_sale  = c.ymd_sale
		    and a.no_pos     = c.no_pos
		    and a.no_rcp      = c.no_rcp
		    and c.ds_sale     <> 'V'
		   and a.cd_store =@cd_store
		   and b.cd_menu = @cd_goods
		   and a.ymd_sale > substring(@ymd_stock,1,6)+'00'
	                and a.ymd_sale <= @ymd_stock
		) t
	

    set @stock1 		= isnull(@stock1,0)
    set @stock2 		= isnull(@stock2,0)
    set @stock3 		= isnull(@stock3,0)

	
    return ( @stock1 + @stock2 - @stock3 )
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SELECT_SUBUL]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[SELECT_SUBUL]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO



/******************************************************************
* goal           : 상품별 수불현황
* create by   : 김환준
* create date : 2007/3/27
* used form   : AG010SM
******************************************************************/
CREATE PROCEDURE SELECT_SUBUL
 	@cd_store	VARCHAR(4),		--점포코드
	@fromdate	VARCHAR(8),
	@todate	varchar(8)

	
AS
BEGIN
	select dbo.GetCommonName(t1.cd_store, '21', t1.stock_class) as stock_class, 
	           isnull(t2.nm_trdpl,'') as nm_trdpl,
	           t1.cd_menu, t1.nm_menu, t1.nm_unit, dbo.GetBeforStock(t1.cd_store, t1.cd_menu, @fromdate) as qty_bef,
	           isnull(t3.qty_buy,0) as qty_buy, 
	           isnull(t5.qty_buy,0) as qty_buy_b, 
	           isnull(t4.qty_sale,0) as qty_sale,
	           isnull(t6.qty_sale,0) as qty_sale_b,
	           dbo.GetBeforStock(t1.cd_store, t1.cd_menu, @fromdate) + isnull(t3.qty_buy,0)- isnull(t5.qty_buy,0)-isnull(t4.qty_sale,0)+isnull(t6.qty_sale,0)  as qty_curr
	   from ms_menu t1,
	           ms_trd t2,
	(select cd_store, cd_goods as cd_menu, sum(qty_buy) as qty_buy
	   from sl_buy_d
	where ymd_buy between @fromdate and @todate and qty_buy > 0
	group by cd_store, cd_goods) t3,
	(select a.cd_store, a.cd_menu, sum(a.qty_sale) as qty_sale
	   from sl_sale_d a, sl_sale_h b
	where a.cd_store = b.cd_store
	    and a.ymd_sale = b.ymd_sale
	    and a.no_pos    = b.no_pos
	    and a.no_rcp    = b.no_rcp
	    and b.ds_sale   <> 'V'
	    and a.ymd_sale between @fromdate and @todate and a.qty_sale > 0
	group by a.cd_store, a.cd_menu) t4,
	(select cd_store, cd_goods as cd_menu, sum(qty_buy) as qty_buy
	   from sl_buy_d
	where ymd_buy between @fromdate and @todate and qty_buy < 0
	group by cd_store, cd_goods) t5,
	(select a.cd_store, a.cd_menu, sum(a.qty_sale) as qty_sale
	   from sl_sale_d a, sl_sale_h b
	where a.cd_store = b.cd_store
	    and a.ymd_sale = b.ymd_sale
	    and a.no_pos    = b.no_pos
	    and a.no_rcp    = b.no_rcp
	    and b.ds_sale   <> 'V'
	    and a.ymd_sale between @fromdate and @todate and a.qty_sale < 0
	group by a.cd_store, a.cd_menu) t6
	
	where t1.cd_store *= t2.cd_store
	    and t1.cd_trdpl *= t2.cd_trdpl
	    and t1.cd_store *= t3.cd_store
	    and t1.cd_menu *= t3.cd_menu
	    and t1.cd_store *= t4.cd_store
	    and t1.cd_menu *= t4.cd_menu
	    and t1.cd_store *= t5.cd_store
	    and t1.cd_menu *= t5.cd_menu
	    and t1.cd_store *= t6.cd_store
	    and t1.cd_menu *= t6.cd_menu
                 and t1.yn_use    = 'Y'
	    and t1.ds_stock = '1'
	    and t1.cd_store = @cd_store

END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SAVE_STOCK_CLOSE]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[SAVE_STOCK_CLOSE]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


CREATE PROCEDURE SAVE_STOCK_CLOSE
	@CD_STORE 		VARCHAR(4),		--점포코드
	@NEXT_CLOSE	VARCHAR(6), 		--마감다음월
	@CURR_CLOSE	VARCHAR(6)		--마감월

AS
BEGIN
	--임시테이블에 월 기초재고를 옮겨놓는다
	delete sl_stock_tmp 

	insert into sl_stock_tmp (cd_store, ym_stock, cd_menu, qty_base)
	  select cd_store, ym_stock, cd_menu, qty_base from sl_stock_month where cd_store =@cd_store and ym_stock =@curr_close


	delete sl_stock_month where cd_store =@cd_store and ym_stock = @curr_close

	insert into sl_stock_month ( cd_store, ym_stock, yn_close, cd_menu, qty_base, qty_in, qty_out, qty_silsa, qty_adj)
	select  a.cd_store, @curr_close, 'Y', a.cd_menu, isnull(e.qty_base,0), isnull(b.qty_buy,0), isnull(c.qty_sale,0), d.qty_silsa, isnull(d.qty_settle,0)
	   from ms_menu a,
	          (select cd_store, cd_goods as cd_menu, sum(isnull(qty_buy,0)) as qty_buy
	              from sl_buy_d
	           where substring(ymd_buy,1,6) = @curr_close
	            group by cd_store, cd_goods
	          ) b,
	          (select a.cd_store, a.cd_menu, sum(a.qty_sale) as qty_sale
		   from sl_sale_d a, sl_sale_h b
		where a.cd_store = b.cd_store
		    and a.ymd_sale = b.ymd_sale
		    and a.no_pos    = b.no_pos
		    and a.no_rcp    = b.no_rcp
		    and b.ds_sale   <> 'V'
		    and substring(a.ymd_sale,1,6) = @curr_close
		group by a.cd_store, a.cd_menu
	          ) c,
	          (select cd_store, cd_menu, qty_silsa, isnull(qty_settle,0) qty_settle
	              from sl_silsa
	           where ym_silsa = @curr_close
	          ) d,
	          sl_stock_tmp e
	where a.cd_store *= b.cd_store
	    and a.cd_menu *= b.cd_menu
	    and a.cd_store *= c.cd_store
	    and a.cd_menu *= c.cd_menu
	    and a.cd_store *= c.cd_store
	    and a.cd_menu *= d.cd_menu
                 and a.cd_menu *= e.cd_menu
	    and a.ds_stock  = '1'
                       and a.yn_use    = 'Y'
	    and a.cd_store  =@cd_store


	--다음월의 기초재고를 입력한다
	delete sl_stock_month where cd_store =@cd_store and ym_stock = @next_close

	insert into sl_stock_month ( cd_store, ym_stock, cd_menu, qty_base)
	select  a.cd_store, @next_close,  a.cd_menu, b.qty_stock
	   from ms_menu a,
	          sl_stock_month b
	where a.cd_store *= b.cd_store
	    and a.cd_menu *= b.cd_menu
	    and b.ym_stock = @curr_close
	    and a.ds_stock  = '1'
	    and a.cd_store  =@cd_store



END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SELECT_DISCOUNT]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[SELECT_DISCOUNT]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO





/* 할인내역 조회 프로시져 */

CREATE PROCEDURE [dbo].[SELECT_DISCOUNT]
	@CD_STORE	VARCHAR(4),
	@NO_POS	VARCHAR(2),
	@YMD_FROM	VARCHAR(8),
	@YMD_TO	VARCHAR(8),
	@CD_SAWON	VARCHAR(6),
	@NO_CLOSE	VARCHAR(1)
AS
BEGIN

	select t1.ymd_sale, t1.name, t1.cnt, amount
	  from
	(
	select dbo.stod(a.ymd_sale) as ymd_sale, b.nm_code1 as name, sum(case when a.dc_code <> 0 then 1 else 0 end)  as cnt, sum(a.dc_code) as amount
	  from sl_sale_h a, ms_code b
	 where a.cd_store = b.cd_store
	   and b.cd_kind  = '07'
	   and a.cd_code  = b.cd_code
	   and a.ds_sale  <> 'V'
	   and a.cd_store = @CD_STORE
	   and a.ymd_sale between @YMD_FROM and @YMD_TO
	   and a.no_pos like @no_pos + '%'
	    and a.cd_sawon like @cd_sawon +'%'
	    and a.no_close   like @no_close +'%'
	group by a.ymd_sale, b.nm_code1
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '영수증할인' as name,  sum(case when dc_receipt <> 0 then 1 else 0 end) as cnt, sum(dc_receipt) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '메뉴할인' as name, sum(case when dc_menu <> 0 then 1 else 0 end)  as cnt,  sum(dc_menu) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '행사할인' as name, sum(case when dc_spc <> 0 then 1 else 0 end)  as cnt, sum(dc_spc) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '회원할인' as name,  sum(case when dc_member <> 0 then 1 else 0 end)  as cnt, sum(dc_member) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '쿠폰할인' as name,  sum(case when dc_coupon <> 0 then 1 else 0 end)  as cnt, sum(dc_coupon) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '부가세할인' as name,  sum(case when dc_vat <> 0 then 1 else 0 end)  as cnt, sum(dc_vat) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	union all
	select dbo.stod(ymd_sale) as ymd_sale, '단차할인' as name,  sum(case when dc_cut <> 0 then 1 else 0 end)  as cnt, sum(dc_cut) as amount
	  from sl_sale_h 
	 where cd_store = @CD_STORE
	   and ymd_sale between @YMD_FROM and @YMD_TO
	   and ds_sale  <> 'V'
	   and no_pos like @no_pos + '%'
	   and cd_sawon like @cd_sawon +'%'
	   and no_close   like @no_close +'%'
	 group by ymd_sale
	) t1
	where t1.amount > 0
	END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[POS_SAVE_CASHIER_MGM]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[POS_SAVE_CASHIER_MGM]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO












CREATE  PROCEDURE POS_SAVE_CASHIER_MGM

	@CD_STORE 	    		VARCHAR(4),
	@YMD_CLOSE			VARCHAR(8),
	@NO_POS			VARCHAR(2),
	@CD_SAWON			VARCHAR(6),
	@AMT_ACCT_IN		INT,
	@AMT_ACCT_OUT		INT,
	@AMT_SALE			INT,
	@AMT_TAX			INT,
	@AMT_CASH			INT,
	@AMT_CARD			INT,
	@AMT_CHECK			INT,
	@AMT_TRUST			INT,
	@AMT_GIFT			INT,
	@AMT_POINT			INT,
	@AMT_LOSS			INT,
	@DC_MENU			INT,
	@DC_CODE			INT,
	@DC_RECEIPT			INT,
	@DC_MEMBER			INT,
	@DC_ENURI			INT,
	@DC_SPC			INT,
	@DC_COUPON			INT,
	@DC_CUT			INT,
	@DC_VAT			INT,
	@AMT_VOID			INT,
	@CNT_CUSTOMER		INT,
	@AMT_AVERAGE		INT,
	@AMT_LACK			INT,
	@AMT_CASHRCP		INT,
	@RCP_BEGIN			VARCHAR(4),
	@RCP_END			VARCHAR(4),
	@_CHECK			INT,
	@_10000			INT,
	@_5000			INT,
	@_1000			INT,
	@_500				INT,
	@_100				INT,
	@_50				INT,
	@_10				INT,
	@SEQ				INT OUTPUT
AS
BEGIN
	
	DECLARE @CNT INT

	SELECT @SEQ =ISNULL(MAX(SEQ),	(SELECT ISNULL(MAX(SEQ),0)+1
						   FROM SL_CASHIER_MGM
						WHERE CD_STORE 	=@CD_STORE
						      AND YMD_CLOSE	=@YMD_CLOSE
						      AND NO_POS	=@NO_POS
						      AND CD_SAWON	=@CD_SAWON
						      AND YN_CLOSE	='Y'
				)
			)
	  FROM SL_CASHIER_MGM 
	 WHERE CD_STORE 	=@CD_STORE
	   AND YMD_CLOSE	=@YMD_CLOSE
	   AND NO_POS		=@NO_POS
	   AND CD_SAWON	=@CD_SAWON
	   AND YN_CLOSE = 'N' 

	SELECT @CNT= COUNT(*)
	   FROM SL_CASHIER_MGM
	WHERE CD_STORE 	=@CD_STORE
	      AND YMD_CLOSE	=@YMD_CLOSE
	      AND NO_POS	=@NO_POS
	      AND CD_SAWON	=@CD_SAWON
	      AND SEQ		=@SEQ

	IF @CNT = 0
	BEGIN

	
		INSERT INTO SL_CASHIER_MGM(
							CD_STORE		,
							YMD_CLOSE		,
							NO_POS		,
							CD_SAWON		,
							SEQ			,
							AMT_ACCT_IN		,
							AMT_ACCT_OUT	,
							AMT_SALE		,
							AMT_TAX		,
							AMT_CASH		,
							AMT_CARD		,
							AMT_CHECK		,
							AMT_TRUST		,
							AMT_GIFT		,
							AMT_POINT		,
							AMT_LOSS		,
							DC_MENU		,
							DC_CODE		,
							DC_RECEIPT		,
							DC_MEMBER		,
							DC_ENURI		,
							DC_SPC		,
							DC_COUPON		,
							DC_CUT		,
							DC_VAT		,
							AMT_VOID		,
							CNT_CUSTOMER	,
							AMT_AVERAGE	,
							AMT_LACK		,
							AMT_CASHRCP	,
							RCP_BEGIN		,
							RCP_END		,
							_CHECK,
							_10000,
							_5000,
							_1000,
							_500,
							_100,
							_50,
							_10,
							YN_CLOSE		
						)
					VALUES
						(
							 @CD_STORE		,
							 @YMD_CLOSE		,
							 @NO_POS		,
							 @CD_SAWON		,
							 @SEQ			,
							 @AMT_ACCT_IN	,
							 @AMT_ACCT_OUT	,
							 @AMT_SALE		,
							 @AMT_TAX		,
							 @AMT_CASH		,
							 @AMT_CARD		,
							 @AMT_CHECK		,
							 @AMT_TRUST	,
							 @AMT_GIFT		,
							 @AMT_POINT		,
							 @AMT_LOSS		,
							 @DC_MENU		,
							 @DC_CODE		,
							 @DC_RECEIPT	,
							 @DC_MEMBER	,
							 @DC_ENURI		,
							 @DC_SPC		,
							 @DC_COUPON	,
							 @DC_CUT		,
							 @DC_VAT		,
							 @AMT_VOID		,
							 @CNT_CUSTOMER	,
							 @AMT_AVERAGE	,
							 @AMT_LACK		,
							 @AMT_CASHRCP	,
							 @RCP_BEGIN		,
							 @RCP_END		,
							 @_CHECK,
							 @_10000,
							 @_5000,
							 @_1000,
							 @_500,
							 @_100,
							 @_50,
							 @_10,
							 'Y'
						)
	END
	ELSE
	BEGIN
		UPDATE SL_CASHIER_MGM SET 
							
						AMT_SALE	 	=@AMT_SALE		,
						AMT_TAX		=@AMT_TAX		,
						AMT_CASH		=@AMT_CASH		,
						AMT_CARD	 	=@AMT_CARD		,
						AMT_CHECK	 	=@AMT_CHECK	,
						AMT_TRUST	 	=@AMT_TRUST	,
						AMT_GIFT	 	=@AMT_GIFT		,
						AMT_POINT	 	=@AMT_POINT		,
						AMT_LOSS	 	=@AMT_LOSS		,
						DC_MENU	 	=@DC_MENU		,
						DC_CODE	 	=@DC_CODE		,
						DC_RECEIPT	 	=@DC_RECEIPT	,
						DC_MEMBER	 	=@DC_MEMBER	,
						DC_ENURI	 	=@DC_ENURI		,
						DC_SPC	 	=@DC_SPC		,
						DC_COUPON		=@DC_COUPON		,
						DC_CUT		=@DC_CUT		,
						DC_VAT		=@DC_VAT		,
						AMT_VOID	 	=@AMT_VOID		,
						CNT_CUSTOMER	=@CNT_CUSTOMER	,
						AMT_AVERAGE	=@AMT_AVERAGE	,
						AMT_LACK		=@AMT_LACK		,
						AMT_CASHRCP	=@AMT_CASHRCP	,
						RCP_BEGIN	 	=@RCP_BEGIN		,
						RCP_END	 	=@RCP_END		,
						_CHECK		=@_CHECK		,
						_10000			=@_10000		,
						_5000			=@_5000		,
						_1000			=@_1000		,
						_500			=@_500		,
						_100			=@_100		,
						_50			=@_50			,
						_10			=@_10			,
						DT_CHANGE		=GETDATE()		,
						YN_CLOSE		= 'Y'
			WHERE CD_STORE 	=@CD_STORE
			      AND YMD_CLOSE	=@YMD_CLOSE
			      AND NO_POS	=@NO_POS
			      AND CD_SAWON	=@CD_SAWON
			      AND SEQ		=@SEQ
	END

	--매출헤더에 계산원마감 번호 셋팅
	UPDATE SL_SALE_H SET NO_CLOSE = @SEQ
	WHERE CD_STORE	=@CD_STORE	
	      AND YMD_SALE	=@YMD_CLOSE
	      AND NO_POS	=@NO_POS
	      AND CD_SAWON	=@CD_SAWON
	      AND NO_CLOSE	=0

	--현금출납에 계산원마감 번호 셋팅
	UPDATE SL_ACCT SET NO_CLOSE = @SEQ
	WHERE CD_STORE		=@CD_STORE	
	      AND YMD_OCCUR		=@YMD_CLOSE
	      AND NO_POS		=@NO_POS
	      AND CD_SAWON_CHG	=@CD_SAWON
	      AND NO_CLOSE		=0
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

