Differences
This shows you the differences between two versions of the page.
— |
control_sql_-_invalid_gl_account_error [2019/01/27 11:29] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | |||
+ | |||
+ | |||
+ | After upgrading to Control 4.5, marking an order Sale, editing, or posting a payment on an Order marked Sale gives an " | ||
+ | |||
+ | |||
+ | |||
+ | ===== Causes ===== | ||
+ | |||
+ | |||
+ | |||
+ | There are records in the GLAccount table with classtypeids of 8055 and 8051 with **VALID** GLClassificationTypes. If the records have invalid GLClassificationTypes, | ||
+ | |||
+ | |||
+ | |||
+ | There are assigned expense accounts (ClassTypeID: | ||
+ | |||
+ | |||
+ | |||
+ | ===== Solution ===== | ||
+ | |||
+ | |||
+ | |||
+ | 1. Run the following queries to correct: | ||
+ | |||
+ | |||
+ | |||
+ | ==== 1a. Correct the assigned expense accounts with incorrect GLClassificationTypes ==== | ||
+ | |||
+ | |||
+ | |||
+ | [[code_formattsql|code_formattsql|code format=" | ||
+ | |||
+ | |||
+ | |||
+ | -- For Control 4.4 and later ( Ledger Table update) | ||
+ | |||
+ | |||
+ | |||
+ | -- Run this to correct Assigned Expenses accounts missing GLClassificationTypes from the | ||
+ | |||
+ | |||
+ | |||
+ | -- GLAccount and Ledger tables | ||
+ | |||
+ | |||
+ | |||
+ | select gl.glaccountid, | ||
+ | |||
+ | |||
+ | |||
+ | from Ledger gl with(nolock) left outer join | ||
+ | |||
+ | |||
+ | |||
+ | glaccount ga on ga.id = gl.glaccountid | ||
+ | |||
+ | |||
+ | |||
+ | where gl.id > 0 and gl.glclassificationtype > 8999 or glaccountclasstypeid | ||
+ | |||
+ | |||
+ | |||
+ | group by glaccountid, | ||
+ | |||
+ | |||
+ | |||
+ | -- UPDATE GLAccount | ||
+ | |||
+ | |||
+ | |||
+ | UPDATE GLAccount | ||
+ | |||
+ | |||
+ | |||
+ | SET GlClassificationType = 9001, | ||
+ | |||
+ | |||
+ | |||
+ | GLClassTypeName = ' | ||
+ | |||
+ | |||
+ | |||
+ | WHERE ClassTypeID = 8051 AND GlClassificationType IS NULL | ||
+ | |||
+ | |||
+ | |||
+ | UPDATE GLAccount | ||
+ | |||
+ | |||
+ | |||
+ | SET GlClassificationType = 9002, | ||
+ | |||
+ | |||
+ | |||
+ | GLClassTypeName = 'Cost Tracking' | ||
+ | |||
+ | |||
+ | |||
+ | WHERE ID = 6002 AND GlClassificationType IS NULL | ||
+ | |||
+ | |||
+ | |||
+ | UPDATE GLAccount | ||
+ | |||
+ | |||
+ | |||
+ | SET GlClassificationType = 9003, | ||
+ | |||
+ | |||
+ | |||
+ | GLClassTypeName = ' | ||
+ | |||
+ | |||
+ | |||
+ | WHERE ID = 6001 AND GlClassificationType IS NULL | ||
+ | |||
+ | |||
+ | |||
+ | -- UPDATE GL | ||
+ | |||
+ | |||
+ | |||
+ | UPDATE Ledger | ||
+ | |||
+ | |||
+ | |||
+ | SET GlClassificationType = GA.GlClassificationType, | ||
+ | |||
+ | |||
+ | |||
+ | GlClassTypeName = GA.GlClassTypeName | ||
+ | |||
+ | |||
+ | |||
+ | FROM Ledger GL LEFT OUTER JOIN | ||
+ | |||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | |||
+ | WHERE GL.ID > 0 AND ( GL.GlClassificationType IS NULL OR GL.GlClassificationType = 0 | ||
+ | |||
+ | |||
+ | |||
+ | OR GL.GlClassificationType = -1 ) | ||
+ | |||
+ | |||
+ | |||
+ | ) | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | ==== 1b. Update the Parts and Ledger tables to use the OffBalanceSheet field. ==== | ||
+ | [[code_formattsql|code_formattsql|code format=" | ||
+ | |||
+ | |||
+ | |||
+ | -- Update Parts Asset accounts | ||
+ | |||
+ | |||
+ | |||
+ | Update Part | ||
+ | |||
+ | |||
+ | |||
+ | Set AssetAccountID = 60, AssetAccountClassTypeID = 8001 | ||
+ | |||
+ | |||
+ | |||
+ | From Part | ||
+ | |||
+ | |||
+ | |||
+ | Left Join GLAccount GLA on part.AssetAccountID = GLA.ID | ||
+ | |||
+ | |||
+ | |||
+ | Where (GLA.GLClassificationType in (9000, | ||
+ | |||
+ | |||
+ | |||
+ | or Part.AssetAccountID is Null) and TrackCosts = 1 | ||
+ | |||
+ | |||
+ | |||
+ | -- Update Part Expense Accounts | ||
+ | |||
+ | |||
+ | |||
+ | Update Part | ||
+ | |||
+ | |||
+ | |||
+ | Set ExpenseAccountID = 61, ExpenseAccountClassTypeID = 8001 | ||
+ | |||
+ | |||
+ | |||
+ | From Part | ||
+ | |||
+ | |||
+ | |||
+ | Left Join GLAccount GLA on part.ExpenseAccountID = GLA.ID | ||
+ | |||
+ | |||
+ | |||
+ | Where (GLA.GLClassificationType in (9000, | ||
+ | |||
+ | |||
+ | |||
+ | or Part.ExpenseAccountID is Null) and TrackCosts = 1 | ||
+ | |||
+ | |||
+ | |||
+ | -- Update Part Computed Cost Accounts | ||
+ | |||
+ | |||
+ | |||
+ | Update Part | ||
+ | |||
+ | |||
+ | |||
+ | Set ComputedCostAccountID = 61, ComputedCostAccountClassTypeID = 8001 | ||
+ | |||
+ | |||
+ | |||
+ | From Part | ||
+ | |||
+ | |||
+ | |||
+ | Left Join GLAccount GLA on part.ComputedCostAccountID = GLA.ID | ||
+ | |||
+ | |||
+ | |||
+ | Where (GLA.GLClassificationType in (9000, | ||
+ | |||
+ | |||
+ | |||
+ | -- Update Ledger | ||
+ | |||
+ | |||
+ | |||
+ | Update Ledger | ||
+ | |||
+ | |||
+ | |||
+ | Set OffBalanceSheet = 1, | ||
+ | |||
+ | |||
+ | |||
+ | GLAccountID = Case when Ledger.GLClassificationType = 9001 then P.ExpenseAccountID | ||
+ | |||
+ | |||
+ | |||
+ | when Ledger.GLClassificationType = 9002 then Coalesce(P.AssetAccountID, | ||
+ | |||
+ | |||
+ | |||
+ | when Ledger.GLClassificationType = 9003 then 34 end, | ||
+ | |||
+ | |||
+ | |||
+ | GLAccountClassTypeID = 8001 | ||
+ | |||
+ | |||
+ | |||
+ | From Ledger | ||
+ | |||
+ | |||
+ | |||
+ | Left Join Part P on P.ID = Ledger.PartID | ||
+ | |||
+ | |||
+ | |||
+ | Where Ledger.GLClassificationType in (9000, | ||
+ | |||
+ | |||
+ | |||
+ | Update Ledger | ||
+ | |||
+ | |||
+ | |||
+ | Set Ledger.GLClassificationType = GLA.GLClassificationType, | ||
+ | |||
+ | |||
+ | |||
+ | Ledger.GLClassTypeName = GLA.GLClassTypeName | ||
+ | |||
+ | |||
+ | |||
+ | From Ledger | ||
+ | |||
+ | |||
+ | |||
+ | Left Join GlAccount GLA on GLA.ID = Ledger.GLAccountID | ||
+ | |||
+ | |||
+ | |||
+ | Where Ledger.GLClassificationType in (9000, | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | 1c. | ||
+ | [[code format=" | ||
+ | |||
+ | |||
+ | |||
+ | update glaccount | ||
+ | |||
+ | |||
+ | |||
+ | set classtypeid = 8001 | ||
+ | |||
+ | |||
+ | |||
+ | where classtypeid in (8051, 8055) | ||
+ | |||
+ | |||
+ | |||
+ | update ledger | ||
+ | |||
+ | |||
+ | |||
+ | set glclassificationtype = ga.glclassificationtype | ||
+ | |||
+ | |||
+ | |||
+ | , glclasstypename = ga.glclasstypename | ||
+ | |||
+ | |||
+ | |||
+ | from ledger gl | ||
+ | |||
+ | |||
+ | |||
+ | left outer join glaccount ga on ga.id = gl.glaccountid | ||
+ | |||
+ | |||
+ | |||
+ | where gl.glclassificationtype | ||
+ | |||
+ | |||
+ | |||
+ | update part set expenseaccountclasstypeid = 8001 where expenseaccountclasstypeid in (8051,8055) | ||
+ | |||
+ | |||
+ | |||
+ | update part set assetaccountclasstypeid = 8001 where assetaccountclasstypeid in (8051,8055) | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | 2. Restart the SSLIP. | ||
+ | ===== Notes ===== | ||
+ | The correcting query was added to version 4.5.1005.2501. Upgrading from a version prior to 4.40.0912.xxxx to versions 4.5.1005.2501 and later will not have this issue. | ||