From 1c5ff7bdd5675c2bca12dcfadb6cdd7062ae8725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:52:09 +0300 Subject: [PATCH] =?UTF-8?q?SalesOrders=20Seeder=20d=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Seeds/LanguagesData.json | 12 + .../Seeds/ListFormSeeder_Crm.cs | 774 +++++++++++++++++- .../Seeds/MenusData.json | 12 +- .../Seeds/PermissionsData.json | 129 +++ .../Enums/TableNameEnum.cs | 5 +- .../TableNameResolver.cs | 3 + .../Erp.Platform.Domain/Data/SeedConsts.cs | 4 +- .../Entities/Tenant/Crm/SalesOrder.cs | 43 + .../Entities/Tenant/Crm/SalesOrderItem.cs | 35 + .../Entities/Tenant/Crm/SalesOrderStatus.cs | 18 + .../Tenant/SupplyChain/DeliveryTerm.cs | 1 + .../Entities/Tenant/SupplyChain/Material.cs | 7 +- .../Tenant/SupplyChain/PaymentTerm.cs | 1 + .../EntityFrameworkCore/PlatformDbContext.cs | 103 ++- ....cs => 20251204142238_Initial.Designer.cs} | 409 ++++++++- ...8_Initial.cs => 20251204142238_Initial.cs} | 177 +++- .../PlatformDbContextModelSnapshot.cs | 407 ++++++++- .../Tenants/Seeds/TenantData.json | 37 + .../Tenants/TenantDataSeeder.cs | 19 +- .../Tenants/TenantSeederDto.cs | 8 + 20 files changed, 2172 insertions(+), 32 deletions(-) create mode 100644 api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrder.cs create mode 100644 api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderItem.cs create mode 100644 api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderStatus.cs rename api/src/Erp.Platform.EntityFrameworkCore/Migrations/{20251204121428_Initial.Designer.cs => 20251204142238_Initial.Designer.cs} (97%) rename api/src/Erp.Platform.EntityFrameworkCore/Migrations/{20251204121428_Initial.cs => 20251204142238_Initial.cs} (98%) diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json index fc23bd5c..d9d6e726 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json @@ -9985,12 +9985,24 @@ "tr": "Aktiviteler", "en": "Activities" }, + { + "resourceName": "Platform", + "key": "App.Crm.SalesOrderStatus", + "tr": "Satış Siparişleri Durumları", + "en": "Sales Order Statuses" + }, { "resourceName": "Platform", "key": "App.Crm.SalesOrder", "tr": "Satış Siparişleri", "en": "Sales Orders" }, + { + "resourceName": "Platform", + "key": "App.Crm.SalesOrderItem", + "tr": "Satış Siparişi Ürünleri", + "en": "Sales Order Items" + }, { "resourceName": "Platform", "key": "App.Mrp.OperationCategory", diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs index 3d702204..c8e728c1 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs @@ -2075,7 +2075,7 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency ColumnCustomizationJson = DefaultColumnCustomizationJson, PermissionJson = DefaultFieldPermissionJson(listForm.Name), PivotSettingsJson = DefaultPivotSettingsJson - }, + }, new() { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, @@ -2280,5 +2280,777 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency #endregion } #endregion + + #region Sales Order Status + listFormName = AppCodes.Crm.SalesOrderStatus; + 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.SalesOrderStatus)), + 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.SalesOrderStatus)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 500, 300, true, true, true, true, false), + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + 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 }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "IsActive", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value } + }), + } + ); + + #region Sales Order Status 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, + SortIndex = 0, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Name", + Width = 300, + ListOrderNo = 2, + 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 = "Description", + Width = 500, + 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.Boolean, + FieldName = "IsActive", + Width = 100, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ]); + #endregion + } + #endregion + + #region Sales Order + listFormName = AppCodes.Crm.SalesOrder; + 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.SalesOrder)), + 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.SalesOrder)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 800, 400, true, true, true, true, false), + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingFormJson = JsonSerializer.Serialize(new List() + { + new() { + Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[ + new EditingFormItemDto { Order = 1, DataField="OrderNumber", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled }, + new EditingFormItemDto { Order = 2, DataField="OrderDate", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxDateBox, EditorOptions = EditorOptionValues.DateFormat }, + new EditingFormItemDto { Order = 3, DataField="CustomerId", ColSpan = 2, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 4, DataField="RequestedDeliveryDate", ColSpan = 1, EditorType2 = EditorTypes.dxDateBox, EditorOptions = EditorOptionValues.DateFormat }, + new EditingFormItemDto { Order = 5, DataField="ConfirmedDeliveryDate", ColSpan = 1, EditorType2 = EditorTypes.dxDateBox, EditorOptions = EditorOptionValues.DateFormat }, + new EditingFormItemDto { Order = 6, DataField="Status", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 7, DataField="Currency", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 8, DataField="PaymentTermId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 9, DataField="DeliveryTermId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 10, DataField="ExchangeRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 11, DataField="DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 12, DataField="TaxRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 13, DataField="SpecialInstructions", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + new EditingFormItemDto { Order = 14, DataField="Notes", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "OrderNumber", FieldDbType = DbType.String, Value = "@AUTONUMBER", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { FieldName = "OrderDate", FieldDbType = DbType.Date, Value = "@DATE", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { FieldName = "Status", FieldDbType = DbType.String, Value = "Taslak", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "Currency", FieldDbType = DbType.String, Value = "TRY", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "DiscountRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "ExchangeRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "TaxRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + }), + CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { + new() { + Hint = "Manage", + Text ="Manage", + UrlTarget="_blank", + AuthName = listFormName, + Url=$"/admin/form/{SeederUtils.GetDefaultFormCodes(listFormName)}/@Id", + IsVisible = true, + }, + }), + }, autoSave: true + ); + + #region Sales Order Status 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, + SortIndex = 0, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "OrderNumber", + Width = 100, + ListOrderNo = 2, + 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 = "CustomerId", + Width = 200, + ListOrderNo = 3, + 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.Date, + FieldName = "OrderDate", + Width = 100, + ListOrderNo = 4, + 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.Date, + FieldName = "RequestedDeliveryDate", + Width = 100, + ListOrderNo = 5, + 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.Date, + FieldName = "ConfirmedDeliveryDate", + Width = 100, + 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 = "Status", + Width = 100, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.SalesOrderStatus), "Name", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Currency", + Width = 100, + ListOrderNo = 8, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Currency), "Code", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "PaymentTermId", + Width = 150, + ListOrderNo = 9, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.PaymentTerm), "Id", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "DeliveryTermId", + Width = 150, + ListOrderNo = 10, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.DeliveryTerm), "Id", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Decimal, + FieldName = "ExchangeRate", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + 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.Decimal, + FieldName = "DiscountRate", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + ListOrderNo = 12, + 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.Decimal, + FieldName = "TaxRate", + Format = "fixedPoint", + Alignment = "right", + 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 = "SpecialInstructions", + Width = 300, + 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 = "Notes", + Width = 300, + ListOrderNo = 15, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + #region Sales Order Item + listFormName = AppCodes.Crm.SalesOrderItem; + 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.SalesOrderItem)), + 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.SalesOrderItem)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 800, 400, true, true, true, true, false), + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingFormJson = JsonSerializer.Serialize(new List() + { + new() { + Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[ + new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 3, DataField="UnitPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 4, DataField="TotalAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 5, DataField="Uom", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 6, DataField="DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 7, DataField="DiscountAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 8, DataField="TaxRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 9, DataField="TaxAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 10, DataField="Status", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 11, DataField="Description", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + new EditingFormItemDto { Order = 12, DataField="Notes", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "Quantity", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "UnitPrice", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "TotalAmount", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "Uom", FieldDbType = DbType.String, Value = "Adet", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "DiscountRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "DiscountAmount", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "TaxRate", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "TaxAmount", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "Status", FieldDbType = DbType.String, Value = "Taslak", CustomValueType = FieldCustomValueTypeEnum.Value } + }), + }, autoSave: true + ); + + #region Sales Order Status 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, + SortIndex = 0, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "MaterialId", + Width = 150, + ListOrderNo = 2, + 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 = 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.Decimal, + FieldName = "UnitPrice", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + ListOrderNo = 4, + 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.Decimal, + FieldName = "TotalAmount", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + ListOrderNo = 5, + 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 = 150, + ListOrderNo = 6, + 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.Decimal, + FieldName = "DiscountRate", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + ListOrderNo = 7, + 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.Decimal, + FieldName = "DiscountAmount", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + 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.Decimal, + FieldName = "TaxRate", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + 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.Decimal, + FieldName = "TaxAmount", + Format = "fixedPoint", + Alignment = "right", + Width = 100, + ListOrderNo = 10, + 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 = "Status", + Width = 100, + ListOrderNo = 11, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.SalesOrderStatus), "Name", "Name"), + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Description", + Width = 300, + ListOrderNo = 12, + 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 = "Notes", + Width = 300, + ListOrderNo = 13, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + // Sales Order ve Sales Order Item arasında Sub Forms ilişkisinin kurulması + await utils.CloneFormLayoutAsync( + AppCodes.Crm.SalesOrder, + JsonSerializer.Serialize(new List() { + new { + TabType = ListFormTabTypeEnum.List, + TabTitle = AppCodes.Crm.SalesOrderItem, + Code = AppCodes.Crm.SalesOrderItem, + Relation = new List() { + new { + ParentFieldName = "Id", + DbType = DbType.Guid, + ChildFieldName = "SalesOrderId" + } + } + } + }) + ); } } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json index ee48c6f9..3b228136 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json @@ -2238,11 +2238,21 @@ "RequiredPermissionName": "App.Crm.Activity", "IsDisabled": false }, + { + "ParentCode": "App.Crm", + "Code": "App.Crm.SalesOrderStatus", + "DisplayName": "App.Crm.SalesOrderStatus", + "Order": 8, + "Url": "/admin/list/App.Crm.SalesOrderStatus", + "Icon": "FcWorkflow", + "RequiredPermissionName": "App.Crm.SalesOrderStatus", + "IsDisabled": false + }, { "ParentCode": "App.Crm", "Code": "App.Crm.SalesOrder", "DisplayName": "App.Crm.SalesOrder", - "Order": 8, + "Order": 9, "Url": "/admin/list/App.Crm.SalesOrder", "Icon": "FcShop", "RequiredPermissionName": "App.Crm.SalesOrder", diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json b/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json index 60943d14..74540375 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json @@ -11793,6 +11793,70 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus", + "ParentName": null, + "DisplayName": "App.Crm.SalesOrderStatus", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Create", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Update", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Delete", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Export", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Import", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderStatus.Note", + "ParentName": "App.Crm.SalesOrderStatus", + "DisplayName": "Note", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { "GroupName": "App.Crm", "Name": "App.Crm.SalesOrder", @@ -11856,6 +11920,71 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, + + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem", + "ParentName": null, + "DisplayName": "App.Crm.SalesOrderItem", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Create", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Update", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Delete", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Export", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Import", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { + "GroupName": "App.Crm", + "Name": "App.Crm.SalesOrderItem.Note", + "ParentName": "App.Crm.SalesOrderItem", + "DisplayName": "Note", + "IsEnabled": true, + "MultiTenancySide": 3, + "MenuGroup": "Erp" + }, + { "GroupName": "App.Mrp", "Name": "App.Mrp.OperationCategory", diff --git a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs index c49df15b..8b34bd37 100644 --- a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -208,5 +208,8 @@ public enum TableNameEnum DeliveryTerm, OrderStatus, PurchaseOrder, - PurchaseOrderItem + PurchaseOrderItem, + SalesOrderStatus, + SalesOrder, + SalesOrderItem } diff --git a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs index 91c75032..d341faf1 100644 --- a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs @@ -191,6 +191,9 @@ public static class TableNameResolver { nameof(TableNameEnum.Opportunity), (TablePrefix.TenantByName, MenuPrefix.Crm) }, { nameof(TableNameEnum.Activity), (TablePrefix.TenantByName, MenuPrefix.Crm) }, { nameof(TableNameEnum.Competitor), (TablePrefix.TenantByName, MenuPrefix.Crm) }, + { nameof(TableNameEnum.SalesOrderStatus), (TablePrefix.TenantByName, MenuPrefix.Crm) }, + { nameof(TableNameEnum.SalesOrder), (TablePrefix.TenantByName, MenuPrefix.Crm) }, + { nameof(TableNameEnum.SalesOrderItem), (TablePrefix.TenantByName, MenuPrefix.Crm) }, // 🔹 MAINTENANCE { nameof(TableNameEnum.WorkcenterType), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, diff --git a/api/src/Erp.Platform.Domain/Data/SeedConsts.cs b/api/src/Erp.Platform.Domain/Data/SeedConsts.cs index 7d8f0f30..eff100ee 100644 --- a/api/src/Erp.Platform.Domain/Data/SeedConsts.cs +++ b/api/src/Erp.Platform.Domain/Data/SeedConsts.cs @@ -508,7 +508,9 @@ public static class SeedConsts public const string OpportunityActivity = Default + ".OpportunityActivity"; public const string OpportunityCompetitor = Default + ".OpportunityCompetitor"; public const string Activity = Default + ".Activity"; - public const string Orders = Default + ".Orders"; + public const string SalesOrderStatus = Default + ".SalesOrderStatus"; + public const string SalesOrder = Default + ".SalesOrder"; + public const string SalesOrderItem = Default + ".SalesOrderItem"; } public static class SupplyChain diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrder.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrder.cs new file mode 100644 index 00000000..4270c543 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrder.cs @@ -0,0 +1,43 @@ +// Domain/Entities/CrmSalesOrder.cs +using System; +using System.Collections.Generic; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class SalesOrder : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public string OrderNumber { get; set; } + public Guid CustomerId { get; set; } + public Partner Customer { get; set; } + + public DateTime OrderDate { get; set; } + public DateTime RequestedDeliveryDate { get; set; } + public DateTime? ConfirmedDeliveryDate { get; set; } + + public string Status { get; set; } + + public decimal Subtotal { get; set; } + public decimal TaxAmount { get; set; } + public decimal DiscountAmount { get; set; } + public decimal TotalAmount { get; set; } + + public string Currency { get; set; } + public Guid PaymentTermId { get; set; } + public PaymentTerm PaymentTerm { get; set; } + + public Guid DeliveryTermId { get; set; } + public DeliveryTerm DeliveryTerm { get; set; } + + public decimal ExchangeRate { get; set; } + public decimal DiscountRate { get; set; } + public decimal TaxRate { get; set; } + + public string SpecialInstructions { get; set; } + public string Notes { get; set; } + + public ICollection Items { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderItem.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderItem.cs new file mode 100644 index 00000000..75c3fdf0 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderItem.cs @@ -0,0 +1,35 @@ +// Domain/Entities/CrmSalesOrderItem.cs +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class SalesOrderItem : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid SalesOrderId { get; set; } + public SalesOrder SalesOrder { get; set; } + + public Guid MaterialId { get; set; } + public Material Material { get; set; } + + public decimal Quantity { get; set; } + public decimal DeliveredQuantity { get; set; } //Sadece listede + + public decimal UnitPrice { get; set; } + public decimal TotalAmount { get; set; } + + public string Uom { get; set; } + + public decimal DiscountRate { get; set; } + public decimal DiscountAmount { get; set; } + + public decimal TaxRate { get; set; } + public decimal TaxAmount { get; set; } + + public string Description { get; set; } + public string Notes { get; set; } + public string Status { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderStatus.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderStatus.cs new file mode 100644 index 00000000..c4e4fbd7 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Crm/SalesOrderStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class SalesOrderStatus : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public string Name { get; set; } + public string Description { get; set; } + public bool IsActive { get; set; } + + public ICollection SalesOrders { get; set; } +} + diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/DeliveryTerm.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/DeliveryTerm.cs index d9d972be..79492bff 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/DeliveryTerm.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/DeliveryTerm.cs @@ -15,4 +15,5 @@ public class DeliveryTerm : FullAuditedEntity, IMultiTenant public bool IsActive { get; set; } public ICollection Quotations { get; set; } + public ICollection SalesOrders { get; set; } } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs index 8fddd69c..efa651a8 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/Material.cs @@ -27,9 +27,14 @@ public class Material : FullAuditedEntity, IMultiTenant // Relations public List AlternativeUoms { get; set; } - public List Specifications { get; set; } public List Suppliers { get; set; } public List Boms { get; set; } public List BomComponents { get; set; } + public List Specifications { get; set; } + public List WorkorderMaterials { get; set; } + public List RequestItems { get; set; } + public List QuotationItems { get; set; } + public List PurchaseOrderItems { get; set; } + public List SalesOrderItems { get; set; } } diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/PaymentTerm.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/PaymentTerm.cs index b7b1be07..a343b22d 100644 --- a/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/PaymentTerm.cs +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/SupplyChain/PaymentTerm.cs @@ -16,6 +16,7 @@ public class PaymentTerm : FullAuditedEntity, IMultiTenant public ICollection Quotations { get; set; } public ICollection PurchaseOrders { get; set; } + public ICollection SalesOrders { get; set; } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index 784e16d6..82639c60 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -222,6 +222,7 @@ public class PlatformDbContext : public DbSet QuotationItems { get; set; } public DbSet OrderStatuses { get; set; } public DbSet PurchaseOrders { get; set; } + public DbSet PurchaseOrderItems { get; set; } #endregion #region Crm @@ -229,6 +230,9 @@ public class PlatformDbContext : public DbSet Opportunities { get; set; } public DbSet Actions { get; set; } public DbSet Competitors { get; set; } + public DbSet SalesOrders { get; set; } + public DbSet SalesOrderItems { get; set; } + public DbSet SalesOrderStatuses { get; set; } #endregion #region Accounting @@ -2756,6 +2760,11 @@ public class PlatformDbContext : b.Property(x => x.Specification).HasMaxLength(500); b.Property(x => x.Justification).HasMaxLength(500); + b.HasOne(x => x.Material) + .WithMany(x => x.RequestItems) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Cascade); + b.HasOne(x => x.Request) .WithMany(x => x.Items) .HasForeignKey(x => x.RequestId) @@ -3521,6 +3530,11 @@ public class PlatformDbContext : b.Property(x => x.LeadTime).HasDefaultValue(0); b.Property(x => x.Description).HasMaxLength(500); + b.HasOne(x => x.Material) + .WithMany(x => x.QuotationItems) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + b.HasOne(x => x.Quotation) .WithMany(x => x.Items) .HasForeignKey(x => x.QuotationId) @@ -3557,6 +3571,11 @@ public class PlatformDbContext : b.Property(x => x.UnitCost).HasPrecision(18, 2); b.Property(x => x.TotalCost).HasPrecision(18, 2); + b.HasOne(x => x.Material) + .WithMany(x => x.WorkorderMaterials) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + b.HasOne(x => x.Workorder) .WithMany(x => x.Materials) .HasForeignKey(x => x.WorkorderId) @@ -3601,7 +3620,7 @@ public class PlatformDbContext : b.Property(x => x.Status).IsRequired().HasMaxLength(64); b.Property(x => x.Currency).IsRequired().HasMaxLength(8); - b.Property(x => x.ExchangeRate).HasPrecision(18, 2).HasDefaultValue(1); + b.Property(x => x.ExchangeRate).HasPrecision(18, 2).HasDefaultValue(0); b.Property(x => x.Subtotal).HasPrecision(18, 2).HasDefaultValue(0); b.Property(x => x.TaxAmount).HasPrecision(18, 2).HasDefaultValue(0); b.Property(x => x.TotalAmount).HasPrecision(18, 2).HasDefaultValue(0); @@ -3640,7 +3659,7 @@ public class PlatformDbContext : b.Property(x => x.PurchaseOrderId).IsRequired(); b.Property(x => x.MaterialId).IsRequired(); b.Property(x => x.UnitPrice).HasPrecision(18, 2).HasDefaultValue(0); - b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(1); + b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(0); b.Property(x => x.Uom).IsRequired().HasMaxLength(64); b.Property(x => x.TotalPrice).HasPrecision(18, 2).HasDefaultValue(0); @@ -3650,10 +3669,90 @@ public class PlatformDbContext : b.Property(x => x.Description).HasMaxLength(1000); + b.HasOne(x => x.Material) + .WithMany(x => x.PurchaseOrderItems) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + b.HasOne(x => x.PurchaseOrder) .WithMany(x => x.PurchaseOrders) .HasForeignKey(x => x.PurchaseOrderId) .OnDelete(DeleteBehavior.Restrict); }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.SalesOrderStatus)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name).IsRequired().HasMaxLength(50); + b.Property(x => x.Description).HasMaxLength(500); + b.Property(x => x.IsActive).HasDefaultValue(true); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.SalesOrder)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.OrderNumber).IsRequired().HasMaxLength(50); + b.Property(x => x.CustomerId).IsRequired(); + b.Property(x => x.OrderDate).IsRequired(); + b.Property(x => x.RequestedDeliveryDate).IsRequired(); + b.Property(x => x.Status).IsRequired().HasMaxLength(64); + b.Property(x => x.Currency).IsRequired().HasMaxLength(8); + b.Property(x => x.PaymentTermId).IsRequired(); + b.Property(x => x.DeliveryTermId).IsRequired(); + b.Property(x => x.Subtotal).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TaxAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TotalAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.DiscountAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.Notes).HasMaxLength(1000); + b.Property(x => x.SpecialInstructions).HasMaxLength(1000); + b.Property(x => x.ExchangeRate).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.DiscountRate).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TaxRate).HasPrecision(18, 2).HasDefaultValue(0); + + b.HasOne(x => x.DeliveryTerm) + .WithMany(x => x.SalesOrders) + .HasForeignKey(x => x.DeliveryTermId) + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne(x => x.PaymentTerm) + .WithMany(x => x.SalesOrders) + .HasForeignKey(x => x.PaymentTermId) + .OnDelete(DeleteBehavior.Restrict); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.SalesOrderItem)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.SalesOrderId).IsRequired(); + b.Property(x => x.MaterialId).IsRequired(); + b.Property(x => x.Description).HasMaxLength(1000); + b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.DeliveredQuantity).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.UnitPrice).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TotalAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.Uom).IsRequired().HasMaxLength(64); + b.Property(x => x.DiscountRate).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.DiscountAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TaxRate).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.TaxAmount).HasPrecision(18, 2).HasDefaultValue(0); + b.Property(x => x.Notes).HasMaxLength(1000); + b.Property(x => x.Status).HasMaxLength(64); + + b.HasOne(x => x.Material) + .WithMany(x => x.SalesOrderItems) + .HasForeignKey(x => x.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne(x => x.SalesOrder) + .WithMany(x => x.Items) + .HasForeignKey(x => x.SalesOrderId) + .OnDelete(DeleteBehavior.Restrict); + }); } } \ No newline at end of file diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.Designer.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.Designer.cs similarity index 97% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.Designer.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.Designer.cs index 1000df8c..7704264f 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.Designer.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Erp.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20251204121428_Initial")] + [Migration("20251204142238_Initial")] partial class Initial { /// @@ -10236,7 +10236,7 @@ namespace Erp.Platform.Migrations .ValueGeneratedOnAdd() .HasPrecision(18, 2) .HasColumnType("decimal(18,2)") - .HasDefaultValue(1m); + .HasDefaultValue(0m); b.Property("IsDeleted") .ValueGeneratedOnAdd() @@ -10375,7 +10375,7 @@ namespace Erp.Platform.Migrations .ValueGeneratedOnAdd() .HasPrecision(18, 2) .HasColumnType("decimal(18,2)") - .HasDefaultValue(1m); + .HasDefaultValue(0m); b.Property("ReceivedQuantity") .ValueGeneratedOnAdd() @@ -11924,6 +11924,321 @@ namespace Erp.Platform.Migrations b.ToTable("Sas_H_Route", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ConfirmedDeliveryDate") + .HasColumnType("datetime2"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("nvarchar(8)"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DeliveryTermId") + .HasColumnType("uniqueidentifier"); + + b.Property("DiscountAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("DiscountRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("ExchangeRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderDate") + .HasColumnType("datetime2"); + + b.Property("OrderNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PaymentTermId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequestedDeliveryDate") + .HasColumnType("datetime2"); + + b.Property("SalesOrderStatusId") + .HasColumnType("uniqueidentifier"); + + b.Property("SpecialInstructions") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Subtotal") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TotalAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeliveryTermId"); + + b.HasIndex("PaymentTermId"); + + b.HasIndex("SalesOrderStatusId"); + + b.ToTable("Crm_T_SalesOrder", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderItem", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DeliveredQuantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("DiscountAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("DiscountRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("SalesOrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TaxAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TotalAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("UnitPrice") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("Uom") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("MaterialId"); + + b.HasIndex("SalesOrderId"); + + b.ToTable("Crm_T_SalesOrderItem", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderStatus", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Crm_T_SalesOrderStatus", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.SalesRejectionReason", b => { b.Property("Id") @@ -18581,9 +18896,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.PurchaseOrderItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("PurchaseOrderItems") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.PurchaseOrder", "PurchaseOrder") @@ -18687,9 +19002,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.QuotationItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("QuotationItems") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.Quotation", "Quotation") @@ -18793,7 +19108,7 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.RequestItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("RequestItems") .HasForeignKey("MaterialId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -18820,6 +19135,56 @@ namespace Erp.Platform.Migrations b.Navigation("Employee"); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.HasOne("Erp.Platform.Entities.Partner", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.DeliveryTerm", "DeliveryTerm") + .WithMany("SalesOrders") + .HasForeignKey("DeliveryTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.PaymentTerm", "PaymentTerm") + .WithMany("SalesOrders") + .HasForeignKey("PaymentTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.SalesOrderStatus", null) + .WithMany("SalesOrders") + .HasForeignKey("SalesOrderStatusId"); + + b.Navigation("Customer"); + + b.Navigation("DeliveryTerm"); + + b.Navigation("PaymentTerm"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderItem", b => + { + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("SalesOrderItems") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.SalesOrder", "SalesOrder") + .WithMany("Items") + .HasForeignKey("SalesOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Material"); + + b.Navigation("SalesOrder"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Schedule", b => { b.HasOne("Erp.Platform.Entities.Branch", "Branch") @@ -19131,9 +19496,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.WorkorderMaterial", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("WorkorderMaterials") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.Workorder", "Workorder") @@ -19469,6 +19834,8 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.DeliveryTerm", b => { b.Navigation("Quotations"); + + b.Navigation("SalesOrders"); }); modelBuilder.Entity("Erp.Platform.Entities.Department", b => @@ -19550,9 +19917,19 @@ namespace Erp.Platform.Migrations b.Navigation("Boms"); + b.Navigation("PurchaseOrderItems"); + + b.Navigation("QuotationItems"); + + b.Navigation("RequestItems"); + + b.Navigation("SalesOrderItems"); + b.Navigation("Specifications"); b.Navigation("Suppliers"); + + b.Navigation("WorkorderMaterials"); }); modelBuilder.Entity("Erp.Platform.Entities.MaterialGroup", b => @@ -19617,6 +19994,8 @@ namespace Erp.Platform.Migrations b.Navigation("PurchaseOrders"); b.Navigation("Quotations"); + + b.Navigation("SalesOrders"); }); modelBuilder.Entity("Erp.Platform.Entities.Payroll", b => @@ -19722,6 +20101,16 @@ namespace Erp.Platform.Migrations b.Navigation("ProjectRisks"); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderStatus", b => + { + b.Navigation("SalesOrders"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Schedule", b => { b.Navigation("Lessons"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.cs similarity index 98% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.cs index b7994f9a..cd00391f 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204121428_Initial.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251204142238_Initial.cs @@ -1172,6 +1172,28 @@ namespace Erp.Platform.Migrations table.PrimaryKey("PK_Crm_T_LossReason", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Crm_T_SalesOrderStatus", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = 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), + 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_Crm_T_SalesOrderStatus", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Hr_T_Badge", columns: table => new @@ -5109,6 +5131,112 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "Crm_T_SalesOrder", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + OrderNumber = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + CustomerId = table.Column(type: "uniqueidentifier", nullable: false), + OrderDate = table.Column(type: "datetime2", nullable: false), + RequestedDeliveryDate = table.Column(type: "datetime2", nullable: false), + ConfirmedDeliveryDate = table.Column(type: "datetime2", nullable: true), + Status = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Subtotal = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TaxAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + DiscountAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TotalAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + Currency = table.Column(type: "nvarchar(8)", maxLength: 8, nullable: false), + PaymentTermId = table.Column(type: "uniqueidentifier", nullable: false), + DeliveryTermId = table.Column(type: "uniqueidentifier", nullable: false), + ExchangeRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + DiscountRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TaxRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + SpecialInstructions = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Notes = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + SalesOrderStatusId = table.Column(type: "uniqueidentifier", 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_Crm_T_SalesOrder", x => x.Id); + table.ForeignKey( + name: "FK_Crm_T_SalesOrder_Adm_T_Partner_CustomerId", + column: x => x.CustomerId, + principalTable: "Adm_T_Partner", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Crm_T_SalesOrder_Crm_T_SalesOrderStatus_SalesOrderStatusId", + column: x => x.SalesOrderStatusId, + principalTable: "Crm_T_SalesOrderStatus", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Crm_T_SalesOrder_Scp_T_DeliveryTerm_DeliveryTermId", + column: x => x.DeliveryTermId, + principalTable: "Scp_T_DeliveryTerm", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Crm_T_SalesOrder_Scp_T_PaymentTerm_PaymentTermId", + column: x => x.PaymentTermId, + principalTable: "Scp_T_PaymentTerm", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Crm_T_SalesOrderItem", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + SalesOrderId = table.Column(type: "uniqueidentifier", nullable: false), + MaterialId = table.Column(type: "uniqueidentifier", nullable: false), + Quantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + DeliveredQuantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + UnitPrice = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TotalAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + Uom = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + DiscountRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + DiscountAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TaxRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + TaxAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Notes = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Status = table.Column(type: "nvarchar(64)", maxLength: 64, 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_Crm_T_SalesOrderItem", x => x.Id); + table.ForeignKey( + name: "FK_Crm_T_SalesOrderItem_Crm_T_SalesOrder_SalesOrderId", + column: x => x.SalesOrderId, + principalTable: "Crm_T_SalesOrder", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Crm_T_SalesOrderItem_Scp_T_Material_MaterialId", + column: x => x.MaterialId, + principalTable: "Scp_T_Material", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateTable( name: "Crm_T_Activity", columns: table => new @@ -6751,7 +6879,7 @@ namespace Erp.Platform.Migrations column: x => x.MaterialId, principalTable: "Scp_T_Material", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Scp_T_QuotationItem_Scp_T_Quotation_QuotationId", column: x => x.QuotationId, @@ -6776,7 +6904,7 @@ namespace Erp.Platform.Migrations RequestId = table.Column(type: "uniqueidentifier", nullable: true), QuotationId = table.Column(type: "uniqueidentifier", nullable: true), Currency = table.Column(type: "nvarchar(8)", maxLength: 8, nullable: false), - ExchangeRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 1m), + ExchangeRate = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), Subtotal = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), TaxAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), TotalAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), @@ -6964,7 +7092,7 @@ namespace Erp.Platform.Migrations column: x => x.MaterialId, principalTable: "Scp_T_Material", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -7004,7 +7132,7 @@ namespace Erp.Platform.Migrations PurchaseOrderId = table.Column(type: "uniqueidentifier", nullable: false), MaterialId = table.Column(type: "uniqueidentifier", nullable: false), UnitPrice = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), - Quantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 1m), + 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), TotalPrice = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), ReceivedQuantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), @@ -7027,7 +7155,7 @@ namespace Erp.Platform.Migrations column: x => x.MaterialId, principalTable: "Scp_T_Material", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Scp_T_PurchaseOrderItem_Scp_T_PurchaseOrder_PurchaseOrderId", column: x => x.PurchaseOrderId, @@ -7882,6 +8010,36 @@ namespace Erp.Platform.Migrations table: "Crm_T_Opportunity", column: "SourceId"); + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrder_CustomerId", + table: "Crm_T_SalesOrder", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrder_DeliveryTermId", + table: "Crm_T_SalesOrder", + column: "DeliveryTermId"); + + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrder_PaymentTermId", + table: "Crm_T_SalesOrder", + column: "PaymentTermId"); + + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrder_SalesOrderStatusId", + table: "Crm_T_SalesOrder", + column: "SalesOrderStatusId"); + + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrderItem_MaterialId", + table: "Crm_T_SalesOrderItem", + column: "MaterialId"); + + migrationBuilder.CreateIndex( + name: "IX_Crm_T_SalesOrderItem_SalesOrderId", + table: "Crm_T_SalesOrderItem", + column: "SalesOrderId"); + migrationBuilder.CreateIndex( name: "IX_Hr_T_CostCenter_DepartmentId", table: "Hr_T_CostCenter", @@ -9064,6 +9222,9 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Crm_T_Competitor"); + migrationBuilder.DropTable( + name: "Crm_T_SalesOrderItem"); + migrationBuilder.DropTable( name: "Hr_T_Expense"); @@ -9331,6 +9492,9 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Crm_T_Opportunity"); + migrationBuilder.DropTable( + name: "Crm_T_SalesOrder"); + migrationBuilder.DropTable( name: "Hr_T_Payroll"); @@ -9436,6 +9600,9 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Prt_T_Source"); + migrationBuilder.DropTable( + name: "Crm_T_SalesOrderStatus"); + migrationBuilder.DropTable( name: "Hr_T_Survey"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 11063c92..95f7db7b 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -10233,7 +10233,7 @@ namespace Erp.Platform.Migrations .ValueGeneratedOnAdd() .HasPrecision(18, 2) .HasColumnType("decimal(18,2)") - .HasDefaultValue(1m); + .HasDefaultValue(0m); b.Property("IsDeleted") .ValueGeneratedOnAdd() @@ -10372,7 +10372,7 @@ namespace Erp.Platform.Migrations .ValueGeneratedOnAdd() .HasPrecision(18, 2) .HasColumnType("decimal(18,2)") - .HasDefaultValue(1m); + .HasDefaultValue(0m); b.Property("ReceivedQuantity") .ValueGeneratedOnAdd() @@ -11921,6 +11921,321 @@ namespace Erp.Platform.Migrations b.ToTable("Sas_H_Route", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ConfirmedDeliveryDate") + .HasColumnType("datetime2"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("nvarchar(8)"); + + b.Property("CustomerId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DeliveryTermId") + .HasColumnType("uniqueidentifier"); + + b.Property("DiscountAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("DiscountRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("ExchangeRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("OrderDate") + .HasColumnType("datetime2"); + + b.Property("OrderNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PaymentTermId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequestedDeliveryDate") + .HasColumnType("datetime2"); + + b.Property("SalesOrderStatusId") + .HasColumnType("uniqueidentifier"); + + b.Property("SpecialInstructions") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Subtotal") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TotalAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeliveryTermId"); + + b.HasIndex("PaymentTermId"); + + b.HasIndex("SalesOrderStatusId"); + + b.ToTable("Crm_T_SalesOrder", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderItem", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DeliveredQuantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("DiscountAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("DiscountRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("SalesOrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TaxAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TaxRate") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TotalAmount") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("UnitPrice") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("Uom") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("MaterialId"); + + b.HasIndex("SalesOrderId"); + + b.ToTable("Crm_T_SalesOrderItem", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderStatus", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Crm_T_SalesOrderStatus", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.SalesRejectionReason", b => { b.Property("Id") @@ -18578,9 +18893,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.PurchaseOrderItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("PurchaseOrderItems") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.PurchaseOrder", "PurchaseOrder") @@ -18684,9 +18999,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.QuotationItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("QuotationItems") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.Quotation", "Quotation") @@ -18790,7 +19105,7 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.RequestItem", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("RequestItems") .HasForeignKey("MaterialId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -18817,6 +19132,56 @@ namespace Erp.Platform.Migrations b.Navigation("Employee"); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.HasOne("Erp.Platform.Entities.Partner", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.DeliveryTerm", "DeliveryTerm") + .WithMany("SalesOrders") + .HasForeignKey("DeliveryTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.PaymentTerm", "PaymentTerm") + .WithMany("SalesOrders") + .HasForeignKey("PaymentTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.SalesOrderStatus", null) + .WithMany("SalesOrders") + .HasForeignKey("SalesOrderStatusId"); + + b.Navigation("Customer"); + + b.Navigation("DeliveryTerm"); + + b.Navigation("PaymentTerm"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderItem", b => + { + b.HasOne("Erp.Platform.Entities.Material", "Material") + .WithMany("SalesOrderItems") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Erp.Platform.Entities.SalesOrder", "SalesOrder") + .WithMany("Items") + .HasForeignKey("SalesOrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Material"); + + b.Navigation("SalesOrder"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Schedule", b => { b.HasOne("Erp.Platform.Entities.Branch", "Branch") @@ -19128,9 +19493,9 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.WorkorderMaterial", b => { b.HasOne("Erp.Platform.Entities.Material", "Material") - .WithMany() + .WithMany("WorkorderMaterials") .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Erp.Platform.Entities.Workorder", "Workorder") @@ -19466,6 +19831,8 @@ namespace Erp.Platform.Migrations modelBuilder.Entity("Erp.Platform.Entities.DeliveryTerm", b => { b.Navigation("Quotations"); + + b.Navigation("SalesOrders"); }); modelBuilder.Entity("Erp.Platform.Entities.Department", b => @@ -19547,9 +19914,19 @@ namespace Erp.Platform.Migrations b.Navigation("Boms"); + b.Navigation("PurchaseOrderItems"); + + b.Navigation("QuotationItems"); + + b.Navigation("RequestItems"); + + b.Navigation("SalesOrderItems"); + b.Navigation("Specifications"); b.Navigation("Suppliers"); + + b.Navigation("WorkorderMaterials"); }); modelBuilder.Entity("Erp.Platform.Entities.MaterialGroup", b => @@ -19614,6 +19991,8 @@ namespace Erp.Platform.Migrations b.Navigation("PurchaseOrders"); b.Navigation("Quotations"); + + b.Navigation("SalesOrders"); }); modelBuilder.Entity("Erp.Platform.Entities.Payroll", b => @@ -19719,6 +20098,16 @@ namespace Erp.Platform.Migrations b.Navigation("ProjectRisks"); }); + modelBuilder.Entity("Erp.Platform.Entities.SalesOrder", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.SalesOrderStatus", b => + { + b.Navigation("SalesOrders"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Schedule", b => { b.Navigation("Lessons"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index e07a404d..2c3c94fc 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -6411,5 +6411,42 @@ "description": "Teklifin iptal edildiğini ifade eder", "isActive": true } + ], + "SalesOrderStatuses": [ + { + "name": "Taslak", + "description": "Satış siparişlerin taslak aşamasında olduğunu ifade eder", + "isActive": true + }, + { + "name": "Onaylandı", + "description": "Satış siparişlerin onaylandığını ifade eder", + "isActive": true + }, + { + "name": "Üretimde", + "description": "Satış siparişlerin üretimde olduğunu ifade eder", + "isActive": true + }, + { + "name": "Hazır", + "description": "Satış siparişlerin hazır olduğunu ifade eder", + "isActive": true + }, + { + "name": "Gönderildi", + "description": "Satış siparişlerin gönderildiğini ifade eder", + "isActive": true + }, + { + "name": "Teslim Edildi", + "description": "Satış siparişlerin teslim edildiğini ifade eder", + "isActive": true + }, + { + "name": "İptal Edildi", + "description": "Satış siparişlerin iptal edildiğini ifade eder", + "isActive": true + } ] } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs index 8dbc7e2f..f877f71d 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantDataSeeder.cs @@ -140,6 +140,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency private readonly IRepository _deliveryTermRepository; private readonly IRepository _quotationStatusRepository; private readonly IRepository _orderStatusRepository; + private readonly IRepository _salesOrderStatusRepository; public TenantDataSeeder( IClock clock, @@ -262,7 +263,8 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IRepository projectTaskRepository, IRepository deliveryTermRepository, IRepository quotationStatusRepository, - IRepository orderStatusRepository + IRepository orderStatusRepository, + IRepository salesOrderStatusRepository ) { _clock = clock; @@ -387,6 +389,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency _deliveryTermRepository = deliveryTermRepository; _quotationStatusRepository = quotationStatusRepository; _orderStatusRepository = orderStatusRepository; + _salesOrderStatusRepository = salesOrderStatusRepository; } private static IConfigurationRoot BuildConfiguration() @@ -2701,6 +2704,20 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IsActive = item.IsActive }, autoSave: true); } + + foreach (var item in items.SalesOrderStatuses) + { + var exists = await _salesOrderStatusRepository.AnyAsync(x => x.Name == item.Name); + if (exists) + continue; + + await _salesOrderStatusRepository.InsertAsync(new SalesOrderStatus + { + Name = item.Name, + Description = item.Description, + IsActive = item.IsActive + }, autoSave: true); + } } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs index 4eb44ad3..5de93941 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Tenants/TenantSeederDto.cs @@ -100,6 +100,7 @@ public class TenantSeederDto public List CustomerSegments { get; set; } public List LossReasons { get; set; } public List OrganizationUnits { get; set; } + public List SalesOrderStatuses { get; set; } //Maintenance public List WorkcenterTypes { get; set; } @@ -143,6 +144,13 @@ public class TenantSeederDto public List ProjectTaskDailies { get; set; } } +public class SalesOrderStatusSeedDto +{ + public string Name { get; set; } + public string Description { get; set; } + public bool IsActive { get; set; } +} + public class OrderStatusSeedDto { public string Name { get; set; }