Proc Subway InvoicePosting Batch

Purpose
The purpose of this stored procedure is to post the invoices that are currently in the unposted tables, update the account balances, and create a matching record in the WeeklySummary table.

This stored procedure logic has been modularized so that it can be called from different processes including the ^^Thursday Night Process^^, Invoice Posting Form, Notes Receivable Creation

Method Signature
[dbo].[proc_Subway_InvoicePosting_Batch]  (   @InvoiceNumbersXML                  XML,  @UserStamp                               VARCHAR(50), )

Procedure Flow

 * 1) Create a temp table with all the InvoiceIds to process from the xml passed in
 * 2) Insert all the selected invoices from InvoiceUnposted to InvoicePosted
 * 3) Insert all the selected invoices from InvoiceItemUnposted to InvoiceItemPosted
 * 4) Determine if any of the invoices have the balance type of Equipment Leasing, if so run the stored procedure ^^proc_Subway_InvoicePosting_EquipmentLease_Batch^^ passing in only those invoices that have the balance type of Equipment Leasing
 * 5) This procedure stores the invoice information in the ELTransactions table, including a running balance.
 * 6) All Entities with negative Account Balances are stored in a table and the CollectedAmount columns is updated by calling the stored procedure ^^proc_Subway_Invoice_UpdateCollectedAmount^^ for each Entity.
 * 7) The Account Balance table is then updated through the stored procedure ^^proc_Subway_AccountBalance_Save_Batch^^
 * 8) All Invoice Items are stored in the ARSubledger table.
 * 9) All Invoice Items are saved to the WeeklySummary table using the stored procedure ^^proc_Subway_WeeklySummary_Save_Batch^^
 * 10) Determine if any of the invoices have the balance type of Notes Receivable, if so run the stored procedure ^^proc_Subway_InvoicePosting_NotesReceivable_Batch^^ passing in only those invoices that have the balance type of Notes Receivable
 * 11) This stored procedure changes the Status Type of the Notes to Active, Paid or Written Off depending on if there is a balance remaining in Account Balance table
 * 12) Determine if any of the invoices have the balance type of Royalties, Advertising, Notes Receivable, Shipping Center or Reality, if so run the stored procedure ^^proc_Subway_InvoicePosting_DAAdjustment_Batch^^ passing in only those invoices that have the balance type of Royalties, Advertising, Notes Receivable, Shipping Center or Reality
 * 13) This stored procedure inserts records into the AdjustmentUnposted table
 * 14) Delete the records from the InvoiceItemUnposted table
 * 15) Update the table InvoiceItemUnpostedHistory with the correct UserStamp of who is executing the Proc_Subway_InvoicePosting_Batch procedure
 * 16) Delete the records from the InvoiceUnposted table
 * 17) Update the table InvoiceUnpostedHistory with the correct UserStamp of who is executing the Proc_Subway_InvoicePosting_Batch procedure

Function
