From 214fd91b66cad37a52194d9643836fc24c1f2631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sun, 7 Dec 2025 23:54:24 +0300 Subject: [PATCH] Store Stock Entry ve Stock Exit --- .../LookUpQueryValues.cs | 10 + .../Seeds/ListFormSeeder_Store.cs | 616 ++++++++++++++++-- .../Seeds/MenusData.json | 2 +- .../Entities/Tenant/Store/Movement.cs | 3 + .../Entities/Tenant/Store/MovementItem.cs | 1 - .../Entities/Tenant/Store/ReferenceType.cs | 1 + .../Entities/Tenant/SupplyChain/Partner.cs | 1 + .../EntityFrameworkCore/PlatformDbContext.cs | 18 +- ....cs => 20251207201503_Initial.Designer.cs} | 26 +- ...9_Initial.cs => 20251207201503_Initial.cs} | 76 ++- .../PlatformDbContextModelSnapshot.cs | 24 +- .../Tenants/Seeds/TenantData.json | 18 +- .../Tenants/TenantDataSeeder.cs | 4 +- .../Tenants/TenantDatabaseViewCreator.cs | 2 +- .../Tenants/TenantSeederDto.cs | 3 +- 15 files changed, 682 insertions(+), 123 deletions(-) rename api/src/Erp.Platform.EntityFrameworkCore/Migrations/{20251207184859_Initial.Designer.cs => 20251207201503_Initial.Designer.cs} (99%) rename api/src/Erp.Platform.EntityFrameworkCore/Migrations/{20251207184859_Initial.cs => 20251207201503_Initial.cs} (99%) diff --git a/api/src/Erp.Platform.Application.Contracts/LookUpQueryValues.cs b/api/src/Erp.Platform.Application.Contracts/LookUpQueryValues.cs index a166843c..e5e0691f 100644 --- a/api/src/Erp.Platform.Application.Contracts/LookUpQueryValues.cs +++ b/api/src/Erp.Platform.Application.Contracts/LookUpQueryValues.cs @@ -265,4 +265,14 @@ public static class LookupQueryValues $"AND (\"ZoneId\" = @param1 OR @param1 IS NULL) " + $"AND \"IsDeleted\" = 'false' " + $"ORDER BY \"Name\";"; + + public static string ReferenceTypeValues(string movementTypeName) => + $"SELECT " + + $"\"Id\" AS \"Key\", " + + $"\"Name\" AS \"Name\" " + + $"FROM \"{FullNameTable(TableNameEnum.ReferenceType)}\" " + + $"WHERE " + + $"(\"MovementTypeName\" = '{movementTypeName}') " + + $"AND \"IsDeleted\" = 'false' " + + $"ORDER BY \"Name\";"; } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs index 4fba4f6f..636bf680 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Store.cs @@ -45,6 +45,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen { var utils = new SeederUtils(_listFormRepository, _listFormFieldRepository); var listFormName = String.Empty; + var movementType = String.Empty; #region Warehouse Type listFormName = AppCodes.Store.WarehouseType; @@ -2246,12 +2247,14 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order=1, ColCount=1, ColSpan=1, ItemType="group", Items= [ - new EditingFormItemDto { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 2, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, - new EditingFormItemDto { Order = 3, DataField = "IsActive", ColSpan = 1, EditorType2=EditorTypes.dxCheckBox }, + new EditingFormItemDto { Order = 1, DataField = "MovementTypeName", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 2, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 3, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, + new EditingFormItemDto { Order = 4, DataField = "IsActive", ColSpan = 1, EditorType2=EditorTypes.dxCheckBox }, ]} }), FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "MovementTypeName", FieldDbType = DbType.String, Value = "Giriş", CustomValueType = FieldCustomValueTypeEnum.Value }, new() { FieldName = "IsActive", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value } }), } @@ -2274,13 +2277,30 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen PermissionJson = DefaultFieldPermissionJson(listForm.Name), PivotSettingsJson = DefaultPivotSettingsJson }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "MovementTypeName", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.MovementType), "Name", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, new() { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.String, FieldName = "Name", Width = 350, - ListOrderNo = 2, + ListOrderNo = 3, Visible = true, IsActive = true, IsDeleted = false, @@ -2298,7 +2318,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.String, FieldName = "Description", Width = 500, - ListOrderNo = 3, + ListOrderNo = 4, Visible = true, IsActive = true, IsDeleted = false, @@ -2314,7 +2334,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.Boolean, FieldName = "IsActive", Width = 100, - ListOrderNo = 4, + ListOrderNo = 5, Visible = true, IsActive = true, IsDeleted = false, @@ -2440,13 +2460,29 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, SourceDbType = DbType.Guid, - FieldName = "ReferenceTypeId", - Width = 100, + FieldName = "PartnerId", + Width = 200, ListOrderNo = 5, Visible = true, IsActive = true, IsDeleted = false, AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Partner), "Id", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "ReferenceTypeId", + Width = 150, + ListOrderNo = 6, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.ReferenceType), "Id", "Name"), ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(listForm.Name), @@ -2458,7 +2494,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.String, FieldName = "ReferenceDocument", Width = 150, - ListOrderNo = 6, + ListOrderNo = 7, Visible = true, IsActive = true, IsDeleted = false, @@ -2473,7 +2509,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.Guid, FieldName = "WarehouseId", Width = 150, - ListOrderNo = 7, + ListOrderNo = 8, Visible = true, IsActive = true, IsDeleted = false, @@ -2489,7 +2525,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.Guid, FieldName = "ZoneId", Width = 200, - ListOrderNo = 8, + ListOrderNo = 9, Visible = true, IsActive = true, IsDeleted = false, @@ -2505,7 +2541,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.Guid, FieldName = "LocationId", Width = 200, - ListOrderNo = 9, + ListOrderNo = 10, Visible = true, IsActive = true, IsDeleted = false, @@ -2521,7 +2557,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.Guid, FieldName = "MaterialId", Width = 200, - ListOrderNo = 10, + ListOrderNo = 11, Visible = true, IsActive = true, IsDeleted = false, @@ -2539,7 +2575,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen Format = "fixedPoint", Alignment = "right", Width = 200, - ListOrderNo = 11, + ListOrderNo = 12, Visible = true, IsActive = true, IsDeleted = false, @@ -2554,7 +2590,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SourceDbType = DbType.String, FieldName = "Uom", Width = 100, - ListOrderNo = 12, + ListOrderNo = 13, Visible = true, IsActive = true, IsDeleted = false, @@ -2570,21 +2606,6 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen 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 = "SerialNumber", - Width = 100, ListOrderNo = 14, Visible = true, IsActive = true, @@ -2629,8 +2650,9 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen } #endregion - #region Movement Entry + #region Stock Entry listFormName = AppCodes.Store.Entry; + movementType = "Giriş"; if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) { var listForm = await _listFormRepository.InsertAsync( @@ -2654,7 +2676,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Movement)), KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false' AND \"MovementType\" = 'Giriş'", + DefaultFilter = $"\"IsDeleted\" = 'false' AND \"MovementType\" = '{movementType}'", SortMode = GridOptions.SortModeSingle, FilterRowJson = DefaultFilterRowJson, HeaderFilterJson = DefaultHeaderFilterJson, @@ -2667,13 +2689,14 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, PagerOptionJson = DefaultPagerOptionJson, InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, - EditingOptionJson = DefaultEditingOptionJson(listFormName, 700, 400, true, true, true, true, false), + InsertAfterCommand = $"UPDATE {TableNameResolver.GetFullTableName(nameof(TableNameEnum.Movement))} SET \"MovementType\" = '{movementType}' WHERE \"Id\" = @Id;", + EditingOptionJson = DefaultEditingOptionJson(listFormName, 600, 300, true, true, true, true, false), EditingFormJson = JsonSerializer.Serialize(new List() { new() { Order=1, ColCount=2, ColSpan=1, ItemType="group", Items= [ - new EditingFormItemDto { Order = 1, DataField = "MovementNumber", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled }, - new EditingFormItemDto { Order = 2, DataField = "MovementType", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions = EditorOptionValues.Disabled }, - new EditingFormItemDto { Order = 3, DataField = "MovementDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox }, + new EditingFormItemDto { Order = 1, DataField = "MovementNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled }, + new EditingFormItemDto { Order = 2, DataField = "MovementDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox }, + new EditingFormItemDto { Order = 3, DataField = "PartnerId", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 4, DataField = "ReferenceTypeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 5, DataField = "ReferenceDocument", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, new EditingFormItemDto { Order = 6, DataField = "Description", ColSpan = 2, EditorType2=EditorTypes.dxTextArea }, @@ -2681,7 +2704,6 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen }), FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { new() { FieldName = "MovementNumber", FieldDbType = DbType.String, Value = "@AUTONUMBER", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, - new() { FieldName = "MovementType", FieldDbType = DbType.String, Value = "Giriş", CustomValueType = FieldCustomValueTypeEnum.Value }, new() { FieldName = "MovementDate", FieldDbType = DbType.Date, Value = "@DATE", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, }), CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { @@ -2735,15 +2757,14 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen new() { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "MovementType", + SourceDbType = DbType.Date, + FieldName = "MovementDate", Width = 100, ListOrderNo = 3, Visible = true, IsActive = true, IsDeleted = false, AllowSearch = true, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.MovementType), "Name", "Name"), ValidationRuleJson = DefaultValidationRuleRequiredJson, ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(listForm.Name), @@ -2752,14 +2773,21 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen new() { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, - SourceDbType = DbType.Date, - FieldName = "MovementDate", - Width = 100, + SourceDbType = DbType.Guid, + FieldName = "PartnerId", + Width = 300, ListOrderNo = 4, Visible = true, IsActive = true, IsDeleted = false, AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.SupplierValues + }), ValidationRuleJson = DefaultValidationRuleRequiredJson, ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(listForm.Name), @@ -2776,7 +2804,13 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen IsActive = true, IsDeleted = false, AllowSearch = true, - LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.ReferenceType), "Id", "Name"), + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.ReferenceTypeValues(movementType), + }), ValidationRuleJson = DefaultValidationRuleRequiredJson, ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(listForm.Name), @@ -2817,7 +2851,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen } #endregion - #region Movement Entry Items + #region Stock Entry Items listFormName = AppCodes.Store.EntryItem; if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) { @@ -2826,7 +2860,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen { ListFormType = ListFormTypeEnum.List, ExportJson = DefaultExportJson, - IsSubForm = false, + IsSubForm = true, ShowNote = true, LayoutJson = DefaultLayoutJson(), CultureName = LanguageCodes.En, @@ -2866,8 +2900,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen new EditingFormItemDto { Order = 5, DataField = "Quantity", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, new EditingFormItemDto { Order = 6, DataField = "Uom", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 7, DataField = "LotNumber", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 8, DataField = "SerialNumber", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, - new EditingFormItemDto { Order = 9, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, + new EditingFormItemDto { Order = 8, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, ]} }), FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { @@ -3045,28 +3078,13 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen PermissionJson = DefaultFieldPermissionJson(listForm.Name), PivotSettingsJson = DefaultPivotSettingsJson }, - new() { - ListFormCode = listForm.ListFormCode, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "SerialNumber", - Width = 150, - ListOrderNo = 9, - 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 = 10, + ListOrderNo = 9, Visible = true, IsActive = true, IsDeleted = false, @@ -3080,7 +3098,7 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen } #endregion - // Putaway ve Putaway Condition Sub Forms ilişkisinin kurulması + // Movement Entry ve Movement Entry Items Sub Forms ilişkisinin kurulması await utils.CloneFormLayoutAsync( AppCodes.Store.Entry, JsonSerializer.Serialize(new List() { @@ -3099,5 +3117,473 @@ public class ListFormSeeder_Warehouse : IDataSeedContributor, ITransientDependen }) ); + #region Stock Exit + listFormName = AppCodes.Store.Exit; + movementType = "Çıkış"; + 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.GetFullTableName(nameof(TableNameEnum.Movement)), + 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, + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + InsertAfterCommand = $"UPDATE {TableNameResolver.GetFullTableName(nameof(TableNameEnum.Movement))} SET \"MovementType\" = '{movementType}' WHERE \"Id\" = @Id;", + EditingOptionJson = DefaultEditingOptionJson(listFormName, 600, 300, true, true, true, true, false), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order=1, ColCount=2, ColSpan=1, ItemType="group", Items= [ + new EditingFormItemDto { Order = 1, DataField = "MovementNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled }, + new EditingFormItemDto { Order = 2, DataField = "MovementDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox }, + new EditingFormItemDto { Order = 3, DataField = "PartnerId", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 4, DataField = "ReferenceTypeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 5, DataField = "ReferenceDocument", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 6, DataField = "Description", ColSpan = 2, EditorType2=EditorTypes.dxTextArea }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "MovementNumber", FieldDbType = DbType.String, Value = "@AUTONUMBER", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { FieldName = "MovementDate", FieldDbType = DbType.Date, Value = "@DATE", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + }), + CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { + new() { + Hint = "Items", + Text ="Items", + UrlTarget="_blank", + AuthName = listFormName, + Url=$"/admin/form/{SeederUtils.GetDefaultFormCodes(listFormName)}/@Id", + IsVisible = true, + }, + }), + }, autoSave: true + ); + + #region Movement Exit 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, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "PartnerId", + Width = 300, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.CustomerValues + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "ReferenceTypeId", + Width = 200, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.ReferenceTypeValues(movementType), + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + 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.String, + FieldName = "Description", + Width = 400, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + #region Stock Exit Items + listFormName = AppCodes.Store.ExitItem; + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + ExportJson = DefaultExportJson, + IsSubForm = true, + 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.GetFullTableName(nameof(TableNameEnum.MovementItem)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = DefaultFilterJson, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = DefaultSearchPanelJson, + GroupPanelJson = DefaultGroupPanelJson, + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(listFormName), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.MovementItem)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 500, 400, true, false, false, true, false), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order=1, ColCount=1, ColSpan=1, ItemType="group", Items= [ + new EditingFormItemDto { Order = 1, DataField = "WarehouseId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 2, DataField = "ZoneId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 3, DataField = "LocationId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 4, DataField = "MaterialId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 5, DataField = "Quantity", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 6, DataField = "Uom", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 7, DataField = "LotNumber", ColSpan = 1, EditorType2=EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 8, DataField = "Description", ColSpan = 1, EditorType2=EditorTypes.dxTextArea }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "Quantity", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "Uom", FieldDbType = DbType.String, Value = "Adet", CustomValueType = FieldCustomValueTypeEnum.Value }, + }), + CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { + new() { + ButtonPosition = UiCommandButtonPositionTypeEnum.Toolbar, + Hint = "Malzeme Depodan Seç", + Text ="Malzeme Depodan Seç", + AuthName = listFormName, + DialogName = "RolesPermission", + DialogParameters = JsonSerializer.Serialize(new { name = "@Name" }), + IsVisible = true, + }, + }), + }, autoSave: true + ); + + #region Movement Exit Items 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.Guid, + FieldName = "WarehouseId", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.WarehouseValues, + CascadeEmptyFields = "ZoneId,LocationId" + }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "ZoneId", + Width = 150, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.ZoneValues, + CascadeRelationField = "WarehouseId", + CascadeFilterOperator="=", + CascadeParentFields = "WarehouseId", + CascadeEmptyFields = "LocationId" + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "LocationId", + Width = 150, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = LookupQueryValues.LocationValues, + CascadeRelationField = "WarehouseId,ZoneId", + CascadeFilterOperator="=", + CascadeParentFields = "WarehouseId,ZoneId", + }), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "MaterialId", + Width = 200, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Material), "Id", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + 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 = 100, + ListOrderNo = 6, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Uom", + Width = 100, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Uom), "Name", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "LotNumber", + Width = 150, + ListOrderNo = 8, + 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 = 9, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + // Movement Entry ve Movement Entry Items Sub Forms ilişkisinin kurulması + await utils.CloneFormLayoutAsync( + AppCodes.Store.Exit, + JsonSerializer.Serialize(new List() { + new { + TabType = ListFormTabTypeEnum.List, + TabTitle = AppCodes.Store.ExitItem, + Code = AppCodes.Store.ExitItem, + Relation = new List() { + new { + ParentFieldName = "Id", + DbType = DbType.Guid, + ChildFieldName = "MovementId" + } + } + } + }) + ); + } } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json index a6fa458d..c51e1659 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json @@ -2712,7 +2712,7 @@ "Code": "App.Store.Exit", "DisplayName": "App.Store.Exit", "Order": 11, - "Url": "/admin/warehouse/issue", + "Url": "/admin/list/App.Store.Exit", "Icon": "FcExport", "RequiredPermissionName": "App.Store.Exit", "IsDisabled": false diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/Movement.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/Movement.cs index 00cdf0ed..ac47a82c 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/Movement.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/Movement.cs @@ -14,6 +14,9 @@ public class Movement : FullAuditedEntity, IMultiTenant public string MovementType { get; set; } // e.g., Inbound, Outbound, Transfer + public Guid? PartnerId { get; set; } + public Partner? Partner { get; set; } + public Guid? ReferenceTypeId { get; set; } // e.g., Sales Order, Purchase Order public ReferenceType? ReferenceType { get; set; } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/MovementItem.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/MovementItem.cs index ac680547..601ec613 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/MovementItem.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/MovementItem.cs @@ -27,7 +27,6 @@ public class MovementItem : FullAuditedEntity, IMultiTenant public string Uom { get; set; } public string LotNumber { get; set; } - public string SerialNumber { get; set; } public string Description { get; set; } } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/ReferenceType.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/ReferenceType.cs index dc21c51f..5cb6a545 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/Store/ReferenceType.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Store/ReferenceType.cs @@ -9,6 +9,7 @@ public class ReferenceType : FullAuditedEntity, IMultiTenant public Guid? TenantId { get; set; } public string Name { get; set; } + public string MovementTypeName { get; set; } public string Description { get; set; } public bool IsActive { get; set; } } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Partner.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Partner.cs index 1ecac7ac..a49a51d9 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Partner.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Partner.cs @@ -49,6 +49,7 @@ public class Partner : FullAuditedEntity, IMultiTenant public ICollection Certificates { get; set; } public ICollection Contacts { get; set; } public ICollection PurchaseOrders { get; set; } + public ICollection Movements { get; set; } //Customer ile ilgil bilgiler public Guid? CustomerTypeId { get; set; } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index 7ee3c066..442dbeb5 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -3791,9 +3791,9 @@ public class PlatformDbContext : b.Property(x => x.IsActive).HasDefaultValue(true); }); - builder.Entity(b => + builder.Entity(b => { - b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.ReferenceType)), Prefix.DbSchema); + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.MovementType)), Prefix.DbSchema); b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(50); @@ -3801,12 +3801,13 @@ public class PlatformDbContext : b.Property(x => x.IsActive).HasDefaultValue(true); }); - builder.Entity(b => + builder.Entity(b => { - b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.MovementType)), Prefix.DbSchema); + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.ReferenceType)), Prefix.DbSchema); b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(50); + b.Property(x => x.MovementTypeName).IsRequired().HasMaxLength(50); b.Property(x => x.Description).HasMaxLength(500); b.Property(x => x.IsActive).HasDefaultValue(true); }); @@ -3818,10 +3819,16 @@ public class PlatformDbContext : b.Property(x => x.MovementNumber).IsRequired().HasMaxLength(50); b.Property(x => x.MovementDate).IsRequired(); - b.Property(x => x.MovementType).IsRequired().HasMaxLength(50); + b.Property(x => x.MovementType).HasMaxLength(50); b.Property(x => x.ReferenceTypeId).IsRequired(); b.Property(x => x.ReferenceDocument).HasMaxLength(100); b.Property(x => x.Description).HasMaxLength(1000); + + b.HasOne(x => x.Partner) + .WithMany(x => x.Movements) + .HasForeignKey(x => x.PartnerId) + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(false); }); builder.Entity(b => @@ -3837,7 +3844,6 @@ public class PlatformDbContext : b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(0); b.Property(x => x.Uom).IsRequired().HasMaxLength(64); b.Property(x => x.LotNumber).HasMaxLength(100); - b.Property(x => x.SerialNumber).HasMaxLength(100); b.Property(x => x.Description).HasMaxLength(1000); b.HasOne(x => x.Warehouse) diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.Designer.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.Designer.cs similarity index 99% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.Designer.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.Designer.cs index 26d71398..17785939 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.Designer.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Erp.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20251207184859_Initial")] + [Migration("20251207201503_Initial")] partial class Initial { /// @@ -7733,10 +7733,12 @@ namespace Erp.Platform.Migrations .HasColumnType("nvarchar(50)"); b.Property("MovementType") - .IsRequired() .HasMaxLength(50) .HasColumnType("nvarchar(50)"); + b.Property("PartnerId") + .HasColumnType("uniqueidentifier"); + b.Property("ReferenceDocument") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); @@ -7750,6 +7752,8 @@ namespace Erp.Platform.Migrations b.HasKey("Id"); + b.HasIndex("PartnerId"); + b.HasIndex("ReferenceTypeId"); b.ToTable("Str_T_Movement", (string)null); @@ -7813,10 +7817,6 @@ namespace Erp.Platform.Migrations .HasColumnType("decimal(18,2)") .HasDefaultValue(0m); - b.Property("SerialNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - b.Property("TenantId") .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); @@ -11497,6 +11497,11 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); + b.Property("MovementTypeName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("Name") .IsRequired() .HasMaxLength(50) @@ -19240,12 +19245,19 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.Movement", b => { + b.HasOne("Erp.Platform.Entities.Partner", "Partner") + .WithMany("Movements") + .HasForeignKey("PartnerId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Erp.Platform.Entities.ReferenceType", "ReferenceType") .WithMany() .HasForeignKey("ReferenceTypeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Partner"); + b.Navigation("ReferenceType"); }); @@ -20842,6 +20854,8 @@ namespace Erp.Platform.Migrations b.Navigation("Contacts"); + b.Navigation("Movements"); + b.Navigation("PurchaseOrders"); }); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.cs similarity index 99% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.cs index f722355f..73374fd3 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207184859_Initial.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251207201503_Initial.cs @@ -3107,6 +3107,7 @@ namespace Erp.Platform.Migrations Id = table.Column(type: "uniqueidentifier", nullable: false), TenantId = table.Column(type: "uniqueidentifier", nullable: true), Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + MovementTypeName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), CreationTime = table.Column(type: "datetime2", nullable: false), @@ -4449,37 +4450,6 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "Str_T_Movement", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - MovementNumber = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - MovementDate = table.Column(type: "datetime2", nullable: false), - MovementType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - ReferenceTypeId = table.Column(type: "uniqueidentifier", nullable: false), - ReferenceDocument = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Str_T_Movement", x => x.Id); - table.ForeignKey( - name: "FK_Str_T_Movement_Str_T_ReferenceType_ReferenceTypeId", - column: x => x.ReferenceTypeId, - principalTable: "Str_T_ReferenceType", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "AbpEntityPropertyChanges", columns: table => new @@ -5428,6 +5398,44 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "Str_T_Movement", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + MovementNumber = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + MovementDate = table.Column(type: "datetime2", nullable: false), + MovementType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + PartnerId = table.Column(type: "uniqueidentifier", nullable: true), + ReferenceTypeId = table.Column(type: "uniqueidentifier", nullable: false), + ReferenceDocument = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Str_T_Movement", x => x.Id); + table.ForeignKey( + name: "FK_Str_T_Movement_Adm_T_Partner_PartnerId", + column: x => x.PartnerId, + principalTable: "Adm_T_Partner", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Str_T_Movement_Str_T_ReferenceType_ReferenceTypeId", + column: x => x.ReferenceTypeId, + principalTable: "Str_T_ReferenceType", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Crm_T_SalesOrderItem", columns: table => new @@ -7462,7 +7470,6 @@ namespace Erp.Platform.Migrations Quantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), Uom = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), LotNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - SerialNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), CreationTime = table.Column(type: "datetime2", nullable: false), CreatorId = table.Column(type: "uniqueidentifier", nullable: true), @@ -9276,6 +9283,11 @@ namespace Erp.Platform.Migrations table: "Str_T_Location", column: "ZoneId"); + migrationBuilder.CreateIndex( + name: "IX_Str_T_Movement_PartnerId", + table: "Str_T_Movement", + column: "PartnerId"); + migrationBuilder.CreateIndex( name: "IX_Str_T_Movement_ReferenceTypeId", table: "Str_T_Movement", diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 9a77b0c4..ad709e22 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -7730,10 +7730,12 @@ namespace Erp.Platform.Migrations .HasColumnType("nvarchar(50)"); b.Property("MovementType") - .IsRequired() .HasMaxLength(50) .HasColumnType("nvarchar(50)"); + b.Property("PartnerId") + .HasColumnType("uniqueidentifier"); + b.Property("ReferenceDocument") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); @@ -7747,6 +7749,8 @@ namespace Erp.Platform.Migrations b.HasKey("Id"); + b.HasIndex("PartnerId"); + b.HasIndex("ReferenceTypeId"); b.ToTable("Str_T_Movement", (string)null); @@ -7810,10 +7814,6 @@ namespace Erp.Platform.Migrations .HasColumnType("decimal(18,2)") .HasDefaultValue(0m); - b.Property("SerialNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - b.Property("TenantId") .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); @@ -11494,6 +11494,11 @@ namespace Erp.Platform.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); + b.Property("MovementTypeName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("Name") .IsRequired() .HasMaxLength(50) @@ -19237,12 +19242,19 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.Movement", b => { + b.HasOne("Erp.Platform.Entities.Partner", "Partner") + .WithMany("Movements") + .HasForeignKey("PartnerId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Erp.Platform.Entities.ReferenceType", "ReferenceType") .WithMany() .HasForeignKey("ReferenceTypeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Partner"); + b.Navigation("ReferenceType"); }); @@ -20839,6 +20851,8 @@ namespace Erp.Platform.Migrations b.Navigation("Contacts"); + b.Navigation("Movements"); + b.Navigation("PurchaseOrders"); }); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index 9008b4cf..d3674ddb 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -6555,36 +6555,43 @@ "ReferenceTypes": [ { "name": "Satın Alma Siparişi", + "movementTypeName": "Giriş", "description": "Satın alma siparişleri için kullanılan referans türü", "isActive": true }, { "name": "Satış Siparişi", + "movementTypeName": "Çıkış", "description": "Satış siparişleri için kullanılan referans türü", "isActive": true }, { "name": "Üretim Emri", + "movementTypeName": "Çıkış", "description": "Üretim emirleri için kullanılan referans türü", "isActive": true }, { "name": "Transfer Emri", + "movementTypeName": "Transfer", "description": "Transfer emirleri için kullanılan referans türü", "isActive": true }, { "name": "İade", + "movementTypeName": "Giriş", "description": "İade işlemleri için kullanılan referans türü", "isActive": true }, { - "name": "Diğer", - "description": "Diğer işlemler için kullanılan referans türü", + "name": "Sayım Giriş", + "movementTypeName": "Giriş", + "description": "Envanter sayımları için kullanılan referans türü", "isActive": true }, { - "name": "Sayım", + "name": "Sayım Çıkış", + "movementTypeName": "Çıkış", "description": "Envanter sayımları için kullanılan referans türü", "isActive": true } @@ -6593,14 +6600,16 @@ { "movementNumber": "GR-2024-001", "movementDate": "2024-01-05T10:30:00", + "partnerCode": "SUP001", "movementType": "Giriş", "referenceType": "Satın Alma Siparişi", "referenceDocument": "PO-2024-001", "description": "Satın Alma Siparişi" }, { - "movementNumber": "GI-2024-001", + "movementNumber": "ÇI-2024-001", "movementDate": "2024-01-10T10:30:00", + "partnerCode": "CUST-001", "movementType": "Çıkış", "referenceType": "Satış Siparişi", "referenceDocument": "SO-2024-001", @@ -6610,6 +6619,7 @@ "movementNumber": "TR-2024-001", "movementDate": "2024-01-17T10:30:00", "movementType": "Transfer", + "partnerCode": null, "referenceType": "Transfer Emri", "referenceDocument": "TR-2024-001", "description": "Depo transferi" diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs index 3bb8691d..850ed52d 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs @@ -2790,6 +2790,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency await _referenceTypeRepository.InsertAsync(new ReferenceType { Name = item.Name, + MovementTypeName = item.MovementTypeName, Description = item.Description, IsActive = item.IsActive }, autoSave: true); @@ -2802,6 +2803,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency continue; var referenceType = await _referenceTypeRepository.FirstOrDefaultAsync(x => x.Name == item.ReferenceType); + var partner = await _partnerRepository.FirstOrDefaultAsync(x => x.Code == item.PartnerCode); await _movementRepository.InsertAsync(new Movement { @@ -2809,6 +2811,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency MovementDate = item.MovementDate, MovementType = item.MovementType, ReferenceTypeId = referenceType?.Id, + PartnerId = partner?.Id, ReferenceDocument = item.ReferenceDocument, Description = item.Description }, autoSave: true); @@ -2837,7 +2840,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency Quantity = item.Quantity, Uom = item.Uom, LotNumber = item.LotNumber, - SerialNumber = item.SerialNumber, Description = item.Description }, autoSave: true); } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs index d3c417b7..fe2650f6 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDatabaseViewCreator.cs @@ -197,6 +197,7 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency m.MovementNumber, m.MovementDate, m.MovementType, + m.PartnerId, m.ReferenceTypeId, m.ReferenceDocument, m.Description AS MainDescription, @@ -210,7 +211,6 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency mi.Quantity, mi.Uom, mi.LotNumber, - mi.SerialNumber, mi.Description, mi.IsDeleted FROM dbo.Str_T_Movement AS m diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs index 001b74d5..519648c1 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs @@ -154,6 +154,7 @@ public class MovementSeedDto public string MovementNumber { get; set; } public DateTime MovementDate { get; set; } public string MovementType { get; set; } + public string PartnerCode { get; set; } public string ReferenceType { get; set; } public string ReferenceDocument { get; set; } public string Description { get; set; } @@ -170,7 +171,6 @@ public class MovementItemSeedDto public decimal Quantity { get; set; } public string Uom { get; set; } public string LotNumber { get; set; } - public string SerialNumber { get; set; } public string Description { get; set; } } @@ -178,6 +178,7 @@ public class MovementItemSeedDto public class ReferenceTypeSeedDto { public string Name { get; set; } + public string MovementTypeName { get; set; } public string Description { get; set; } public bool IsActive { get; set; } }