
[dbo].[BcGetTransactionsForBatchHeader]
CREATE procedure [dbo].[BcGetTransactionsForBatchHeader]
@batchId int
as
begin
set nocount on
select
BcTransactionBatchItemId = BcTransactionBatchItem.BcTransactionBatchItemId,
Amount = AcctTransactions.TransactionAmount,
ItemDescription = isnull( AcctTransactions.ItemDescription, 'MSS GL Item' ),
TransactionType = AcctTransactions.TransactionType,
PostingDate = AcctTransactions.JournalDate,
ProjectCode = BcTransactionBatchItem.ProjectCode,
ProjectDimensionValueBcId = BcTransactionBatchItem.ProjectDimensionValueBcId,
CustomerBcId = BcTransactionBatchItem.CustomerBcId,
CustomerNumber = AccountingCustomer.CustomerNumber,
NominalAccountBcId = BcTransactionBatchItem.NominalAccountBcId,
NominalAccountNumber = NominalAccountingAccount.Code,
OpposingAccountBcId = BcTransactionBatchItem.OpposingAccountBcId,
OpposingAccountNumber = OpposingAccountingAccount.Code,
NominalBranchDimensionValueBcId = BcTransactionBatchItem.NominalBranchDimensionValueBcId,
NominalDivisionDimensionValueBcId = BcTransactionBatchItem.NominalDivisionDimensionValueBcId,
MoveTypeDimensionValueBcId = BcTransactionBatchItem.MoveTypeDimensionValueBcId,
OpposingBranchDimensionValueBcId = BcTransactionBatchItem.OpposingBranchDimensionValueBcId,
OpposingDivisionDimensionValueBcId = BcTransactionBatchItem.OpposingDivisionDimensionValueBcId,
ArDriverSalesDimensionValueBcId = BcTransactionBatchItem.ArDriverSalesDimensionValueBcId,
RevenueDriverSalesDimensionValueBcId = BcTransactionBatchItem.RevenueDriverSalesDimensionValueBcId,
VendorBcId = BcTransactionBatchItem.VendorBcId,
VendorNumber = AccountingVendor.VendorNumber,
Ten99 = AcctTransactions.[1099Flag]
from BcTransactionBatchItem
inner join AcctTransactions on BcTransactionBatchItem.AcctTransactionFid = AcctTransactions.ATPriKey
inner join BcAccount NominalBcAccount on BcTransactionBatchItem.NominalAccountBcId = NominalBcAccount.BcId
inner join AccountingAccount NominalAccountingAccount on NominalBcAccount.AccountingAccountFid = NominalAccountingAccount.AccountingAccountId
inner join BcAccount OpposingBcAccount on BcTransactionBatchItem.OpposingAccountBcId = OpposingBcAccount.BcId
inner join AccountingAccount OpposingAccountingAccount on OpposingBcAccount.AccountingAccountFid = OpposingAccountingAccount.AccountingAccountId
left outer join BcVendor on BcTransactionBatchItem.VendorBcId = BcVendor.BcId
left outer join AccountingVendor on BcVendor.AccountingVendorFid = AccountingVendor.AccountingVendorId
left outer join BcCustomer on BcTransactionBatchItem.CustomerBcId = BcCustomer.BcId
left outer join AccountingCustomer on BcCustomer.AccountingCustomerFid = AccountingCustomer.AccountingCustomerId
where BcTransactionBatchItem.BcTransactionBatchFid = @batchId
end
GO
GRANT EXECUTE ON [dbo].[BcGetTransactionsForBatchHeader] TO [MssExec]
GO