Stored Procedures [dbo].[AdvanceBATBuildGLNumber_Legacy]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)Direction
@inSessionIDvarchar(50)50
@inSourcevarchar(50)50
@inSourceIDint4
@inBranchIDint4
@inDivisionIDint4
@outGLNumbervarchar(66)66Out
@outAccountingAccountIdint4Out
@outErrorCodeint4Out
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/*
*    Don't call this stored proc directly but instead use AdvanceBATBuildGLNumber_Synonym.
*    AdvanceBATBuildGLNumber_Synonym will either point to:
* AdvanceBATBuildGLNumber_XLedger if XLedger is active, or
*    AdvanceBATBuildGLNumber_Legacy otherwise.
*
*    Description: Gets the GL number for the expense account to use for an advance.
*
* Parameters:
* @param @inSessionID Current BAT session ID
* @param @inSource Source of BAT errors ('Advance')
* @param @inSourceID ID of the record from the Source table that caused a BAT error.
* @param @inBranchID Primary key of the Branch for the advance
* @param @inDivisionID Primary key of the Division for the advance
* @param @outGLNumber GL number of the expense account for the advance
* @param @outAccountingAccountId Always returns null (this only will have a value in the XLedger version of this stored proc).
* @param @outErrorCode Error code if an error occurs
*/


create procedure [dbo].[AdvanceBATBuildGLNumber_Legacy]
    @inSessionID varchar(50),
    @inSource varchar(50),
    @inSourceID int,
    @inBranchID int,
    @inDivisionID int,
    @outGLNumber varchar(66) output,
    @outAccountingAccountId int output,
    @outErrorCode     int output
as

set nocount on

declare @theManualGLFlag bit
declare @theAdvanceSetupAccount varchar(16)
declare @theAdvanceSetupSubAccount varchar(16)

-- Return a null AccountingAccount ID. This only gets set to a value in the XLedger version of this stored proc, AdvanceBATBuildGLNumber_XLedger.
set @outAccountingAccountId = null

-- For advances, we need to get some info about the expense GL account from the AdvanceSetup table.
select
    @theManualGLFlag = AdvanceSetup.ManualGLFlag,
    @outGLNumber = AdvanceSetup.ManualGL,
    @theAdvanceSetupAccount = AdvanceSetup.Account,
    @theAdvanceSetupSubAccount = AdvanceSetup.SubAccount
from AdvanceSetup
    
-- If a Manual GL account number is not being used, we need to build the GL number.
if( @theManualGLFlag = 0 )
begin
    exec BATBuildGLNumber
        @inMainAccount = @theAdvanceSetupAccount,
        @inSubAccount = @theAdvanceSetupSubAccount,
        @inBranchID = @inBranchID,
        @inDivisionID = @inDivisionID,
        @outGlNumber = @outGLNumber output,
        @outErrorCode = @outErrorCode output
end
GO
GRANT EXECUTE ON  [dbo].[AdvanceBATBuildGLNumber_Legacy] TO [MssExec]
GO
Uses
Used By