
[dbo].[BATBuildRevenueGLNumber_Legacy]
create procedure [dbo].[BATBuildRevenueGLNumber_Legacy]
@inSessionID varchar(50),
@inOrderID int,
@inItemCodeID int,
@inLaborTypeID int,
@inBranchID int,
@inDivisionID int,
@inSource varchar(50),
@inSourceID int,
@inObject varchar(15),
@inObjectID int,
@outRevenueGLNumber varchar(66) output,
@outAccountingAccountId int output,
@outErrorCode int output
as
set nocount on
declare @theICDetailID int
set @theICDetailID = -1
declare @theICCommissionsID int
set @theICCommissionsID = -1
declare @theRevenueMainAccount varchar(16)
declare @theRevenueSubAccount varchar(16)
declare @theErrorCode int
declare @ERROR_MISSING_GLNUMBER int
set @ERROR_MISSING_GLNUMBER = 752
set @outRevenueGLNumber = ''
set @outErrorCode = 0
set @theErrorCode = 0
set @outAccountingAccountId = null
exec BATGetRevenueGLICMapID
@inSessionID = @inSessionID,
@inOrderID = @inOrderID,
@inItemCodeID = @inItemCodeID,
@inSource = @inSource,
@inSourceID = @inSourceID,
@inObject = @inObject,
@inObjectID = @inObjectID,
@outICDetailID = @theICDetailID output,
@outErrorCode = @theErrorCode output
if( 0 != @theErrorCode )
begin
set @outErrorCode = 1
set @theErrorCode = 0
end
else
begin
select
@theRevenueMainAccount = ICDetail.RevGLAccount,
@theRevenueSubAccount = ICDetail.RevGLSubAccount
from ICDetail
where ICDetail.ICDPriKey = @theICDetailID
exec BATCheckSegmentLengths
@inSessionID = @inSessionID,
@inSource = @inSource,
@inSourceID = @inSourceID,
@inObject = @inObject,
@inObjectID = @inObjectID,
@inMainAccount = @theRevenueMainAccount,
@inSubAccount = @theRevenueSubAccount,
@inBranchID = @inBranchID,
@inDivisionID = @inDivisionID,
@outErrorCode = @theErrorCode output
if( 0 != @theErrorCode )
begin
set @outErrorCode = 1
set @theErrorCode = 0
end
else
begin
exec BATBuildGLNumber
@inMainAccount = @theRevenueMainAccount,
@inSubAccount = @theRevenueSubAccount,
@inBranchID = @inBranchID,
@inDivisionID = @inDivisionID,
@outGlNumber = @outRevenueGLNumber output,
@outErrorCode = @theErrorCode output
if( @theErrorCode != 0 )
begin
exec @outErrorCode = spBATRecordError @inSessionID, @inSource, @inSourceID, @theErrorCode, @inObject, @inObjectID
end
exec @theErrorCode =
spBATCheckGLNumber
@inSessionID = @inSessionID,
@GLNumber = @outRevenueGLNumber,
@BranchPriKey = @inBranchID,
@Source = @inSource,
@SourcePriKey = @inSourceID,
@inObject = @inObject,
@inObjectID = @inObjectID
if( 0 != @theErrorCode )
begin
declare @theItemCode int
set @theItemCode =
isnull( (
select ItemCode
from ItemCode
where ICPriKey = @inItemCodeID
), -1 )
set @outRevenueGLNumber = isnull( @outRevenueGLNumber, '' )
exec spBATRecordError
@inSessionID,
@inSource,
@inSourceID,
@ERROR_MISSING_GLNUMBER,
@inObject,
@inObjectID,
@outRevenueGLNumber,
@theItemCode
set @outErrorCode = 1
end
end
end
GO
GRANT EXECUTE ON [dbo].[BATBuildRevenueGLNumber_Legacy] TO [MssExec]
GO