-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Classification lvl + unique account_group code per classification. (n…
…eed to be more tested)
- Loading branch information
Showing
23 changed files
with
232 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/Ubik.Accounting.Api/Data/Config/AccountGroupClassificationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore; | ||
using Ubik.Accounting.Api.Models; | ||
|
||
namespace Ubik.Accounting.Api.Data.Config | ||
{ | ||
public class AccountGroupClassificationConfiguration : IEntityTypeConfiguration<AccountGroupClassification> | ||
{ | ||
public void Configure(EntityTypeBuilder<AccountGroupClassification> builder) | ||
{ | ||
builder.ToTable("AccountGroupClassifications"); | ||
|
||
builder.Property(a => a.Code) | ||
.IsRequired() | ||
.HasMaxLength(20); | ||
|
||
builder.Property(a => a.Label) | ||
.IsRequired() | ||
.HasMaxLength(100); | ||
|
||
builder.Property(a => a.Description) | ||
.HasMaxLength(700); | ||
|
||
builder.Property(a => a.Version) | ||
.IsConcurrencyToken(); | ||
|
||
builder.Property(a => a.TenantId) | ||
.IsRequired(); | ||
|
||
builder.Property(a => a.CreatedAt) | ||
.IsRequired(); | ||
|
||
builder.Property(a => a.CreatedBy) | ||
.IsRequired(); | ||
|
||
builder.HasIndex(a => a.Code) | ||
.IsUnique(); | ||
|
||
builder.HasIndex(a => a.TenantId); | ||
|
||
//TODO: Change that quick with userservice | ||
builder | ||
.HasQueryFilter(a => a.TenantId == Guid.Parse("727449e8-e93c-49e6-a5e5-1bf145d3e62d")); | ||
|
||
builder | ||
.HasOne(a => a.CreatedByUser) | ||
.WithMany() | ||
.HasForeignKey(b => b.CreatedBy) | ||
.IsRequired(true); | ||
|
||
builder | ||
.HasOne(a => a.ModifiedByUser) | ||
.WithMany() | ||
.HasForeignKey(b => b.ModifiedBy) | ||
.IsRequired(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/Ubik.Accounting.Api/Data/Init/AccountGroupClassificationsData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Ubik.Accounting.Api.Models; | ||
|
||
namespace Ubik.Accounting.Api.Data.Init | ||
{ | ||
internal static class AccountGroupClassificationsData | ||
{ | ||
internal static void Load(AccountingContext context) | ||
{ | ||
if (!context.AccountGroupClassifications.Any()) | ||
{ | ||
var baseValuesGeneral = new BaseValuesGeneral(); | ||
var baseValuesForTenants = new BaseValuesForTenants(); | ||
var baseValuesForUsers = new BaseValuesForUsers(); | ||
var baseValuesForAccountGroupClassifications = new BaseValuesForAccountGroupClassifications(); | ||
var accountGroupClassifications = new AccountGroupClassification[] | ||
{ | ||
new AccountGroupClassification | ||
{ | ||
Id = baseValuesForAccountGroupClassifications.AccountGroupClassificationId1, | ||
CreatedBy = baseValuesForUsers.UserId1, | ||
CreatedAt = baseValuesGeneral.GenerationTime, | ||
Code = "SWISSPLAN", | ||
Description = "Plan comptable suisse", | ||
Label = "Test", | ||
ModifiedBy = baseValuesForUsers.UserId1, | ||
ModifiedAt = baseValuesGeneral.GenerationTime, | ||
Version = Guid.NewGuid(), | ||
TenantId = baseValuesForTenants.TenantId | ||
}, | ||
new AccountGroupClassification | ||
{ | ||
Id = baseValuesForAccountGroupClassifications.AccountGroupClassificationId2, | ||
CreatedBy = baseValuesForUsers.UserId1, | ||
CreatedAt = baseValuesGeneral.GenerationTime, | ||
Code = "SWISSPLAN2", | ||
Description = "Plan comptable suisse2", | ||
Label = "Test", | ||
ModifiedBy = baseValuesForUsers.UserId1, | ||
ModifiedAt = baseValuesGeneral.GenerationTime, | ||
Version = Guid.NewGuid(), | ||
TenantId = baseValuesForTenants.TenantId | ||
} | ||
}; | ||
|
||
foreach (AccountGroupClassification cl in accountGroupClassifications) | ||
{ | ||
context.AccountGroupClassifications.Add(cl); | ||
} | ||
context.SaveChanges(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.