2024-07-17 19:35:00.336573
SELECT company_code, CONCAT(company_code, ' - ', company_name) company_name 
            FROM group_companies  ORDER BY default_company DESC

2024-07-17 19:35:00.349808
SELECT db_name FROM group_companies 
                WHERE company_code = 'UKE'

2024-07-17 19:35:00.365602
SELECT employee_code, 
                    CONCAT(employee_code, ' - ', initials, ' ', last_name) name 
            FROM uke_db.0_employee_master  ORDER BY name

2024-07-17 19:35:00.424036
SELECT id, value_code, value_name FROM 0_list_values  
		WHERE list_code= 'PETTY_CASH_TYPES' AND value_code='I_OWE_YOU'

2024-07-17 19:35:02.362857
SELECT DISTINCT al.id, al.batch_no, al.tran_date, al.amount, al.batch_complete, al.project_name, al.type, al.trans_no, al.pay_date, 
                    al.pay_amount, al.run_id  
                FROM ( (SELECT iou.id, iou.batch_no, iou.tran_date, iou.amount, iou.batch_complete, pm.description project_name, 0 type, 
                0 trans_no, '' pay_date, 0 pay_amount 0 run_id 
            FROM 0_i_owe_you iou 
                LEFT JOIN 0_i_owe_you_payments p  
                    ON p.iou_id = iou.id 
                        AND p.expense_source = '107' 
                LEFT JOIN 0_bank_trans bt 
                    ON iou.id = bt.person_id 
                        AND bt.type IN('230', '232')  
                LEFT JOIN 0_projects_master pm 
                    ON pm.project_id = iou.project_id
            WHERE iou.approval_status = '30' 
                AND iou.tran_date >= '2023-01-01' 
                AND iou.tran_date <= '2024-07-31'
                AND iou.approval_status IN (30, 130)
                AND p.id IS NULL AND bt.trans_no IS NULL  AND iou.batch_complete = 0  AND iou.employee_code ='1062' AND iou.type ='951' AND iou.batch_no = 0   ORDER BY iou.batch_no, iou.id ) UNION (SELECT iou.id, iou.batch_no, iou.tran_date, iou.amount, iou.batch_complete, pm.description project_name, p.expense_source type, 
                p.id trans_no, p.payment_date pay_date, p.amount pay_amount, p.id run_id 
            FROM 0_i_owe_you iou 
                LEFT JOIN 0_i_owe_you_payments p  
                    ON p.iou_id = iou.id 
                        AND p.expense_source = '107' 
                LEFT JOIN 0_projects_master pm 
                    ON pm.project_id = iou.project_id
            WHERE iou.approval_status = '30' 
                AND iou.tran_date >= '2023-01-01' 
                AND iou.tran_date <= '2024-07-31'
                AND iou.approval_status IN (30, 130)
                AND p.id > 0  AND iou.batch_complete = 0  AND iou.employee_code ='1062' AND iou.type ='951' AND iou.batch_no = 0   ORDER BY iou.batch_no, iou.id ) UNION (SELECT iou.id, iou.batch_no, iou.tran_date, iou.amount, iou.batch_complete, pm.description project_name, bt.type, 
                bt.trans_no, bt.trans_date pay_date, bt.amount*-1 pay_amount, bt.id run_id 
            FROM 0_i_owe_you iou 
                LEFT JOIN 0_bank_trans bt 
                    ON iou.id = bt.person_id 
                        AND bt.type IN('230', '232')  
                LEFT JOIN 0_projects_master pm 
                    ON pm.project_id = iou.project_id
                LEFT JOIN 0_list_values dp 
                    ON dp.id = pm.department_id
                LEFT JOIN 0_employee_master em 
                    ON em.employee_code = iou.employee_code   
            WHERE iou.approval_status = '30' 
                AND iou.tran_date >= '2023-01-01' 
                AND iou.tran_date <= '2024-07-31'
                AND iou.approval_status IN (30, 130)
                AND bt.trans_no > 0  AND iou.batch_complete = 0  AND iou.employee_code ='1062' AND iou.type ='951' AND iou.batch_no = 0   ORDER BY iou.batch_no, iou.id ) ) al 
                WHERE 1 = 1 
                ORDER BY al.id, al.tran_date, al.pay_date, al.run_id, al.trans_no

2024-07-17 19:35:02.449905
rollback

