Академический Документы
Профессиональный Документы
Культура Документы
GO
/****** Object: StoredProcedure [dbo].[SBO_SP_TransactionNotification] Script Date:
9/3/2018 6:23:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[SBO_SP_TransactionNotification]
AS
begin
-- Return values
declare @error int -- Result (0 for no error)
declare @error_message nvarchar (200) -- Error string to be displayed
select @error = 0
select @error_message = N'Ok'
Declare @Result AS INT
Declare @code AS nvarchar(20)
-----------------------------------------------------------------------------------------
---------------------------------------
-----Query Manager Remove Message--------
IF @object_type='160' and @transaction_type=N'D'
Begin
END
end
---------------------------------------Warehouse Details----------
IF @object_type='64' and @transaction_type IN (N'U')
Begin
END
------------------------------- Production Order Validation----------------------
IF @object_type='202' and @transaction_type IN (N'A',N'U')
Begin
-- Item Validation
--select @Error=2021, @error_message = 'Item Not Exits in BOM...'+ ItemCode from WOR1
--where ItemCode not in (select Code from ITT1 a,OWOR b where a.Father=b.ItemCode
--and b.DocEntry=@list_of_cols_val_tab_del
--union all
--select U_itemid from [@FAST_PROD_BOM_D0] a,OWOR b where a.U_masterid=b.ItemCode
--and b.DocEntry=@list_of_cols_val_tab_del )
--and DocEntry=@list_of_cols_val_tab_del
-----------------------------------------------------------------------------
End
--if exists(SELECT
T0.DOCENTRY,T0.DOCNUM,T0.ITEMCODE,T1.U_NEWSEQ,T1.U_OPERID,T2.U_MNO,ISNULL(T2.OutQtyRT,0.0
00000) OutQtyRT FROM [dbo].[OWOR] T0
--INNER JOIN [@INM_WOR2] T1 ON T0.DOCENTRY=T1.CODE
--LEFT OUTER JOIN (SELECT T0.DOCNUM,T0.U_DocDate,T0.U_ItemCode,T0.U_Active,T1.Lineid
OperLine,T1.U_OperID,T1.U_Operaton,T1.U_PTS
--,T2.U_mno, ISNULL(T2.OutQtyRT,0.000000) OutQtyRT FROM [dbo].[@INM_OCRM] T0
--INNER JOIN [dbo].[@INM_CRM1] T1 ON T0.DocEntry=T1.DocEntry
--LEFT OUTER JOIN
--(SELECT DOCENTRY,U_UNIQID,U_MNO,ISNULL(U_OutQtyRT,0.000000) OutQtyRT FROM
[dbo].[@INM_CRM2] WHERE ISNULL(U_MNO,'')!=''
--AND U_SELECTED='Y' AND U_Usage='R' AND ISNULL(U_OutQtyRT,0.000000)=0.000000
--) T2 ON T1.DocEntry=T2.DocEntry AND T1.LineId=T2.U_UniqID
--WHERE T1.U_OperID NOT IN ('PACKING') AND T1.U_OperID IS NOT NULL AND T1.U_PTS='Y'
-- AND ISNULL(T2.OutQtyRT,0.000000)=0.000000 AND T0.U_ACTIVE='Y') T2 ON
T0.ITEMCODE=T2.U_ITEMCODE AND T1.U_OPERID=T2.U_OPERID
--WHERE T1.U_PTS='Y' and T1.U_OperID NOT IN ('PACKING') AND T1.U_OperID IS NOT NULL and
T0.docentry=@list_of_cols_val_tab_del)
--BEGIN
--DECLARE @OPER NVARCHAR(150),@MAC NVARCHAR(250)
--SELECT @OPER=T1.U_OPERID,@MAC=CASE WHEN ISNULL(T2.U_MNO,'')='' THEN 'Kindly Link
Machine Details On CRM' ELSE
--'For Machine No:'+T2.U_MNO+' Enter Qty.Per.Hr Details On CRM Master' end FROM
[dbo].[OWOR] T0
--INNER JOIN [@INM_WOR2] T1 ON T0.DOCENTRY=T1.CODE
--LEFT OUTER JOIN (SELECT T0.DOCNUM,T0.U_DocDate,T0.U_ItemCode,T0.U_Active,T1.Lineid
OperLine,T1.U_OperID,T1.U_Operaton,T1.U_PTS
--,T2.U_mno, ISNULL(T2.OutQtyRT,0.000000) OutQtyRT FROM [dbo].[@INM_OCRM] T0
--INNER JOIN [dbo].[@INM_CRM1] T1 ON T0.DocEntry=T1.DocEntry
--LEFT OUTER JOIN
--(SELECT DOCENTRY,U_UNIQID,U_MNO,ISNULL(U_OutQtyRT,0.000000) OutQtyRT FROM
[dbo].[@INM_CRM2] WHERE ISNULL(U_MNO,'')!=''
--AND U_SELECTED='Y' AND U_Usage='R' AND ISNULL(U_OutQtyRT,0.000000)=0.000000
--) T2 ON T1.DocEntry=T2.DocEntry AND T1.LineId=T2.U_UniqID
--WHERE T1.U_OperID NOT IN ('PACKING') AND T1.U_OperID IS NOT NULL AND T1.U_PTS='Y'
-- AND ISNULL(T2.OutQtyRT,0.000000)=0.000000 AND T0.U_ACTIVE='Y') T2 ON
T0.ITEMCODE=T2.U_ITEMCODE AND T1.U_OPERID=T2.U_OPERID
--WHERE T1.U_PTS='Y' and T1.U_OperID NOT IN ('PACKING') AND T1.U_OperID IS NOT NULL and
T0.docentry=@list_of_cols_val_tab_del
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
BEGIN
IF @Result <> 0
BEGIN
IF @Result <> 0
---------------------------------- RDC-------------------------
BEGIN
IF @Result <> 0
BEGIN
IF @Result <> 0
BEGIN
IF @Result <> 0
BEGIN
EXEC @Result = [dbo].[@INSPL_Subcontract_TN_SubcontractingBOM]
@list_of_cols_val_tab_del
IF @Result <> 0
BEGIN
IF @Result <> 0
BEGIN
IF @Result <> 0
--------------------------------- DC Advise-------------------------
BEGIN
IF @Result <> 0
BEGIN
BEGIN
IF @Result <> 0
--------------------------------- JO Amendment------------------------
BEGIN
IF @Result <> 0
IF @Result <> 0
SELECT @error = U_ErrorCode , @error_message = U_ErrorName FROM OADM
END
END
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
END
BEGIN
end
BEGIN
if exists( select a.docentry from [@INM_ORSE] a inner join [@INM_RSE1] b on
a.docentry=b.docentry
left join OUSR c on a.UserSign=c.USERID
where a.u_type='SR'
and (a.series=3711)
and a.U_FromWhs in ('RY-CUST')
and c.USERID not in ('33','39','1','102')
and a.DocEntry=@list_of_cols_val_tab_del)
SELECT @Error=100,@error_message = 'You have not permission to make Sales Return Entry'
--BEGIN
--Set @Basetype=(Select U_Type From [@inm_orse] Where DocEntry=@list_of_cols_val_tab_del)
--Set @code=(
--select top 1 aa.cardcode from (select a.cardcode,A.DocEntry,c.U_SREntry,c.U_ItemCode
from ordn a inner join rdn1 b on a.docentry=b.docentry
--LEFT JOIN [@INM_ORSE] C ON A.DOCENTRY=C.U_SREntry and b.itemcode=c.U_ItemCode
--and c.docentry<>@list_of_cols_val_tab_del
--where B.whscode in ('J-RWS-C','RY-CUST')
--and a.docdate>='01-DEC-17'
--and datediff(dd,a.DocDate,getdate())>2) aa
--where (isnull(aa.u_srentry,0)=0 or isnull(aa.u_itemcode,'')=''))
--if exists (select A.DocEntry from [@INM_ORSE] a where a.u_itemcode is not null
--and isnull(a.U_RejQty,0)>0
-- and @Basetype<>'SR'
-- and isnull(@code,'')<>''
-- and a.DocEntry=@list_of_cols_val_tab_del)
-- SELECT @Error=10,@error_message = 'Sales Return are pending for Rejectio Salvage '
--END
BEGIN
if exists(SELECT
A.DOCNUM,A.U_DocDt,A.U_Type,A.U_ItemCode,A.U_RejQty,A.U_ActWgt,SUM(B.U_ScrQty) U_ScrQty
,SUM(B.U_Weight) U_Weight,SUM(B.U_TotalWgt) U_TotalWgt,A.U_ProdApp,A.U_QCApp,A.U_StrApp
FROM [dbo].[@INM_ORSE] A
INNER JOIN [dbo].[@INM_RSE1] B ON A.DOCENTRY=B.DocEntry
WHERE B.U_ScrQty<>0 AND isnull(A.U_ActWgt,0.000000)=0 and
a.DocEntry=@list_of_cols_val_tab_del
GROUP BY
A.DOCNUM,A.U_DocDt,A.U_Type,A.U_ItemCode,A.U_RejQty,A.U_ActWgt,A.U_ProdApp,A.U_QCApp,A.U_
StrApp)
SELECT @Error=20 , @error_message = 'Kindly Enter Physical Weight....'
end
BEGIN
Set @Basetype=(Select U_Type From [@inm_orse] Where DocEntry=@list_of_cols_val_tab_del)
if exists (select A.DocEntry from [@INM_ORSE] a where a.U_DocDt>='20171101'
and a.u_itemcode is not null
and isnull(a.U_RejQty,0)>0
and (isnull(a.U_StrApp,'')='No' or ISNULL(a.U_ProdApp,'')='No' or
ISNULL(a.U_QCApp,'')='No' )
and datediff(dd,a.U_docdt,getdate())>2
and @Basetype<>'DA'
and a.DocEntry<>@list_of_cols_val_tab_del
)
SELECT @Error=10,@error_message = 'Rej. Documents are pending for Approval for last 2
days. Pls Chk QM-Pending Transaction --Pending Stock Posting - Rejection/Salvage ver2.0'
END
END
END
BEGIN
BEGIN
IF EXISTS (select a.DocEntry from oige a inner join ige1 b on a.docentry=b.docentry
where isnull(b.u_baseentry,'')<>''
and isnull(b.u_basetype,'')=''
end
IF @Result <> 0
END
BEGIN
BEGIN
IF EXISTS (select a.DocEntry from oign a inner join ign1 b on a.docentry=b.docentry
where isnull(b.u_baseentry,'')<>''
and isnull(b.u_basetype,'')=''
end
IF @Result <> 0
BEGIN
BEGIN
IF EXISTS (select a.DocEntry from OWTR a inner join WTR1 b on a.docentry=b.docentry
where isnull(b.u_baseentry,'')<>''
and isnull(b.u_basetype,'')=''
end
IF @Result <> 0
END
BEGIN
if exists(SELECT a.DocEntry FROM OWTR A INNER JOIN WTR1 B ON A.DOCENTRY=B.DOCENTRY
INNER JOIN
(select a.DocEntry,a.itemcode,b.SysNumber,c.DistNumber from oitl a inner join itl1 b on
a.LogEntry=b.logentry
inner join osrn c on a.itemcode=c.itemcode and b.SysNumber=c.SysNumber
where a.itemcode=b.ItemCode
and a.doctype='67') C ON a.docentry=c.DocEntry and b.itemcode=c.ItemCode
begin
declare @SERIALNO NVARCHAR (30),@ITEMCOD2 NVARCHAR (100)
begin
-------------------------------- GRPO-------------------------
IF @object_type = '20' and @transaction_type IN (N'A',N'U')
BEGIN
EXEC @Result = [dbo].[@INSPL_Purchase_TN_GoodsReceiptPO]
@list_of_cols_val_tab_del
IF @Result <> 0
SELECT @error = U_ErrorCode , @error_message = U_ErrorName FROM OADM
END
end
end
end
end
end
end
end
end
end
SELECT @error=1050, @error_message = 'Please contact manager. You dont have permission
Modify the Item Approval Stage'
SELECT @error=1050, @error_message = 'Please contact manager. You dont have permission
Modify the Active/Inactive'
SELECT @error=1052, @error_message = 'Please contact manager. You dont have permission
Modify the Active/Inactive'
SELECT @error=1050, @error_message = 'Please contact manager. You dont have permission
Modify the GST/HSN'
SELECT @error=1050, @error_message = 'Please contact manager. You dont have permission
Modify the GST/HSN'
end
end
end
end
end
end
IF @object_type='30' and @transaction_type IN (N'A',N'U')
Begin
end
--end
BEGIN
IF @Result <> 0
END
End
end
SELECT @Error = 2003 , @error_message ='PO Date For the PO No:'+@pono+' is '+@podate+'
you cant add GRPO Today'
end
end
end
--begin
--Select @error = -121, @error_message = 'Credit memo qty shouldnt be greater than
rejection qty'
--end
--end
--begin
--Select @error = -121, @error_message = 'Credit memo amount should not be greater than
rejection amt'
--end
--END
end
-------After Eway Bill All Locations Considered Delivery Type as Direct So Disable this
Below Control----------
----------------------------------------------------------------------------------------
end
end
-------After Eway Bill All Locations Considered Delivery Type as Direct So Disable this
Below Control----------
-----------------------------------------------------------------------------------------
----
if exists(select a.docentry,b.price,c.price from odln a inner join dln1 b on
a.docentry=b.docentry
inner join rdr1 c on b.baseentry=c.docentry and b.baseline=c.linenum and b.basetype=17
where a.doctype='I'
and isnull(b.price,0)<>isnull(c.price,0)
and a.DocEntry=@list_of_cols_val_tab_del )
SELECT @Error=1505, @error_message = 'Delivery and Sales Order Price Mismatching'
end
-------After Eway Bill All Locations Considered Delivery Type as Direct So Disable this
Below Control----------
end
end
end
end
BEGIN
IF @Result <> 0
END
BEGIN
IF @Result <> 0
END
SELECT @Error=1721, @error_message = 'Please add the item into Price List'
end
-----------------------------Meharaj----------------------
IF @object_type='15' and @transaction_type IN (N'A',N'U')
Begin
SET @error=6601
SET @error_message = 'Please Enter Weight for '+@ITEM+' in Item Master first...'
End
End
SET @error=6603
SET @error_message = @SCRITEM+' is a ScrapItem You cant add as a BOM Child...'
End
End
-- Item Master Scrap Item OITT
IF @transaction_type IN (N'A') AND (@Object_type = N'66')
BEGIN
If Exists (select A.ScrapItem,B.Code from
(SELECT DISTINCT U_ScrapItem ScrapItem FROM [dbo].[OITM] B WHERE
ISNULL(B.U_ScrapItem,'')!='') A
INNER JOIN [dbo].[OITT] B ON A.ScrapItem=B.Code
WHERE B.Code=@list_of_cols_val_tab_del)
begin
SET @error=6604
SET @error_message = @list_of_cols_val_tab_del+' is a ScrapItem You cant add as a BOM
Father...'
End
End
--------Approval template------
IF @transaction_type IN (N'A','U') AND (@Object_type = N'ATP')
BEGIN
IF EXISTS (SELECT A.CODE,a.Object,A.U_Name,b.U_OrgName,C.firstName,C.lastName FROM
[dbo].[@INIA_OATP] A
INNER JOIN [dbo].[@INIA_ATP1] b on a.code=b.Code
LEFT OUTER JOIN [dbo].[OHEM] C ON B.U_UserId=C.userId
WHERE A.U_Active='Y' AND C.empID IS NULL AND a.Code =@list_of_cols_val_tab_del)
BEGIN
DECLARE @USR NVARCHAR(250)
SET @USR=(SELECT TOP 1 b.U_OrgName FROM [dbo].[@INIA_OATP] A
INNER JOIN [dbo].[@INIA_ATP1] b on a.code=b.Code
LEFT OUTER JOIN [dbo].[OHEM] C ON B.U_UserId=C.userId
WHERE A.U_Active='Y' AND C.empID IS NULL AND a.DocEntry =@list_of_cols_val_tab_del)
SET @error=1050
SET @error_message = @USR+' User Not Linked With Employee Master...'
End
End
SET @error=1050
SET @error_message = 'Inventory revaluation cant be done when stock is zero'
END
--SET @error=1050
--SET @error_message = 'Payment shold be deducted for Rejection Qty '
--END
SELECT @Error=1721, @error_message = 'Price is not matching with price list price'
end
--------------- meharaj comment the control 26-10-2016 19:00---------
-------------------------------- Draft Validation-------------------------
--IF @object_type = '112' and @transaction_type IN (N'A',N'U')
--BEGIN
--SET @error=1050
--SET @error_message = 'Please select Document type as service or select correct series'
--END
end
SELECT @Error=1721, @error_message = 'Please add the item into Price List'
SELECT @Error=1721, @error_message = 'Price is not matching with price list price'
-----------------------------------------------------------------------------------------
---------
--SET @error=1050
--SET @error_message = 'Already Draftis raised for this Invoice'
--where a.u_type='S'
----AND a.U_GRNNo=1002946
--group by a.U_GRNEntry ,b.U_ItemCode,B.U_BaseLine) m on b.DocEntry=m.U_GRNEntry and
b.LineId=m.U_BaseLine
--left join RPC1 R ON d.docentry=r.baseentry and d.LineNum=r.BaseLine
--where isnull(b.U_InspQty,0)>0
--and f.DocType='S'
--and (isnull((m.rejqty*(c.linetotal/b.U_Quantity)),0)-isnull(r.linetotal,0))>0) c on
b.DocEntry=c.inv_docentry and b.InvType=c.objtype
-- where a.DocEntry=@list_of_cols_val_tab_del )
--SET @error=1000
--SET @error_message = 'Please raise credit memo for the Invoice'
--end
--SET @error=1050
--SET @error_message = 'Please select Document type as service or select correct series'
--SET @error=1050
--SET @error_message = 'Already item is available in OPen PO for the vendor'
--SET @error=1050
--SET @error_message = 'Already item is available in draft PO for the vendor'
--end
--end
end
end
-------------------Sales Screens-----------------------
--IF @object_type='17' and @transaction_type IN (N'U')
--Begin
--end
end
IF @object_type='16' and @transaction_type IN (N'U')
Begin
end
end
BEGIN
if exists(SELECT a.DocEntry FROM ORDN A INNER JOIN RDN1 B ON A.DOCENTRY=B.DOCENTRY
INNER JOIN
(select a.DocEntry,a.itemcode,b.SysNumber,c.DistNumber from oitl a inner join itl1 b on
a.LogEntry=b.logentry
inner join osrn c on a.itemcode=c.itemcode and b.SysNumber=c.SysNumber
where a.itemcode=b.ItemCode
and a.doctype='16') C ON a.docentry=c.DocEntry and b.itemcode=c.ItemCode
begin
declare @SERIALNO2 NVARCHAR (30),@ITEMCOD3 NVARCHAR (100)
begin
SELECT @Error=16, @error_message = 'Itemcode:'+@ITEMCOD3+', '+'Serial No:'+@serialno2+'
is already available in Rejection and Salvage.Please reselect'
end
end
end
--end
--end
--end
end
end
--end
end
--end
--end
end
--end
--end
end
end
end
-----------------closed------------------------------------------
end