CREATE VIEW `hr_autopay_bank_report_b` AS
    SELECT 
        `sb`.`login_id` AS `staff_code`,
        `hs`.`bank_account` AS `bank_account`,
        CONCAT(`sb`.`surname`, ' ', `sb`.`firstname`) AS `staff_name`,
        `hpci`.`actual_amount` AS `actual_salary`,
        (`hpci`.`mpf_er` + `hpci`.`pf_er`) AS `pf_er`,
        (`hpci`.`mpf_ee` + `hpci`.`pf_ee`) AS `pf_ee`,
        `hpci`.`actual_salary` AS `bank_amount`,
        `hpci`.`calculation_id` AS `calculation_id`
    FROM
        (((`hr_pay_calculation_item` `hpci`
        LEFT JOIN `hr_staff` `hs` ON ((`hs`.`id` = `hpci`.`staff_id`)))
        LEFT JOIN `staff_basic` `sb` ON ((`sb`.`login_id` = `hs`.`staff_code`)))
        LEFT JOIN `hr_pay_calculation` `hpc` ON ((`hpc`.`id` = `hpci`.`calculation_id`)))
    GROUP BY `hpci`.`calculation_id` , `hs`.`staff_code`
    ORDER BY `hpci`.`calculation_id` , CONCAT(`sb`.`surname`, ' ', `sb`.`firstname`) , `sb`.`login_id`;
