Closed lasuk closed 4 months ago
While working on PR #47 (Maintenance of GitHob Actions), I came up with a design idea:
Problem: The interdependence between the VAT codes and accounts results in some accounts with attached VAT code preventing those VAT codes from being deleted and vice versa.
Solution:
Add a flag 'ignore_references' or similar when mirroring or deleting VAT codes and accounts. See sketch for VAT codes in c236493d (prepared together with our friend ChatGPT).
Mirror both objects twice, first ignoring referenced accounts and vat codes:
# Restore default VAT and accounts
initial_vat = pd.read_csv(StringIO(VAT_CODES), skipinitialspace=True)
initial_accounts = pd.read_csv(StringIO(ACCOUNTS), skipinitialspace=True)
# First, delete unneeded VAT codes and accounts that are not reference
cashctrl_ledger.mirror_vat_codes(target_state=initial_vat, delete="keep_referenced")
cashctrl_ledger.mirror_account_chart(target=initial_accounts, delete="keep_referenced")
# Then also delete VAT codes and accounts that were initially referenced
cashctrl_ledger.mirror_vat_codes(target_state=initial_vat, delete=True)
cashctrl_ledger.mirror_account_chart(target=initial_accounts, delete=True)
The 'keep_reference' option when deleting VAT codes might be even more useful when combined with @AlexTheWizardL's suggestion to extend 'delete_VAT_codes' to delete duplicates.
Issue
The script to resetting the CashCtrl test account to the original state fails in the presence of duplicate tax codes with below error:
This issue occurs fairly often. See for example Run#28.
Tasks
scripts/restore_initial_state.py
to remove duplicate tax codes.