Stored Procedures [dbo].[XLedgerMarkTransactionsPostAsSuccess]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@batchIdint4
@journalHeadersXLedgerTransactionHeaderInsertItemmax
@journalHeaderMappingsXLedgerTransactionHeaderMappingInsertItemmax
@applyToMappingsXLedgerApplyToUploadInfoInsertItemmax
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
CREATE PROCEDURE [dbo].[XLedgerMarkTransactionsPostAsSuccess]
    @batchId int,
    @journalHeaders XLedgerTransactionHeaderInsertItem readonly,
    @journalHeaderMappings XLedgerTransactionHeaderMappingInsertItem readonly,
    @applyToMappings XLedgerApplyToUploadInfoInsertItem readonly
as
begin
    set nocount on
    insert into XLedgerTransactionHeader
    (
        XLedgerDbId,
        XLedgerJournalEntryBatchFid,
        ArApMatchIdentifier,
        ArApExternalIdentifier,
        XLedgerTransactionHoldStatusFid
    )
    select
        XLedgerDbId,
        @batchId,
        JournalHeaders.MatchIdentifier,
        JournalHeaders.ExternalIdentifier,
        XLedgerTransactionHoldStatus.XLedgerTransactionHoldStatusId -- null if we never intend to place the header on hold.
    from
        @journalHeaders JournalHeaders
    left outer join XLedgerTransactionHoldStatus on
        XLedgerTransactionHoldStatus.[Description] = 'NotYetOnHold' and
        JournalHeaders.PlaceOnHold = 1

    update XLedgerJournalEntryBatchItem set
        XLedgerTransactionHeaderFid = XLedgerTransactionHeader.XLedgerTransactionHeaderId,
        ExternalIdentifier = JournalHeaderMappings.ExternalIdentifier
    from @journalHeaderMappings JournalHeaderMappings
    inner join XLedgerJournalEntryBatchItem on
        JournalHeaderMappings.XLedgerJournalEntryBatchItemId = XLedgerJournalEntryBatchItem.XLedgerJournalEntryBatchItemId
    inner join XLedgerTransactionHeader on JournalHeaderMappings.JournalHeaderXLedgerDbId = XLedgerTransactionHeader.XLedgerDbId

    insert into XLedgerApplyToJournalDetail(
        ExternalIdentifier
    )
    select distinct ExternalIdentifier from
        @applyToMappings ApplyToMappings

    insert into XLedgerApplyToJournalDetailMap
    (
        XLedgerApplyToJournalDetailFid,
        AcctTransactionsApplyToInfoFid
    )
    select
        XLedgerApplyToJournalDetail.XLedgerApplyToJournalDetailId,
        ApplyToMappings.AcctTransactionsApplyToInfoId
    from @applyToMappings ApplyToMappings
    inner join XLedgerApplyToJournalDetail on XLedgerApplyToJournalDetail.ExternalIdentifier = ApplyToMappings.ExternalIdentifier
end
GO
GRANT EXECUTE ON  [dbo].[XLedgerMarkTransactionsPostAsSuccess] TO [MssExec]
GO
Uses