diff --git a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs index 5f9e40f..b756a86 100644 --- a/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs +++ b/Marco.Pms.DataAccess/Data/ApplicationDbContext.cs @@ -133,6 +133,12 @@ namespace Marco.Pms.DataAccess.Data public DbSet ProjectServiceMappings { get; set; } public DbSet ProjectOrgMappings { get; set; } + // Inventory + //public DbSet PurchaseOrderStatus { get; set; } + //public DbSet RequisitionStatus { get; set; } + //public DbSet PurchaseStatusMappings { get; set; } + //public DbSet RequisitionStatusMappings { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/Marco.Pms.Model/Dtos/Activities/CreateWorkStatusMasterDto.cs b/Marco.Pms.Model/Dtos/Activities/CreateWorkStatusMasterDto.cs index b4ff25f..8b99f62 100644 --- a/Marco.Pms.Model/Dtos/Activities/CreateWorkStatusMasterDto.cs +++ b/Marco.Pms.Model/Dtos/Activities/CreateWorkStatusMasterDto.cs @@ -2,7 +2,7 @@ { public class CreateWorkStatusMasterDto { - public string? Name { get; set; } - public string? Description { get; set; } + public required string Name { get; set; } + public required string Description { get; set; } } } diff --git a/Marco.Pms.Model/Dtos/Activities/UpdateWorkStatusMasterDto.cs b/Marco.Pms.Model/Dtos/Activities/UpdateWorkStatusMasterDto.cs index a40052f..48dca5d 100644 --- a/Marco.Pms.Model/Dtos/Activities/UpdateWorkStatusMasterDto.cs +++ b/Marco.Pms.Model/Dtos/Activities/UpdateWorkStatusMasterDto.cs @@ -3,7 +3,7 @@ public class UpdateWorkStatusMasterDto { public Guid Id { get; set; } - public string? Name { get; set; } - public string? Description { get; set; } + public required string Name { get; set; } + public required string Description { get; set; } } } diff --git a/Marco.Pms.Model/Dtos/Inventory/PurchaseOrderStatusDto.cs b/Marco.Pms.Model/Dtos/Inventory/PurchaseOrderStatusDto.cs new file mode 100644 index 0000000..f04ad08 --- /dev/null +++ b/Marco.Pms.Model/Dtos/Inventory/PurchaseOrderStatusDto.cs @@ -0,0 +1,9 @@ +namespace Marco.Pms.Model.Dtos.Inventory +{ + public class PurchaseOrderStatusDto + { + public Guid? Id { get; set; } + public required string Name { get; set; } + public required string Description { get; set; } + } +} diff --git a/Marco.Pms.Model/Dtos/Inventory/RequisitionStatusDto.cs b/Marco.Pms.Model/Dtos/Inventory/RequisitionStatusDto.cs new file mode 100644 index 0000000..c5cc491 --- /dev/null +++ b/Marco.Pms.Model/Dtos/Inventory/RequisitionStatusDto.cs @@ -0,0 +1,9 @@ +namespace Marco.Pms.Model.Dtos.Inventory +{ + public class RequisitionStatusDto + { + public Guid? Id { get; set; } + public required string Name { get; set; } + public required string Description { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/Item.cs b/Marco.Pms.Model/Inventory/Item.cs new file mode 100644 index 0000000..e4525b2 --- /dev/null +++ b/Marco.Pms.Model/Inventory/Item.cs @@ -0,0 +1,40 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Master; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class Item : TenantRelation + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public Guid ItemGroupId { get; set; } + + [ValidateNever] + [ForeignKey("ItemGroupId")] + public ItemGroupMaster? ItemGroup { get; set; } + public Guid TechnicalUnitId { get; set; } + + [ValidateNever] + [ForeignKey("TechnicalUnitId")] + public TechnicalUnit? ItemCategTechnicalUnitory { get; set; } + public string ItemUId { get; set; } = "Item-00001"; + public int Threshold { get; set; } + public bool IsActive { get; set; } = true; + public DateTime CreatedAt { get; set; } + public Guid CreatedById { get; set; } + + [ValidateNever] + [ForeignKey("CreatedById")] + public Employee? CreatedBy { get; set; } + public DateTime? UpdatedAt { get; set; } + public Guid? UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/ItemCategoryMaster.cs b/Marco.Pms.Model/Inventory/ItemCategoryMaster.cs new file mode 100644 index 0000000..f390fd4 --- /dev/null +++ b/Marco.Pms.Model/Inventory/ItemCategoryMaster.cs @@ -0,0 +1,12 @@ +using Marco.Pms.Model.Utilities; + +namespace Marco.Pms.Model.Inventory +{ + public class ItemCategoryMaster : TenantRelation + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public bool IsActive { get; set; } = true; + } +} diff --git a/Marco.Pms.Model/Inventory/ItemGroupMaster.cs b/Marco.Pms.Model/Inventory/ItemGroupMaster.cs new file mode 100644 index 0000000..9a468e4 --- /dev/null +++ b/Marco.Pms.Model/Inventory/ItemGroupMaster.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class ItemGroupMaster + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public bool IsActive { get; set; } = true; + public Guid ItemCategoryId { get; set; } + + [ValidateNever] + [ForeignKey("ItemCategoryId")] + public ItemCategoryMaster? ItemCategory { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/ItemManufacturerMapping.cs b/Marco.Pms.Model/Inventory/ItemManufacturerMapping.cs new file mode 100644 index 0000000..1f8a82b --- /dev/null +++ b/Marco.Pms.Model/Inventory/ItemManufacturerMapping.cs @@ -0,0 +1,23 @@ +using Marco.Pms.Model.Master; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class ItemManufacturerMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid ItemId { get; set; } + + [ValidateNever] + [ForeignKey("ItemId")] + public Item? Item { get; set; } + public Guid ManufacturerId { get; set; } + + [ValidateNever] + [ForeignKey("ManufacturerId")] + public Manufacturer? Manufacturer { get; set; } + public bool IsActive { get; set; } = true; + } +} diff --git a/Marco.Pms.Model/Inventory/ItemSupplierMapping.cs b/Marco.Pms.Model/Inventory/ItemSupplierMapping.cs new file mode 100644 index 0000000..4348ef5 --- /dev/null +++ b/Marco.Pms.Model/Inventory/ItemSupplierMapping.cs @@ -0,0 +1,31 @@ +using Marco.Pms.Model.Master; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class ItemSupplierMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid ItemManufacturerMappingId { get; set; } + + [ValidateNever] + [ForeignKey("ItemManufacturerMappingId")] + public ItemManufacturerMapping? ItemManufacturerMapping { get; set; } + public Guid SupplierId { get; set; } + + [ValidateNever] + [ForeignKey("SupplierId")] + public Supplier? Supplier { get; set; } + public double BasePrice { get; set; } + public int PurchaseLeadTime { get; set; } + public Guid CurrencyId { get; set; } + + [ValidateNever] + [ForeignKey("CurrencyId")] + public CurrencyMaster? Currency { get; set; } + public bool IsActive { get; set; } = true; + } +} + diff --git a/Marco.Pms.Model/Inventory/ItemTaxTypeMapping.cs b/Marco.Pms.Model/Inventory/ItemTaxTypeMapping.cs new file mode 100644 index 0000000..d225d3e --- /dev/null +++ b/Marco.Pms.Model/Inventory/ItemTaxTypeMapping.cs @@ -0,0 +1,24 @@ +using Marco.Pms.Model.Master; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class ItemTaxTypeMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid ItemId { get; set; } + + [ValidateNever] + [ForeignKey("ItemId")] + public Item? Item { get; set; } + public Guid ServicesTaxTypeId { get; set; } + + [ValidateNever] + [ForeignKey("ServicesTaxTypeId")] + public ServicesTaxType? ServicesTaxType { get; set; } + public int Rate { get; set; } + public bool IsActive { get; set; } = true; + } +} diff --git a/Marco.Pms.Model/Inventory/PurchaseOrder.cs b/Marco.Pms.Model/Inventory/PurchaseOrder.cs new file mode 100644 index 0000000..ade7321 --- /dev/null +++ b/Marco.Pms.Model/Inventory/PurchaseOrder.cs @@ -0,0 +1,50 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Projects; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class PurchaseOrder : TenantRelation + { + public Guid Id { get; set; } + public Guid ItemSupplierMappingId { get; set; } + + [ValidateNever] + [ForeignKey("ItemSupplierMappingId")] + public ItemSupplierMapping? ItemSupplierMapping { get; set; } + public Guid ProjectId { get; set; } + + [ValidateNever] + [ForeignKey("ProjectId")] + public Project? Project { get; set; } + public Guid RequisitionBatchId { get; set; } + public int NumberOfItems { get; set; } + public double PricePerItem { get; set; } + public double TotalBasePrice { get; set; } + public double TotalTaxPrice { get; set; } + public double TotalDiscountPrice { get; set; } + public double TotalPrice { get; set; } + public Guid PurchaseOrderStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PurchaseOrderStatusId")] + public PurchaseOrderStatus? PurchaseOrderStatus { get; set; } + public Guid BatchId { get; set; } + public string PurchaseOrderUId { get; set; } = "PO-00001"; + public bool IsActive { get; set; } = true; + public DateTime CreatedAt { get; set; } + public Guid CreatedById { get; set; } + + [ValidateNever] + [ForeignKey("CreatedById")] + public Employee? CreatedBy { get; set; } + public DateTime? UpdatedAt { get; set; } + public Guid? UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Inventory/PurchaseOrderStatus.cs b/Marco.Pms.Model/Inventory/PurchaseOrderStatus.cs new file mode 100644 index 0000000..4625a1d --- /dev/null +++ b/Marco.Pms.Model/Inventory/PurchaseOrderStatus.cs @@ -0,0 +1,12 @@ +using Marco.Pms.Model.Utilities; + +namespace Marco.Pms.Model.Inventory +{ + public class PurchaseOrderStatus : TenantRelation + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public bool IsActive { get; set; } = true; + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Inventory/PurchaseOrderStatusLogs.cs b/Marco.Pms.Model/Inventory/PurchaseOrderStatusLogs.cs new file mode 100644 index 0000000..5ee91f2 --- /dev/null +++ b/Marco.Pms.Model/Inventory/PurchaseOrderStatusLogs.cs @@ -0,0 +1,29 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class PurchaseOrderStatusLogs : TenantRelation + { + public Guid Id { get; set; } + public Guid PreviousPurchaseStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PreviousPurchaseStatusId")] + public PurchaseOrderStatus? PreviousPurchaseStatus { get; set; } + public string? Comment { get; set; } + public Guid PurchaseStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PurchaseStatusId")] + public PurchaseOrderStatus? PurchaseStatus { get; set; } + public DateTime UpdatedAt { get; set; } + public Guid UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Inventory/PurchaseStatusEmployeeMapping.cs b/Marco.Pms.Model/Inventory/PurchaseStatusEmployeeMapping.cs new file mode 100644 index 0000000..78673a1 --- /dev/null +++ b/Marco.Pms.Model/Inventory/PurchaseStatusEmployeeMapping.cs @@ -0,0 +1,23 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Master; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class PurchaseStatusEmployeeMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid PurchaseOrderStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PurchaseOrderStatusId")] + public PurchaseOrderStatus? PurchaseOrderStatus { get; set; } + public Guid EmployeeId { get; set; } + + [ValidateNever] + [ForeignKey("EmployeeId")] + public Employee? Employee { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/PurchaseStatusMapping.cs b/Marco.Pms.Model/Inventory/PurchaseStatusMapping.cs new file mode 100644 index 0000000..f9ec199 --- /dev/null +++ b/Marco.Pms.Model/Inventory/PurchaseStatusMapping.cs @@ -0,0 +1,26 @@ +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class PurchaseStatusMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid PreviousPurchaseStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PreviousPurchaseStatusId")] + public PurchaseOrderStatus? PreviousPurchaseStatus { get; set; } + public Guid PurchaseStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PurchaseStatusId")] + public PurchaseOrderStatus? PurchaseStatus { get; set; } + public Guid NextPurchaseStatusId { get; set; } + + [ValidateNever] + [ForeignKey("NextPurchaseStatusId")] + public PurchaseOrderStatus? NextPurchaseStatus { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Inventory/Requisition.cs b/Marco.Pms.Model/Inventory/Requisition.cs new file mode 100644 index 0000000..755da90 --- /dev/null +++ b/Marco.Pms.Model/Inventory/Requisition.cs @@ -0,0 +1,44 @@ +using Marco.Pms.Model.Employees; +using Marco.Pms.Model.Projects; +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class Requisition : TenantRelation + { + public Guid Id { get; set; } + public Guid ItemId { get; set; } + + [ValidateNever] + [ForeignKey("ItemId")] + public Item? Item { get; set; } + public Guid ProjectId { get; set; } + + [ValidateNever] + [ForeignKey("ProjectId")] + public Project? Project { get; set; } + public Guid BatchId { get; set; } + public int NumberOfItems { get; set; } + public Guid RequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("RequisitionStatusId")] + public RequisitionStatus? RequisitionStatus { get; set; } + public string RequisitionUId { get; set; } = "Requisition-00001"; + public bool IsActive { get; set; } = true; + public DateTime CreatedAt { get; set; } + public Guid CreatedById { get; set; } + + [ValidateNever] + [ForeignKey("CreatedById")] + public Employee? CreatedBy { get; set; } + public DateTime? UpdatedAt { get; set; } + public Guid? UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/RequisitionStatus.cs b/Marco.Pms.Model/Inventory/RequisitionStatus.cs new file mode 100644 index 0000000..cd0023a --- /dev/null +++ b/Marco.Pms.Model/Inventory/RequisitionStatus.cs @@ -0,0 +1,12 @@ +using Marco.Pms.Model.Utilities; + +namespace Marco.Pms.Model.Inventory +{ + public class RequisitionStatus : TenantRelation + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public bool IsActive { get; set; } = true; + } +} diff --git a/Marco.Pms.Model/Inventory/RequisitionStatusEmployeeMapping.cs b/Marco.Pms.Model/Inventory/RequisitionStatusEmployeeMapping.cs new file mode 100644 index 0000000..c6c0f6e --- /dev/null +++ b/Marco.Pms.Model/Inventory/RequisitionStatusEmployeeMapping.cs @@ -0,0 +1,21 @@ +using Marco.Pms.Model.Employees; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class RequisitionStatusEmployeeMapping + { + public Guid Id { get; set; } + public Guid RequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("RequisitionStatusId")] + public RequisitionStatus? RequisitionStatus { get; set; } + public Guid EmployeeId { get; set; } + + [ValidateNever] + [ForeignKey("EmployeeId")] + public Employee? Employee { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/RequisitionStatusLogs.cs b/Marco.Pms.Model/Inventory/RequisitionStatusLogs.cs new file mode 100644 index 0000000..a580e21 --- /dev/null +++ b/Marco.Pms.Model/Inventory/RequisitionStatusLogs.cs @@ -0,0 +1,28 @@ +using Marco.Pms.Model.Employees; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class RequisitionStatusLogs + { + public Guid Id { get; set; } + public Guid PreviousRequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PreviousRequisitionStatusId")] + public PurchaseOrderStatus? PreviousRequisitionStatus { get; set; } + public string? Comment { get; set; } + public Guid RequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("RequisitionStatusId")] + public RequisitionStatus? RequisitionStatus { get; set; } + public DateTime UpdatedAt { get; set; } + public Guid UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/RequisitionStatusMapping.cs b/Marco.Pms.Model/Inventory/RequisitionStatusMapping.cs new file mode 100644 index 0000000..6590a38 --- /dev/null +++ b/Marco.Pms.Model/Inventory/RequisitionStatusMapping.cs @@ -0,0 +1,26 @@ +using Marco.Pms.Model.Utilities; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class RequisitionStatusMapping : TenantRelation + { + public Guid Id { get; set; } + public Guid PreviousRequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("PreviousRequisitionStatusId")] + public RequisitionStatus? PreviousRequisitionStatus { get; set; } + public Guid RequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("RequisitionStatusId")] + public RequisitionStatus? RequisitionStatus { get; set; } + public Guid NextRequisitionStatusId { get; set; } + + [ValidateNever] + [ForeignKey("NextRequisitionStatusId")] + public RequisitionStatus? NextRequisitionStatus { get; set; } + } +} diff --git a/Marco.Pms.Model/Inventory/Supplier.cs b/Marco.Pms.Model/Inventory/Supplier.cs new file mode 100644 index 0000000..b1f95e6 --- /dev/null +++ b/Marco.Pms.Model/Inventory/Supplier.cs @@ -0,0 +1,31 @@ +using Marco.Pms.Model.Employees; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class Supplier + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string? Email { get; set; } + public string SupplierGroup { get; set; } = default!; + public string BankName { get; set; } = default!; + public string AccountNumber { get; set; } = default!; + public string IFSC { get; set; } = default!; + public string SupplierUId { get; set; } = "Supplier-00001"; + public bool IsActive { get; set; } = true; + public DateTime CreatedAt { get; set; } + public Guid CreatedById { get; set; } + + [ValidateNever] + [ForeignKey("CreatedById")] + public Employee? CreatedBy { get; set; } + public DateTime? UpdatedAt { get; set; } + public Guid? UpdatedById { get; set; } + + [ValidateNever] + [ForeignKey("UpdatedById")] + public Employee? UpdatedBy { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Inventory/SupplierStateMapping.cs b/Marco.Pms.Model/Inventory/SupplierStateMapping.cs new file mode 100644 index 0000000..0a92c99 --- /dev/null +++ b/Marco.Pms.Model/Inventory/SupplierStateMapping.cs @@ -0,0 +1,29 @@ +using Marco.Pms.Model.Master; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Inventory +{ + public class SupplierStateMapping + { + public Guid Id { get; set; } + public Guid StateId { get; set; } + + [ValidateNever] + [ForeignKey("StateId")] + public StateMaster? State { get; set; } + public string Street { get; set; } = default!; + public string CityName { get; set; } = default!; + public string PinCode { get; set; } = default!; + public string Country { get; set; } = default!; + public string GSTNumber { get; set; } = default!; + public string ContactPerson { get; set; } = default!; + public string ContactEmail { get; set; } = default!; + public string ContactPhone { get; set; } = default!; + public Guid SupplierId { get; set; } + + [ValidateNever] + [ForeignKey("SupplierId")] + public Supplier? Supplier { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Master/Manufacturer.cs b/Marco.Pms.Model/Master/Manufacturer.cs new file mode 100644 index 0000000..8289184 --- /dev/null +++ b/Marco.Pms.Model/Master/Manufacturer.cs @@ -0,0 +1,8 @@ +namespace Marco.Pms.Model.Master +{ + public class Manufacturer + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + } +} diff --git a/Marco.Pms.Model/Master/ServicesTaxType.cs b/Marco.Pms.Model/Master/ServicesTaxType.cs new file mode 100644 index 0000000..565b15f --- /dev/null +++ b/Marco.Pms.Model/Master/ServicesTaxType.cs @@ -0,0 +1,9 @@ +namespace Marco.Pms.Model.Master +{ + public class ServicesTaxType + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + } +} diff --git a/Marco.Pms.Model/Master/StateMaster.cs b/Marco.Pms.Model/Master/StateMaster.cs new file mode 100644 index 0000000..60b87b8 --- /dev/null +++ b/Marco.Pms.Model/Master/StateMaster.cs @@ -0,0 +1,10 @@ +namespace Marco.Pms.Model.Master +{ + public class StateMaster + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public int StateCode { get; set; } = default!; + } +} diff --git a/Marco.Pms.Model/Master/TaxSlabMaster.cs b/Marco.Pms.Model/Master/TaxSlabMaster.cs new file mode 100644 index 0000000..acb3464 --- /dev/null +++ b/Marco.Pms.Model/Master/TaxSlabMaster.cs @@ -0,0 +1,8 @@ +namespace Marco.Pms.Model.Master +{ + public class TaxSlabMaster + { + public Guid Id { get; set; } + public int Percentage { get; set; } + } +} \ No newline at end of file diff --git a/Marco.Pms.Model/Master/TechnicalUnit.cs b/Marco.Pms.Model/Master/TechnicalUnit.cs new file mode 100644 index 0000000..cfd0567 --- /dev/null +++ b/Marco.Pms.Model/Master/TechnicalUnit.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Marco.Pms.Model.Master +{ + public class TechnicalUnit + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public Guid UnitTypeId { get; set; } + + [ValidateNever] + [ForeignKey("UnitTypeId")] + public UnitType? UnitType { get; set; } + } +} diff --git a/Marco.Pms.Model/Master/UnitType.cs b/Marco.Pms.Model/Master/UnitType.cs new file mode 100644 index 0000000..a87e9ef --- /dev/null +++ b/Marco.Pms.Model/Master/UnitType.cs @@ -0,0 +1,9 @@ +namespace Marco.Pms.Model.Master +{ + public class UnitType + { + public Guid Id { get; set; } + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + } +} diff --git a/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusDetailsVM.cs b/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusDetailsVM.cs new file mode 100644 index 0000000..1a905fe --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusDetailsVM.cs @@ -0,0 +1,12 @@ +namespace Marco.Pms.Model.ViewModels.Inventory +{ + public class PurchaseOrderStatusDetailsVM + { + public Guid Id { get; set; } + public string? Name { get; set; } + public string? Description { get; set; } + public bool IsActive { get; set; } + public List? PreviousPurchaseStatus { get; set; } + public List? NextPurchaseStatus { get; set; } + } +} diff --git a/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusVM.cs b/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusVM.cs new file mode 100644 index 0000000..a3580c7 --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Inventory/PurchaseOrderStatusVM.cs @@ -0,0 +1,10 @@ +namespace Marco.Pms.Model.ViewModels.Inventory +{ + public class PurchaseOrderStatusVM + { + public Guid Id { get; set; } + public string? Name { get; set; } + public string? Description { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusDetailsVM.cs b/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusDetailsVM.cs new file mode 100644 index 0000000..ac21a4f --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusDetailsVM.cs @@ -0,0 +1,12 @@ +namespace Marco.Pms.Model.ViewModels.Inventory +{ + public class RequisitionStatusDetailsVM + { + public Guid Id { get; set; } + public string? Name { get; set; } + public string? Description { get; set; } + public bool IsActive { get; set; } + public List? PreviousRequisitionStatus { get; set; } + public List? NextRequisitionStatus { get; set; } + } +} diff --git a/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusVM.cs b/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusVM.cs new file mode 100644 index 0000000..78d3653 --- /dev/null +++ b/Marco.Pms.Model/ViewModels/Inventory/RequisitionStatusVM.cs @@ -0,0 +1,10 @@ +namespace Marco.Pms.Model.ViewModels.Inventory +{ + public class RequisitionStatusVM + { + public Guid Id { get; set; } + public string? Name { get; set; } + public string? Description { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/Marco.Pms.Services/Service/MasterService.cs b/Marco.Pms.Services/Service/MasterService.cs index 091ba3c..3503a17 100644 --- a/Marco.Pms.Services/Service/MasterService.cs +++ b/Marco.Pms.Services/Service/MasterService.cs @@ -1863,9 +1863,9 @@ namespace Marco.Pms.Services.Service return ApiResponse.ErrorResponse("An error occurred", "Unable to fetch work status list", 500); } } - public async Task> CreateWorkStatus(CreateWorkStatusMasterDto createWorkStatusDto, Employee loggedInEmployee, Guid tenantId) + public async Task> CreateWorkStatus(CreateWorkStatusMasterDto model, Employee loggedInEmployee, Guid tenantId) { - _logger.LogInfo("CreateWorkStatus called with Name: {Name}", createWorkStatusDto.Name ?? ""); + _logger.LogInfo("CreateWorkStatus called with Name: {Name}", model.Name); try { @@ -1880,19 +1880,19 @@ namespace Marco.Pms.Services.Service // Step 2: Check if work status with the same name already exists var existingWorkStatus = await _context.WorkStatusMasters - .FirstOrDefaultAsync(ws => ws.Name == createWorkStatusDto.Name && ws.TenantId == tenantId); + .FirstOrDefaultAsync(ws => ws.Name == model.Name && ws.TenantId == tenantId); if (existingWorkStatus != null) { - _logger.LogWarning("Work status already exists: {Name}", createWorkStatusDto.Name ?? ""); + _logger.LogWarning("Work status already exists: {Name}", model.Name); return ApiResponse.ErrorResponse("Work status already exists", "Work status already exists", 400); } // Step 3: Create new WorkStatusMaster entry var workStatus = new WorkStatusMaster { - Name = createWorkStatusDto.Name?.Trim() ?? "", - Description = createWorkStatusDto.Description?.Trim() ?? "", + Name = model.Name.Trim(), + Description = model.Description.Trim(), IsSystem = false, TenantId = tenantId }; @@ -1909,16 +1909,16 @@ namespace Marco.Pms.Services.Service return ApiResponse.ErrorResponse("An error occurred", "Unable to create work status", 500); } } - public async Task> UpdateWorkStatus(Guid id, UpdateWorkStatusMasterDto updateWorkStatusDto, Employee loggedInEmployee, Guid tenantId) + public async Task> UpdateWorkStatus(Guid id, UpdateWorkStatusMasterDto model, Employee loggedInEmployee, Guid tenantId) { - _logger.LogInfo("UpdateWorkStatus called for WorkStatus ID: {Id}, New Name: {Name}", id, updateWorkStatusDto.Name ?? ""); + _logger.LogInfo("UpdateWorkStatus called for WorkStatus ID: {Id}, New Name: {Name}", id, model.Name); try { // Step 1: Validate input - if (id == Guid.Empty || id != updateWorkStatusDto.Id) + if (id == Guid.Empty || id != model.Id) { - _logger.LogWarning("Invalid ID provided for update. Route ID: {RouteId}, DTO ID: {DtoId}", id, updateWorkStatusDto.Id); + _logger.LogWarning("Invalid ID provided for update. Route ID: {RouteId}, DTO ID: {DtoId}", id, model.Id); return ApiResponse.ErrorResponse("Invalid data provided", "The provided work status ID is invalid", 400); } @@ -1942,20 +1942,31 @@ namespace Marco.Pms.Services.Service // Step 4: Check for duplicate name (optional) var isDuplicate = await _context.WorkStatusMasters - .AnyAsync(ws => ws.Name == updateWorkStatusDto.Name && ws.Id != id && ws.TenantId == tenantId); + .AnyAsync(ws => ws.Name == model.Name.Trim() && ws.Id != id && ws.TenantId == tenantId); if (isDuplicate) { - _logger.LogWarning("Duplicate work status name '{Name}' detected during update. ID: {Id}", updateWorkStatusDto.Name ?? "", id); + _logger.LogWarning("Duplicate work status name '{Name}' detected during update. ID: {Id}", model.Name, id); return ApiResponse.ErrorResponse("Work status with the same name already exists", "Duplicate name", 400); } + // Capture original state for audit log + var existingEntityBson = _updateLogHelper.EntityToBsonDocument(workStatus); + // Step 5: Update fields - workStatus.Name = updateWorkStatusDto.Name?.Trim() ?? ""; - workStatus.Description = updateWorkStatusDto.Description?.Trim() ?? ""; + workStatus.Name = model.Name.Trim(); + workStatus.Description = model.Description.Trim(); await _context.SaveChangesAsync(); + await _updateLogHelper.PushToUpdateLogsAsync(new UpdateLogsObject + { + EntityId = workStatus.Id.ToString(), + UpdatedById = loggedInEmployee.Id.ToString(), + OldObject = existingEntityBson, + UpdatedAt = DateTime.UtcNow + }, "WorkStatusMasterModificationLog"); + _logger.LogInfo("Work status updated successfully. ID: {Id}", id); return ApiResponse.SuccessResponse(workStatus, "Work status updated successfully", 200); } @@ -2003,10 +2014,21 @@ namespace Marco.Pms.Services.Service ); } + // Capture original state for audit log + var existingEntityBson = _updateLogHelper.EntityToBsonDocument(workStatus); + // Step 5: Delete and persist _context.WorkStatusMasters.Remove(workStatus); await _context.SaveChangesAsync(); + await _updateLogHelper.PushToUpdateLogsAsync(new UpdateLogsObject + { + EntityId = workStatus.Id.ToString(), + UpdatedById = loggedInEmployee.Id.ToString(), + OldObject = existingEntityBson, + UpdatedAt = DateTime.UtcNow + }, "WorkStatusMasterModificationLog"); + _logger.LogInfo("Work status deleted successfully. Id: {Id}", id); return ApiResponse.SuccessResponse(new { }, "Work status deleted successfully", 200); }