Skip to content

Commit 820e685

Browse files
nothing done
1 parent a559300 commit 820e685

File tree

7 files changed

+159
-3
lines changed

7 files changed

+159
-3
lines changed

.DS_Store

2 KB
Binary file not shown.

backend/.DS_Store

0 Bytes
Binary file not shown.

backend/build/test

16.5 KB
Binary file not shown.

backend/build/test.o

25.9 KB
Binary file not shown.

backend/test/test.cpp

Lines changed: 159 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ TEST_CASE("DeductionUnderSection16 Initialization from JSON", "[DeductionUnderSe
989989

990990

991991
}
992-
/*
992+
993993

994994
// --- IncomeUnderHeadSalaries Class Tests ---
995995
TEST_CASE("IncomeUnderHeadSalaries Initialization from JSON", "[IncomeUnderHeadSalaries]") {
@@ -1061,9 +1061,96 @@ TEST_CASE("IncomeUnderHeadSalaries Initialization from JSON", "[IncomeUnderHeadS
10611061

10621062
IncomeUnderHeadSalaries incomeSalaries(&netIncome, &deductions);
10631063

1064-
// Verify IncomeUnderHeadSalaries fields (if any)
1065-
// Add REQUIRE statements as needed
1064+
SECTION("calculateIncomeUnderHeadSalaries Function") {
1065+
// Test with initial values
1066+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(2246000 - deductions.calculateTotalDeductions())); // Adjust the expected value as needed
1067+
1068+
// Test with modified salary values
1069+
salary.basicSalary = 1000000;
1070+
salary.pension = 0;
1071+
salary.dearnessAllowance = 0;
1072+
salary.bonusCommissions = 0;
1073+
salary.advanceSalary = 0;
1074+
salary.arrears = 0;
1075+
salary.leaveEncashment = 0;
1076+
salary.gratuity = 0;
1077+
salary.hra = 0;
1078+
salary.entertainmentAllowance = 0;
1079+
salary.professionalTax = 0;
1080+
salary.otherComponents = 0;
1081+
perq.rentFreeAccommodation = 0;
1082+
perq.concessionInRent = 0;
1083+
perq.companyCar = 0;
1084+
perq.freeUtilities = 0;
1085+
perq.medicalFacilities = 0;
1086+
perq.interestFreeLoans = 0;
1087+
perq.stockOptions = 0;
1088+
perq.educationForChildren = 0;
1089+
profits.terminationCompensation = 0;
1090+
profits.retirementCompensation = 0;
1091+
profits.goldenHandshake = 0;
1092+
profits.keymanInsurancePayout = 0;
1093+
profits.preEmploymentPayments = 0;
1094+
profits.postResignationPayments = 0;
1095+
foreignRetirement.AmountFrom89ACountry = 0;
1096+
foreignRetirement.AmountFromNon89ACountry = 0;
1097+
1098+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(950000 - deductions.calculateTotalDeductions())); // Adjust the expected value as needed
1099+
1100+
// Test with modified salary values
1101+
salary.basicSalary = 1000000;
1102+
salary.pension = 50000;
1103+
salary.dearnessAllowance = 25000;
1104+
salary.bonusCommissions = 60000;
1105+
1106+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1085000 - deductions.calculateTotalDeductions())); // Adjust the expected value as needed
1107+
1108+
// Test with modified perquisites values
1109+
perq.rentFreeAccommodation = 10000;
1110+
perq.concessionInRent = 5000;
1111+
perq.companyCar = 20000;
1112+
perq.freeUtilities = 6000;
1113+
perq.medicalFacilities = 7500;
1114+
perq.interestFreeLoans = 10000;
1115+
perq.stockOptions = 25000;
1116+
perq.educationForChildren = 3000;
1117+
REQUIRE(perq.calculatePerquisites17_2() == Catch::Approx(69000));
1118+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1154000 - deductions.calculateTotalDeductions())); // Adjust the expected value as needed
1119+
1120+
// Test with modified profits values
1121+
profits.terminationCompensation = 10000;
1122+
profits.retirementCompensation = 5000;
1123+
profits.goldenHandshake = 2000;
1124+
profits.keymanInsurancePayout = 3000;
1125+
profits.preEmploymentPayments = 1500;
1126+
profits.postResignationPayments = 2500;
1127+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1128000)); // Adjust the expected value as needed
1128+
1129+
// Test with modified foreign retirement values
1130+
foreignRetirement.AmountFrom89ACountry = 10000;
1131+
foreignRetirement.AmountFromNon89ACountry = 5000;
1132+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1133000)); // Adjust the expected value as needed
1133+
1134+
// Test with old tax regime
1135+
empDetails.oldTaxRegime = true;
1136+
exemptions.rentPaid = 240000;
1137+
exemptions.metroCity = true;
1138+
exemptions.ltaAmount = 30000;
1139+
exemptions.childrenEduAllowance = 4800;
1140+
exemptions.hostelAllowance = 7200;
1141+
exemptions.transportAllowance = 19200;
1142+
exemptions.totalPension = 0;
1143+
exemptions.commutedPension = 0;
1144+
exemptions.vrsCompensation = 0;
1145+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1193000 - exemptions.calculateTotalExemptions() - lessUnder89A.calculateLess())); // Adjust the expected value as needed
1146+
1147+
// Test with new tax regime
1148+
empDetails.oldTaxRegime = false;
1149+
REQUIRE(incomeSalaries.calculateIncomeUnderHeadSalaries() == Catch::Approx(1168000)); // Adjust the expected value as needed
1150+
}
1151+
10661152
}
1153+
/*
10671154
10681155
// --- IncomeUnderHouseProperty Class Tests ---
10691156
TEST_CASE("IncomeUnderHouseProperty Initialization from JSON", "[IncomeUnderHouseProperty]") {
@@ -1082,6 +1169,75 @@ TEST_CASE("IncomeUnderHouseProperty Initialization from JSON", "[IncomeUnderHous
10821169
REQUIRE(houseProperty.municipalTaxes == 15000);
10831170
REQUIRE(houseProperty.unrealisedRent == 0);
10841171
REQUIRE(houseProperty.letOutInterestOnBorowedCapital == 0);
1172+
1173+
SECTION("IncomeUnderHouseProperty Function Tests") {
1174+
// Test calculateIncomeFromSelfOccupiedProperty function
1175+
SECTION("calculateIncomeFromSelfOccupiedProperty Function") {
1176+
// Test with self-occupied interest less than 200000
1177+
houseProperty.selfOccupiedInterestOnBorowedCapital = 150000;
1178+
REQUIRE(houseProperty.calculateIncomeFromSelfOccupiedProperty() == Catch::Approx(-150000.0));
1179+
1180+
// Test with self-occupied interest equal to 200000
1181+
houseProperty.selfOccupiedInterestOnBorowedCapital = 200000;
1182+
REQUIRE(houseProperty.calculateIncomeFromSelfOccupiedProperty() == Catch::Approx(-200000.0));
1183+
1184+
// Test with self-occupied interest greater than 200000
1185+
houseProperty.selfOccupiedInterestOnBorowedCapital = 250000;
1186+
REQUIRE(houseProperty.calculateIncomeFromSelfOccupiedProperty() == Catch::Approx(-200000.0));
1187+
}
1188+
1189+
// Test calculateIncomeFromLetOutProperty function
1190+
SECTION("calculateIncomeFromLetOutProperty Function") {
1191+
// Test with net annual value less than or equal to 0
1192+
houseProperty.rentalIncome = 100000;
1193+
houseProperty.municipalTaxes = 100000;
1194+
houseProperty.unrealisedRent = 0;
1195+
houseProperty.letOutInterestOnBorowedCapital = 50000;
1196+
REQUIRE(houseProperty.calculateIncomeFromLetOutProperty() == Catch::Approx(0.0));
1197+
1198+
// Test with net annual value greater than 0
1199+
houseProperty.rentalIncome = 200000;
1200+
houseProperty.municipalTaxes = 50000;
1201+
houseProperty.unrealisedRent = 0;
1202+
houseProperty.letOutInterestOnBorowedCapital = 50000;
1203+
REQUIRE(houseProperty.calculateIncomeFromLetOutProperty() == Catch::Approx(55000.0));
1204+
1205+
// Test with net annual value greater than 0 and unrealised rent
1206+
houseProperty.rentalIncome = 200000;
1207+
houseProperty.municipalTaxes = 50000;
1208+
houseProperty.unrealisedRent = 30000;
1209+
houseProperty.letOutInterestOnBorowedCapital = 50000;
1210+
REQUIRE(houseProperty.calculateIncomeFromLetOutProperty() == Catch::Approx(20000.0));
1211+
}
1212+
1213+
// Test calculateIncomeUnderHouseProperty function
1214+
SECTION("calculateIncomeUnderHouseProperty Function") {
1215+
// Test with income from self-occupied property and let-out property
1216+
houseProperty.selfOccupiedInterestOnBorowedCapital = 150000;
1217+
houseProperty.rentalIncome = 200000;
1218+
houseProperty.municipalTaxes = 50000;
1219+
houseProperty.unrealisedRent = 30000;
1220+
houseProperty.letOutInterestOnBorowedCapital = 50000;
1221+
REQUIRE(houseProperty.calculateIncomeUnderHouseProperty() == Catch::Approx(-100000.0));
1222+
1223+
// Test with income from self-occupied property only
1224+
houseProperty.selfOccupiedInterestOnBorowedCapital = 150000;
1225+
houseProperty.rentalIncome = 0;
1226+
houseProperty.municipalTaxes = 0;
1227+
houseProperty.unrealisedRent = 0;
1228+
houseProperty.letOutInterestOnBorowedCapital = 0;
1229+
REQUIRE(houseProperty.calculateIncomeUnderHouseProperty() == Catch::Approx(-150000.0));
1230+
1231+
// Test with income from let-out property only
1232+
houseProperty.selfOccupiedInterestOnBorowedCapital = 0;
1233+
houseProperty.rentalIncome = 200000;
1234+
houseProperty.municipalTaxes = 50000;
1235+
houseProperty.unrealisedRent = 30000;
1236+
houseProperty.letOutInterestOnBorowedCapital = 50000;
1237+
REQUIRE(houseProperty.calculateIncomeUnderHouseProperty() == Catch::Approx(20000.0));
1238+
}
1239+
}
1240+
10851241
}
10861242
10871243
// --- OtherIncome Class Tests ---

cpp/.DS_Store

0 Bytes
Binary file not shown.

node_modules/.DS_Store

22 KB
Binary file not shown.

0 commit comments

Comments
 (0)