diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs index 636bf680..ae283f2f 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs @@ -3585,5 +3585,301 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen }) ); + #region Stock Transfer + listFormName = AppCodes.Store.Transfer; + movementType = "Transfer"; + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + ExportJson = DefaultExportJson, + IsSubForm = false, + ShowNote = true, + LayoutJson = DefaultLayoutJson(), + CultureName = LanguageCodes.En, + ListFormCode = listFormName, + Name = listFormName, + Title = listFormName, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = true, + IsBranch = false, + IsOrganizationUnit = false, + Description = listFormName, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = TableNameResolver.GetFullSpecialViewName(MenuPrefix.Store, TablePrefix.TenantPrefix, nameof(TableNameEnum.TransferItem)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = $"\"IsDeleted\" = 'false' AND \"MovementType\" = '{movementType}'", + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = DefaultSearchPanelJson, + GroupPanelJson = DefaultGroupPanelJson, + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(listFormName), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Movement)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 600, 300, true, false, false, true, false), + CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { + new() { + ButtonPosition = UiCommandButtonPositionTypeEnum.Toolbar, + Hint = "Malzeme Depodan Seç", + Text ="Malzeme Depodan Seç", + AuthName = listFormName + ".Create", + DialogName = "RolesPermission", + DialogParameters = JsonSerializer.Serialize(new { name = "@Name" }), + IsVisible = true, + }, + }), + }, autoSave: true + ); + + #region Stock Transfer Fields + await _listFormFieldRepository.InsertManyAsync([ + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "Id", + Width = 100, + ListOrderNo = 1, + Visible = false, + IsActive = true, + IsDeleted = false, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "MovementNumber", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + SortIndex = 1, + SortDirection = GridColumnOptions.SortOrderDesc, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Date, + FieldName = "MovementDate", + Width = 100, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "MovementType", + Width = 100, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.MovementType), "Name", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "ReferenceTypeId", + Width = 150, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.ReferenceType), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "ReferenceDocument", + Width = 150, + ListOrderNo = 6, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "WarehouseId", + Width = 150, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Warehouse), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "ZoneId", + Width = 200, + ListOrderNo = 8, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Zone), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "LocationId", + Width = 200, + ListOrderNo = 9, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Location), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "MaterialId", + Width = 200, + ListOrderNo = 10, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Material), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Decimal, + FieldName = "Quantity", + Format = "fixedPoint", + Alignment = "right", + Width = 200, + ListOrderNo = 11, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Uom", + Width = 100, + ListOrderNo = 12, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Uom), "Name", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "LotNumber", + Width = 100, + ListOrderNo = 13, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "MainDescription", + Width = 400, + ListOrderNo = 14, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Description", + Width = 400, + ListOrderNo = 15, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ]); + #endregion + } + #endregion } } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json index c51e1659..eb2c8915 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json @@ -2722,7 +2722,7 @@ "Code": "App.Store.Transfer", "DisplayName": "App.Store.Transfer", "Order": 12, - "Url": "/admin/warehouse/transfer", + "Url": "/admin/list/App.Store.Transfer", "Icon": "FcSynchronize", "RequiredPermissionName": "App.Store.Transfer", "IsDisabled": false diff --git a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs index 7153004b..e951cef8 100644 --- a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -216,5 +216,6 @@ public enum TableNameEnum Movement, MovementItem, MovementType, - ReferenceType + ReferenceType, + TransferItem, //Gerçek bir tablo ismi değil. View eklemek amacıyla eklendi. } diff --git a/api/src/Erp.Platform.Domain.Shared/Enums/TablePrefixEnum.cs b/api/src/Erp.Platform.Domain.Shared/Enums/TablePrefixEnum.cs index 43f3704e..cef6da66 100644 --- a/api/src/Erp.Platform.Domain.Shared/Enums/TablePrefixEnum.cs +++ b/api/src/Erp.Platform.Domain.Shared/Enums/TablePrefixEnum.cs @@ -4,9 +4,9 @@ namespace Erp.Platform; public static class TablePrefix { - private const string HostPrefix = "H"; - private const string TenantPrefix = "T"; - private const string BranchPrefix = "B"; + public const string HostPrefix = "H"; + public const string TenantPrefix = "T"; + public const string BranchPrefix = "B"; public static string PlatformByName(MenuPrefix MenuGroup, TableNameEnum tableName) { diff --git a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs index 51e7c27f..2913c8a1 100644 --- a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs @@ -279,5 +279,10 @@ public static class TableNameResolver return ViewPrefix + entry.Method(entry.PrefixGroup, tableEnum); } + + public static string GetFullSpecialViewName(MenuPrefix menu, string Prefix, string objectName) + { + return $"{ViewPrefix}{MenuPrefixExtensions.ToPrefix(menu)}_{Prefix}_{objectName}"; + } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index d3674ddb..0a26564d 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -6607,7 +6607,7 @@ "description": "Satın Alma Siparişi" }, { - "movementNumber": "ÇI-2024-001", + "movementNumber": "CI-2024-001", "movementDate": "2024-01-10T10:30:00", "partnerCode": "CUST-001", "movementType": "Çıkış", @@ -6639,7 +6639,7 @@ "description": "2024 yılı son çeyrek 360° derece performans değerlendirmesi" }, { - "movementNumber": "GI-2024-001", + "movementNumber": "CI-2024-001", "materialCode": "SF001", "warehouseCode": "WH-001", "zoneCode": "Z002", diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs index fe2650f6..269ea06d 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs @@ -38,7 +38,9 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency await CreateOrUpdateProjectTaskViewAsync(dbContext, nameof(TableNameEnum.ProjectTask)); - await CreateOrUpdateMovementViewAsync(dbContext, nameof(TableNameEnum.MovementItem)); + await CreateOrUpdateMovementItemViewAsync(dbContext, nameof(TableNameEnum.MovementItem)); + + await CreateOrUpdateMovementTransferViewAsync(dbContext, nameof(TableNameEnum.TransferItem)); _logger.LogInformation("Database view seeding completed successfully."); } @@ -177,9 +179,9 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency } /// - /// Creates or updates the V_T_Str_Movement view + /// Creates or updates the V_T_Str_MovementItem view /// - private async Task CreateOrUpdateMovementViewAsync(PlatformDbContext dbContext, string viewName) + private async Task CreateOrUpdateMovementItemViewAsync(PlatformDbContext dbContext, string viewName) { string fullViewName = TableNameResolver.GetFullViewName(viewName); @@ -228,5 +230,58 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency throw; } } + + /// + /// Creates or updates the V_T_Str_MovementTransfer view + /// + private async Task CreateOrUpdateMovementTransferViewAsync(PlatformDbContext dbContext, string viewName) + { + string fullViewName = TableNameResolver.GetFullSpecialViewName(MenuPrefix.Store, TablePrefix.TenantPrefix, viewName); + + try + { + var createViewSql = $@" + IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[{fullViewName}]')) + DROP VIEW [dbo].[{fullViewName}]; + + EXEC(' + CREATE VIEW [dbo].[{fullViewName}] + AS + SELECT + mi.TenantId, + m.MovementNumber, + m.MovementDate, + m.MovementType, + m.PartnerId, + m.ReferenceTypeId, + m.ReferenceDocument, + m.Description AS MainDescription, + + mi.Id, + mi.MovementId, + mi.WarehouseId, + mi.ZoneId, + mi.LocationId, + mi.MaterialId, + mi.Quantity, + mi.Uom, + mi.LotNumber, + mi.Description, + mi.IsDeleted + FROM dbo.Str_T_Movement AS m + INNER JOIN dbo.Str_T_MovementItem AS mi ON m.Id = mi.MovementId + ') + "; + + await dbContext.Database.ExecuteSqlRawAsync(createViewSql); + + _logger.LogInformation($"Created/Updated {fullViewName} view successfully."); + } + catch (Exception ex) + { + _logger.LogError(ex, $"Error occurred while creating {fullViewName} view."); + throw; + } + } }