bug fixes: orgs load properly (metatable set), orgs can't have same name, orgs now saved on modifying operations

This commit is contained in:
Luke Miller
2021-04-16 20:27:31 -04:00
parent 6bc5f4077e
commit cff1d393c0
3 changed files with 28 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ local store_orgs = function()
modpol.ocutil.fatal_error ("store_data: orgs")
end
local nn = modpol.ocutil.table_length (modpol.orgs)
local nn = modpol.ocutil.table_length (modpol.orgs.array)
local str = "entries"
if nn == 1 then str = "entry" end
modpol.ocutil.log (nn .. " orgs stored to disk")
@@ -80,7 +80,7 @@ end
modpol.store_data = function()
store_ledger()
store_orgs()
store_old_ledgers()
-- store_old_ledgers()
end
-- ===================================================================
@@ -116,7 +116,12 @@ local load_orgs = function()
end
modpol.orgs = func()
local nn = modpol.ocutil.table_length (modpol.orgs)
-- this block resets the metatable after being loaded in so that the class functions work
for id, org in ipairs(modpol.orgs.array) do
setmetatable(org, modpol.orgs)
end
local nn = modpol.ocutil.table_length (modpol.orgs.array)
local str = "entries"
if nn == 1 then str = "entry" end
modpol.ocutil.log (nn .. " orgs loaded from disk")
@@ -152,7 +157,7 @@ end
modpol.load_storage = function()
load_ledger()
load_orgs()
load_old_ledgers()
-- load_old_ledgers()
end
-- ===================================================================