P05-02: 全費目と資金区分:表金・裏金、維持費未払い、仕入れ、人件費、元本、利息、税の帳簿への接続(原 P05-02 の完了の条件)
This commit is contained in:
@@ -300,6 +300,28 @@ func _approved_runtime_migrations(expected: Dictionary, reader: Dictionary) -> D
|
||||
old[&"elevators"] = raised
|
||||
fields.append("elevators_v1_to_v2")
|
||||
proof["elevators"] = {"only_version_changed": same_otherwise}
|
||||
# P05-02 A12: a save from before the funds were split gains the five empty fund
|
||||
# accounts on load; every other economy field stays byte-identical.
|
||||
var has_back_cash := func(economy: Variant) -> bool:
|
||||
if not economy is Dictionary:
|
||||
return false
|
||||
for account: Variant in (economy as Dictionary).get(&"accounts", []):
|
||||
if account is Dictionary and String((account as Dictionary).get(&"account_id", "")) == "BACK_CASH":
|
||||
return true
|
||||
return false
|
||||
if not has_back_cash.call(old.get(&"economy")) and has_back_cash.call(now.get(&"economy")):
|
||||
var added := {"BACK_CASH": false, "LOAN_INTEREST_EXPENSE": false, "LOAN_INTEREST_PAYABLE": true, "RANK_TAX_EXPENSE": false, "RANK_TAX_PAYABLE": true}
|
||||
var economy: Dictionary = (old[&"economy"] as Dictionary).duplicate(true)
|
||||
var accounts: Array = (economy[&"accounts"] as Array).duplicate(true)
|
||||
for account_id: String in added:
|
||||
accounts.append({&"account_id": account_id, &"allow_negative": added[account_id], &"system": false})
|
||||
accounts.sort_custom(func(left: Dictionary, right: Dictionary) -> bool: return String(left[&"account_id"]) < String(right[&"account_id"]))
|
||||
economy[&"accounts"] = accounts
|
||||
var only_accounts_added: bool = var_to_bytes(economy) == var_to_bytes(now[&"economy"])
|
||||
ok = ok and only_accounts_added
|
||||
old[&"economy"] = economy
|
||||
fields.append("economy_A12_empty_fund_accounts")
|
||||
proof["economy_A12"] = {"added_accounts": added.keys(), "only_accounts_added": only_accounts_added}
|
||||
if not fields.is_empty():
|
||||
# Saves keep the Runtime's own key order, so the mapped tree follows it.
|
||||
ok = ok and old.size() == now.size()
|
||||
|
||||
Reference in New Issue
Block a user