-- Pacific Logistics · slice 29 · Tax Returns (Iter 5 Turn 3)
--
-- No new tables — every report reads from existing facts:
--   PAYE / SDL / NSSF / WCF  →  payroll_records
--   VAT (output vs input)    →  journal_lines on COAs 3008 / 4010
--
-- Adds grants only.

-- Codes used by the report queries (verified this slice):
--   3008 = VAT Recoverable        (input VAT — debit-natural)
--   4010 = VAT Payable            (output VAT — credit-natural)
--   4003 = NSSF Payable
--   4004 = PAYE Payable
--   4006 = SDL Payable
--   4008 = WCF Payable

INSERT IGNORE INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on) VALUES
-- Executive (1)
(1,  'TaxReturns', 'index',      1, NOW()),
(1,  'TaxReturns', 'paye',       1, NOW()),
(1,  'TaxReturns', 'vat',        1, NOW()),
(1,  'TaxReturns', 'statutory',  1, NOW()),
-- Finance Manager (2)
(2,  'TaxReturns', 'index',      1, NOW()),
(2,  'TaxReturns', 'paye',       1, NOW()),
(2,  'TaxReturns', 'vat',        1, NOW()),
(2,  'TaxReturns', 'statutory',  1, NOW()),
(2,  'TaxReturns', 'payeCsv',    1, NOW()),
-- Accountant (3)
(3,  'TaxReturns', 'index',      1, NOW()),
(3,  'TaxReturns', 'paye',       1, NOW()),
(3,  'TaxReturns', 'vat',        1, NOW()),
(3,  'TaxReturns', 'statutory',  1, NOW()),
(3,  'TaxReturns', 'payeCsv',    1, NOW()),
-- Administrator (10)
(10, 'TaxReturns', 'index',      1, NOW()),
(10, 'TaxReturns', 'paye',       1, NOW()),
(10, 'TaxReturns', 'vat',        1, NOW()),
(10, 'TaxReturns', 'statutory',  1, NOW()),
(10, 'TaxReturns', 'payeCsv',    1, NOW());

SELECT ug.user_group_name, GROUP_CONCAT(ugp.action_allowed ORDER BY ugp.action_allowed) AS actions
  FROM user_groups_perms ugp
  JOIN user_groups ug ON ug.c0d = ugp.user_group_id
 WHERE ugp.controller_allowed = 'TaxReturns'
 GROUP BY ug.c0d, ug.user_group_name;
