
[dbo].[BATBuildARAPGLNumber_XLedger]
create procedure [dbo].[BATBuildARAPGLNumber_XLedger]
@inSessionID varchar(50),
@inOrderID int,
@inTransactionType varchar(30),
@inSource varchar(50),
@inSourceID int,
@inObject varchar(15),
@inObjectID int,
@inBranchID int,
@inDivisionID int,
@inAuthorityID int,
@outGLNumber varchar(66) output,
@outAccountingAccountId int output,
@outErrorCode int output
as
set nocount on
set @outGLNumber = null
set @outErrorCode = 0
set @outAccountingAccountId = null
declare @ERROR_TRANSACTION_TYPE_IS_INVALID int = 1263
declare @ERROR_TRANSACTION_TYPE_IS_NOT_MAPPED_IN_XLEDGERGLARAP int = 1264
if( @inTransactionType not in ( 'AR', 'AP' ) )
begin
exec @outErrorCode = spBATRecordError
@inSessionID,
@inSource,
@inSourceID,
@ERROR_TRANSACTION_TYPE_IS_INVALID,
@inObject,
@inObjectID,
@inTransactionType
end
if( @outErrorCode = 0 )
begin
select @outAccountingAccountId = AccountingAccountFid
from XLedgerGLARAP
where TypeName = @inTransactionType
if( @outAccountingAccountId is null )
begin
exec @outErrorCode = spBATRecordError
@inSessionID,
@inSource,
@inSourceID,
@ERROR_TRANSACTION_TYPE_IS_NOT_MAPPED_IN_XLEDGERGLARAP,
@inObject,
@inObjectID,
@inTransactionType
end
end
if( @outErrorCode = 0 )
begin
select @outGLNumber = AccountingAccount.Code
from AccountingAccount
where AccountingAccountId = @outAccountingAccountId
end
GO
GRANT EXECUTE ON [dbo].[BATBuildARAPGLNumber_XLedger] TO [MssExec]
GO