55 lines
3.7 KiB
SQL
55 lines
3.7 KiB
SQL
-- Refinery (المصفاة): role REFINERY_OP (موظف عطاء الصرف) sees the الارساليات screen with the شحن الديزل (Excel) report, print and the
|
|
-- payment actions. Safe to re-run; not run by the app.
|
|
-- Run order: part 1 in the NTP schema (only needed where the role row is missing; it exists in the legacy data), part 2 in the primary
|
|
-- (NAFITHTCS) schema, after db/grains-screen-permissions.sql. Afterwards assign role REFINERY_OP to the users who need it (NTPUSERS):
|
|
-- they sign in as before. The API applies the rows within about a minute, the browser on the next reload / sign-in.
|
|
-- SU needs no rows. Everything else of the refinery module (wage claims, commission claims, wallets, variables, cards, the other
|
|
-- trip reports, the reverse-advance actions, recalculate balance) stays with REFINERY_MGR and SU.
|
|
|
|
-- ---------------------------------------------------------------------------------------------------------------------------
|
|
-- Part 1 (NTP schema): the role row, copied from REFINERY_MGR (level, type, manager columns) when REFINERY_OP does not exist yet.
|
|
-- ---------------------------------------------------------------------------------------------------------------------------
|
|
INSERT INTO ROLES (CODE, NAME, DIRECTMANAGER, EMPLOYEES, MANAGERS, LEVELNUMBER, ROLETYPE, TENDER)
|
|
SELECT 'REFINERY_OP', 'موظف عطاء الصرف', r.DIRECTMANAGER, r.EMPLOYEES, r.MANAGERS, r.LEVELNUMBER, r.ROLETYPE, r.TENDER
|
|
FROM ROLES r
|
|
WHERE r.CODE = 'REFINERY_MGR'
|
|
AND NOT EXISTS (SELECT 1 FROM ROLES x WHERE x.CODE = 'REFINERY_OP');
|
|
|
|
COMMIT;
|
|
|
|
-- ---------------------------------------------------------------------------------------------------------------------------
|
|
-- Part 2 (primary schema): 13 keys.
|
|
-- screen refinery.trips (list, view, history)
|
|
-- report refinery.trips.dieselReport (شحن الديزل Excel)
|
|
-- print refinery.trips.print (cash voucher)
|
|
-- diesel refinery.trips.firstAdvance, secondAdvance
|
|
-- cash refinery.trips.cashPayment, receipt
|
|
-- bank / orange refinery.trips.payment, orangePayment
|
|
-- e-wallet refinery.trips.exchange, exchangeAudit, activateWalletExchange, confirmExchange (Dinarak is OFF until configured)
|
|
-- ---------------------------------------------------------------------------------------------------------------------------
|
|
INSERT INTO GRAINS_SCREEN_PERMISSIONS (ROLECODE, RESOURCE_KEY)
|
|
SELECT 'REFINERY_OP', v.resource_key
|
|
FROM (SELECT 'refinery.trips' AS resource_key FROM dual UNION ALL
|
|
SELECT 'refinery.trips.dieselReport' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.print' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.firstAdvance' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.secondAdvance' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.cashPayment' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.receipt' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.payment' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.orangePayment' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.exchange' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.exchangeAudit' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.activateWalletExchange' FROM dual UNION ALL
|
|
SELECT 'refinery.trips.confirmExchange' FROM dual) v
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM GRAINS_SCREEN_PERMISSIONS p
|
|
WHERE p.rolecode = 'REFINERY_OP' AND p.resource_key = v.resource_key);
|
|
|
|
COMMIT;
|
|
|
|
-- Check (expect 13 rows):
|
|
-- SELECT resource_key FROM GRAINS_SCREEN_PERMISSIONS WHERE rolecode = 'REFINERY_OP' ORDER BY resource_key;
|
|
-- Take a right away by deleting its row, e.g.:
|
|
-- DELETE FROM GRAINS_SCREEN_PERMISSIONS WHERE rolecode = 'REFINERY_OP' AND resource_key = 'refinery.trips.confirmExchange';
|