CREATE PROCEDURE [dbo].[ValidateAccountingSystemRequirements_XLedger]
@inBatSessionID varchar(50),
@inErrorLoggingSessionId varchar(50),
@inIsStorageProcessing bit = null,
@outErrorCode int output
as
begin
set nocount on
set @outErrorCode = 0
declare @theStorageRows int
declare @theCounter int
declare @theBATProcessPriKeyStr varchar(10)
declare @theItemCodeStr varchar(10)
declare @theNominalBranchID varchar(5)
declare @theNominalBranchFid int
declare @theNominalBranchObjectValueXLedgerDbId bigint
declare @theOpposingBranchID varchar(5)
declare @theOpposingBranchFid int
declare @theOpposingBranchObjectValueXLedgerDbId bigint
declare @theNominalXLedgerCompanyXLedgerDbId bigint
declare @theOpposingXLedgerCompanyXLedgerDbId bigint
declare @theNominalDivisionFid int
declare @theNominalDivisionObjectValueXLedgerDbId bigint
declare @theOpposingDivisionFid int
declare @theOpposingDivisionObjectValueXLedgerDbId bigint
declare @theNominalAccountingAccountFid int
declare @theOpposingAccountingAccountFid int
declare @theMustHaveAccountingCustomer bit
declare @theAccountingCustomerFid int
declare @theXLedgerCustomerXLedgerDbId bigint
declare @theAccountingCustomerNumber varchar(15)
declare @theBATProcessCustomerNumber varchar(15)
declare @theAccountingCustomerHidden bit
declare @theMustHaveAccountingVendor bit
declare @theAccountingVendorFid int
declare @theXLedgerSupplierXLedgerDbId bigint
declare @theAccountingVendorNumber varchar(15)
declare @theBATProcessVendorNumber varchar(15)
declare @theAccountingVendorHidden bit
declare @theTransactionType varchar(30)
declare @theBatErrorCode int
declare @theNominalBranchCanPost bit
declare @theNominalBranchHidden bit
declare @theOpposingBranchCanPost bit
declare @theOpposingBranchHidden bit
declare @theNominalAccountingAccountCanPost bit
declare @theNominalAccountingAccountHidden bit
declare @theNominalAccountingAccountCode nvarchar(32)
declare @theOpposingAccountingAccountCanPost bit
declare @theOpposingAccountingAccountHidden bit
declare @theOpposingAccountingAccountCode nvarchar(32)
declare @theSourceTable varchar(50)
declare @theSourceRecordId int
declare @theObjectTable varchar(20) = 'Order'
declare @theOrderId int
declare @theUnknownItem varchar(5) = '???'
declare @MSS_BRANCH_NOT_SET_ON_BATPROCESS_RECORD int = 1530
declare @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_BRANCH_OBJECT_VALUE int = 1531
declare @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_COMPANY_OBJECT_VALUE int = 1532
declare @MSS_ITEM_CODE_NOT_MAPPED_TO_AN_XLEDGER_GL_ACCOUNT int = 1533
declare @MSS_CUSTOMER_NOT_MAPPED_TO_AN_XLEDGER_CUSTOMER int = 1534
declare @MSS_VENDOR_NOT_MAPPED_TO_AN_XLEDGER_SUPPLIER int = 1535
declare @MSS_BRANCH_MARKED_AS_CANNOT_POST_IN_XLEDGER int = 1536
declare @MSS_BRANCH_MARKED_AS_HIDDEN_IN_XLEDGER int = 1537
declare @MSS_GL_ACCOUNT_MARKED_AS_CANNOT_POST_IN_XLEDGER int = 1538
declare @MSS_GL_ACCOUNT_MARKED_AS_HIDDEN_IN_XLEDGER int = 1539
declare @MSS_CUSTOMER_MARKED_AS_HIDDEN_IN_XLEDGER int = 1540
declare @MSS_VENDOR_MARKED_AS_HIDDEN_IN_XLEDGER int = 1541
declare @MSS_CUSTOMER_NOT_PROVIDED_WHEN_ITS_REQUIRED int = 1542
declare @MSS_VENDOR_NOT_PROVIDED_WHEN_ITS_REQUIRED int = 1543
declare @thePrePostingTable table
(
PrePostingTableId int not null identity(1,1),
BATProcessPriKey int not null,
NominalBranchID varchar(5),
NominalBranchObjectValueXLedgerDbId bigint,
NominalBranchCanPost bit,
NominalBranchHidden bit,
OpposingBranchID varchar(5),
OpposingBranchObjectValueXLedgerDbId bigint,
OpposingBranchCanPost bit,
OpposingBranchHidden bit,
NominalXLedgerCompanyXLedgerDbId bigint,
OpposingXLedgerCompanyXLedgerDbId bigint,
NominalAccountingAccountCanPost bit,
NominalAccountingAccountHidden bit,
NominalAccountingAccountCode nvarchar(32),
OpposingAccountingAccountCanPost bit,
OpposingAccountingAccountHidden bit,
OpposingAccountingAccountCode nvarchar(32),
AccountingCustomerFid int,
XLedgerCustomerXLedgerDbId bigint,
AccountingCustomerNumber varchar(15),
AccountingCustomerHidden bit,
AccountingVendorFid int,
XLedgerSupplierXLedgerDbId bigint,
AccountingVendorNumber varchar(15),
AccountingVendorHidden bit
)
insert into @thePrePostingTable
(
BATProcessPriKey,
NominalBranchID,
NominalBranchObjectValueXLedgerDbId,
NominalBranchCanPost,
NominalBranchHidden,
OpposingBranchID,
OpposingBranchObjectValueXLedgerDbId,
OpposingBranchCanPost,
OpposingBranchHidden,
NominalXLedgerCompanyXLedgerDbId,
OpposingXLedgerCompanyXLedgerDbId,
NominalAccountingAccountCanPost,
NominalAccountingAccountHidden,
NominalAccountingAccountCode,
OpposingAccountingAccountCanPost,
OpposingAccountingAccountHidden,
OpposingAccountingAccountCode,
XLedgerCustomerXLedgerDbId,
AccountingCustomerNumber,
AccountingCustomerHidden,
XLedgerSupplierXLedgerDbId,
AccountingVendorNumber,
AccountingVendorHidden
)
select
BATProcessPriKey = BATProcess.BATProcessPriKey,
NominalBranchID = isnull( NominalBranch.BranchID, @theUnknownItem ),
NominalBranchObjectValueXLedgerDbId = NominalXLedgerBranchObjectValue.XLedgerDbId,
NominalBranchCanPost = NominalXLedgerBranchObjectValue.CanPost,
NominalBranchHidden = NominalXLedgerBranchObjectValue.[Hidden],
OpposingBranchID = isnull( OpposingBranch.BranchID, @theUnknownItem ),
OpposingBranchObjectValueXLedgerDbId = OpposingXLedgerBranchObjectValue.XLedgerDbId,
OpposingBranchCanPost = OpposingXLedgerBranchObjectValue.CanPost,
OpposingBranchHidden = OpposingXLedgerBranchObjectValue.[Hidden],
NominalXLedgerCompanyXLedgerDbId = NominalXLedgerCompany.XLedgerDbId,
OpposingXLedgerCompanyXLedgerDbId = OpposingXLedgerCompany.XLedgerDbId,
NominalAccountingAccountCanPost = NominalAccountingAccount.CanPost,
NominalAccountingAccountHidden = NominalAccountingAccount.[Hidden],
NominalAccountingAccountCode = NominalAccountingAccount.Code,
OpposingAccountingAccountCanPost = OpposingAccountingAccount.CanPost,
OpposingAccountingAccountHidden = OpposingAccountingAccount.[Hidden],
OpposingAccountingAccountCode = OpposingAccountingAccount.Code,
XLedgerCustomerXLedgerDbId = XLedgerCustomer.ExternalDbId,
AccountingCustomerNumber = AccountingCustomer.CustomerNumber,
AccountingCustomerHidden = AccountingCustomer.[Hidden],
XLedgerSupplierXLedgerDbId = XLedgerSupplier.ExternalDbId,
AccountingVendorNumber = AccountingVendor.VendorNumber,
AccountingVendorHidden = AccountingVendor.[Hidden]
from BATProcess
left outer join Branch as NominalBranch on NominalBranch.BranchPriKey = BATProcess.NominalBranchFid
left outer join XLedgerBranchObjectValue as NominalXLedgerBranchObjectValue on
NominalXLedgerBranchObjectValue.BranchFid = BATProcess.NominalBranchFid
left outer join XLedgerCompany as NominalXLedgerCompany on
NominalXLedgerCompany.XLedgerCompanyId = NominalXLedgerBranchObjectValue.XLedgerCompanyFid
left outer join Branch as OpposingBranch on OpposingBranch.BranchPriKey = BATProcess.OpposingBranchFid
left outer join XLedgerBranchObjectValue as OpposingXLedgerBranchObjectValue on
OpposingXLedgerBranchObjectValue.BranchFid = BATProcess.OpposingBranchFid
left outer join XLedgerCompany as OpposingXLedgerCompany on
OpposingXLedgerCompany.XLedgerCompanyId = OpposingXLedgerBranchObjectValue.XLedgerCompanyFid
left outer join AccountingAccount as NominalAccountingAccount on NominalAccountingAccount.AccountingAccountId = BATProcess.NominalAccountingAccountFid
left outer join AccountingAccount as OpposingAccountingAccount on OpposingAccountingAccount.AccountingAccountId = BATProcess.OpposingAccountingAccountFid
left outer join XLedgerCustomer on XLedgerCustomer.AccountingCustomerFid = BATProcess.AccountingCustomerFid
left outer join AccountingCustomer on AccountingCustomer.AccountingCustomerId = BATProcess.AccountingCustomerFid
left outer join XLedgerSupplier on XLedgerSupplier.AccountingVendorFid = BATProcess.AccountingVendorFid
left outer join AccountingVendor on AccountingVendor.AccountingVendorId = BATProcess.AccountingVendorFid
where BATProcess.BATSessionID = @inBatSessionID
order by BATProcess.BATProcessPriKey
set @theStorageRows = @@rowcount
set @theCounter = 1
while( @theCounter <= @theStorageRows )
begin
select
@theBATProcessPriKeyStr = convert( varchar(10), PrePostingTable.BATProcessPriKey ),
@theOrderId = BATProcess.OrdPriKey,
@theItemCodeStr = convert( varchar(10), BATProcess.ItemCode ),
@theSourceTable = BATProcess.[Source],
@theSourceRecordId = BATProcess.SourceRecord,
@theNominalBranchID = PrePostingTable.NominalBranchID,
@theNominalBranchFid = BATProcess.NominalBranchFid,
@theNominalBranchObjectValueXLedgerDbId = PrePostingTable.NominalBranchObjectValueXLedgerDbId,
@theNominalBranchCanPost = PrePostingTable.NominalBranchCanPost,
@theNominalBranchHidden = PrePostingTable.NominalBranchHidden,
@theOpposingBranchID = PrePostingTable.OpposingBranchID,
@theOpposingBranchFid = BATProcess.OpposingBranchFid,
@theOpposingBranchObjectValueXLedgerDbId = PrePostingTable.OpposingBranchObjectValueXLedgerDbId,
@theOpposingBranchCanPost = PrePostingTable.OpposingBranchCanPost,
@theOpposingBranchHidden = PrePostingTable.OpposingBranchHidden,
@theNominalXLedgerCompanyXLedgerDbId = PrePostingTable.NominalXLedgerCompanyXLedgerDbId,
@theOpposingXLedgerCompanyXLedgerDbId = PrePostingTable.OpposingXLedgerCompanyXLedgerDbId,
@theNominalAccountingAccountFid = BATProcess.NominalAccountingAccountFid,
@theNominalAccountingAccountCanPost = PrePostingTable.NominalAccountingAccountCanPost,
@theNominalAccountingAccountHidden = PrePostingTable.NominalAccountingAccountHidden,
@theNominalAccountingAccountCode = PrePostingTable.NominalAccountingAccountCode,
@theOpposingAccountingAccountFid = BATProcess.OpposingAccountingAccountFid,
@theOpposingAccountingAccountCanPost = PrePostingTable.OpposingAccountingAccountCanPost,
@theOpposingAccountingAccountHidden = PrePostingTable.OpposingAccountingAccountHidden,
@theOpposingAccountingAccountCode = PrePostingTable.OpposingAccountingAccountCode,
@theMustHaveAccountingCustomer = case
when BATProcess.TransactionType like 'A/R%' then 1
else 0
end,
@theAccountingCustomerFid = BATProcess.AccountingCustomerFid,
@theBATProcessCustomerNumber = isnull( BATProcess.CustomerNumber, @theUnknownItem ),
@theXLedgerCustomerXLedgerDbId = PrePostingTable.XLedgerCustomerXLedgerDbId,
@theAccountingCustomerNumber = PrePostingTable.AccountingCustomerNumber,
@theAccountingCustomerHidden = PrePostingTable.AccountingCustomerHidden,
@theMustHaveAccountingVendor = case
when BATProcess.TransactionType like 'A/P%' then 1
else 0
end,
@theAccountingVendorFid = BATProcess.AccountingVendorFid,
@theBATProcessVendorNumber = isnull( BATProcess.VendorNumber, @theUnknownItem ),
@theXLedgerSupplierXLedgerDbId = PrePostingTable.XLedgerSupplierXLedgerDbId,
@theAccountingVendorNumber = PrePostingTable.AccountingVendorNumber,
@theAccountingVendorHidden = PrePostingTable.AccountingVendorHidden,
@theTransactionType = BATProcess.TransactionType
from @thePrePostingTable as PrePostingTable
inner join BATProcess on BATProcess.BATProcessPriKey = PrePostingTable.BATProcessPriKey
where PrePostingTableId = @theCounter
if( isnull( @theNominalBranchID, @theUnknownItem ) = @theUnknownItem )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_SET_ON_BATPROCESS_RECORD,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = 'Nominal',
@inParam2 = @theBATProcessPriKeyStr
set @outErrorCode = 1
end
else if( @theNominalBranchObjectValueXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_BRANCH_OBJECT_VALUE,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalBranchID,
@inParam2 = @theBATProcessPriKeyStr
set @outErrorCode = 1
end
if( isnull( @theOpposingBranchID, @theUnknownItem ) = @theUnknownItem )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_SET_ON_BATPROCESS_RECORD,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = 'Opposing',
@inParam2 = @theBATProcessPriKeyStr
set @outErrorCode = 1
end
else if( @theOpposingBranchObjectValueXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_BRANCH_OBJECT_VALUE,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingBranchID,
@inParam2 = @theBATProcessPriKeyStr
set @outErrorCode = 1
end
if( @theNominalBranchObjectValueXLedgerDbId is not null )
begin
if( @theNominalXLedgerCompanyXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_COMPANY_OBJECT_VALUE,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalBranchID
set @outErrorCode = 1
end
if( isnull( @theNominalBranchCanPost, 0 ) = 0 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_MARKED_AS_CANNOT_POST_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalBranchID
set @outErrorCode = 1
end
if( isnull( @theNominalBranchHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalBranchID
set @outErrorCode = 1
end
end
if( @theOpposingBranchObjectValueXLedgerDbId is not null )
begin
if( @theOpposingXLedgerCompanyXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_NOT_MAPPED_TO_AN_XLEDGER_COMPANY_OBJECT_VALUE,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingBranchID
set @outErrorCode = 1
end
if( isnull( @theOpposingBranchCanPost, 0 ) = 0 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_MARKED_AS_CANNOT_POST_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingBranchID
set @outErrorCode = 1
end
if( isnull( @theOpposingBranchHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_BRANCH_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingBranchID
set @outErrorCode = 1
end
end
if( @theNominalAccountingAccountFid is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_ITEM_CODE_NOT_MAPPED_TO_AN_XLEDGER_GL_ACCOUNT,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theItemCodeStr
set @outErrorCode = 1
end
else
begin
if( isnull( @theNominalAccountingAccountCanPost, 0 ) = 0 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_GL_ACCOUNT_MARKED_AS_CANNOT_POST_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalAccountingAccountCode
set @outErrorCode = 1
end
if( isnull( @theNominalAccountingAccountHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_GL_ACCOUNT_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theNominalAccountingAccountCode
set @outErrorCode = 1
end
end
if( @theOpposingAccountingAccountFid is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_ITEM_CODE_NOT_MAPPED_TO_AN_XLEDGER_GL_ACCOUNT,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theItemCodeStr
set @outErrorCode = 1
end
else
begin
if( isnull( @theOpposingAccountingAccountCanPost, 0 ) = 0 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_GL_ACCOUNT_MARKED_AS_CANNOT_POST_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingAccountingAccountCode
set @outErrorCode = 1
end
if( isnull( @theOpposingAccountingAccountHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_GL_ACCOUNT_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theOpposingAccountingAccountCode
set @outErrorCode = 1
end
end
if( @theMustHaveAccountingCustomer = 1 )
begin
if( @theAccountingCustomerFid is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_CUSTOMER_NOT_PROVIDED_WHEN_ITS_REQUIRED,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theTransactionType,
@inParam2 = @theBATProcessCustomerNumber
set @outErrorCode = 1
end
else if( @theXLedgerCustomerXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_CUSTOMER_NOT_MAPPED_TO_AN_XLEDGER_CUSTOMER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theAccountingCustomerNumber
set @outErrorCode = 1
end
if( isnull( @theAccountingCustomerHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_CUSTOMER_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theAccountingCustomerNumber
set @outErrorCode = 1
end
end
if( @theMustHaveAccountingVendor = 1 )
begin
if( @theAccountingVendorFid is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_VENDOR_NOT_PROVIDED_WHEN_ITS_REQUIRED,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theTransactionType,
@inParam2 = @theBATProcessVendorNumber
set @outErrorCode = 1
end
else if( @theXLedgerSupplierXLedgerDbId is null )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_VENDOR_NOT_MAPPED_TO_AN_XLEDGER_SUPPLIER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theAccountingVendorNumber
set @outErrorCode = 1
end
if( isnull( @theAccountingVendorHidden, 1 ) = 1 )
begin
exec @theBatErrorCode = spRecordBatOrStorageError
@inIsStorageProcessing = @inIsStorageProcessing,
@inErrorCodeID = @MSS_VENDOR_MARKED_AS_HIDDEN_IN_XLEDGER,
@inOrderID = @theOrderId,
@inSessionID = @inErrorLoggingSessionId,
@inSourceTable = @theSourceTable,
@inSourceID = @theSourceRecordId,
@inObjectTable = @theObjectTable,
@inObjectID = @theOrderId,
@inParam1 = @theAccountingVendorNumber
set @outErrorCode = 1
end
end
set @theCounter = @theCounter + 1
end
end
GO
GRANT EXECUTE ON [dbo].[ValidateAccountingSystemRequirements_XLedger] TO [MssExec]
GO