Proc Subway CashReceiptBatchPosting NoteReceivable DAAdjustment Batch

Purpose
This procedure inserts a new record or updates an existing record in the table WeeklySummary. It was made into its own stored procedure so it could be called when creating Invoices, Cash Receipts, or Beginning Balances

Method Signature
[dbo].[proc_Subway_CashReceiptBatchPosting_NoteReceivable_DAAdjustment_Batch] (           @BalanceXML AS XML    ,	    @UserStamp VARCHAR(300)    )

Procedure Flow

 * 1) Create a temp table with all the CashReceiptBatchIds to process from the XML passed in, these are the selected cash receipt batches
 * 2) Insert Franchise Sales commissions into the table AdjustmentUnPosted table. This inserts all the Notes that are Paid and have a Loan Type of Minority Loan for the Current DA and where the Franchise Fee is greater than or equal to the Cash Receipt Total.
 * 3) Insert Pending Franchise Fee Commisions into the DACommission table. This inserts all records that are of type Franchise Agreement, have a adjustment posting type of Franchise Sales Commission for the Current DA and where the Franchise Fee is greater than or equal to the Cash Receipt Total.
 * 4)  Insert Unpaid Franchise Fee Commissions into the DACommission table. This inserts all records that are of type Franchise Agreement, for the balance type Royalty where the Cash Receipt Item Type and Account Type is AR for the Current DA and where the Franchise Fee is less than the Cash Receipt Total.
 * 5) Update the Commission Amount in the table DACommission for the balance type Royalty where the Cash Receipt Item Type and Account Type is AR for the Current DA and where the Franchise Fee is less than the Cash Receipt Total.
 * 6)  Insert Store Opening Commission into the AdjustmentUnPosted table. This inserts all the Notes that are Paid and have a Loan Type of Minority Loan for the Current DA and where the Franchise Fee is greater than or equal to the Cash Receipt Total and the Franchise does not ave a Commission Approved Date.
 * 7) Insert Pending Franchise Fee Commisions into the DACommission table. This inserts all records that are of type Franchise Agreement, have a adjustment posting type of Franchise Sales Commission for the Current DA and where the Franchise Fee is greater than or equal to the Cash Receipt Total.