From 3083083148e434a6894b6edc481343aa16808dbf Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Wed, 23 Jul 2025 10:51:58 +0530 Subject: [PATCH] Created the get Expense details API --- .../Data/ApplicationDbContext.cs | 14 +- .../20250501162003_Initmigration.Designer.cs | 2 +- .../20250501162003_Initmigration.cs | 2 +- ...0_Changed_DataType_ApproverdBY.Designer.cs | 2 +- ...0508055854_Added_IsSystem_Flag.Designer.cs | 2 +- ...dded_WorkCategory_Master_Table.Designer.cs | 2 +- ...y_For_WorkCategery_To_WorkItem.Designer.cs | 2 +- ...13_Changed_Freture_Permissions.Designer.cs | 2 +- ...Added_Directory_Related_Tables.Designer.cs | 2 +- ...ed_ContactProjectMapping_Table.Designer.cs | 2 +- ...53019_Fixed_Typo_Of_ColumnName.Designer.cs | 2 +- ...d_Feature_Directory_Management.Designer.cs | 2 +- ...5939_Added_Mail_Related_Tables.Designer.cs | 2 +- ..._Attendance_Feature_Permission.Designer.cs | 2 +- ...02139_Added_OTP_And_MPIN_Table.Designer.cs | 2 +- ...t_And_Removed_From_MailDetails.Designer.cs | 2 +- ...sUsed_FLag_In_OTPDetails_Table.Designer.cs | 2 +- ..._Name_Column_In_Projects_Table.Designer.cs | 2 +- ...43_Added_TaskAttachments_Table.Designer.cs | 2 +- ...ved_By_In_TaskAllocation_Table.Designer.cs | 2 +- ...orkItemForParentId_Description.Designer.cs | 2 +- ..._New_Status_Master_In_Progress.Designer.cs | 2 +- ...ontacts_And_ContactNotes_Table.Designer.cs | 2 +- ...e_Permissiom_View_All_Employee.Designer.cs | 2 +- ..._Permission_To_ViewTeamMembers.Designer.cs | 2 +- ..._ForeginKey_In_Decuments_Table.Designer.cs | 2 +- ...8_Added_Expense_Related_Tables.Designer.cs | 14 +- ...0721124928_Added_Expense_Related_Tables.cs | 12 +- .../ApplicationDbContextModelSnapshot.cs | 16 +-- Marco.Pms.Helpers/CacheHelper/ExpenseCache.cs | 11 ++ .../ViewModels/Expenses/ExpenseDetailsVM.cs | 31 +++++ .../Controllers/ExpenseController.cs | 6 +- .../Helpers/CacheUpdateHelper.cs | 62 +++++---- .../MappingProfiles/MappingProfile.cs | 6 + Marco.Pms.Services/Service/ExpensesService.cs | 122 +++++++++++++++++- .../ServiceInterfaces/IExpensesService.cs | 1 + 36 files changed, 261 insertions(+), 84 deletions(-) create mode 100644 Marco.Pms.Model/ViewModels/Expenses/ExpenseDetailsVM.cs diff --git a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs index 82e1e68..c01668f 100644 --- a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs +++ b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs @@ -215,7 +215,7 @@ namespace Marco.Pms.DataAccess.Data Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), Name = "In Review", Description = "These issues are currently under review", - ColorCode = "#6c757d", + ColorCode = "#8592a3", IsDefault = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") }, @@ -395,7 +395,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Draft", DisplayName = "Draft", Description = "Expense has been created but not yet submitted.", - Color = "#6c757d", + Color = "#8592a3", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") @@ -406,7 +406,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Review Pending", DisplayName = "Review", Description = "Reviewer is currently reviewing the expense.", - Color = "#0d6efd", + Color = "#696cff", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") @@ -417,7 +417,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Approval Pending", DisplayName = "Approve", Description = "Review is completed, waiting for action of approver.", - Color = "#0dcaf0", + Color = "#03c3ec", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") @@ -428,7 +428,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Rejected", DisplayName = "Reject", Description = "Expense was declined, often with a reason(either review rejected or approval rejected.", - Color = "#dc3545", + Color = "#ff3e1d", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") @@ -439,7 +439,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Process Pending", DisplayName = "Process", Description = "Approved expense is awaiting final payment.", - Color = "#ffc107", + Color = "#ffab00", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") @@ -450,7 +450,7 @@ namespace Marco.Pms.DataAccess.Data Name = "Processed", DisplayName = "Paid", Description = "Expense has been settled.", - Color = "#198754", + Color = "#71dd37", IsSystem = true, IsActive = true, TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26") diff --git a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.Designer.cs index fcb6e0b..331a01e 100644 --- a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.Designer.cs @@ -1274,7 +1274,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs index eb6b5d3..63c4e45 100644 --- a/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs +++ b/Marco.Pms.DataAccess/Migrations/20250501162003_Initmigration.cs @@ -1295,7 +1295,7 @@ namespace Marco.Pms.DataAccess.Migrations columns: new[] { "Id", "ColorCode", "Description", "IsDefault", "Name", "TenantId" }, values: new object[,] { - { new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), "#6c757d", "These issues are currently under review", true, "In Review", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), "#8592a3", "These issues are currently under review", true, "In Review", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, { new Guid("6b0c409b-3e80-4165-8b39-f3fcacb4c797"), "#FFCC99", "This is a newly created issue.", true, "New", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, { new Guid("6c5ac37d-5b7d-40f3-adec-2dabaa5cca86"), "#E6FF99", "Assigned to employee or team of employees", true, "Assigned", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, { new Guid("7f96bcd5-0c66-411b-8a1d-9d1a4785194e"), "#99E6FF", "These issues are currently in progress", true, "In Progress", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, diff --git a/Marco.Pms.DataAccess/Migrations/20250505121140_Changed_DataType_ApproverdBY.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250505121140_Changed_DataType_ApproverdBY.Designer.cs index 4ce716b..4f4da8c 100644 --- a/Marco.Pms.DataAccess/Migrations/20250505121140_Changed_DataType_ApproverdBY.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250505121140_Changed_DataType_ApproverdBY.Designer.cs @@ -1216,7 +1216,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250508055854_Added_IsSystem_Flag.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250508055854_Added_IsSystem_Flag.Designer.cs index a43da65..ca6478a 100644 --- a/Marco.Pms.DataAccess/Migrations/20250508055854_Added_IsSystem_Flag.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250508055854_Added_IsSystem_Flag.Designer.cs @@ -1222,7 +1222,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250510074238_Added_WorkCategory_Master_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250510074238_Added_WorkCategory_Master_Table.Designer.cs index 5a16b4c..69834c6 100644 --- a/Marco.Pms.DataAccess/Migrations/20250510074238_Added_WorkCategory_Master_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250510074238_Added_WorkCategory_Master_Table.Designer.cs @@ -1299,7 +1299,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250511170748_Added_Foreign_key_For_WorkCategery_To_WorkItem.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250511170748_Added_Foreign_key_For_WorkCategery_To_WorkItem.Designer.cs index 748eb32..0348ebc 100644 --- a/Marco.Pms.DataAccess/Migrations/20250511170748_Added_Foreign_key_For_WorkCategery_To_WorkItem.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250511170748_Added_Foreign_key_For_WorkCategery_To_WorkItem.Designer.cs @@ -1299,7 +1299,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250513125713_Changed_Freture_Permissions.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250513125713_Changed_Freture_Permissions.Designer.cs index baf9d7f..8db96d1 100644 --- a/Marco.Pms.DataAccess/Migrations/20250513125713_Changed_Freture_Permissions.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250513125713_Changed_Freture_Permissions.Designer.cs @@ -1267,7 +1267,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs index aad7361..b873cd3 100644 --- a/Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs @@ -1602,7 +1602,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs index 492cf00..0040f43 100644 --- a/Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs @@ -1626,7 +1626,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs index 39fe4c3..96a4717 100644 --- a/Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs @@ -1593,7 +1593,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs index 6e2f931..39f365c 100644 --- a/Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs @@ -1633,7 +1633,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250530055939_Added_Mail_Related_Tables.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250530055939_Added_Mail_Related_Tables.Designer.cs index 09c4047..64dfc97 100644 --- a/Marco.Pms.DataAccess/Migrations/20250530055939_Added_Mail_Related_Tables.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250530055939_Added_Mail_Related_Tables.Designer.cs @@ -1358,7 +1358,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250604094759_Added_Self_Attendance_Feature_Permission.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250604094759_Added_Self_Attendance_Feature_Permission.Designer.cs index c80bbc1..fb39591 100644 --- a/Marco.Pms.DataAccess/Migrations/20250604094759_Added_Self_Attendance_Feature_Permission.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250604094759_Added_Self_Attendance_Feature_Permission.Designer.cs @@ -1366,7 +1366,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250605102139_Added_OTP_And_MPIN_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250605102139_Added_OTP_And_MPIN_Table.Designer.cs index 242339f..1269342 100644 --- a/Marco.Pms.DataAccess/Migrations/20250605102139_Added_OTP_And_MPIN_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250605102139_Added_OTP_And_MPIN_Table.Designer.cs @@ -1425,7 +1425,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250606095355_Added_Subject_In_MailingList_And_Removed_From_MailDetails.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250606095355_Added_Subject_In_MailingList_And_Removed_From_MailDetails.Designer.cs index bdf0ba4..53e758a 100644 --- a/Marco.Pms.DataAccess/Migrations/20250606095355_Added_Subject_In_MailingList_And_Removed_From_MailDetails.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250606095355_Added_Subject_In_MailingList_And_Removed_From_MailDetails.Designer.cs @@ -1425,7 +1425,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250607061133_Added_IsUsed_FLag_In_OTPDetails_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250607061133_Added_IsUsed_FLag_In_OTPDetails_Table.Designer.cs index fe82feb..7b5acc1 100644 --- a/Marco.Pms.DataAccess/Migrations/20250607061133_Added_IsUsed_FLag_In_OTPDetails_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250607061133_Added_IsUsed_FLag_In_OTPDetails_Table.Designer.cs @@ -1428,7 +1428,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250610051758_Added_Short_Name_Column_In_Projects_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250610051758_Added_Short_Name_Column_In_Projects_Table.Designer.cs index c50d6d8..63cdcab 100644 --- a/Marco.Pms.DataAccess/Migrations/20250610051758_Added_Short_Name_Column_In_Projects_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250610051758_Added_Short_Name_Column_In_Projects_Table.Designer.cs @@ -1428,7 +1428,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250612094243_Added_TaskAttachments_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250612094243_Added_TaskAttachments_Table.Designer.cs index 1407de2..f601434 100644 --- a/Marco.Pms.DataAccess/Migrations/20250612094243_Added_TaskAttachments_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250612094243_Added_TaskAttachments_Table.Designer.cs @@ -1811,7 +1811,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250616064217_Added_Apporved_By_In_TaskAllocation_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250616064217_Added_Apporved_By_In_TaskAllocation_Table.Designer.cs index a00f9f1..cee5400 100644 --- a/Marco.Pms.DataAccess/Migrations/20250616064217_Added_Apporved_By_In_TaskAllocation_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250616064217_Added_Apporved_By_In_TaskAllocation_Table.Designer.cs @@ -1835,7 +1835,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250618112021_EnhancedWorkItemForParentId_Description.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250618112021_EnhancedWorkItemForParentId_Description.Designer.cs index 4d39cf1..2ce46f8 100644 --- a/Marco.Pms.DataAccess/Migrations/20250618112021_EnhancedWorkItemForParentId_Description.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250618112021_EnhancedWorkItemForParentId_Description.Designer.cs @@ -1835,7 +1835,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250619060620_Added_New_Status_Master_In_Progress.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250619060620_Added_New_Status_Master_In_Progress.Designer.cs index 08ee943..0ea341d 100644 --- a/Marco.Pms.DataAccess/Migrations/20250619060620_Added_New_Status_Master_In_Progress.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250619060620_Added_New_Status_Master_In_Progress.Designer.cs @@ -1817,7 +1817,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250630071352_Added_UpdatedBy_In_Contacts_And_ContactNotes_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250630071352_Added_UpdatedBy_In_Contacts_And_ContactNotes_Table.Designer.cs index 7bc5be3..0a4cef2 100644 --- a/Marco.Pms.DataAccess/Migrations/20250630071352_Added_UpdatedBy_In_Contacts_And_ContactNotes_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250630071352_Added_UpdatedBy_In_Contacts_And_ContactNotes_Table.Designer.cs @@ -1857,7 +1857,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250630073319_Added_New_Feature_Permissiom_View_All_Employee.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250630073319_Added_New_Feature_Permissiom_View_All_Employee.Designer.cs index cfa4dea..43bbdbe 100644 --- a/Marco.Pms.DataAccess/Migrations/20250630073319_Added_New_Feature_Permissiom_View_All_Employee.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250630073319_Added_New_Feature_Permissiom_View_All_Employee.Designer.cs @@ -1857,7 +1857,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250630111659_Changed_Name_Of_Feature_Permission_To_ViewTeamMembers.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250630111659_Changed_Name_Of_Feature_Permission_To_ViewTeamMembers.Designer.cs index 4ddc1f7..a882d1f 100644 --- a/Marco.Pms.DataAccess/Migrations/20250630111659_Changed_Name_Of_Feature_Permission_To_ViewTeamMembers.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250630111659_Changed_Name_Of_Feature_Permission_To_ViewTeamMembers.Designer.cs @@ -1857,7 +1857,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250702042830_Added_UploadedBy_ForeginKey_In_Decuments_Table.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250702042830_Added_UploadedBy_ForeginKey_In_Decuments_Table.Designer.cs index c0c77b8..f18d9be 100644 --- a/Marco.Pms.DataAccess/Migrations/20250702042830_Added_UploadedBy_ForeginKey_In_Decuments_Table.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250702042830_Added_UploadedBy_ForeginKey_In_Decuments_Table.Designer.cs @@ -1862,7 +1862,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.Designer.cs b/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.Designer.cs index 27368b8..40fe611 100644 --- a/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.Designer.cs +++ b/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.Designer.cs @@ -1934,7 +1934,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8"), - Color = "#6c757d", + Color = "#8592a3", Description = "Expense has been created but not yet submitted.", DisplayName = "Draft", IsActive = true, @@ -1945,7 +1945,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), - Color = "#0d6efd", + Color = "#696cff", Description = "Reviewer is currently reviewing the expense.", DisplayName = "Review", IsActive = true, @@ -1956,7 +1956,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"), - Color = "#0dcaf0", + Color = "#03c3ec", Description = "Review is completed, waiting for action of approver.", DisplayName = "Approve", IsActive = true, @@ -1967,7 +1967,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), - Color = "#dc3545", + Color = "#ff3e1d", Description = "Expense was declined, often with a reason(either review rejected or approval rejected.", DisplayName = "Reject", IsActive = true, @@ -1978,7 +1978,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("f18c5cfd-7815-4341-8da2-2c2d65778e27"), - Color = "#ffc107", + Color = "#ffab00", Description = "Approved expense is awaiting final payment.", DisplayName = "Process", IsActive = true, @@ -1989,7 +1989,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("61578360-3a49-4c34-8604-7b35a3787b95"), - Color = "#198754", + Color = "#71dd37", Description = "Expense has been settled.", DisplayName = "Paid", IsActive = true, @@ -2535,7 +2535,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.cs b/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.cs index 22a0444..ffc5400 100644 --- a/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.cs +++ b/Marco.Pms.DataAccess/Migrations/20250721124928_Added_Expense_Related_Tables.cs @@ -372,12 +372,12 @@ namespace Marco.Pms.DataAccess.Migrations columns: new[] { "Id", "Color", "Description", "DisplayName", "IsActive", "IsSystem", "Name", "TenantId" }, values: new object[,] { - { new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8"), "#6c757d", "Expense has been created but not yet submitted.", "Draft", true, true, "Draft", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"), "#0dcaf0", "Review is completed, waiting for action of approver.", "Approve", true, true, "Approval Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("61578360-3a49-4c34-8604-7b35a3787b95"), "#198754", "Expense has been settled.", "Paid", true, true, "Processed", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), "#0d6efd", "Reviewer is currently reviewing the expense.", "Review", true, true, "Review Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), "#dc3545", "Expense was declined, often with a reason(either review rejected or approval rejected.", "Reject", true, true, "Rejected", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, - { new Guid("f18c5cfd-7815-4341-8da2-2c2d65778e27"), "#ffc107", "Approved expense is awaiting final payment.", "Process", true, true, "Process Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") } + { new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8"), "#8592a3", "Expense has been created but not yet submitted.", "Draft", true, true, "Draft", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"), "#03c3ec", "Review is completed, waiting for action of approver.", "Approve", true, true, "Approval Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("61578360-3a49-4c34-8604-7b35a3787b95"), "#71dd37", "Expense has been settled.", "Paid", true, true, "Processed", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), "#696cff", "Reviewer is currently reviewing the expense.", "Review", true, true, "Review Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), "#ff3e1d", "Expense was declined, often with a reason(either review rejected or approval rejected.", "Reject", true, true, "Rejected", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }, + { new Guid("f18c5cfd-7815-4341-8da2-2c2d65778e27"), "#ffab00", "Approved expense is awaiting final payment.", "Process", true, true, "Process Pending", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") } }); migrationBuilder.InsertData( diff --git a/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs b/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs index 242e512..3406e12 100644 --- a/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Marco.Pms.DataAccess/Migrations/ApplicationDbContextModelSnapshot.cs @@ -20,7 +20,7 @@ namespace Marco.Pms.DataAccess.Migrations .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 64); - //MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b => { @@ -1931,7 +1931,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8"), - Color = "#6c757d", + Color = "#8592a3", Description = "Expense has been created but not yet submitted.", DisplayName = "Draft", IsActive = true, @@ -1942,7 +1942,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), - Color = "#0d6efd", + Color = "#696cff", Description = "Reviewer is currently reviewing the expense.", DisplayName = "Review", IsActive = true, @@ -1953,7 +1953,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"), - Color = "#0dcaf0", + Color = "#03c3ec", Description = "Review is completed, waiting for action of approver.", DisplayName = "Approve", IsActive = true, @@ -1964,7 +1964,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), - Color = "#dc3545", + Color = "#ff3e1d", Description = "Expense was declined, often with a reason(either review rejected or approval rejected.", DisplayName = "Reject", IsActive = true, @@ -1975,7 +1975,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("f18c5cfd-7815-4341-8da2-2c2d65778e27"), - Color = "#ffc107", + Color = "#ffab00", Description = "Approved expense is awaiting final payment.", DisplayName = "Process", IsActive = true, @@ -1986,7 +1986,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("61578360-3a49-4c34-8604-7b35a3787b95"), - Color = "#198754", + Color = "#71dd37", Description = "Expense has been settled.", DisplayName = "Paid", IsActive = true, @@ -2532,7 +2532,7 @@ namespace Marco.Pms.DataAccess.Migrations new { Id = new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), - ColorCode = "#6c757d", + ColorCode = "#8592a3", Description = "These issues are currently under review", IsDefault = true, Name = "In Review", diff --git a/Marco.Pms.Helpers/CacheHelper/ExpenseCache.cs b/Marco.Pms.Helpers/CacheHelper/ExpenseCache.cs index 5e63178..02263e2 100644 --- a/Marco.Pms.Helpers/CacheHelper/ExpenseCache.cs +++ b/Marco.Pms.Helpers/CacheHelper/ExpenseCache.cs @@ -91,6 +91,17 @@ namespace Marco.Pms.Helpers.CacheHelper return (totalPages, totalCount, expenses); } + + public async Task GetExpenseDetailsByIdAsync(Guid id, Guid tenantId) + { + var filter = Builders.Filter.And( + Builders.Filter.Eq(e => e.Id, id.ToString()), + Builders.Filter.Eq(e => e.TenantId, tenantId.ToString()) + ); + var expense = await _collection.Find(filter).FirstOrDefaultAsync(); + + return expense; + } private async Task InitializeCollectionAsync() { var indexKeys = Builders.IndexKeys.Ascending(x => x.ExpireAt); diff --git a/Marco.Pms.Model/ViewModels/Expenses/ExpenseDetailsVM.cs b/Marco.Pms.Model/ViewModels/Expenses/ExpenseDetailsVM.cs new file mode 100644 index 0000000..e44347a --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Expenses/ExpenseDetailsVM.cs @@ -0,0 +1,31 @@ +using Marco.Pms.Model.ViewModels.Activities; +using Marco.Pms.Model.ViewModels.Master; +using Marco.Pms.Model.ViewModels.Projects; + +namespace Marco.Pms.Model.ViewModels.Expenses +{ + public class ExpenseDetailsVM + { + public Guid Id { get; set; } + public ProjectInfoVM? Project { get; set; } + public ExpensesTypeMasterVM? ExpensesType { get; set; } + public PaymentModeMatserVM? PaymentMode { get; set; } + public BasicEmployeeVM? PaidBy { get; set; } + public BasicEmployeeVM? CreatedBy { get; set; } + public DateTime TransactionDate { get; set; } + public DateTime CreatedAt { get; set; } + public string SupplerName { get; set; } = string.Empty; + public double Amount { get; set; } + public ExpensesStatusMasterVM? Status { get; set; } + public List? NextStatus { get; set; } + public bool PreApproved { get; set; } = false; + public string? TransactionId { get; set; } + public string Description { get; set; } = string.Empty; + public string? Location { get; set; } + public List S3Key { get; set; } = new List(); + public List? ThumbS3Key { get; set; } + public string? GSTNumber { get; set; } + public int? NoOfPersons { get; set; } + public bool IsActive { get; set; } = true; + } +} diff --git a/Marco.Pms.Services/Controllers/ExpenseController.cs b/Marco.Pms.Services/Controllers/ExpenseController.cs index 8f3351d..5a17d3d 100644 --- a/Marco.Pms.Services/Controllers/ExpenseController.cs +++ b/Marco.Pms.Services/Controllers/ExpenseController.cs @@ -47,9 +47,11 @@ namespace Marco.Pms.Services.Controllers } [HttpGet("details/{id}")] - public string Get(int id) + public async Task GetExpenseDetails(Guid id) { - return "value"; + var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync(); + var response = await _expensesService.GetExpenseDetailsAsync(id, loggedInEmployee, tenantId); + return StatusCode(response.StatusCode, response); } /// diff --git a/Marco.Pms.Services/Helpers/CacheUpdateHelper.cs b/Marco.Pms.Services/Helpers/CacheUpdateHelper.cs index bbec308..13de18a 100644 --- a/Marco.Pms.Services/Helpers/CacheUpdateHelper.cs +++ b/Marco.Pms.Services/Helpers/CacheUpdateHelper.cs @@ -900,39 +900,43 @@ namespace Marco.Pms.Services.Helpers catch (Exception ex) { _logger.LogError(ex, "Error occurd while storing expense related table in cahce"); + return; } + return; } - public async Task AddExpenseByIdAsync(Guid Id, Guid tenantId) + public async Task AddExpenseByIdAsync(Guid Id, Guid tenantId) { var expense = await _context.Expenses.AsNoTracking().FirstOrDefaultAsync(e => e.Id == Id && e.TenantId == tenantId); var expenseCache = _mapper.Map(expense); - if (expense != null) + if (expense == null) { - try + return null; + } + try + { + var billAttachments = await _context.BillAttachments + .Include(ba => ba.Document) + .AsNoTracking() + .Where(ba => ba.ExpensesId == expense.Id && ba.Document != null) + .GroupBy(ba => ba.ExpensesId) + .Select(g => new { - var billAttachments = await _context.BillAttachments - .Include(ba => ba.Document) - .AsNoTracking() - .Where(ba => ba.ExpensesId == expense.Id && ba.Document != null) - .GroupBy(ba => ba.ExpensesId) - .Select(g => new - { - S3Keys = g.Select(ba => ba.Document!.S3Key).ToList(), - ThumbS3Keys = g.Select(ba => ba.Document!.ThumbS3Key ?? ba.Document.S3Key).ToList() - }) - .FirstOrDefaultAsync(); - if (billAttachments != null) - { - expenseCache.S3Key = billAttachments.S3Keys; - expenseCache.ThumbS3Key = billAttachments.ThumbS3Keys; - } - } - catch (Exception ex) + S3Keys = g.Select(ba => ba.Document!.S3Key).ToList(), + ThumbS3Keys = g.Select(ba => ba.Document!.ThumbS3Key ?? ba.Document.S3Key).ToList() + }) + .FirstOrDefaultAsync(); + if (billAttachments != null) { - _logger.LogError(ex, "Error occurd while fetched expense related tables to save in cahce"); + expenseCache.S3Key = billAttachments.S3Keys; + expenseCache.ThumbS3Key = billAttachments.ThumbS3Keys; } } + catch (Exception ex) + { + _logger.LogError(ex, "Error occurd while fetched expense related tables to save in cahce"); + return null; + } try { await _expenseCache.AddExpenseToCacheAsync(expenseCache); @@ -940,8 +944,12 @@ namespace Marco.Pms.Services.Helpers catch (Exception ex) { _logger.LogError(ex, "Error occurd while storing expense related table in cahce"); + return null; } + return expenseCache; + + } public async Task AddExpensesListToCache(List expenses) { @@ -1000,6 +1008,16 @@ namespace Marco.Pms.Services.Helpers return (0, 0, null); } + public async Task GetExpenseDetailsById(Guid id, Guid tenantId) + { + var response = await _expenseCache.GetExpenseDetailsByIdAsync(id, tenantId); + if (response == null || response.Id == string.Empty) + { + return null; + } + return response; + } + #endregion #region ======================================================= Report Cache ======================================================= diff --git a/Marco.Pms.Services/MappingProfiles/MappingProfile.cs b/Marco.Pms.Services/MappingProfiles/MappingProfile.cs index 6e4ca8e..c21b93d 100644 --- a/Marco.Pms.Services/MappingProfiles/MappingProfile.cs +++ b/Marco.Pms.Services/MappingProfiles/MappingProfile.cs @@ -13,6 +13,7 @@ using Marco.Pms.Model.Projects; using Marco.Pms.Model.ViewModels.Activities; using Marco.Pms.Model.ViewModels.Employee; using Marco.Pms.Model.ViewModels.Expanses; +using Marco.Pms.Model.ViewModels.Expenses; using Marco.Pms.Model.ViewModels.Master; using Marco.Pms.Model.ViewModels.Projects; @@ -177,6 +178,11 @@ namespace Marco.Pms.Services.MappingProfiles dest => dest.Id, opt => opt.MapFrom(src => Guid.Parse(src.Id))); + CreateMap() + .ForMember( + dest => dest.Id, + opt => opt.MapFrom(src => Guid.Parse(src.Id))); + #endregion #region ======================================================= Master ======================================================= diff --git a/Marco.Pms.Services/Service/ExpensesService.cs b/Marco.Pms.Services/Service/ExpensesService.cs index d55b915..a8ea7b8 100644 --- a/Marco.Pms.Services/Service/ExpensesService.cs +++ b/Marco.Pms.Services/Service/ExpensesService.cs @@ -5,10 +5,12 @@ using Marco.Pms.Model.Dtos.Expenses; using Marco.Pms.Model.Employees; using Marco.Pms.Model.Entitlements; using Marco.Pms.Model.Expenses; +using Marco.Pms.Model.MongoDBModels.Expenses; using Marco.Pms.Model.MongoDBModels.Utility; using Marco.Pms.Model.Utilities; using Marco.Pms.Model.ViewModels.Activities; using Marco.Pms.Model.ViewModels.Expanses; +using Marco.Pms.Model.ViewModels.Expenses; using Marco.Pms.Model.ViewModels.Master; using Marco.Pms.Model.ViewModels.Projects; using Marco.Pms.Services.Helpers; @@ -210,7 +212,7 @@ namespace Marco.Pms.Services.Service Message = dbEx.Message, StackTrace = dbEx.StackTrace, Source = dbEx.Source, - innerexcption = new + InnerException = new { Message = dbEx.InnerException?.Message, StackTrace = dbEx.InnerException?.StackTrace, @@ -226,7 +228,7 @@ namespace Marco.Pms.Services.Service Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, - innerexcption = new + InnerException = new { Message = ex.InnerException?.Message, StackTrace = ex.InnerException?.StackTrace, @@ -236,9 +238,35 @@ namespace Marco.Pms.Services.Service } } - public string Get(int id) + public async Task> GetExpenseDetailsAsync(Guid id, Employee loggedInEmployee, Guid tenantId) { - return "value"; + try + { + var expenseDetails = await _cache.GetExpenseDetailsById(id, tenantId); + if (expenseDetails == null) + { + expenseDetails = await _cache.AddExpenseByIdAsync(id, tenantId); + } + var vm = GetAllExpnesRelatedTablesFromMongoDB([expenseDetails]); + return ApiResponse.SuccessResponse(vm, "Successfully fetched the details of expense", 200); + + } + catch (Exception ex) + { + _logger.LogError(ex, "An unhandled exception occurred while fetching an expense details {ExpenseId}.", id); + return ApiResponse.ErrorResponse("An internal server error occurred.", new + { + Message = ex.Message, + StackTrace = ex.StackTrace, + Source = ex.Source, + InnerException = new + { + Message = ex.InnerException?.Message, + StackTrace = ex.InnerException?.StackTrace, + Source = ex.InnerException?.Source, + } + }, 500); + } } /// @@ -391,7 +419,7 @@ namespace Marco.Pms.Services.Service Message = dbEx.Message, StackTrace = dbEx.StackTrace, Source = dbEx.Source, - innerexcption = new + InnerException = new { Message = dbEx.InnerException?.Message, StackTrace = dbEx.InnerException?.StackTrace, @@ -407,7 +435,7 @@ namespace Marco.Pms.Services.Service Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, - innerexcption = new + InnerException = new { Message = ex.InnerException?.Message, StackTrace = ex.InnerException?.StackTrace, @@ -423,7 +451,7 @@ namespace Marco.Pms.Services.Service Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, - innerexcption = new + InnerException = new { Message = ex.InnerException?.Message, StackTrace = ex.InnerException?.StackTrace, @@ -716,6 +744,7 @@ namespace Marco.Pms.Services.Service public void Delete(int id) { } + #region =================================================================== Helper Functions =================================================================== private async Task> GetAllExpnesRelatedTables(List model) @@ -797,6 +826,85 @@ namespace Marco.Pms.Services.Service return expenseList; } + private async Task> GetAllExpnesRelatedTablesFromMongoDB(List model) + { + List expenseList = new List(); + var projectIds = model.Select(m => Guid.Parse(m.ProjectId)).ToList(); + var statusIds = model.Select(m => Guid.Parse(m.StatusId)).ToList(); + var expensesTypeIds = model.Select(m => Guid.Parse(m.ExpensesTypeId)).ToList(); + var paymentModeIds = model.Select(m => Guid.Parse(m.PaymentModeId)).ToList(); + var createdByIds = model.Select(m => Guid.Parse(m.CreatedById)).ToList(); + var paidByIds = model.Select(m => Guid.Parse(m.PaidById)).ToList(); + + var projectTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.Projects.AsNoTracking().Where(p => projectIds.Contains(p.Id)).ToListAsync(); + }); + var paidByTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.Employees.AsNoTracking().Where(e => paidByIds.Contains(e.Id)).ToListAsync(); + }); + var createdByTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.Employees.AsNoTracking().Where(e => createdByIds.Contains(e.Id)).ToListAsync(); + }); + var expenseTypeTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.ExpensesTypeMaster.AsNoTracking().Where(et => expensesTypeIds.Contains(et.Id)).ToListAsync(); + }); + var paymentModeTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.PaymentModeMatser.AsNoTracking().Where(pm => paymentModeIds.Contains(pm.Id)).ToListAsync(); + }); + var statusMappingTask = Task.Run(async () => + { + await using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.ExpensesStatusMapping + .Include(s => s.Status) + .Include(s => s.NextStatus) + .AsNoTracking() + .Where(es => statusIds.Contains(es.StatusId) && es.Status != null) + .GroupBy(s => s.StatusId) + .Select(g => new + { + StatusId = g.Key, + Status = g.Select(s => s.Status).FirstOrDefault(), + NextStatus = g.Select(s => s.NextStatus).ToList() + }).ToListAsync(); + }); + + // Await all prerequisite checks at once. + await Task.WhenAll(projectTask, expenseTypeTask, paymentModeTask, statusMappingTask, paidByTask, createdByTask); + + var projects = await projectTask; + var expenseTypes = await expenseTypeTask; + var paymentModes = await paymentModeTask; + var statusMappings = await statusMappingTask; + var paidBys = await paidByTask; + var createdBys = await createdByTask; + + expenseList = model.Select(m => + { + var response = _mapper.Map(m); + + response.Project = projects.Where(p => p.Id == Guid.Parse(m.ProjectId)).Select(p => _mapper.Map(p)).FirstOrDefault(); + response.PaidBy = paidBys.Where(p => p.Id == Guid.Parse(m.PaidById)).Select(p => _mapper.Map(p)).FirstOrDefault(); + response.CreatedBy = createdBys.Where(e => e.Id == Guid.Parse(m.CreatedById)).Select(e => _mapper.Map(e)).FirstOrDefault(); + response.Status = statusMappings.Where(s => s.StatusId == Guid.Parse(m.StatusId)).Select(s => _mapper.Map(s.Status)).FirstOrDefault(); + response.NextStatus = statusMappings.Where(s => s.StatusId == Guid.Parse(m.StatusId)).Select(s => _mapper.Map>(s.NextStatus)).FirstOrDefault(); + response.PaymentMode = paymentModes.Where(pm => pm.Id == Guid.Parse(m.PaymentModeId)).Select(pm => _mapper.Map(pm)).FirstOrDefault(); + response.ExpensesType = expenseTypes.Where(et => et.Id == Guid.Parse(m.ExpensesTypeId)).Select(et => _mapper.Map(et)).FirstOrDefault(); + + return response; + }).ToList(); + + return expenseList; + } /// /// Deserializes the filter string, handling multiple potential formats (e.g., direct JSON vs. escaped JSON string). diff --git a/Marco.Pms.Services/Service/ServiceInterfaces/IExpensesService.cs b/Marco.Pms.Services/Service/ServiceInterfaces/IExpensesService.cs index 2cf2721..75d937a 100644 --- a/Marco.Pms.Services/Service/ServiceInterfaces/IExpensesService.cs +++ b/Marco.Pms.Services/Service/ServiceInterfaces/IExpensesService.cs @@ -7,6 +7,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces public interface IExpensesService { Task> GetExpensesListAsync(Employee loggedInEmployee, Guid tenantId, string? filter, int pageSize, int pageNumber); + Task> GetExpenseDetailsAsync(Guid id, Employee loggedInEmployee, Guid tenantId); Task> CreateExpenseAsync(CreateExpensesDto dto, Employee loggedInEmployee, Guid tenantId); Task> ChangeStatusAsync(ExpenseRecordDto model, Employee loggedInEmployee, Guid tenantId); Task> UpdateExpanseAsync(Guid id, UpdateExpensesDto model, Employee loggedInEmployee, Guid tenantId);