CREATE PROCEDURE `spAddFeesDetails` ( IN `P_FeeId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_InstituteId` INTEGER , IN `P_BatchId` INTEGER , IN `P_IsRecurringMonthly` BIT , IN `P_DateOfFeeCollection` DATETIME , IN `P_StudentId` INTEGER , IN `P_FeesAmount` DECIMAL , IN `P_DefaultFeeAmount` DECIMAL , IN `P_SetupDate` DATE , IN `P_IsSendNotificationFeeDue` BIT , IN `P_IsSendSMSFeeDue` BIT ) BEGIN IF EXISTS ( SELECT ? FROM `tbankaccountdetail` WHERE `TeacherId` = `P_TeacherId` ) THEN IF ( `P_FeeId` = ? ) THEN IF NOT EXISTS ( SELECT ? FROM `tfeesetup` WHERE `TeacherId` = `P_TeacherId` AND `BatchId` = `P_BatchId` AND `StudentId` = `P_StudentId` AND SQL_TSI_MONTH ( `SetupDate` ) = SQL_TSI_MONTH ( `P_SetupDate` ) AND YEAR ( `SetupDate` ) = YEAR ( `P_SetupDate` ) ) THEN START TRANSACTION ; INSERT INTO `vida_lms` . `tfeesetup` ( `TeacherId` , `BatchId` , `IsRecurringMonthly` , `DateOfFeeCollection` , `StudentId` , `FeeAmount` , `CreatedDateTime` , `CreatedUserId` , `DefaultFeeAmount` , `SetupDate` , `IsSendSMSFeeDue` , `IsSendNotificationFeeDue` ) VALUES ( `P_TeacherId` , `P_BatchId` , `P_IsRecurringMonthly` , `P_DateOfFeeCollection` , `P_StudentId` , `P_FeesAmount` 