INSERT INTO `bm_project_prepayment` (`project_code`, `project_name`, `business_unit`, `contact_unit`, `type`, `initial_amount`, `first_payment_date`, `current_balance`, `remarks`, `operator`, `is_active`) VALUES (#{projectCode}, #{projectName}, #{businessUnit}, #{contactUnit}, #{type}, #{initialAmount}, #{firstPaymentDate}, #{initialAmount}, #{remarks}, #{operator}, '1') INSERT INTO `bm_monthly_operations` (`p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`, `next_month`, `proposed_amount`, `handler`, `next_remarks`, `is_active`, `operator`,`current_balance`) VALUES (#{prepaymentId}, #{month}, #{operationType}, #{amount}, #{executor}, #{remarks}, #{nextMonth}, #{proposedAmount}, #{handler}, #{nextRemarks}, '1', #{operator},#{currentBalance}) UPDATE `bm_project_prepayment` SET `current_balance` = #{currentBalanceNew}, `operator` = #{operator} WHERE `id` = #{prepaymentId} UPDATE `bm_project_prepayment` SET `operator` = #{operator} ,project_code = #{projectCode} ,project_name = #{projectName} ,business_unit = #{businessUnit} ,contact_unit = #{contactUnit} ,type = #{type} ,initial_amount = #{initialAmount} ,first_payment_date = #{firstPaymentDate} ,current_balance = #{currentBalance} ,remarks = #{remarks} WHERE `id` = #{id} UPDATE `bm_monthly_operations` SET `month` = #{month}, `operation_type` = #{operationType}, `amount` = #{amount}, `executor` = #{executor},operator = #{operator} ,remarks = #{remarks} ,next_month = #{nextMonth} ,proposed_amount = #{proposedAmount} ,handler = #{handler} ,next_remarks = #{nextRemarks} WHERE `id` = #{id} and is_active = '1' UPDATE `bm_project_prepayment` SET `is_active` = '0', operator = #{userId} WHERE `id` = #{id} UPDATE `bm_monthly_operations` SET `is_active` = '0', operator = #{userId} WHERE `id` = #{id}