BEG QTY ALL SCHEMA

This commit is contained in:
benz 2026-01-27 09:44:48 +08:00
parent d562071717
commit a07ad39ea7
5 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,14 @@
use powerpos
go
alter table beg_inventory drop column beq_qty
go
alter table beg_inventory add beg_qty decimal(18,2)
go
alter table delivery drop column dr_type
go
alter table delivery add dr_type varchar(50) default 'RECEIVING'
go

Binary file not shown.

View File

@ -0,0 +1,91 @@
USE POWERPOS
GO
/****** Object: StoredProcedure [dbo].[sp_insert_begbal_todate] Script Date: 01/21/2026 9:56:36 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
DROP PROCEDURE sp_insert_begbal_todate
go
--exec sp_insert_begbal_todate '1/4/2026','PASIG001','PASIG001'
CREATE PROCEDURE [dbo].[sp_insert_begbal_todate]
-- Add the parameters for the stored procedure here
@dDate datetime,
@cStoreid varchar(50),
@cMachine varchar(50)
AS
BEGIN
--PASIG001
--PASIG001
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
exec sp_update_stock_inventory
exec sp_update_stock_inventory_carcass
--insert parent items to beg_inventory
delete from beg_inventory
where trans_date = @ddate
--trans_type = 1 - for items in items table
--trans_type = 2 - for items(carcass) in delivery table
insert into beg_inventory(
trans_date,
itemcode,
itemname,
beg_qty, --ending_balance
machine_id,
store_id,
trans_type,
ref_no)
select
@ddate,
a.itemcode,
a.itemname,
isnull(a.end_qty,0),
@cMachine,
@cStoreid,
1,
''
from items a
where isnull(is_parent,0) =0
and isnull(end_qty,0) >0 and end_qty != isnull((select beg_qty from beg_inventory z where z.store_id = @cStoreid and z.itemcode = a.itemcode and z.posted = 0 and z.trans_date = @dDate),0)
--union all
--select
--@ddate,
--a.itemcode,
--a.itemname,
--a.end_qty,
--@cMachine,
--@cStoreid,
--2,
--ref_no
--from delivery a
--where a.is_parent =1
--and dr_type = 'RECEIVING'
END
GO

Binary file not shown.

View File

@ -0,0 +1,48 @@
USE POWERPOS
GO
/****** Object: StoredProcedure [dbo].[sp_update_stock_inventory_carcass] Script Date: 01/22/2026 8:55:38 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
DROP PROCEDURE sp_update_stock_inventory_carcass
GO
CREATE PROCEDURE [dbo].[sp_update_stock_inventory_carcass]
as
BEGIN
SET NOCOUNT ON;
--reset balances
update delivery
set qty_in =0,qty_out=0,end_qty=0
update delivery set qty_out = (select isnull(sum(a.qty),0) from cuts_history a
where a.parent_code= delivery.itemcode
and a.source_batch = delivery.ref_no)
--from delivery, cuts_history
--where delivery.itemcode = cuts_history.parent_code
--and delivery.ref_no = cuts_history.parent_batch
update delivery
set end_qty = isnull(qty,0) - isnull(qty_out,0)
END
GO