Expense File

1.  Update the MunID in the work table: UPDATE aa_al_expenditures JOIN m_municipalities ON SystemCode = MunDOECode SET aa_al_expenditures.MunID = m_municipalities.MunID WHERE MunModID = 2 AND MunState = 'AL' AND MunType = 'District'

2.  Update the SadID in the work table: UPDATE aa_al_expenditures JOIN m_schoolannualdata ON MunID = SadScdID AND FiscalYear = SadYear SET aa_al_expenditures.SadID = m_schoolannualdata.SadID WHERE SadScenario = 'Baseline'

3.  Check for missing SadID’s and insert records for each one missing: INSERT INTO m_schoolannualdata (SadScdID, SadYear, SadDataStatus, SadScenario, SadDateAdded, SadDateModified) SELECT DISTINCT aa_al_expenditures.MunID AS SadScdID, FiscalYear AS SadYear, 'Audited' AS SadDataStatus, 'Baseline' AS SadScenario, NOW() AS SadDateAdded, NOW() AS SadDateModified FROM aa_al_expenditures JOIN m_municipalities ON SystemCode = MunDOECode WHERE SadID IS NULL AND MunModID = 2 AND MunState = 'AL' AND MunType = 'District'

4.  Run the update to SadID script again.

5.  Now insert the Expenditure records to the financial detail table: INSERT INTO s_financialdatadetail (SfdMunID, SfdSadID, SfdFtsID, SfdSscID, SfdFundCode, SfdDescription, SfdAmount, SfdDateAdded, SfdDateModified) SELECT MunID, SadID, SfdFtsID, SfdSscID, SfdFundCode, Object, ROUND(REPLACE(REPLACE(Expenditue,'$',''),',',''),0), SfdDateAdded, SfdDateModified FROM aa_al_expenditures