================================================================== JOSAN PLATFORM · PHASE 10 BATCH 1 · VERIFICATION LOG Run: 2026-11-20 07:40 UTC · 10.11.14-MariaDB-0ubuntu0.24.04.1 · PHP 8.3.6 ================================================================== ### 4. MIGRATIONS 006 AND 007 ON A PHASE 9 DATABASE (upgrade path) --- Build the database exactly as Phase 9 shipped it, with Phase 9 demo data Phase 9 schema.sql + seed_admin.sql imported Remove all demo data later with: php database/demo_seed.php --remove Migrations recorded before upgrade: 001_phase5_photos_documents.sql 002_phase5_invoice_links.sql 003_phase6_payments.sql 004_industries_list.sql 005_phase9_security.sql Accounting tables before upgrade: 0 --- $ php database/check_trigger_support.php (Batch 1 code) Josan platform: database trigger support check · 2026-11-20 07:40 UTC Server: 10.11.14-MariaDB-0ubuntu0.24.04.1 · database josan · user josan@localhost Binary logging: OFF · log_bin_trust_function_creators: OFF Grants: GRANT USAGE ON *.* TO `josan`@`localhost` IDENTIFIED BY PASSWORD '***' GRANT ALL PRIVILEGES ON `josan`.* TO `josan`@`localhost` GRANT ALL PRIVILEGES ON `josan_restore_test`.* TO `josan`@`localhost` PASS CREATE TRIGGER is allowed PASS The trigger blocks a change (posted entries will be protected) RESULT: this host supports the database protection. Run php database/migrate.php. --- $ php database/migrate.php (Batch 1 code) Applying 006_phase10_accounting_foundation.sql ... done Applying 007_journal_protection.sql ... done 2 update(s) applied. exit code: 0 --- $ php database/migrate.php (second run: nothing left to do) Database is up to date. exit code: 0 --- Result in the database migration applied_at 001_phase5_photos_documents.sql 2026-11-20 07:40:11 002_phase5_invoice_links.sql 2026-11-20 07:40:11 003_phase6_payments.sql 2026-11-20 07:40:11 004_industries_list.sql 2026-11-20 07:40:11 005_phase9_security.sql 2026-11-20 07:40:11 006_phase10_accounting_foundation.sql 2026-11-20 07:40:12 007_journal_protection.sql 2026-11-20 07:40:12 accounting_table ENGINE accounting_settings InnoDB accounts InnoDB journal_entries InnoDB journal_lines InnoDB TRIGGER_NAME ACTION_TIMING EVENT_MANIPULATION EVENT_OBJECT_TABLE trg_accounts_protect_delete BEFORE DELETE accounts trg_accounts_protect_update BEFORE UPDATE accounts trg_journal_entries_no_delete BEFORE DELETE journal_entries trg_journal_entries_no_update BEFORE UPDATE journal_entries trg_journal_lines_closed BEFORE INSERT journal_lines trg_journal_lines_no_delete BEFORE DELETE journal_lines trg_journal_lines_no_update BEFORE UPDATE journal_lines number_sequences_doc_type enum('job','estimate','invoice','receipt','journal') --- $ php database/setup_accounting.php (existing businesses get their Chart of Accounts) Houston Pro Plumbing LLC (Plumbing): Plumbing and electrical services, 52 accounts Bright Spark Electrical Inc. (Electrical): Plumbing and electrical services, 52 accounts Summit Construction & Remodeling LLC (Construction): Construction and contracting, 54 accounts Fresh Start Cleaning Services (Cleaning): Cleaning and maintenance, 50 accounts 4 business(es) set up. --- second run Every business already has its Chart of Accounts. --- $ php tests/integrity_check.php (upgraded database) Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 0 journal entries, 208 accounts. No problems found. exit code: 0 ### 1–3. FRESH DATABASE: accounting_test, separation_test, integrity_check --- Fresh install from Batch 1 schema.sql (as on a new server) schema.sql + seed_admin.sql imported tables: 30 triggers: 7 migrations recorded: 001_phase5_photos_documents.sql, 002_phase5_invoice_links.sql, 003_phase6_payments.sql, 004_industries_list.sql, 005_phase9_security.sql, 006_phase10_accounting_foundation.sql, 007_journal_protection.sql Database is up to date. Remove all demo data later with: php database/demo_seed.php --remove --- $ php tests/accounting_test.php Industry templates: PASS each registered industry gets the right template (14 industries) PASS Construction and contracting: set up on registration (54 accounts, all 8 classifications, system and default accounts) PASS Plumbing and electrical services: set up on registration (52 accounts, all 8 classifications, system and default accounts) PASS Cleaning and maintenance: set up on registration (50 accounts, all 8 classifications, system and default accounts) PASS General professional services: set up on registration (48 accounts, all 8 classifications, system and default accounts) PASS Retail and trading: set up on registration (49 accounts, all 8 classifications, system and default accounts) PASS Hospitality: set up on registration (52 accounts, all 8 classifications, system and default accounts) PASS the six templates have different income and cost accounts PASS construction has job-cost sub-accounts; retail and hospitality have inventory PASS setting up again changes nothing Accounting settings: PASS another business's account is refused as a default PASS a liability is refused as the cash account PASS invalid fiscal month and reporting basis refused PASS valid settings saved (fiscal year July, cash reporting, another bank account) PASS the other business's settings did not change PASS fiscal year July: Jul 1 2026 – Jun 30 2027 PASS the database refuses a currency other than USD PASS the database refuses a default account of another business Chart of Accounts: PASS account created (expense, debit normal balance, logged) PASS duplicate code refused by the form PASS duplicate code refused by create_account and the database PASS the same code is fine in another business PASS invalid code, empty name and unknown classification refused PASS sub-account and sub-sub-account created PASS a fourth level is refused PASS a sub-account must share the parent classification PASS a parent from another business is refused (form and database) PASS an account cannot be moved under its own sub-account (no loops) PASS code, name and description edited and logged PASS contra account gets the opposite normal balance PASS a system account cannot change classification PASS a system account can be renamed and recoded PASS a system account cannot be deactivated or deleted PASS the database refuses to deactivate, retype or delete a system account PASS the database refuses to move an account to another business PASS a default account cannot be deactivated PASS a parent with active sub-accounts cannot be deactivated PASS an unused account can be deactivated, then activated PASS an unused account with no sub-accounts can be deleted PASS hierarchy order: sub-account listed right under its parent, one level deeper Journal engine: PASS balanced entry posted with the first number PASS several credit lines in one entry (receivable / revenue / sales tax) PASS posting records date, description, source, creator details, time and a fingerprint PASS unbalanced entry rejected with the difference PASS one-line entry rejected PASS a line with both a debit and a credit rejected PASS zero and negative amounts rejected PASS an account of another business rejected PASS a date before the books start date rejected PASS an inactive account rejected PASS rejected entries write nothing and use no number PASS the database refuses an unbalanced entry and a two-sided line PASS the same posting key cannot post twice (points to the existing entry) PASS three simultaneous postings of one key: exactly one entry PASS 20 entries posted in parallel: unique, gap-free journal numbers Posted entries are final: PASS the database refuses to change a posted entry PASS the database refuses to change a posted line PASS the database refuses to delete a posted entry or line PASS the database refuses an extra line on a posted entry PASS a used account cannot change classification or be deleted PASS an account with a balance cannot be deactivated PASS reversal swaps every debit and credit, links both ways, keeps the reason PASS after the reversal the accounts are back where they were PASS the original entry is unchanged PASS an entry can be reversed only once PASS a reversal cannot be reversed PASS a reversal needs a reason and cannot be dated before the entry PASS the database refuses a second reversal of the same entry PASS reversal logged in the activity history PASS books start date cannot move after the first entry Business separation: PASS the other business's journal shows none of these entries PASS the other business's chart contains none of these accounts PASS the database refuses a line pointing at another business (entry or account) PASS journal numbers are per business (the other business starts at 00001) PASS the same posting key may be used by another business All 75 accounting tests passed. exit code: 0 --- $ php tests/separation_test.php Separation test against http://127.0.0.1:8080 Staff member who may only access Business A: PASS staff can sign in PASS control: own Business A opens PASS blocked: GET admin/business_view.php?business=12 PASS blocked: GET admin/business_edit.php?business=12 PASS blocked: GET admin/owner_edit.php?business=12 PASS blocked: GET admin/owner_edit.php?business=12&id=9 PASS blocked: GET admin/owner_edit.php?business=11&id=9 PASS blocked: GET logo.php?business=12 PASS blocked: GET admin/business_view.php?business=999999999 PASS blocked: GET admin/staff.php PASS blocked: GET admin/activity.php PASS blocked: GET admin/settings.php PASS blocked: GET admin/customers.php?business=12 PASS blocked: GET admin/customer_view.php?business=12&id=18 PASS blocked: GET admin/customer_view.php?business=11&id=18 PASS blocked: GET admin/customer_edit.php?business=12&id=18 PASS blocked: GET admin/customer_edit.php?business=11&id=18 PASS blocked: GET admin/jobs.php?business=12 PASS blocked: GET admin/job_view.php?business=12&id=22 PASS blocked: GET admin/job_view.php?business=11&id=22 PASS blocked: GET admin/job_edit.php?business=12&id=22 PASS blocked: GET admin/job_edit.php?business=11&id=22 PASS blocked: GET admin/invoices.php?business=12 PASS blocked: GET admin/estimates.php?business=12 PASS blocked: GET admin/invoice_view.php?business=12&id=11 PASS blocked: GET admin/invoice_view.php?business=11&id=11 PASS blocked: GET admin/invoice_edit.php?business=11&id=11 PASS blocked: GET admin/estimate_view.php?business=11&id=10 PASS blocked: GET admin/estimate_edit.php?business=11&id=10 PASS blocked: GET admin/invoice_edit.php?business=11&estimate=10 PASS blocked: GET admin/doc_pdf.php?business=11&type=invoice&id=11 PASS blocked: GET admin/doc_pdf.php?business=12&type=estimate&id=10 PASS blocked: GET photo.php?user=9 PASS blocked: GET admin/payments.php?business=12 PASS blocked: GET admin/payment_view.php?business=11&id=9 PASS blocked: GET admin/payment_view.php?business=12&id=9 PASS blocked: GET admin/payment_pdf.php?business=11&id=9 PASS blocked: GET admin/payment_new.php?business=11&invoice=11 PASS blocked: GET admin/payment_new.php?business=12&invoice=11 PASS blocked: GET admin/expenses.php?business=12 PASS blocked: GET admin/expense_view.php?business=11&id=21 PASS blocked: GET admin/expense_view.php?business=12&id=21 PASS blocked: GET admin/expense_edit.php?business=11&id=21 PASS blocked: GET admin/expense_edit.php?business=12 PASS blocked: GET file.php?business=11&id=1 PASS blocked: GET file.php?business=12&id=1 PASS business list shows A and not B PASS blocked: POST add category to B PASS blocked: toggle B's category through A's page PASS blocked: POST deactivate B PASS blocked: set B owner's password through A PASS A's customer list shows only A's customers PASS A's job list filtered by B's customer shows nothing of B PASS blocked: new job in A for B's customer PASS blocked: complete B's job through A PASS blocked: cancel B's job via business={B} PASS blocked: edit B's customer through A PASS blocked: POST without CSRF token PASS blocked: cancel B's invoice through A PASS blocked: record a payment on B's invoice through A PASS blocked: cancel B's payment through A PASS blocked: cancel B's expense through A PASS blocked: remove B's file through A PASS B's category and job refused on an expense in A PASS B's job cannot prefill an invoice in A PASS no Business B data: admin/dashboard.php PASS no Business B data: admin/dashboard.php?period=year PASS no Business B data: admin/dashboard.php?period=year&biz=12 PASS no Business B data: admin/customers.php?status=all PASS no Business B data: admin/customers.php?biz=12 PASS no Business B data: admin/jobs.php PASS no Business B data: admin/jobs.php?biz=12 PASS no Business B data: admin/invoices.php PASS no Business B data: admin/invoices.php?biz=12 PASS no Business B data: admin/estimates.php PASS no Business B data: admin/estimates.php?biz=12 PASS no Business B data: admin/payments.php PASS no Business B data: admin/payments.php?biz=12 PASS no Business B data: admin/expenses.php PASS no Business B data: admin/expenses.php?biz=12 PASS no Business B data: admin/reports.php?report=cash_summary&period=year PASS no Business B data: admin/reports.php?report=cash_summary&period=year&biz=12 PASS no Business B data: admin/reports.php?report=cash_summary&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=sales_tax&period=year PASS no Business B data: admin/reports.php?report=sales_tax&period=year&biz=12 PASS no Business B data: admin/reports.php?report=sales_tax&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=ar_aging&period=year PASS no Business B data: admin/reports.php?report=ar_aging&period=year&biz=12 PASS no Business B data: admin/reports.php?report=ar_aging&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=payments&period=year PASS no Business B data: admin/reports.php?report=payments&period=year&biz=12 PASS no Business B data: admin/reports.php?report=payments&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=expenses&period=year PASS no Business B data: admin/reports.php?report=expenses&period=year&biz=12 PASS no Business B data: admin/reports.php?report=expenses&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=job_profit&period=year PASS no Business B data: admin/reports.php?report=job_profit&period=year&biz=12 PASS no Business B data: admin/reports.php?report=job_profit&period=year&biz=12&format=csv PASS no Business B data: admin/reports.php?report=customer_balances&period=year PASS no Business B data: admin/reports.php?report=customer_balances&period=year&biz=12 PASS no Business B data: admin/reports.php?report=customer_balances&period=year&biz=12&format=csv PASS report PDF for ?biz=B is not B (no B receipt in it) PASS blocked: GET admin/accounts.php?business=12 PASS blocked: GET admin/account_edit.php?business=12&id=567 PASS blocked: GET admin/account_edit.php?business=11&id=567 PASS blocked: GET admin/accounting_settings.php?business=12 PASS blocked: GET admin/journal.php?business=12 PASS blocked: GET admin/journal_view.php?business=12&id=30 PASS blocked: GET admin/journal_view.php?business=11&id=30 PASS blocked: GET admin/journal_new.php?business=12 PASS A's journal filtered by B's account shows nothing of B PASS Accounting overview lists A and not B PASS blocked: journal entry in A using B's accounts PASS blocked: reverse B's entry through A PASS blocked: delete B's account through A PASS blocked: B's account as A's default cash account PASS blocked: staff GET admin/backups.php PASS blocked: staff GET admin/backups.php?download=1 PASS blocked: staff GET admin/settings.php PASS blocked: staff GET admin/staff.php PASS All-businesses customers shows A PASS dashboard ?biz=B does not show B's name Owner of Business A: PASS owner can sign in PASS ?business=B ignored: owner still sees only A PASS owner cannot fetch B's logo PASS blocked: owner GET owner/customer_view.php?id=18 PASS blocked: owner GET owner/job_view.php?id=22 PASS blocked: owner GET owner/invoice_view.php?id=11 PASS blocked: owner GET owner/estimate_view.php?id=10 PASS blocked: owner GET owner/doc_pdf.php?type=invoice&id=11 PASS blocked: owner GET owner/invoice_view.php?id=12 PASS blocked: owner GET photo.php?user=9 PASS blocked: owner GET admin/invoice_edit.php?business=11 PASS blocked: owner GET admin/customers.php PASS blocked: owner GET admin/jobs.php PASS blocked: owner GET admin/invoices.php PASS blocked: owner GET admin/dashboard.php?biz=12 PASS blocked: owner GET owner/payment_view.php?id=9 PASS blocked: owner GET owner/payment_pdf.php?id=9 PASS blocked: owner GET admin/payments.php PASS blocked: owner GET admin/payment_new.php?business=11&invoice=11 PASS blocked: owner GET owner/expense_view.php?id=21 PASS blocked: owner GET file.php?id=1 PASS blocked: owner GET file.php?business=12&id=1 PASS blocked: owner GET admin/expenses.php PASS blocked: owner GET admin/expense_edit.php?business=11 PASS owner customer list ignores ?business=B PASS owner job list ignores ?business=B PASS owner sees own job read-only (no edit buttons) PASS owner report has no Business B data: owner/reports.php?report=cash_summary&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=cash_summary&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=sales_tax&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=sales_tax&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=ar_aging&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=ar_aging&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=payments&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=payments&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=expenses&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=expenses&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=job_profit&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=job_profit&period=year&biz=12&business=12&format=csv PASS owner report has no Business B data: owner/reports.php?report=customer_balances&period=year&biz=12 PASS owner report has no Business B data: owner/reports.php?report=customer_balances&period=year&biz=12&business=12&format=csv PASS blocked: owner GET admin/reports.php PASS owner journal ignores ?business=B (own entries only) PASS owner chart of accounts is their own, read-only PASS blocked: owner GET owner/journal_view.php?id=30 PASS blocked: owner GET owner/journal_view.php?business=12&id=30 PASS blocked: owner GET admin/accounts.php?business=11 PASS blocked: owner GET admin/journal_new.php?business=11 PASS blocked: owner GET admin/accounting_settings.php?business=11 PASS blocked: owner GET admin/account_edit.php?business=11 PASS blocked: owner GET admin/accounting.php PASS owner cannot reverse an entry PASS blocked: owner GET admin/customers.php?business=11 PASS blocked: owner GET admin/job_edit.php?business=11 PASS blocked: owner GET admin/job_view.php?business=11&id=21 PASS blocked: GET admin/dashboard.php PASS blocked: GET admin/businesses.php PASS blocked: GET admin/business_view.php?business=11 PASS blocked: GET admin/business_view.php?business=12 PASS blocked: GET admin/owner_edit.php?business=11 PASS blocked: GET admin/staff.php PASS blocked: GET admin/backups.php PASS blocked: GET admin/backups.php?download=1 Not signed in: PASS customer link opens with its token PASS receipt link opens with its token PASS not signed in: payments list redirects to login PASS customer link with a wrong token is 404 PASS customer link with no token is 404 PASS redirected to sign in: admin/business_view.php?business=11 PASS redirected to sign in: owner/dashboard.php PASS redirected to sign in: logo.php?business=12 PASS redirected to sign in: photo.php?user=9 PASS redirected to sign in: owner/doc_pdf.php?type=invoice&id=11 PASS redirected to sign in: file.php?business=12&id=1 PASS redirected to sign in: admin/reports.php?report=cash_summary PASS redirected to sign in: owner/reports.php?report=ar_aging&format=csv PASS redirected to sign in: admin/accounts.php?business=11 PASS redirected to sign in: owner/journal.php PASS redirected to sign in: admin/journal_view.php?business=11&id=29 Database rules: PASS database refuses a Business B job for a Business A customer All 202 separation checks passed. exit code: 0 --- $ php tests/integrity_check.php Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 0 journal entries, 208 accounts. No problems found. exit code: 0 ### 5. DATABASE TRIGGERS: direct SQL as the application's own database user (josan@localhost, ALL PRIVILEGES on josan) Target: posted entry id 34 (HPP-JE-00003), system account id 1 (1000 Cash on Hand) Fingerprint of entry 34 before: a8fd6919f1c67096d70217961078f285 mysql> UPDATE journal_entries SET description = 'tampered', total_debit = 1, total_credit = 1 WHERE id = 34; -------------- UPDATE journal_entries SET description = 'tampered', total_debit = 1, total_credit = 1 WHERE id = 34 -------------- ERROR 1644 (45000) at line 1: Posted journal entries cannot be changed. Post a reversing entry instead. mysql> UPDATE journal_lines SET debit = 999999 WHERE entry_id = 34 AND line_no = 1; -------------- UPDATE journal_lines SET debit = 999999 WHERE entry_id = 34 AND line_no = 1 -------------- ERROR 1644 (45000) at line 1: Posted journal lines cannot be changed. mysql> DELETE FROM journal_lines WHERE entry_id = 34; -------------- DELETE FROM journal_lines WHERE entry_id = 34 -------------- ERROR 1644 (45000) at line 1: Posted journal lines cannot be deleted. mysql> DELETE FROM journal_entries WHERE id = 34; -------------- DELETE FROM journal_entries WHERE id = 34 -------------- ERROR 1644 (45000) at line 1: Posted journal entries cannot be deleted. Post a reversing entry instead. mysql> INSERT INTO journal_lines (business_id, entry_id, line_no, account_id, debit, credit) VALUES (1, 34, 3, 34, 50, 0); -------------- INSERT INTO journal_lines (business_id, entry_id, line_no, account_id, debit, credit) VALUES (1, 34, 3, 34, 50, 0) -------------- ERROR 1644 (45000) at line 1: Lines cannot be added to a posted journal entry. mysql> UPDATE accounts SET is_active = 0 WHERE id = 1; -------------- UPDATE accounts SET is_active = 0 WHERE id = 1 -------------- ERROR 1644 (45000) at line 1: System accounts keep their type and stay active. mysql> UPDATE accounts SET account_class = 'expense', normal_balance = 'debit' WHERE id = 1; -------------- UPDATE accounts SET account_class = 'expense', normal_balance = 'debit' WHERE id = 1 -------------- ERROR 1644 (45000) at line 1: System accounts keep their type and stay active. mysql> UPDATE accounts SET is_system = 0, system_key = NULL WHERE id = 1; -------------- UPDATE accounts SET is_system = 0, system_key = NULL WHERE id = 1 -------------- ERROR 1644 (45000) at line 1: System accounts keep their type and stay active. mysql> DELETE FROM accounts WHERE id = 1; -------------- DELETE FROM accounts WHERE id = 1 -------------- ERROR 1644 (45000) at line 1: System accounts cannot be deleted. mysql> UPDATE accounts SET business_id = 2 WHERE id = 34; -------------- UPDATE accounts SET business_id = 2 WHERE id = 34 -------------- ERROR 1644 (45000) at line 1: An account cannot move to another business. Controls (permitted changes still work): mysql> UPDATE accounts SET name = 'Cash on Hand' WHERE id = 1; (statement succeeded) mysql> UPDATE accounts SET description = 'Office rent' WHERE id = 34; (statement succeeded) Fingerprint of entry 34 after: a8fd6919f1c67096d70217961078f285 (unchanged) System account after: 1000 Cash on Hand | class=asset | active=1 | system_key=cash The database administrator (root) is held by the same triggers: root> UPDATE journal_lines SET debit = 1 WHERE entry_id = 34; -------------- UPDATE journal_lines SET debit = 1 WHERE entry_id = 34 -------------- ERROR 1644 (45000) at line 1: Posted journal lines cannot be changed. ### 6. THE SIX INDUSTRY TEMPLATES Template Total Asset Liab Equity Income COGS Expns OthInc OthExp Sys Sub Contra Construction and contracting 54 11 7 4 3 6 19 2 2 9 10 2 PASS Construction and contracting: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Contract Revenue; industry examples: 4100 Change Order Revenue, 4200 Materials Billed, 5000 Job Costs, 5010 Job Materials Plumbing and electrical services 52 10 6 4 4 4 20 2 2 9 8 2 PASS Plumbing and electrical services: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Service Revenue; industry examples: 4100 Installation Revenue, 4200 Parts and Materials Sales, 4300 Emergency and After-Hours Revenue, 5000 Cost of Services Cleaning and maintenance 50 10 5 4 3 4 20 2 2 9 8 2 PASS Cleaning and maintenance: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Cleaning and Maintenance Services; industry examples: 4100 Recurring Service Contracts, 4200 One-Time and Special Services, 5000 Cost of Services, 5010 Cleaning Supplies and Chemicals General professional services 48 9 6 4 3 2 20 2 2 9 6 2 PASS General professional services: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Professional Fees; industry examples: 4100 Consulting Revenue, 4200 Reimbursable Expenses Billed, 5000 Cost of Services, 5020 Contract Labor Retail and trading 49 10 5 4 3 3 20 2 2 9 5 3 PASS Retail and trading: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Sales; industry examples: 4100 Sales Returns and Allowances, 4200 Shipping and Delivery Income, 5000 Cost of Goods Sold, 5100 Freight In Hospitality 52 10 7 4 4 3 20 2 2 9 5 2 PASS Hospitality: codes unique, all 8 classifications, the 9 system accounts, sub-accounts share the parent classification, contra balances opposite revenue account: 4000 Food Sales; industry examples: 4100 Beverage Sales, 4200 Room Revenue, 4300 Catering and Events, 5000 Food Cost Industry mapping: Construction→construction Roofing→construction Plumbing→trades Electrical→trades HVAC→trades Cleaning→cleaning Maintenance→cleaning Landscaping→cleaning Retail→retail Wholesale Trading→retail Hospitality→hospitality Restaurant→hospitality Consulting→professional Other→professional Businesses in the database: PASS Houston Pro Plumbing LLC (Plumbing) → Plumbing and electrical services: 52 accounts (template has 52), 9 system PASS Bright Spark Electrical Inc. (Electrical) → Plumbing and electrical services: 52 accounts (template has 52), 9 system PASS Summit Construction & Remodeling LLC (Construction) → Construction and contracting: 54 accounts (template has 54), 9 system PASS Fresh Start Cleaning Services (Cleaning) → Cleaning and maintenance: 50 accounts (template has 50), 9 system ### 7. DEFAULT ACCOUNTS POINT TO VALID ACCOUNTS OF THE SAME BUSINESS PASS Houston Pro Plumbing LLC (business 1) Cash: 1000 Cash on Hand (asset, business 1) Bank: 1010 Business Checking (asset, business 1) Accounts receivable: 1100 Accounts Receivable (asset, business 1) Accounts payable: 2000 Accounts Payable (liability, business 1) Revenue: 4000 Service Revenue (income, business 1) Sales tax: 2200 Sales Tax Payable (liability, business 1) PASS Bright Spark Electrical Inc. (business 2) Cash: 1000 Cash on Hand (asset, business 2) Bank: 1010 Business Checking (asset, business 2) Accounts receivable: 1100 Accounts Receivable (asset, business 2) Accounts payable: 2000 Accounts Payable (liability, business 2) Revenue: 4000 Service Revenue (income, business 2) Sales tax: 2200 Sales Tax Payable (liability, business 2) PASS Summit Construction & Remodeling LLC (business 3) Cash: 1000 Cash on Hand (asset, business 3) Bank: 1010 Business Checking (asset, business 3) Accounts receivable: 1100 Accounts Receivable (asset, business 3) Accounts payable: 2000 Accounts Payable (liability, business 3) Revenue: 4000 Contract Revenue (income, business 3) Sales tax: 2200 Sales Tax Payable (liability, business 3) PASS Fresh Start Cleaning Services (business 4) Cash: 1000 Cash on Hand (asset, business 4) Bank: 1010 Business Checking (asset, business 4) Accounts receivable: 1100 Accounts Receivable (asset, business 4) Accounts payable: 2000 Accounts Payable (liability, business 4) Revenue: 4000 Cleaning and Maintenance Services (income, business 4) Sales tax: 2200 Sales Tax Payable (liability, business 4) PASS database refuses another business account as a default Cannot add or update a child row: a foreign key constraint fails (`josan`.`accounting_settings`, CONSTRAINT `fk_acctset_cash` FOREIGN KEY (`business_id`, `cash_account_id`) REFERENCES `accounts` (`business_id`, `id`)) PASS settings form refuses another business account Choose an active assets account for Cash. PASS settings form refuses an account of the wrong classification Choose an active liabilities account for Sales tax. ### 8. AN ENTRY IS REFUSED WHEN UNBALANCED, DUPLICATED OR USING ANOTHER BUSINESS'S ACCOUNT PASS unbalanced ($250.00 debit, $249.99 credit) refused; nothing saved; no number used engine: Debits ($250.00) must equal credits ($249.99). Difference: $0.01. PASS database refuses an entry whose debit and credit totals differ CONSTRAINT `chk_journal_balanced` failed for `josan`.`journal_entries` PASS duplicate refused: the same posting key posted once (HPP-JE-00003); the second attempt points back to it engine: This entry has already been posted. PASS database refuses a second entry with the same posting key Duplicate entry '1-verify:dup:1795160494' for key 'uq_journal_posting_key' PASS another business's account (Bright Spark's bank, id 54) refused engine: Line 1: choose an account of this business. PASS control: a line with this business's own account is accepted on an open entry PASS database refuses a line pointing at another business's account Cannot add or update a child row: a foreign key constraint fails (`josan`.`journal_lines`, CONSTRAINT `fk_jline_account` FOREIGN KEY (`business_id`, `account_id`) REFERENCES `accounts` (`business_id`, `id`)) PASS test entry rolled back (nothing left behind) ### 9. REVERSAL, AND THE ORIGINAL STAYS UNCHANGED Original HPP-JE-00003 lines: 1010 Business Checking debit 1000.00 credit 0.00 3000 Owner's Equity debit 0.00 credit 1000.00 Reversal HPP-JE-00004 lines (reason: Verification: contribution recorded twice): 1010 Business Checking debit 0.00 credit 1000.00 3000 Owner's Equity debit 1000.00 credit 0.00 PASS original entry and its lines are byte-for-byte unchanged after the reversal (row snapshot compared) PASS linked both ways: HPP-JE-00003 reversed by HPP-JE-00004 PASS bank balance back where it was before the contribution PASS a second reversal of the same entry is refused This entry was already reversed by HPP-JE-00004. PASS a reversal cannot itself be reversed This entry is itself a reversal and cannot be reversed. Post a new entry instead. Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 4 journal entries, 208 accounts. No problems found. ALL VERIFICATION CHECKS PASSED ### HOSTING WITHOUT TRIGGER PERMISSION (simulated Namecheap restriction) Database user josan_lim has every cPanel privilege except TRIGGER on josan_limited (a Phase 9 database). GRANT USAGE ON *.* TO `josan_lim`@`localhost` IDENTIFIED BY PASSWORD '*E913DC3BA46F2E02527BF95254816759CAA62D54' GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `josan_limited`.* TO `josan_lim`@`localhost` --- 1. $ php database/check_trigger_support.php Josan platform: database trigger support check · 2026-11-20 07:42 UTC Server: 10.11.14-MariaDB-0ubuntu0.24.04.1 · database josan_limited · user josan_lim@localhost Binary logging: OFF · log_bin_trust_function_creators: OFF Grants: GRANT USAGE ON *.* TO `josan_lim`@`localhost` IDENTIFIED BY PASSWORD '***' GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `josan_limited`.* TO `josan_lim`@`localhost` FAIL CREATE TRIGGER refused: SQLSTATE[42000]: Syntax error or access violation: 1142 TRIGGER command denied to user 'josan_lim'@'localhost' for table `josan_limited`.`zz_trigger_check_d2a1ba` cPanel > MySQL Databases > the user > ALL PRIVILEGES on this database (includes TRIGGER), then run again. RESULT: triggers are NOT available. Posting journal entries will stay disabled until they are (see README "Database protection"). exit code: 1 --- 2. $ php database/migrate.php Applying 006_phase10_accounting_foundation.sql ... done Applying 007_journal_protection.sql ... FAILED SQLSTATE[42000]: Syntax error or access violation: 1142 TRIGGER command denied to user 'josan_lim'@'localhost' for table `josan_limited`.`journal_entries` The database user is not allowed to create triggers, so the books cannot be protected at database level. Nothing was skipped: posting journal entries stays DISABLED until this update is applied. 1. cPanel > MySQL Databases: give the user ALL PRIVILEGES on the database (includes TRIGGER). 2. Run php database/check_trigger_support.php and send its output to the host's support if it still fails. 3. Only if the host cannot allow triggers, and Josan accepts it: set 'ledger_protection' => 'application' in includes/config.php (see README "Database protection"). Fix the problem and run this again. Statements before the failure may already be applied. exit code: 1 Migrations recorded: 001_phase5_photos_documents.sql, 002_phase5_invoice_links.sql, 003_phase6_payments.sql, 004_industries_list.sql, 005_phase9_security.sql, 006_phase10_accounting_foundation.sql Triggers installed: 0 --- 3. $ php database/migrate.php (run again: 007 is retried, never skipped) Applying 007_journal_protection.sql ... FAILED SQLSTATE[42000]: Syntax error or access violation: 1142 TRIGGER command denied to user 'josan_lim'@'localhost' for table `josan_limited`.`journal_entries` The database user is not allowed to create triggers, so the books cannot be protected at database level. Nothing was skipped: posting journal entries stays DISABLED until this update is applied. 1. cPanel > MySQL Databases: give the user ALL PRIVILEGES on the database (includes TRIGGER). 2. Run php database/check_trigger_support.php and send its output to the host's support if it still fails. 3. Only if the host cannot allow triggers, and Josan accepts it: set 'ledger_protection' => 'application' in includes/config.php (see README "Database protection"). Fix the problem and run this again. Statements before the failure may already be applied. exit code: 1 --- 4. Businesses and charts still work (demo data, Chart of Accounts) Remove all demo data later with: php database/demo_seed.php --remove 208 accounts in 4 businesses --- 5. Posting a journal entry Screen notice on every Accounting page: Posting is disabled: the database protection for the books is not installed (7 of 7 triggers missing). Run php database/migrate.php; see README "Database protection". Posting: REFUSED - Posting is disabled: the database protection for the books is not installed (7 of 7 triggers missing). Run php database/migrate.php; see README "Database protection". --- 6. $ php tests/integrity_check.php Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 0 journal entries, 208 accounts. 1 problem(s): - database protection: missing triggers: trg_journal_entries_no_update, trg_journal_entries_no_delete, trg_journal_lines_no_update, trg_journal_lines_no_delete, trg_journal_lines_closed, trg_accounts_protect_update, trg_accounts_protect_delete (posting is disabled until they are installed) exit code: 1 --- 7. $ php database/golive_check.php (protection line) FAIL Database protection for the books missing (trg_journal_entries_no_update, trg_journal_entries_no_delete, trg_journal_lines_no_update, trg_journal_lines_no_delete, trg_journal_lines_closed, trg_accounts_protect_update, trg_accounts_protect_delete): posting is DISABLED; see README "Database protection" === Explicit decision: Josan accepts application-only protection ('ledger_protection' => 'application' in config.php) config.php:57: 'ledger_protection' => 'application', --- $ php database/migrate.php SKIPPED 007_journal_protection.sql: config.php sets 'ledger_protection' => 'application' (reduced protection, chosen explicitly). Not recorded as applied: remove that setting and run this again once triggers are allowed. Database is up to date. exit code: 0 --- Posting a journal entry Screen notice on every Accounting page: Reduced protection: the database triggers that lock posted entries are not installed (7 of 7 missing). config.php accepts application-only protection. Posting: POSTED HPP-JE-00001 --- $ php tests/integrity_check.php WARNING: reduced protection accepted in config.php; missing database triggers: trg_journal_entries_no_update, trg_journal_entries_no_delete, trg_journal_lines_no_update, trg_journal_lines_no_delete, trg_journal_lines_closed, trg_accounts_protect_update, trg_accounts_protect_delete Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 1 journal entries, 208 accounts. No problems found. exit code: 0 --- $ php database/golive_check.php (protection line) WARN Database protection for the books missing (trg_journal_entries_no_update, trg_journal_entries_no_delete, trg_journal_lines_no_update, trg_journal_lines_no_delete, trg_journal_lines_closed, trg_accounts_protect_update, trg_accounts_protect_delete): reduced protection accepted in config.php === The host enables triggers; the setting is removed GRANT TRIGGER ON josan_limited.* (cPanel: ALL PRIVILEGES) --- $ php database/check_trigger_support.php GRANT USAGE ON *.* TO `josan_lim`@`localhost` IDENTIFIED BY PASSWORD '***' PASS CREATE TRIGGER is allowed PASS The trigger blocks a change (posted entries will be protected) RESULT: this host supports the database protection. Run php database/migrate.php. --- $ php database/migrate.php Applying 007_journal_protection.sql ... done 1 update(s) applied. exit code: 0 Triggers installed: 7 --- Posting a journal entry Screen notice on every Accounting page: (none: fully protected) Posting: POSTED HPP-JE-00002 --- $ php tests/integrity_check.php Checked 10 invoices, 8 payments, 20 expenses, 0 attachments, 2 journal entries, 208 accounts. No problems found. exit code: 0 ### 10. FULL REGRESSION, PHASES 1–10, ON A FRESH INSTALL --- part 1 db:1 web:200 mail:1 == test_phase12.py 33/33 checks passed Remove all demo data later with: php database/demo_seed.php --remove == test_phase3.py 37/37 checks passed == test_phase4.py 34/34 checks passed == test_dashboard.py 90/90 checks passed == test_phase6.py 58/58 checks passed --- part 2 db:1 web:200 mail:1 == test_phase7.py 46/46 checks passed == test_category.py 13/13 checks passed == test_industry.py 18/18 checks passed == test_phase8.py 50/50 checks passed == test_audit_workflow.py 74/74 checks passed == test_phase9.py 57/57 checks passed == test_phase10.py 61/61 checks passed == test_phase5.py 59/59 checks passed == separation_test All 202 separation checks passed. == stale_check_test All 10 stale-check tests passed. == backup_restore_test All 10 restore checks passed. == accounting_test All 75 accounting tests passed. == money_test All 34 money tests passed. == ip_test All 23 IP tests passed. == integrity_check Checked 10 invoices, 7 payments, 26 expenses, 4 attachments, 3 journal entries, 517 accounts. No problems found. == php errors: 0 bytes ================================================================== SUMMARY accounting_test (fresh database): 75 / 75 passed separation_test (fresh database): 202 / 202 passed integrity_check (fresh database): no problems, exit 0 migrations 006 + 007 on Phase 9 data: applied, exit 0; second run: up to date trigger attacks (direct SQL): 10 / 10 refused (incl. root); 2 / 2 permitted edits succeed templates / defaults / posting / reversal verification: ALL PASSED host without TRIGGER privilege: posting disabled until protection installed or explicitly waived full regression Phases 1-10: 630 browser + 354 PHP checks passed, integrity clean, 0 PHP errors ==================================================================